Search in sources :

Example 6 with IteratorSetting

use of org.apache.accumulo.proxy.thrift.IteratorSetting in project accumulo by apache.

the class TestProxyNamespaceOperations method namespaceIteratorConflict.

@Test(expected = AccumuloException.class)
public void namespaceIteratorConflict() throws TException {
    IteratorSetting setting = new IteratorSetting(40, "DebugTheThings", "org.apache.accumulo.core.iterators.DebugIterator", new HashMap<>());
    Set<IteratorScope> scopes = new HashSet<>();
    scopes.add(IteratorScope.SCAN);
    tpc.proxy().attachNamespaceIterator(userpass, testnamespace, setting, scopes);
    tpc.proxy().checkNamespaceIteratorConflicts(userpass, testnamespace, setting, scopes);
}
Also used : IteratorSetting(org.apache.accumulo.proxy.thrift.IteratorSetting) IteratorScope(org.apache.accumulo.proxy.thrift.IteratorScope) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with IteratorSetting

use of org.apache.accumulo.proxy.thrift.IteratorSetting in project accumulo by apache.

the class TestProxyNamespaceOperations method namespaceIterators.

@Test
public void namespaceIterators() throws TException {
    IteratorSetting setting = new IteratorSetting(40, "DebugTheThings", "org.apache.accumulo.core.iterators.DebugIterator", new HashMap<>());
    Set<IteratorScope> scopes = new HashSet<>();
    scopes.add(IteratorScope.SCAN);
    tpc.proxy().attachNamespaceIterator(userpass, testnamespace, setting, scopes);
    assertEquals(setting, tpc.proxy().getNamespaceIteratorSetting(userpass, testnamespace, "DebugTheThings", IteratorScope.SCAN));
    assertTrue(tpc.proxy().listNamespaceIterators(userpass, testnamespace).containsKey("DebugTheThings"));
    Set<IteratorScope> scopes2 = new HashSet<>();
    scopes2.add(IteratorScope.MINC);
    tpc.proxy().checkNamespaceIteratorConflicts(userpass, testnamespace, setting, scopes2);
    tpc.proxy().removeNamespaceIterator(userpass, testnamespace, "DebugTheThings", scopes);
    assertFalse(tpc.proxy().listNamespaceIterators(userpass, testnamespace).containsKey("DebugTheThings"));
}
Also used : IteratorSetting(org.apache.accumulo.proxy.thrift.IteratorSetting) IteratorScope(org.apache.accumulo.proxy.thrift.IteratorScope) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 8 with IteratorSetting

use of org.apache.accumulo.proxy.thrift.IteratorSetting in project accumulo by apache.

the class TestProxyReadWrite method asynchReadWrite.

@Test
public void asynchReadWrite() throws Exception {
    int maxInserts = 10000;
    Map<ByteBuffer, List<ColumnUpdate>> mutations = new HashMap<>();
    String format = "%1$05d";
    String writer = tpc.proxy().createWriter(userpass, testtable, null);
    for (int i = 0; i < maxInserts; i++) {
        addMutation(mutations, String.format(format, i), "cf" + i, "cq" + i, Util.randString(10));
        if (i % 1000 == 0 || i == maxInserts - 1) {
            tpc.proxy().update(writer, mutations);
            mutations.clear();
        }
    }
    tpc.proxy().flush(writer);
    tpc.proxy().closeWriter(writer);
    String regex = ".*[02468]";
    org.apache.accumulo.core.client.IteratorSetting is = new org.apache.accumulo.core.client.IteratorSetting(50, regex, RegExFilter.class);
    RegExFilter.setRegexs(is, regex, null, null, null, false);
    IteratorSetting pis = Util.iteratorSetting2ProxyIteratorSetting(is);
    ScanOptions opts = new ScanOptions();
    opts.iterators = Collections.singletonList(pis);
    String cookie = tpc.proxy().createScanner(userpass, testtable, opts);
    int i = 0;
    boolean hasNext = true;
    int k = 1000;
    int numRead = 0;
    while (hasNext) {
        ScanResult kvList = tpc.proxy().nextK(cookie, k);
        for (KeyValue kv : kvList.getResults()) {
            assertEquals(i, Integer.parseInt(new String(kv.getKey().getRow())));
            numRead++;
            i += 2;
        }
        hasNext = kvList.isMore();
    }
    assertEquals(maxInserts / 2, numRead);
}
Also used : ScanResult(org.apache.accumulo.proxy.thrift.ScanResult) KeyValue(org.apache.accumulo.proxy.thrift.KeyValue) HashMap(java.util.HashMap) ByteBuffer(java.nio.ByteBuffer) IteratorSetting(org.apache.accumulo.proxy.thrift.IteratorSetting) List(java.util.List) ScanOptions(org.apache.accumulo.proxy.thrift.ScanOptions) BatchScanOptions(org.apache.accumulo.proxy.thrift.BatchScanOptions) Test(org.junit.Test)

