Class NamespaceOperationsImpl
- java.lang.Object
-
- org.apache.accumulo.core.clientImpl.NamespaceOperationsHelper
-
- org.apache.accumulo.core.clientImpl.NamespaceOperationsImpl
-
- All Implemented Interfaces:
NamespaceOperations
public class NamespaceOperationsImpl extends NamespaceOperationsHelper
-
-
Constructor Summary
Constructors Constructor Description NamespaceOperationsImpl(ClientContext context, TableOperationsImpl tableOps)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
addConstraint(String namespace, String constraintClassName)
Add a new constraint to a namespace.void
attachIterator(String namespace, IteratorSetting setting, EnumSet<IteratorUtil.IteratorScope> scopes)
Add an iterator to a namespace on the given scopes.void
create(String namespace)
Create an empty namespace with no initial configuration.void
delete(String namespace)
Delete an empty namespaceboolean
exists(String namespace)
A method to check if a namespace exists in Accumulo.Map<String,String>
getConfiguration(String namespace)
Gets properties of a namespace, which are inherited by tables in this namespace.Map<String,String>
getNamespaceProperties(String namespace)
Gets properties specific to this namespace.SortedSet<String>
list()
Retrieve a list of namespaces in Accumulo.Map<String,String>
modifyProperties(String namespace, Consumer<Map<String,String>> mapMutator)
For a detailed overview of the behavior of this method seeInstanceOperations.modifyProperties(Consumer)
which operates on a different layer of properties but has the same behavior and better documentation.Map<String,String>
namespaceIdMap()
Get a mapping of namespace name to internal namespace id.void
removeProperty(String namespace, String property)
Removes a property from a namespace.void
rename(String oldNamespaceName, String newNamespaceName)
Rename a namespacevoid
setProperty(String namespace, String property, String value)
Sets a property on a namespace which applies to all tables in the namespace.boolean
testClassLoad(String namespace, String className, String asTypeName)
Test to see if the instance can load the given class as the given type.-
Methods inherited from class org.apache.accumulo.core.clientImpl.NamespaceOperationsHelper
attachIterator, checkIteratorConflicts, defaultNamespace, getIteratorSetting, listConstraints, listIterators, removeConstraint, removeIterator, systemNamespace
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.accumulo.core.client.admin.NamespaceOperations
getProperties
-
-
-
-
Constructor Detail
-
NamespaceOperationsImpl
public NamespaceOperationsImpl(ClientContext context, TableOperationsImpl tableOps)
-
-
Method Detail
-
list
public SortedSet<String> list()
Description copied from interface:NamespaceOperations
Retrieve a list of namespaces in Accumulo.- Returns:
- List of namespaces in accumulo
-
exists
public boolean exists(String namespace)
Description copied from interface:NamespaceOperations
A method to check if a namespace exists in Accumulo.- Parameters:
namespace
- the name of the namespace- Returns:
- true if the namespace exists
-
create
public void create(String namespace) throws AccumuloException, AccumuloSecurityException, NamespaceExistsException
Description copied from interface:NamespaceOperations
Create an empty namespace with no initial configuration. Valid names for a namespace contain letters, numbers, and the underscore character. A safe way to ignore namespaces that do exist would be to do something like the following:try { connector.namespaceOperations().create("mynamespace"); } catch (NamespaceExistsException e) { // ignore or log }
- Parameters:
namespace
- the name of the namespace- Throws:
AccumuloException
- if a general error occursAccumuloSecurityException
- if the user does not have permissionNamespaceExistsException
- if the specified namespace already exists
-
delete
public void delete(String namespace) throws AccumuloException, AccumuloSecurityException, NamespaceNotFoundException, NamespaceNotEmptyException
Description copied from interface:NamespaceOperations
Delete an empty namespace- Parameters:
namespace
- the name of the namespace- Throws:
AccumuloException
- if a general error occursAccumuloSecurityException
- if the user does not have permissionNamespaceNotFoundException
- if the specified namespace doesn't existNamespaceNotEmptyException
- if the namespaces still contains tables
-
rename
public void rename(String oldNamespaceName, String newNamespaceName) throws AccumuloSecurityException, NamespaceNotFoundException, AccumuloException, NamespaceExistsException
Description copied from interface:NamespaceOperations
Rename a namespace- Parameters:
oldNamespaceName
- the old namespace namenewNamespaceName
- the new namespace name- Throws:
AccumuloSecurityException
- if the user does not have permissionNamespaceNotFoundException
- if the old namespace does not existAccumuloException
- if a general error occursNamespaceExistsException
- if the new namespace already exists
-
setProperty
public void setProperty(String namespace, String property, String value) throws AccumuloException, AccumuloSecurityException, NamespaceNotFoundException
Description copied from interface:NamespaceOperations
Sets a property on a namespace which applies to all tables in the namespace. Note that it may take a few seconds to propagate the change everywhere.- Parameters:
namespace
- the name of the namespaceproperty
- the name of a per-table propertyvalue
- the value to set a per-table property to- Throws:
AccumuloException
- if a general error occursAccumuloSecurityException
- if the user does not have permissionNamespaceNotFoundException
- if the specified namespace doesn't exist
-
modifyProperties
public Map<String,String> modifyProperties(String namespace, Consumer<Map<String,String>> mapMutator) throws AccumuloException, AccumuloSecurityException, NamespaceNotFoundException
Description copied from interface:NamespaceOperations
For a detailed overview of the behavior of this method seeInstanceOperations.modifyProperties(Consumer)
which operates on a different layer of properties but has the same behavior and better documentation.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 this namespace's layer to the mapMutator.
mapMutator
- This consumer should modify the passed in snapshot of namespace 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 namespace. This map is immutable and contains the snapshot passed to mapMutator and the changes made by mapMutator.
- Throws:
AccumuloException
AccumuloSecurityException
NamespaceNotFoundException
-
removeProperty
public void removeProperty(String namespace, String property) throws AccumuloException, AccumuloSecurityException, NamespaceNotFoundException
Description copied from interface:NamespaceOperations
Removes a property from a namespace. Note that it may take a few seconds to propagate the change everywhere.- Parameters:
namespace
- the name of the namespaceproperty
- the name of a per-table property- Throws:
AccumuloException
- if a general error occursAccumuloSecurityException
- if the user does not have permissionNamespaceNotFoundException
- if the specified namespace doesn't exist
-
getConfiguration
public Map<String,String> getConfiguration(String namespace) throws AccumuloException, AccumuloSecurityException, NamespaceNotFoundException
Description copied from interface:NamespaceOperations
Gets properties of a namespace, which are inherited by tables in this namespace. Note that recently changed properties may not be available immediately. This new method returns a Map instead of an Iterable.- Parameters:
namespace
- the name of the namespace- Returns:
- all properties visible by this namespace (system and per-table properties). Note that recently changed properties may not be visible immediately.
- Throws:
AccumuloException
- if a general error occursAccumuloSecurityException
- if the user does not have permissionNamespaceNotFoundException
- if the specified namespace doesn't exist
-
getNamespaceProperties
public Map<String,String> getNamespaceProperties(String namespace) throws AccumuloException, AccumuloSecurityException, NamespaceNotFoundException
Description copied from interface:NamespaceOperations
Gets properties specific to this namespace. Note that recently changed properties may not be available immediately. This new method returns a Map instead of an Iterable.- Parameters:
namespace
- the name of the namespace- Returns:
- per-table properties specific to this namespace. Note that recently changed properties may not be visible immediately.
- Throws:
AccumuloException
- if a general error occursAccumuloSecurityException
- if the user does not have permissionNamespaceNotFoundException
- if the specified namespace doesn't exist
-
namespaceIdMap
public Map<String,String> namespaceIdMap()
Description copied from interface:NamespaceOperations
Get a mapping of namespace name to internal namespace id.- Returns:
- the map from namespace name to internal namespace id
-
testClassLoad
public boolean testClassLoad(String namespace, String className, String asTypeName) throws NamespaceNotFoundException, AccumuloException, AccumuloSecurityException
Description copied from interface:NamespaceOperations
Test to see if the instance can load the given class as the given type. This check uses the table classpath property if it is set.- Parameters:
namespace
- the name of the namespaceclassName
- the class to try to loadasTypeName
- the interface or superclass the given class is attempted to load as- Returns:
- true if the instance can load the given class as the given type, false otherwise
- Throws:
NamespaceNotFoundException
- if the specified namespace doesn't existAccumuloException
- if a general error occursAccumuloSecurityException
- if the user does not have permission
-
attachIterator
public void attachIterator(String namespace, IteratorSetting setting, EnumSet<IteratorUtil.IteratorScope> scopes) throws AccumuloSecurityException, AccumuloException, NamespaceNotFoundException
Description copied from interface:NamespaceOperations
Add an iterator to a namespace on the given scopes.- Specified by:
attachIterator
in interfaceNamespaceOperations
- Overrides:
attachIterator
in classNamespaceOperationsHelper
- Parameters:
namespace
- the name of the namespacesetting
- object specifying the properties of the iteratorscopes
- the set of scopes the iterator should apply to- Throws:
AccumuloSecurityException
- if the user does not have permissionAccumuloException
- if a general error occursNamespaceNotFoundException
- if the specified namespace doesn't exist
-
addConstraint
public int addConstraint(String namespace, String constraintClassName) throws AccumuloException, AccumuloSecurityException, NamespaceNotFoundException
Description copied from interface:NamespaceOperations
Add a new constraint to a namespace.- Specified by:
addConstraint
in interfaceNamespaceOperations
- Overrides:
addConstraint
in classNamespaceOperationsHelper
- Parameters:
namespace
- the name of the namespaceconstraintClassName
- the full name of the constraint class- Returns:
- the unique id number assigned to the constraint
- Throws:
AccumuloException
- if a general error occursAccumuloSecurityException
- if the user does not have permissionNamespaceNotFoundException
- if the specified namespace doesn't exist
-
-