Tabnine Logo
NamespaceOperations
Code IndexAdd Tabnine to your IDE (free)

How to use
NamespaceOperations
in
org.apache.accumulo.core.client.admin

Best Java code snippets using org.apache.accumulo.core.client.admin.NamespaceOperations (Showing top 20 results out of 315)

origin: prestodb/presto

/**
 * Ensures the given Accumulo namespace exist, creating it if necessary
 *
 * @param schema Presto schema (Accumulo namespace)
 */
public void ensureNamespace(String schema)
{
  try {
    // If the table schema is not "default" and the namespace does not exist, create it
    if (!schema.equals(DEFAULT) && !connector.namespaceOperations().exists(schema)) {
      connector.namespaceOperations().create(schema);
    }
  }
  catch (AccumuloException | AccumuloSecurityException e) {
    throw new PrestoException(UNEXPECTED_ACCUMULO_ERROR, "Failed to check for existence or create Accumulo namespace", e);
  }
  catch (NamespaceExistsException e) {
    // Suppress race condition between test for existence and creation
    LOG.warn("NamespaceExistsException suppressed when creating " + schema);
  }
}
origin: apache/accumulo

 namespaces = accumuloClient.namespaceOperations().list();
} catch (Exception e) {
 log.debug("Unable to obtain list of namespaces", e);
origin: apache/accumulo

@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState)
  throws AccumuloException, AccumuloSecurityException, TableExistsException,
  TableNotFoundException, IOException, ClassNotFoundException, NamespaceExistsException,
  NamespaceNotFoundException {
 if (createNamespaceOptCopyConfig == null) {
  getOptions();
 }
 String namespace = cl.getArgs()[0];
 shellState.getAccumuloClient().namespaceOperations().create(namespace);
 // Copy options if flag was set
 Iterable<Entry<String,String>> configuration = null;
 if (cl.hasOption(createNamespaceOptCopyConfig.getOpt())) {
  String copy = cl.getOptionValue(createNamespaceOptCopyConfig.getOpt());
  if (shellState.getAccumuloClient().namespaceOperations().exists(namespace)) {
   configuration = shellState.getAccumuloClient().namespaceOperations().getProperties(copy);
  }
 }
 if (configuration != null) {
  for (Entry<String,String> entry : configuration) {
   if (Property.isValidTablePropertyKey(entry.getKey())) {
    shellState.getAccumuloClient().namespaceOperations().setProperty(namespace,
      entry.getKey(), entry.getValue());
   }
  }
 }
 return 0;
}
origin: apache/accumulo

