本文整理了Java中org.apache.accumulo.core.client.Connector.createConditionalWriter()
方法的一些代码示例,展示了Connector.createConditionalWriter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Connector.createConditionalWriter()
方法的具体详情如下:
包路径:org.apache.accumulo.core.client.Connector
类名称:Connector
方法名:createConditionalWriter
[英]Factory method to create a ConditionalWriter connected to Accumulo.
[中]方法创建连接到Accumulo的ConditionalWriter。
代码示例来源:origin: org.apache.accumulo/accumulo-test
} catch (TableExistsException tee) {}
ConditionalWriter cw = env.getConnector().createConditionalWriter(tableName,
new ConditionalWriterConfig().setMaxWriteThreads(1));
state.set("cw", cw);
代码示例来源:origin: org.apache.accumulo/accumulo-test
try (ConditionalWriter cw = conn.createConditionalWriter(tableName,
new ConditionalWriterConfig())) {
代码示例来源:origin: org.apache.accumulo/accumulo-test
try (ConditionalWriter cw = conn.createConditionalWriter(tableName,
new ConditionalWriterConfig())) {
代码示例来源:origin: org.apache.accumulo/accumulo-test
private void conditionWriteSome(String tableName, int n, ConditionalWriterConfig cfg)
throws Exception {
Connector c = getConnector();
ConditionalWriter cw = c.createConditionalWriter(tableName, cfg);
for (int i = 0; i < n; i++) {
ConditionalMutation m = new ConditionalMutation((CharSequence) (i + ""),
new Condition("", ""));
m.put("", "", "X");
assertEquals(Status.ACCEPTED, cw.write(m).getStatus());
}
}
代码示例来源:origin: org.apache.accumulo/accumulo-test
@Test(expected = IllegalArgumentException.class)
public void testNoConditions() throws AccumuloException, AccumuloSecurityException,
TableExistsException, TableNotFoundException {
String table = getUniqueNames(1)[0];
Connector conn = getConnector();
conn.tableOperations().create(table);
try (
ConditionalWriter cw = conn.createConditionalWriter(table, new ConditionalWriterConfig())) {
ConditionalMutation cm1 = new ConditionalMutation("r1");
cm1.put("tx", "seq", "1");
cm1.put("data", "x", "a");
cw.write(cm1);
}
}
代码示例来源:origin: org.apache.accumulo/accumulo-test
@Test
public void testOffline() throws Exception {
String table = getUniqueNames(1)[0];
Connector conn = getConnector();
conn.tableOperations().create(table);
try (
ConditionalWriter cw = conn.createConditionalWriter(table, new ConditionalWriterConfig())) {
conn.tableOperations().offline(table, true);
ConditionalMutation cm1 = new ConditionalMutation("r1", new Condition("tx", "seq"));
cm1.put("tx", "seq", "1");
cm1.put("data", "x", "a");
Result result = cw.write(cm1);
try {
Status status = result.getStatus();
Assert.fail("Expected exception writing conditional mutation to offline table. Got status: "
+ status);
} catch (AccumuloException ae) {
Assert.assertEquals(TableOfflineException.class, ae.getCause().getClass());
}
try {
conn.createConditionalWriter(table, new ConditionalWriterConfig());
Assert.fail("Expected exception creating conditional writer to offline table");
} catch (TableOfflineException e) {}
}
}
代码示例来源:origin: org.apache.accumulo/accumulo-test
@Test
public void testDeleteTable() throws Exception {
String table = getUniqueNames(1)[0];
Connector conn = getConnector();
try {
conn.createConditionalWriter(table, new ConditionalWriterConfig());
Assert.fail("Creating conditional writer for table that doesn't exist should fail");
} catch (TableNotFoundException e) {}
conn.tableOperations().create(table);
try (
ConditionalWriter cw = conn.createConditionalWriter(table, new ConditionalWriterConfig())) {
conn.tableOperations().delete(table);
ConditionalMutation cm1 = new ConditionalMutation("r1", new Condition("tx", "seq"));
cm1.put("tx", "seq", "1");
cm1.put("data", "x", "a");
Result result = cw.write(cm1);
try {
Status status = result.getStatus();
Assert.fail("Expected exception writing conditional mutation to deleted table. Got status: "
+ status);
} catch (AccumuloException ae) {
Assert.assertEquals(TableDeletedException.class, ae.getCause().getClass());
}
}
}
代码示例来源:origin: org.apache.accumulo/accumulo-test
mutations.add(cm3);
try (ConditionalWriter cw = conn.createConditionalWriter(tableName,
new ConditionalWriterConfig().setAuthorizations(new Authorizations("A")))) {
Iterator<Result> results = cw.write(mutations.iterator());
代码示例来源:origin: io.fluo/fluo-core
public SharedResources(Environment env) throws TableNotFoundException {
this.env = env;
curator = CuratorUtil.newAppCurator(env.getConfiguration());
curator.start();
int numTservers = env.getConnector().instanceOperations().getTabletServers().size();
int numBWThreads = FluoConfigurationImpl.getNumBWThreads(env.getConfiguration(), numTservers);
bw =
env.getConnector().createBatchWriter(env.getTable(),
new BatchWriterConfig().setMaxWriteThreads(numBWThreads));
sbw = new SharedBatchWriter(bw);
int numCWThreads = FluoConfigurationImpl.getNumCWThreads(env.getConfiguration(), numTservers);
cw =
env.getConnector().createConditionalWriter(
env.getTable(),
new ConditionalWriterConfig().setAuthorizations(env.getAuthorizations())
.setMaxWriteThreads(numCWThreads));
bulkCw =
env.getConnector().createConditionalWriter(
env.getTable(),
new ConditionalWriterConfig().setAuthorizations(env.getAuthorizations())
.setMaxWriteThreads(numCWThreads));
txInfoCache = new TxInfoCache(env);
visCache = new VisibilityCache();
metricRegistry = new MetricRegistry();
}
代码示例来源:origin: apache/incubator-rya
conditionalWriter = accumuloConn.createConditionalWriter(pcjTableName, new ConditionalWriterConfig());
代码示例来源:origin: org.apache.accumulo/accumulo-test
@Test
public void testConstraints() throws Exception {
// ensure constraint violations are properly reported
Connector conn = getConnector();
String tableName = getUniqueNames(1)[0];
conn.tableOperations().create(tableName);
conn.tableOperations().addConstraint(tableName, AlphaNumKeyConstraint.class.getName());
conn.tableOperations().clone(tableName, tableName + "_clone", true,
new HashMap<String,String>(), new HashSet<String>());
Scanner scanner = conn.createScanner(tableName + "_clone", new Authorizations());
try (ConditionalWriter cw = conn.createConditionalWriter(tableName + "_clone",
new ConditionalWriterConfig())) {
ConditionalMutation cm0 = new ConditionalMutation("99006+", new Condition("tx", "seq"));
cm0.put("tx", "seq", "1");
Assert.assertEquals(Status.VIOLATED, cw.write(cm0).getStatus());
Assert.assertFalse("Should find no results in the table is mutation result was violated",
scanner.iterator().hasNext());
ConditionalMutation cm1 = new ConditionalMutation("99006", new Condition("tx", "seq"));
cm1.put("tx", "seq", "1");
Assert.assertEquals(Status.ACCEPTED, cw.write(cm1).getStatus());
Assert.assertTrue("Accepted result should be returned when reading table",
scanner.iterator().hasNext());
}
}
代码示例来源:origin: org.apache.accumulo/accumulo-proxy
@Override
public String createConditionalWriter(ByteBuffer login, String tableName,
ConditionalWriterOptions options) throws org.apache.accumulo.proxy.thrift.AccumuloException,
org.apache.accumulo.proxy.thrift.AccumuloSecurityException,
org.apache.accumulo.proxy.thrift.TableNotFoundException, TException {
try {
ConditionalWriterConfig cwc = new ConditionalWriterConfig();
if (options.getMaxMemory() != 0) {
// TODO
}
if (options.isSetThreads() && options.getThreads() != 0)
cwc.setMaxWriteThreads(options.getThreads());
if (options.isSetTimeoutMs() && options.getTimeoutMs() != 0)
cwc.setTimeout(options.getTimeoutMs(), TimeUnit.MILLISECONDS);
if (options.isSetAuthorizations() && options.getAuthorizations() != null)
cwc.setAuthorizations(getAuthorizations(options.getAuthorizations()));
if (options.isSetDurability() && options.getDurability() != null)
cwc.setDurability(getDurability(options.getDurability()));
ConditionalWriter cw = getConnector(login).createConditionalWriter(tableName, cwc);
UUID id = UUID.randomUUID();
conditionalWriterCache.put(id, cw);
return id.toString();
} catch (Exception e) {
handleExceptionTNF(e);
return null;
}
}
代码示例来源:origin: org.apache.accumulo/accumulo-test
try (ConditionalWriter cw = conn.createConditionalWriter(table,
new ConditionalWriterConfig().setTimeout(3, TimeUnit.SECONDS))) {
代码示例来源:origin: org.apache.rya/accumulo.rya
writer = connector.createConditionalWriter(detailsTableName, new ConditionalWriterConfig());
final Result result = writer.write(mutation);
switch(result.getStatus()) {
代码示例来源:origin: apache/incubator-rya
writer = connector.createConditionalWriter(detailsTableName, new ConditionalWriterConfig());
final Result result = writer.write(mutation);
switch(result.getStatus()) {
代码示例来源:origin: org.apache.fluo/fluo-core
public SharedResources(Environment env) throws TableNotFoundException {
this.env = env;
curator = CuratorUtil.newAppCurator(env.getConfiguration());
curator.start();
int numTservers = env.getConnector().instanceOperations().getTabletServers().size();
int numBWThreads = FluoConfigurationImpl.getNumBWThreads(env.getConfiguration(), numTservers);
bw = env.getConnector().createBatchWriter(env.getTable(),
new BatchWriterConfig().setMaxWriteThreads(numBWThreads));
sbw = new SharedBatchWriter(bw);
int numCWThreads = FluoConfigurationImpl.getNumCWThreads(env.getConfiguration(), numTservers);
cw = env.getConnector().createConditionalWriter(env.getTable(), new ConditionalWriterConfig()
.setAuthorizations(env.getAuthorizations()).setMaxWriteThreads(numCWThreads));
bulkCw =
env.getConnector().createConditionalWriter(env.getTable(), new ConditionalWriterConfig()
.setAuthorizations(env.getAuthorizations()).setMaxWriteThreads(numCWThreads));
txInfoCache = new TxInfoCache(env);
visCache = new VisibilityCache(env.getConfiguration());
metricRegistry = new MetricRegistry();
int commitThreads = env.getConfiguration().getInt(FluoConfigurationImpl.ASYNC_COMMIT_THREADS,
FluoConfigurationImpl.ASYNC_COMMIT_THREADS_DEFAULT);
asyncCommitExecutor = FluoExecutors.newFixedThreadPool(commitThreads, "async-commits");
commitThreads = env.getConfiguration().getInt(FluoConfigurationImpl.SYNC_COMMIT_THREADS,
FluoConfigurationImpl.SYNC_COMMIT_THREADS_DEFAULT);
syncCommitExecutor = FluoExecutors.newFixedThreadPool(commitThreads, "sync-commits");
acw = new AsyncConditionalWriter(env, cw);
bulkAcw = new AsyncConditionalWriter(env, bulkCw);
}
代码示例来源:origin: org.apache.accumulo/accumulo-test
@Test
public void testError() throws Exception {
String table = getUniqueNames(1)[0];
Connector conn = getConnector();
conn.tableOperations().create(table);
try (
ConditionalWriter cw = conn.createConditionalWriter(table, new ConditionalWriterConfig())) {
IteratorSetting iterSetting = new IteratorSetting(5, BadIterator.class);
ConditionalMutation cm1 = new ConditionalMutation("r1",
new Condition("tx", "seq").setIterators(iterSetting));
cm1.put("tx", "seq", "1");
cm1.put("data", "x", "a");
Result result = cw.write(cm1);
try {
Status status = result.getStatus();
Assert
.fail("Expected exception using iterator which throws an error, Got status: " + status);
} catch (AccumuloException ae) {
}
}
}
代码示例来源:origin: org.apache.accumulo/accumulo-test
try (ConditionalWriter cw = conn.createConditionalWriter(tableName,
new ConditionalWriterConfig())) {
代码示例来源:origin: org.apache.accumulo/accumulo-test
ConditionalWriter cw1 = conn2.createConditionalWriter(table1,
new ConditionalWriterConfig());
ConditionalWriter cw2 = conn2.createConditionalWriter(table2,
new ConditionalWriterConfig());
ConditionalWriter cw3 = conn2.createConditionalWriter(table3,
new ConditionalWriterConfig())) {
代码示例来源:origin: org.apache.accumulo/accumulo-test
try (ConditionalWriter cw = conn.createConditionalWriter(tableName,
new ConditionalWriterConfig())) {
内容来源于网络,如有侵权,请联系作者删除!