Interface InstanceOperations


public interface InstanceOperations
  • Method Details

    • setProperty

      void setProperty(String property, String value) throws AccumuloException, AccumuloSecurityException
      Sets a system property in zookeeper. Tablet servers will pull this setting and override the equivalent setting in accumulo.properties. Changes can be seen using getSystemConfiguration().

      Only some properties can be changed by this method, an IllegalArgumentException will be thrown if there is an attempt to set a read-only property.

      Parameters:
      property - the name of a system property
      value - the value to set a system property to
      Throws:
      AccumuloException - if a general error occurs
      AccumuloSecurityException - if the user does not have permission
    • modifyProperties

      Modify system properties using a Consumer that accepts a mutable map containing the current system property overrides stored in ZooKeeper. If the supplied Consumer alters the map without throwing an Exception, then the resulting map will atomically replace the current system property overrides in ZooKeeper. Only properties which can be stored in ZooKeeper will be accepted.

      Accumulo has multiple layers of properties that for many APIs and SPIs are presented as a single merged view. This API does not offer that merged view, it only offers the properties set at the system layer to the mapMutator.

      This new API offers two distinct advantages over the older setProperty(String, String) API. The older API offered the ability to unconditionally set a single property. This new API offers the following.

      • Ability to unconditionally set multiple properties atomically. If five properties are mutated by this API, then eventually all of the servers will see those changes all at once. This is really important for configuring something like a scan iterator that requires setting multiple properties.
      • Ability to conditionally set multiple properties atomically. With this new API a snapshot of the current instance configuration is passed in to the mapMutator. Code can inspect the current config and decide what if any changes it would like to make. If the config changes while mapMutator is doing inspection and modification, then those actions will be ignored and it will be called again with the latest snapshot of the config.

      Below is an example of using this API to conditionally set some instance properties. If while trying to set the compaction planner properties another process modifies the manager balancer properties, then it would automatically retry and call the lambda again with the latest snapshot of instance properties.

               
                   AccumuloClient client = getClient();
                   Map<String,String> acceptedProps = client.instanceOperations().modifyProperties(currProps -> {
                     var planner = currProps.get("tserver.compaction.major.service.default.planner");
                     //This code will only change the compaction planner if its currently set to default settings.
                     //The endsWith() function was used to make the example short, would be better to use equals().
                     if(planner != null && planner.endsWith("DefaultCompactionPlanner") {
                       // tservers will eventually see these compaction planner changes and when they do they will see all of the changes at once
                       currProps.keySet().removeIf(
                          prop -> prop.startsWith("tserver.compaction.major.service.default.planner.opts."));
                       currProps.put("tserver.compaction.major.service.default.planner","MyPlannerClassName");
                       currProps.put("tserver.compaction.major.service.default.planner.opts.myOpt1","val1");
                       currProps.put("tserver.compaction.major.service.default.planner.opts.myOpt2","val2");
                      }
                   });
      
                   // Since three properties were set may want to check for the values of all
                   // three, just checking one in this example to keep it short.
                   if("MyPlannerClassName".equals(acceptedProps.get("tserver.compaction.major.service.default.planner"))){
                      // the compaction planner change was accepted or already existed, so take action for that outcome
                   } else {
                      // the compaction planner change was not done, so take action for that outcome
                   }
                 
               }
       
      Parameters:
      mapMutator - This consumer should modify the passed snapshot of instance properties to contain the desired keys and values. It should be safe for Accumulo to call this consumer multiple times, this may be done automatically when certain retryable errors happen. The consumer should probably avoid accessing the Accumulo client as that could lead to undefined behavior.
      Returns:
      The map that became Accumulo's new properties for this table. This map is immutable and contains the snapshot passed to mapMutator and the changes made by mapMutator.
      Throws:
      AccumuloException - if a general error occurs
      AccumuloSecurityException - if the user does not have permission
      IllegalArgumentException - if the Consumer alters the map by adding properties that cannot be stored in ZooKeeper
      Since:
      2.1.0
    • removeProperty

      void removeProperty(String property) throws AccumuloException, AccumuloSecurityException
      Removes a system property from zookeeper. Changes can be seen using getSystemConfiguration()
      Parameters:
      property - the name of a system property
      Throws:
      AccumuloException - if a general error occurs
      AccumuloSecurityException - if the user does not have permission
    • getSystemConfiguration

      Map<String,String> getSystemConfiguration() throws AccumuloException, AccumuloSecurityException
      Retrieve the system-wide configuration.
      Returns:
      A map of system properties set in zookeeper. If a property is not set in zookeeper, then it will return the value set in accumulo.properties on some server. If nothing is set in an accumulo.properties file, the default value for each property will be used.
      Throws:
      AccumuloException
      AccumuloSecurityException
    • getSiteConfiguration

      Retrieve the site configuration (that is set in the server configuration file).
      Returns:
      A map of system properties set in accumulo.properties on some server. If nothing is set in an accumulo.properties file, the default value for each property will be used.
      Throws:
      AccumuloException
      AccumuloSecurityException
    • getManagerLocations

      List<String> getManagerLocations()
      Returns the location(s) of the accumulo manager and any redundant servers.
      Returns:
      a list of locations in hostname:port form.
      Since:
      2.1.0
    • getScanServers

      Set<String> getScanServers()
      Returns the locations of the active scan servers
      Returns:
      A set of currently active scan servers.
    • getTabletServers

      List<String> getTabletServers()
      List the currently active tablet servers participating in the accumulo instance
      Returns:
      A list of currently active tablet servers.
    • getActiveScans

      List the active scans on a tablet server.
      Parameters:
      tserver - The tablet server address. This should be of the form <ip address>:<port>
      Returns:
      A list of active scans on tablet server.
      Throws:
      AccumuloException
      AccumuloSecurityException
    • getActiveCompactions

      List the active compaction running on a tablet server. Using this method with getTabletServers() will only show compactions running on tservers, leaving out any external compactions running on compactors. Use getActiveCompactions() to get a list of all compactions running on tservers and compactors.
      Parameters:
      tserver - The tablet server address. This should be of the form <ip address>:<port>
      Returns:
      the list of active compactions
      Throws:
      AccumuloException
      AccumuloSecurityException
      Since:
      1.5.0
    • getActiveCompactions

      List all internal and external compactions running in Accumulo.
      Returns:
      the list of active compactions
      Throws:
      AccumuloException
      AccumuloSecurityException
      Since:
      2.1.0
    • ping

      void ping(String tserver) throws AccumuloException
      Throws an exception if a tablet server can not be contacted.
      Parameters:
      tserver - The tablet server address. This should be of the form <ip address>:<port>
      Throws:
      AccumuloException
      Since:
      1.5.0
    • testClassLoad

      boolean testClassLoad(String className, String asTypeName) throws AccumuloException, AccumuloSecurityException
      Test to see if the instance can load the given class as the given type. This check does not consider per table classpaths, see TableOperations.testClassLoad(String, String, String)
      Returns:
      true if the instance can load the given class as the given type, false otherwise
      Throws:
      AccumuloException
      AccumuloSecurityException
    • waitForBalance

      void waitForBalance() throws AccumuloException
      Waits for the tablet balancer to run and return no migrations.
      Throws:
      AccumuloException
      Since:
      1.7.0
    • getInstanceID

      @Deprecated(since="2.1.0") String getInstanceID()
      Deprecated.
      in 2.1.0 Use getInstanceId()
      Returns a unique string that identifies this instance of accumulo.
      Returns:
      a String
      Since:
      2.0.0
    • getInstanceId

      InstanceId getInstanceId()
      Returns a unique ID object that identifies this instance of accumulo.
      Returns:
      an InstanceId
      Since:
      2.1.0