Search in sources :

Example 1 with NamespaceOperations

use of org.apache.accumulo.core.client.admin.NamespaceOperations in project accumulo by apache.

the class NamespacesIT method verifyNamespaceOperationsExceptions.

@Test
public void verifyNamespaceOperationsExceptions() throws Exception {
    IteratorSetting setting = new IteratorSetting(200, VersioningIterator.class);
    NamespaceOperations ops = c.namespaceOperations();
    // this one doesn't throw an exception, so don't fail; just check that it works
    assertFalse(ops.exists(namespace));
    // namespace operations that should throw a NamespaceNotFoundException
    int numRun = 0;
    NAMESPACENOTFOUND: for (int i = 0; ; ++i) try {
        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);
                fail();
                break;
            case 7:
                ops.listIterators(namespace);
                fail();
                break;
            case 8:
                ops.removeConstraint(namespace, 1);
                fail();
                break;
            case 9:
                ops.removeIterator(namespace, "thing", EnumSet.allOf(IteratorScope.class));
                fail();
                break;
            case 10:
                ops.removeProperty(namespace, "a");
                fail();
                break;
            case 11:
                ops.rename(namespace, namespace + "2");
                fail();
                break;
            case 12:
                ops.setProperty(namespace, "k", "v");
                fail();
                break;
            case 13:
                ops.testClassLoad(namespace, VersioningIterator.class.getName(), SortedKeyValueIterator.class.getName());
                fail();
                break;
            default:
                // break out of infinite loop
                // check test integrity
                assertEquals(14, i);
                // check test integrity
                assertEquals(14, numRun);
                break NAMESPACENOTFOUND;
        }
    } catch (Exception e) {
        numRun++;
        if (!(e instanceof NamespaceNotFoundException))
            throw new Exception("Case " + i + " resulted in " + e.getClass().getName(), e);
    }
    // namespace operations that should throw a NamespaceExistsException
    numRun = 0;
    NAMESPACEEXISTS: for (int i = 0; ; ++i) try {
        switch(i) {
            case 0:
                ops.create(namespace + "0");
                // should fail here
                ops.create(namespace + "0");
                fail();
                break;
            case 1:
                ops.create(namespace + i + "_1");
                ops.create(namespace + i + "_2");
                // should fail here
                ops.rename(namespace + i + "_1", namespace + i + "_2");
                fail();
                break;
            case 2:
                ops.create(Namespace.DEFAULT);
                fail();
                break;
            case 3:
                ops.create(Namespace.ACCUMULO);
                fail();
                break;
            case 4:
                ops.create(namespace + i + "_1");
                // should fail here
                ops.rename(namespace + i + "_1", Namespace.DEFAULT);
                fail();
                break;
            case 5:
                ops.create(namespace + i + "_1");
                // should fail here
                ops.rename(namespace + i + "_1", Namespace.ACCUMULO);
                fail();
                break;
            default:
                // break out of infinite loop
                // check test integrity
                assertEquals(6, i);
                // check test integrity
                assertEquals(6, numRun);
                break NAMESPACEEXISTS;
        }
    } catch (Exception e) {
        numRun++;
        if (!(e instanceof NamespaceExistsException))
            throw new Exception("Case " + i + " resulted in " + e.getClass().getName(), e);
    }
}
Also used : IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) NamespaceOperations(org.apache.accumulo.core.client.admin.NamespaceOperations) SortedKeyValueIterator(org.apache.accumulo.core.iterators.SortedKeyValueIterator) IteratorScope(org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope) VersioningIterator(org.apache.accumulo.core.iterators.user.VersioningIterator) NumericValueConstraint(org.apache.accumulo.test.constraints.NumericValueConstraint) NamespaceExistsException(org.apache.accumulo.core.client.NamespaceExistsException) NumericValueConstraint(org.apache.accumulo.test.constraints.NumericValueConstraint) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NamespaceExistsException(org.apache.accumulo.core.client.NamespaceExistsException) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException) NamespaceNotEmptyException(org.apache.accumulo.core.client.NamespaceNotEmptyException) TableExistsException(org.apache.accumulo.core.client.TableExistsException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) IOException(java.io.IOException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) ThriftTableOperationException(org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 AccumuloException (org.apache.accumulo.core.client.AccumuloException)1 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)1 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)1 MutationsRejectedException (org.apache.accumulo.core.client.MutationsRejectedException)1 NamespaceExistsException (org.apache.accumulo.core.client.NamespaceExistsException)1 NamespaceNotEmptyException (org.apache.accumulo.core.client.NamespaceNotEmptyException)1 NamespaceNotFoundException (org.apache.accumulo.core.client.NamespaceNotFoundException)1 TableExistsException (org.apache.accumulo.core.client.TableExistsException)1 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)1 NamespaceOperations (org.apache.accumulo.core.client.admin.NamespaceOperations)1 ThriftTableOperationException (org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException)1 IteratorScope (org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope)1 SortedKeyValueIterator (org.apache.accumulo.core.iterators.SortedKeyValueIterator)1 VersioningIterator (org.apache.accumulo.core.iterators.user.VersioningIterator)1 NumericValueConstraint (org.apache.accumulo.test.constraints.NumericValueConstraint)1 Test (org.junit.Test)1