Example 9 with IteratorSetting

use of org.apache.accumulo.proxy.thrift.IteratorSetting in project accumulo by apache.

the class TestProxyReadWrite method readWriteBatchOneShotWithFilterIterator.

/**
 * Insert 100000 cells which have as the row [0..99999] (padded with zeros). Filter the results so only the even numbers come back.
 */
@Test
public void readWriteBatchOneShotWithFilterIterator() throws Exception {
    int maxInserts = 10000;
    Map<ByteBuffer, List<ColumnUpdate>> mutations = new HashMap<>();
    String format = "%1$05d";
    for (int i = 0; i < maxInserts; i++) {
        addMutation(mutations, String.format(format, i), "cf" + i, "cq" + i, Util.randString(10));
        if (i % 1000 == 0 || i == maxInserts - 1) {
            tpc.proxy().updateAndFlush(userpass, testtable, mutations);
            mutations.clear();
        }
    }
    String regex = ".*[02468]";
    org.apache.accumulo.core.client.IteratorSetting is = new org.apache.accumulo.core.client.IteratorSetting(50, regex, RegExFilter.class);
    RegExFilter.setRegexs(is, regex, null, null, null, false);
    IteratorSetting pis = Util.iteratorSetting2ProxyIteratorSetting(is);
    ScanOptions opts = new ScanOptions();
    opts.iterators = Collections.singletonList(pis);
    String cookie = tpc.proxy().createScanner(userpass, testtable, opts);
    int i = 0;
    boolean hasNext = true;
    int k = 1000;
    while (hasNext) {
        ScanResult kvList = tpc.proxy().nextK(cookie, k);
        for (KeyValue kv : kvList.getResults()) {
            assertEquals(Integer.parseInt(new String(kv.getKey().getRow())), i);
            i += 2;
        }
        hasNext = kvList.isMore();
    }
}
Also used : ScanResult(org.apache.accumulo.proxy.thrift.ScanResult) KeyValue(org.apache.accumulo.proxy.thrift.KeyValue) HashMap(java.util.HashMap) ByteBuffer(java.nio.ByteBuffer) IteratorSetting(org.apache.accumulo.proxy.thrift.IteratorSetting) List(java.util.List) ScanOptions(org.apache.accumulo.proxy.thrift.ScanOptions) BatchScanOptions(org.apache.accumulo.proxy.thrift.BatchScanOptions) Test(org.junit.Test)

Example 10 with IteratorSetting

use of org.apache.accumulo.proxy.thrift.IteratorSetting in project accumulo by apache.

the class SimpleProxyBase method attachNamespaceIteratorLoginFailure.

@Test(expected = AccumuloSecurityException.class, timeout = 5000)
public void attachNamespaceIteratorLoginFailure() throws Exception {
    IteratorSetting setting = new IteratorSetting(100, "DebugTheThings", DebugIterator.class.getName(), Collections.emptyMap());
    client.attachNamespaceIterator(badLogin, namespaceName, setting, EnumSet.allOf(IteratorScope.class));
}
Also used : DebugIterator(org.apache.accumulo.core.iterators.DebugIterator) IteratorSetting(org.apache.accumulo.proxy.thrift.IteratorSetting) IteratorScope(org.apache.accumulo.proxy.thrift.IteratorScope) Test(org.junit.Test)

Aggregations

IteratorSetting (org.apache.accumulo.proxy.thrift.IteratorSetting)14 Test (org.junit.Test)14 IteratorScope (org.apache.accumulo.proxy.thrift.IteratorScope)9 NumericValueConstraint (org.apache.accumulo.test.constraints.NumericValueConstraint)6 ByteBuffer (java.nio.ByteBuffer)5 HashMap (java.util.HashMap)5 List (java.util.List)4 DebugIterator (org.apache.accumulo.core.iterators.DebugIterator)4 BatchScanOptions (org.apache.accumulo.proxy.thrift.BatchScanOptions)4 NamespaceNotFoundException (org.apache.accumulo.proxy.thrift.NamespaceNotFoundException)4 ScanOptions (org.apache.accumulo.proxy.thrift.ScanOptions)4 TableNotFoundException (org.apache.accumulo.proxy.thrift.TableNotFoundException)4 ArrayList (java.util.ArrayList)3 Client (org.apache.accumulo.proxy.thrift.AccumuloProxy.Client)3 AccumuloSecurityException (org.apache.accumulo.proxy.thrift.AccumuloSecurityException)3 KeyValue (org.apache.accumulo.proxy.thrift.KeyValue)3 MutationsRejectedException (org.apache.accumulo.proxy.thrift.MutationsRejectedException)3 NamespaceExistsException (org.apache.accumulo.proxy.thrift.NamespaceExistsException)3 NamespaceNotEmptyException (org.apache.accumulo.proxy.thrift.NamespaceNotEmptyException)3 ScanResult (org.apache.accumulo.proxy.thrift.ScanResult)3