if (!shellState.getAccumuloClient().namespaceOperations().testClassLoad(namespace, classname,
  SortedKeyValueIterator.class.getName())) {
 throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE,
shellState.getAccumuloClient().namespaceOperations().attachIterator(namespace, setting, scopes);
origin: org.apache.accumulo/accumulo-test

assertFalse(ops.exists(namespace));
  switch (i) {
   case 0:
    ops.addConstraint(namespace, NumericValueConstraint.class.getName());
    fail();
    break;
   case 1:
    ops.attachIterator(namespace, setting);
    fail();
    break;
   case 2:
    ops.checkIteratorConflicts(namespace, setting, EnumSet.of(IteratorScope.scan));
    fail();
    break;
   case 3:
    ops.delete(namespace);
    fail();
    break;
   case 4:
    ops.getIteratorSetting(namespace, "thing", IteratorScope.scan);
    fail();
    break;
   case 5:
    ops.getProperties(namespace);
    fail();
    break;
   case 6:
    ops.listConstraints(namespace);
origin: org.apache.accumulo/accumulo-test

namespace = "__CREATE_NAMESPACE_WITH_PERM_TEST__";
loginAs(testUser);
test_user_conn.namespaceOperations().create(namespace);
loginAs(rootUser);
if (!root_conn.namespaceOperations().list().contains(namespace))
 throw new IllegalStateException("Should be able to create a namespace");
break;
namespace = "__DROP_NAMESPACE_WITH_PERM_TEST__";
loginAs(rootUser);
root_conn.namespaceOperations().create(namespace);
loginAs(testUser);
test_user_conn.namespaceOperations().delete(namespace);
loginAs(rootUser);
if (root_conn.namespaceOperations().list().contains(namespace))
 throw new IllegalStateException("Should be able to delete a namespace");
break;
String namespace2 = namespace + "2";
loginAs(rootUser);
root_conn.namespaceOperations().create(namespace);
loginAs(testUser);
test_user_conn.namespaceOperations().setProperty(namespace,
  Property.TABLE_BLOOM_ERRORRATE.getKey(), "003.14159%");
loginAs(rootUser);
Map<String,String> propies = map(root_conn.namespaceOperations().getProperties(namespace));
if (!propies.get(Property.TABLE_BLOOM_ERRORRATE.getKey()).equals("003.14159%"))
 throw new IllegalStateException("Should be able to set a table property");
loginAs(testUser);
origin: org.apache.accumulo/accumulo-test

assertFalse(c.namespaceOperations().exists(namespace));
assertFalse(c.tableOperations().exists(t1));
assertFalse(c.tableOperations().exists(t2));
c.namespaceOperations().create(namespace);
c.tableOperations().create(t1);
c.tableOperations().create(t0);
assertTrue(c.namespaceOperations().exists(namespace));
assertTrue(c.tableOperations().exists(t1));
assertTrue(c.tableOperations().exists(t0));
c.namespaceOperations().setProperty(namespace, k, v);
assertTrue(checkNamespaceHasProp(namespace, k, v));
assertTrue(checkTableHasProp(t1, k, v));
c.namespaceOperations().removeProperty(namespace, k);
assertFalse(checkNamespaceHasProp(namespace, k, v));
assertFalse(checkTableHasProp(t1, k, v));
c.namespaceOperations().setProperty(Namespaces.DEFAULT_NAMESPACE, k, v);
assertFalse(checkNamespaceHasProp(namespace, k, v));
assertFalse(checkTableHasProp(t1, k, v));
c.namespaceOperations().setProperty(namespace, k2, v2);
c.tableOperations().setProperty(t2, k2, table_v2);
assertTrue(checkNamespaceHasProp(namespace, k2, v2));
c.tableOperations().delete(t2);
c.tableOperations().delete(t0);
c.namespaceOperations().delete(namespace);
origin: org.apache.accumulo/accumulo-test

@Test
public void renameNamespaceWithTable() throws Exception {
 String namespace2 = namespace + "_renamed";
 String t1 = namespace + ".t";
 String t2 = namespace2 + ".t";
 c.namespaceOperations().create(namespace);
 c.tableOperations().create(t1);
 assertTrue(c.namespaceOperations().exists(namespace));
 assertTrue(c.tableOperations().exists(t1));
 assertFalse(c.namespaceOperations().exists(namespace2));
 assertFalse(c.tableOperations().exists(t2));
 String namespaceId = c.namespaceOperations().namespaceIdMap().get(namespace);
 String tableId = c.tableOperations().tableIdMap().get(t1);
 c.namespaceOperations().rename(namespace, namespace2);
 assertFalse(c.namespaceOperations().exists(namespace));
 assertFalse(c.tableOperations().exists(t1));
 assertTrue(c.namespaceOperations().exists(namespace2));
 assertTrue(c.tableOperations().exists(t2));
 // verify id's didn't change
 String namespaceId2 = c.namespaceOperations().namespaceIdMap().get(namespace2);
 String tableId2 = c.tableOperations().tableIdMap().get(t2);
 assertEquals(namespaceId, namespaceId2);
 assertEquals(tableId, tableId2);
}
origin: org.apache.accumulo/accumulo-test

@Test
public void verifyIteratorInheritance() throws Exception {
 String t1 = namespace + ".1";
 c.namespaceOperations().create(namespace);
 c.tableOperations().create(t1);
 String iterName = namespace + "_iter";
 assertFalse(c.namespaceOperations().listIterators(namespace).containsKey(iterName));
 assertFalse(c.tableOperations().listIterators(t1).containsKey(iterName));
 c.namespaceOperations().checkIteratorConflicts(namespace, setting,
   EnumSet.allOf(IteratorScope.class));
 c.namespaceOperations().attachIterator(namespace, setting);
 sleepUninterruptibly(2, TimeUnit.SECONDS);
 try {
  c.namespaceOperations().checkIteratorConflicts(namespace, setting,
    EnumSet.allOf(IteratorScope.class));
  fail();
 IteratorSetting setting2 = c.namespaceOperations().getIteratorSetting(namespace,
   setting.getName(), IteratorScope.scan);
 assertEquals(setting, setting2);
 assertTrue(c.namespaceOperations().listIterators(namespace).containsKey(iterName));
 assertTrue(c.tableOperations().listIterators(t1).containsKey(iterName));
 s = c.createScanner(t1, Authorizations.EMPTY);
 c.namespaceOperations().removeIterator(namespace, setting.getName(),
   EnumSet.allOf(IteratorScope.class));
 sleepUninterruptibly(2, TimeUnit.SECONDS);
 assertFalse(c.namespaceOperations().listIterators(namespace).containsKey(iterName));
origin: org.apache.accumulo/accumulo-test

@Test(expected = NamespaceNotEmptyException.class)
public void deleteNonEmptyNamespace() throws Exception {
 String tableName1 = namespace + ".1";
 assertFalse(c.namespaceOperations().exists(namespace));
 assertFalse(c.tableOperations().exists(tableName1));
 c.namespaceOperations().create(namespace);
 c.tableOperations().create(tableName1);
 assertTrue(c.namespaceOperations().exists(namespace));
 assertTrue(c.tableOperations().exists(tableName1));
 c.namespaceOperations().delete(namespace); // should fail
}
origin: apache/accumulo

 && !shellState.getAccumuloClient().namespaceOperations().exists(namespace)) {
throw new NamespaceNotFoundException(null, namespace, null);
    + ", still removing from zookeeper if it's there.");
 shellState.getAccumuloClient().namespaceOperations().removeProperty(namespace, property);
 Shell.log.debug("Successfully deleted namespace configuration option.");
} else {
  new ColumnVisibility(value); // validate that it is a valid expression
 shellState.getAccumuloClient().namespaceOperations().setProperty(namespace, property,
   value);
 Shell.log.debug("Successfully set table configuration option.");
   shellState.getContext(), Tables.getTableId(shellState.getContext(), tableName)));
 for (Entry<String,String> e : shellState.getAccumuloClient().namespaceOperations()
   .getProperties(n)) {
  namespaceConfig.put(e.getKey(), e.getValue());
 acuconf = shellState.getAccumuloClient().tableOperations().getProperties(tableName);
} else if (namespace != null) {
 acuconf = shellState.getAccumuloClient().namespaceOperations().getProperties(namespace);
origin: org.apache.accumulo/accumulo-test

@Test
public void listNamespaces() throws Exception {
 SortedSet<String> namespaces = c.namespaceOperations().list();
 Map<String,String> map = c.namespaceOperations().namespaceIdMap();
 assertEquals(2, namespaces.size());
 assertEquals(2, map.size());
 assertNull(map.get(namespace));
 c.namespaceOperations().create(namespace);
 namespaces = c.namespaceOperations().list();
 map = c.namespaceOperations().namespaceIdMap();
 assertEquals(3, namespaces.size());
 assertEquals(3, map.size());
 assertNotNull(map.get(namespace));
 c.namespaceOperations().delete(namespace);
 namespaces = c.namespaceOperations().list();
 map = c.namespaceOperations().namespaceIdMap();
 assertEquals(2, namespaces.size());
 assertEquals(2, map.size());
origin: org.apache.accumulo/accumulo-test

@Test
public void notInstancePreferredVolumeChooser() throws Exception {
 log.info("Starting notInstancePreferredVolumeChooser");
 // Create namespace
 Connector connector = getConnector();
 connector.namespaceOperations().create(namespace1);
 // Set properties on the namespace
 String propertyName = Property.TABLE_VOLUME_CHOOSER.getKey();
 String volume = PreferredVolumeChooser.class.getName();
 connector.namespaceOperations().setProperty(namespace1, propertyName, volume);
 propertyName = "table.custom.preferredVolumes";
 volume = v3.toString();
 connector.namespaceOperations().setProperty(namespace1, propertyName, volume);
 // Create table1 on namespace1
 String tableName = namespace1 + ".1";
 connector.tableOperations().create(tableName);
 String tableID = connector.tableOperations().tableIdMap().get(tableName);
 // Add 10 splits to the table
 addSplits(connector, tableName);
 // Write some data to the table
 writeAndReadData(connector, tableName);
 // Verify the new files are written to the Volumes specified
 verifyVolumes(connector, tableName, TabletsSection.getRange(tableID),
   v1.toString() + "," + v2.toString() + "," + v4.toString());
}
origin: org.apache.accumulo/accumulo-test

c.namespaceOperations().create(namespace);
c.tableOperations().create(t1);
assertTrue(c.tableOperations().exists(t1));
assertFalse(c.namespaceOperations().exists(namespace2));
assertFalse(c.tableOperations().exists(t2));
assertFalse(c.tableOperations().exists(t3));
c.namespaceOperations().create(namespace2);
c.tableOperations().create(t2);
c.tableOperations().create(t3);
assertTrue(c.namespaceOperations().exists(namespace2));
assertFalse(c.tableOperations().exists(t2));
assertFalse(c.tableOperations().exists(t3));
assertFalse(checkTableHasProp(t1, k2, k2v1));
assertFalse(checkTableHasProp(t1, k2, k2v2));
c.namespaceOperations().setProperty(namespace, k1, k1v1);
c.namespaceOperations().setProperty(namespace2, k1, k1v2);
c.namespaceOperations().setProperty(namespace, k2, k2v1);
c.namespaceOperations().setProperty(namespace2, k2, k2v1);
c.tableOperations().setProperty(t1, k2, k2v2);
assertTrue(checkNamespaceHasProp(namespace, k1, k1v1));
assertTrue(c.namespaceOperations().exists(namespace2));
assertTrue(c.tableOperations().exists(t1));
assertTrue(c.tableOperations().exists(t2));
origin: org.apache.accumulo/accumulo-test

@Test
public void verifyConstraintInheritance() throws Exception {
 String t1 = namespace + ".1";
 c.namespaceOperations().create(namespace);
 c.tableOperations().create(t1, new NewTableConfiguration().withoutDefaultIterators());
 String constraintClassName = NumericValueConstraint.class.getName();
   c.namespaceOperations().listConstraints(namespace).containsKey(constraintClassName));
 assertFalse(c.tableOperations().listConstraints(t1).containsKey(constraintClassName));
 c.namespaceOperations().addConstraint(namespace, constraintClassName);
 boolean passed = false;
 for (int i = 0; i < 5; i++) {
  if (!c.namespaceOperations().listConstraints(namespace).containsKey(constraintClassName)) {
   Thread.sleep(500);
   continue;
 Integer namespaceNum = null;
 for (int i = 0; i < 5; i++) {
  namespaceNum = c.namespaceOperations().listConstraints(namespace).get(constraintClassName);
  if (null == namespaceNum) {
   Thread.sleep(500);
 c.namespaceOperations().removeConstraint(namespace, namespaceNum);
 passed = false;
 for (int i = 0; i < 5; i++) {
  if (c.namespaceOperations().listConstraints(namespace).containsKey(constraintClassName)) {
   Thread.sleep(500);
   continue;
origin: apache/accumulo

public static String getNamespaceOpt(final CommandLine cl, final Shell shellState)
  throws NamespaceNotFoundException, AccumuloException, AccumuloSecurityException {
 String namespace = null;
 if (cl.hasOption(ShellOptions.namespaceOption)) {
  namespace = cl.getOptionValue(ShellOptions.namespaceOption);
  if (!shellState.getAccumuloClient().namespaceOperations().exists(namespace)) {
   throw new NamespaceNotFoundException(namespace, namespace,
     "specified namespace that doesn't exist");
  }
 } else {
  throw new NamespaceNotFoundException(null, null, "no namespace specified");
 }
 return namespace;
}
origin: apache/accumulo

for (String constraint : cl.getArgs()) {
 if (namespace != null) {
  if (!shellState.getAccumuloClient().namespaceOperations().testClassLoad(namespace,
    constraint, Constraint.class.getName())) {
   throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE,
       + Constraint.class.getName());
  i = shellState.getAccumuloClient().namespaceOperations().addConstraint(namespace,
    constraint);
  shellState.getReader().println("Added constraint " + constraint + " to namespace "
 i = Integer.parseInt(constraint);
 if (namespace != null) {
  shellState.getAccumuloClient().namespaceOperations().removeConstraint(namespace, i);
  shellState.getReader()
    .println("Removed constraint " + i + " from namespace " + namespace);
if (namespace != null) {
 for (Entry<String,Integer> property : shellState.getAccumuloClient().namespaceOperations()
   .listConstraints(namespace).entrySet()) {
  shellState.getReader().println(property.toString());
origin: org.apache.accumulo/accumulo-test

 @Override
 public void visit(State state, Environment env, Properties props) throws Exception {
  Connector conn = env.getConnector();

  Random rand = (Random) state.get("rand");

  @SuppressWarnings("unchecked")
  List<String> namespaces = (List<String>) state.get("namespaces");

  String namespace = namespaces.get(rand.nextInt(namespaces.size()));

  try {
   conn.namespaceOperations().create(namespace);
   log.debug("Created namespace " + namespace);
  } catch (NamespaceExistsException e) {
   log.debug("Create namespace " + namespace + " failed, it exists");
  }
 }
}
origin: org.apache.accumulo/accumulo-test

int choice = Integer.parseInt(parts[1]);
Property property = tableSettings[choice].property;
if (env.getConnector().namespaceOperations().exists(namespace)) {
 log.debug("Setting " + property.getKey() + " on " + namespace + " back to "
   + property.getDefaultValue());
 try {
  env.getConnector().namespaceOperations().setProperty(namespace, property.getKey(),
    property.getDefaultValue());
 } catch (AccumuloException ex) {
origin: org.apache.accumulo/accumulo-test

@Test
public void testModifyingPermissions() throws Exception {
 String tableName = namespace + ".modify";
 c.namespaceOperations().create(namespace);
 c.tableOperations().create(tableName);
 assertTrue(
   NamespacePermission.READ));
 c.namespaceOperations().delete(namespace);
org.apache.accumulo.core.client.adminNamespaceOperations

Javadoc

Provides an API for administering namespaces All tables exist in a namespace. The default namespace has no name, and is used if an explicit namespace is not specified. Fully qualified table names look like "namespaceName.tableName". Tables in the default namespace are fully qualified simply as "tableName".

Most used methods

  • create
    Create an empty namespace with no initial configuration. Valid names for a namespace contain letters
  • exists
    A method to check if a namespace exists in Accumulo.
  • list
    Retrieve a list of namespaces in Accumulo.
  • getProperties
    Gets properties of a namespace, which are inherited by tables in this namespace. Note that recently
  • addConstraint
    Add a new constraint to a namespace.
  • attachIterator
    Add an iterator to a namespace on the given scopes.
  • delete
    Delete an empty namespace
  • getIteratorSetting
    Get the settings for an iterator.
  • listConstraints
    List constraints on a namespace with their assigned numbers.
  • listIterators
    Get a list of iterators for this namespace.
  • namespaceIdMap
    Get a mapping of namespace name to internal namespace id.
  • removeConstraint
    Remove a constraint from a namespace.
  • namespaceIdMap,
  • removeConstraint,
  • removeIterator,
  • removeProperty,
  • rename,
  • setProperty,
  • testClassLoad,
  • checkIteratorConflicts,
  • defaultNamespace,
  • systemNamespace

Popular in Java

  • Creating JSON documents from java classes using gson
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getSharedPreferences (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • String (java.lang)
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now