Interface InstanceOperations
-
Method Summary
Modifier and TypeMethodDescriptionDeprecated.getActiveCompactions(String tserver) Deprecated.getActiveCompactions(Collection<ServerId> servers) List the active compaction running on a collection of TabletServers or Compactors.getActiveScans(String tserver) Deprecated.getActiveScans(Collection<ServerId> servers) List the active scans on a collection of servers.Deprecated.Returns a unique ID object that identifies this instance of accumulo.Deprecated.Return the current manager time.Deprecated.getServer(ServerId.Type type, ResourceGroupId resourceGroup, String host, int port) Resolve the server of the given type and address to a ServerIdgetServers(ServerId.Type type) Returns all servers of the given types.getServers(ServerId.Type type, Predicate<ResourceGroupId> resourceGroupPredicate, BiPredicate<String, Integer> hostPortPredicate) Returns the servers of a given type that match the given criteriaRetrieve the site configuration (that is set in the server configuration file).Retrieve the system-wide, merged view of the system configuration.Retrieve a map of the system properties set in Zookeeper.Deprecated.modifyProperties(Consumer<Map<String, String>> mapMutator) Modify system properties using a Consumer that accepts a mutable map containing the current system property overrides stored in ZooKeeper.voidCheck to see if a server process at the host and port is up and responding to RPC requests.voidCheck to see if a server process at the host and port is up and responding to RPC requests.voidremoveProperty(String property) Removes a system property from zookeeper.voidsetProperty(String property, String value) Sets a system property in zookeeper.booleantestClassLoad(String className, String asTypeName) Test to see if the instance can load the given class as the given type.voidWaits for the tablet balancer to run and return no migrations.
-
Method Details
-
setProperty
Sets a system property in zookeeper. Tablet servers will pull this setting and override the equivalent setting in accumulo.properties. Changes can be seen usinggetSystemConfiguration().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 propertyvalue- the value to set a system property to- Throws:
AccumuloException- if a general error occursAccumuloSecurityException- if the user does not have permission
-
modifyProperties
Map<String,String> modifyProperties(Consumer<Map<String, String>> mapMutator) throws AccumuloException, AccumuloSecurityException, IllegalArgumentExceptionModify 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("compaction.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("RatioBasedCompactionPlanner") { // 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("compaction.service.default.planner.opts.")); currProps.put("compaction.service.default.planner","MyPlannerClassName"); currProps.put("compaction.service.default.planner.opts.myOpt1","val1"); currProps.put("compaction.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("compaction.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 occursAccumuloSecurityException- if the user does not have permissionIllegalArgumentException- if the Consumer alters the map by adding properties that cannot be stored in ZooKeeper- Since:
- 2.1.0
-
removeProperty
Removes a system property from zookeeper. Changes can be seen usinggetSystemConfiguration()- Parameters:
property- the name of a system property- Throws:
AccumuloException- if a general error occursAccumuloSecurityException- if the user does not have permission
-
getSystemConfiguration
Retrieve the system-wide, merged view of the system configuration. Accumulo has multiple layers of properties, in order of precedence (highest - lowest):- the system properties set in Zookeeper
- the properties set in the site configuration file
- the default properties
modifyProperties,setPropertyandremoveProperty. Properties can be further refined by namespaceNamespaceOperationsand by tableTableOperations. Note that this connects to a random server, so the configuration returned will be influenced by the site configuration local to the server and the resource group of the server.- 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:
AccumuloExceptionAccumuloSecurityException
-
getSiteConfiguration
Retrieve the site configuration (that is set in the server configuration file). Note that this connects to a random server, so the configuration returned will be influenced by the site configuration local to the server.- 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:
AccumuloExceptionAccumuloSecurityException
-
getSystemProperties
Retrieve a map of the system properties set in Zookeeper. Note that this does not return a merged view of the properties from its parent configuration. SeegetSystemConfiguration()for a merged view.- Returns:
- A map of the system properties set in Zookeeper only.
- Throws:
AccumuloExceptionAccumuloSecurityException- Since:
- 4.0.0
-
getManagerLocations
Deprecated.Returns the location(s) of the accumulo manager and any redundant servers.- Returns:
- a list of locations in
hostname:portform. - Since:
- 2.1.0
-
getCompactors
Deprecated.Returns the locations of the active compactors- Returns:
- A set of currently active compactors.
- Since:
- 2.1.4
-
getScanServers
Deprecated.Returns the locations of the active scan servers- Returns:
- A set of currently active scan servers.
- Since:
- 2.1.0
-
getTabletServers
Deprecated.List the currently active tablet servers participating in the accumulo instance- Returns:
- A list of currently active tablet servers.
-
getServer
Resolve the server of the given type and address to a ServerId- Parameters:
type- type of serverresourceGroup- group of server, can be nullhost- host name, cannot be nullport- host port- Returns:
- ServerId if found, else null
- Since:
- 4.0.0
-
getServers
Returns all servers of the given types. For the Manager, Monitor, and Garbage Collector, the result will contain only one element for the current active process.- Returns:
- set of servers of the supplied type
- Since:
- 4.0.0
-
getServers
Set<ServerId> getServers(ServerId.Type type, Predicate<ResourceGroupId> resourceGroupPredicate, BiPredicate<String, Integer> hostPortPredicate) Returns the servers of a given type that match the given criteria- Parameters:
resourceGroupPredicate- only returns servers where the resource group matches this predicate. For the Manager, Monitor, and Garbage Collector, this parameter is not used.hostPortPredicate- only returns servers where its host and port match this predicate.- Returns:
- set of servers of the supplied type matching the supplied test
- Since:
- 4.0.0
-
getActiveScans
@Deprecated(since="4.0.0") List<ActiveScan> getActiveScans(String tserver) throws AccumuloException, AccumuloSecurityException Deprecated.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:
AccumuloExceptionAccumuloSecurityException
-
getActiveScans
List<ActiveScan> getActiveScans(Collection<ServerId> servers) throws AccumuloException, AccumuloSecurityException List the active scans on a collection of servers.- Parameters:
servers- Collection of server types and addresses- Returns:
- A list of active scans on the given servers.
- Throws:
IllegalArgumentException- when the type of the server is not TABLET_SERVER or SCAN_SERVERAccumuloExceptionAccumuloSecurityException- Since:
- 4.0.0
-
getActiveCompactions
@Deprecated(since="4.0.0") List<ActiveCompaction> getActiveCompactions(String tserver) throws AccumuloException, AccumuloSecurityException Deprecated.List the active compaction running on a TabletServer or Compactor. The server address can be retrieved usinggetCompactors()orgetTabletServers(). UsegetActiveCompactions()to get a list of all compactions running on tservers and compactors. Implementation updated in 2.1.4 to accept a compactor address.- Parameters:
tserver- The server address. This should be of the form<ip address>:<port>- Returns:
- the list of active compactions
- Throws:
AccumuloExceptionAccumuloSecurityException- Since:
- 1.5.0
-
getActiveCompactions
@Deprecated(since="4.0.0") List<ActiveCompaction> getActiveCompactions() throws AccumuloException, AccumuloSecurityExceptionDeprecated.List all internal and external compactions running in Accumulo.- Returns:
- the list of active compactions
- Throws:
AccumuloExceptionAccumuloSecurityException- Since:
- 2.1.0
-
getActiveCompactions
List<ActiveCompaction> getActiveCompactions(Collection<ServerId> servers) throws AccumuloException, AccumuloSecurityException List the active compaction running on a collection of TabletServers or Compactors. The server addresses can be retrieved usinggetServers(Type). UsegetActiveCompactions()to get a list of all compactions running on tservers and compactors.- Parameters:
servers- The collection of servers- Returns:
- the list of active compactions
- Throws:
IllegalArgumentException- if a type of server is not TABLET_SERVER or COMPACTORAccumuloExceptionAccumuloSecurityException- Since:
- 4.0.0
-
ping
Check to see if a server process at the host and port is up and responding to RPC requests.- Parameters:
tserver- The server address. This should be of the form<ip address>:<port>- Throws:
AccumuloException- if the server cannot be contacted- Since:
- 1.5.0
-
ping
Check to see if a server process at the host and port is up and responding to RPC requests.- Parameters:
server- ServerId object for the server to be pinged, only the host and port is used.- Throws:
AccumuloException- if the server cannot be contacted- Since:
- 4.0.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, seeTableOperations.testClassLoad(String, String, String)- Returns:
- true if the instance can load the given class as the given type, false otherwise
- Throws:
AccumuloExceptionAccumuloSecurityException
-
waitForBalance
Waits for the tablet balancer to run and return no migrations.- Throws:
AccumuloException- Since:
- 1.7.0
-
getInstanceId
InstanceId getInstanceId()Returns a unique ID object that identifies this instance of accumulo.- Returns:
- an InstanceId
- Since:
- 2.1.0
-
getManagerTime
Return the current manager time. This duration represents the amount of time an accumulo manager process has been running. The duration is persisted and should only increase over the lifetime of an Accumulo instance.- Returns:
- current time
- Throws:
AccumuloExceptionAccumuloSecurityException- Since:
- 4.0.0
-
getActiveCompactions(Collection)