本文整理匯總了Java中com.datastax.driver.core.BatchStatement.Type方法的典型用法代碼示例。如果您正苦於以下問題:Java BatchStatement.Type方法的具體用法?Java BatchStatement.Type怎麽用?Java BatchStatement.Type使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.datastax.driver.core.BatchStatement
的用法示例。
在下文中一共展示了BatchStatement.Type方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: untilApplied
import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public static boolean untilApplied(Session session, BatchStatement.Type type, Consumer<BatchStatement> transaction) {
for (int i = 1; i <= MAX_RETRY; i ++) {
BatchStatement batchStatement = new BatchStatement(type);
transaction.accept(batchStatement);
if (batchStatement.size() == 0) return false;
boolean applied;
if (batchStatement.size() > 1) {
applied = session.execute(batchStatement).wasApplied();
} else {
Statement statement = Iterables.getOnlyElement(batchStatement.getStatements());
applied = session.execute(statement).wasApplied();
}
if (applied) return true;
log.warn("Attempt {}/{} failed executing {}", i, MAX_RETRY, batchStatement);
try {
Thread.sleep(100 * i);
} catch (InterruptedException e) {
throw new AttemptsFailedException(e);
}
}
throw new AttemptsFailedException();
}
示例2: batchInsert
import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public ResultSet batchInsert(final Class<?> targetClass, final Collection<? extends Map<String, Object>> propsList, final BatchStatement.Type type) {
N.checkArgument(N.notNullOrEmpty(propsList), "'propsList' can't be null or empty.");
final BatchStatement batchStatement = new BatchStatement(type == null ? BatchStatement.Type.LOGGED : type);
if (settings != null) {
batchStatement.setConsistencyLevel(settings.getConsistency());
batchStatement.setSerialConsistencyLevel(settings.getSerialConsistency());
batchStatement.setRetryPolicy(settings.getRetryPolicy());
if (settings.traceQuery) {
batchStatement.enableTracing();
} else {
batchStatement.disableTracing();
}
}
CP pair = null;
for (Map<String, Object> props : propsList) {
pair = prepareAdd(targetClass, props);
batchStatement.add(prepareStatement(pair.cql, pair.parameters.toArray()));
}
return session.execute(batchStatement);
}
示例3: sendBatch
import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public void sendBatch(BatchStatement.Type type, boolean addCounter, boolean addNonCounter)
{
assert addCounter || addNonCounter;
BatchStatement b = new BatchStatement(type);
for (int i = 0; i < 10; i++)
{
if (addNonCounter)
b.add(noncounter.bind(i, "foo"));
if (addCounter)
b.add(counter.bind((long)i, i));
}
session.execute(b);
}
示例4: FactoryData
import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
private FactoryData(final SocketAddress[] contactPoints, final ColumnMapping[] columns, final boolean useTls,
final String clusterName, final String keyspace, final String table, final String username,
final String password, final boolean useClockForTimestampGenerator, final int bufferSize,
final boolean batched, final BatchStatement.Type batchType) {
super(bufferSize, null);
this.contactPoints = convertAndAddDefaultPorts(contactPoints);
this.columns = columns;
this.useTls = useTls;
this.clusterName = clusterName;
this.keyspace = keyspace;
this.table = table;
this.username = username;
this.password = password;
this.useClockForTimestampGenerator = useClockForTimestampGenerator;
this.batched = batched;
this.batchType = batchType;
}
示例5: batch
import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public static ResultSet batch(Session session, BatchStatement.Type type, Consumer<BatchStatement> transaction) {
BatchStatement batchStatement = new BatchStatement(type);
transaction.accept(batchStatement);
if (batchStatement.size() == 0) return null;
if (batchStatement.size() > 1) {
return session.execute(batchStatement);
} else {
Statement statement = Iterables.getOnlyElement(batchStatement.getStatements());
return session.execute(statement);
}
}
示例6: batchUpdate
import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public ResultSet batchUpdate(final Collection<?> entities, final BatchStatement.Type type) {
N.checkArgument(N.notNullOrEmpty(entities), "'entities' can't be null or empty.");
final Class<?> targetClass = Seq.of(entities).first().get().getClass();
final Set<String> keyNameSet = Maps.getOrDefault(entityKeyNamesMap, targetClass, ID_SET);
return batchUpdate(entities, keyNameSet, type);
}
示例7: asyncBatchInsert
import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public CompletableFuture<ResultSet> asyncBatchInsert(final Collection<?> entities, final BatchStatement.Type type) {
return asyncExecutor.execute(new Callable<ResultSet>() {
@Override
public ResultSet call() {
return batchInsert(entities, type);
}
});
}
示例8: asyncBatchUpdate
import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public CompletableFuture<ResultSet> asyncBatchUpdate(final Collection<?> entities, final BatchStatement.Type type) {
return asyncExecutor.execute(new Callable<ResultSet>() {
@Override
public ResultSet call() {
return batchUpdate(entities, type);
}
});
}
示例9: getBatchType
import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
protected BatchStatement.Type getBatchType() {
BatchStatement.Type type = BatchStatement.Type.LOGGED;
if (batchType != null && BatchStatement.Type.UNLOGGED.name().equalsIgnoreCase(batchType)) {
type = BatchStatement.Type.UNLOGGED;
}
return type;
}
示例10: SaveToCassandraActionExecutionFunction
import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public SaveToCassandraActionExecutionFunction(String cassandraQuorum, int cassandraPort, int maxBatchSize,
BatchStatement.Type batchType) {
this.cassandraQuorum = cassandraQuorum;
this.cassandraPort = cassandraPort;
this.maxBatchSize = maxBatchSize;
this.batchType = batchType;
}
示例11: getManager
import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public static CassandraManager getManager(final String name, final SocketAddress[] contactPoints,
final ColumnMapping[] columns, final boolean useTls,
final String clusterName, final String keyspace, final String table,
final String username, final String password,
final boolean useClockForTimestampGenerator, final int bufferSize,
final boolean batched, final BatchStatement.Type batchType) {
return getManager(name,
new FactoryData(contactPoints, columns, useTls, clusterName, keyspace, table, username, password,
useClockForTimestampGenerator, bufferSize, batched, batchType), CassandraManagerFactory.INSTANCE);
}
示例12: SchemaInsert
import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public SchemaInsert(Timer timer, StressSettings settings, PartitionGenerator generator, SeedManager seedManager, Distribution batchSize, RatioDistribution useRatio, Integer thriftId, PreparedStatement statement, ConsistencyLevel cl, BatchStatement.Type batchType)
{
super(timer, settings, new DataSpec(generator, seedManager, batchSize, useRatio), statement, thriftId, cl, ValidationType.NOT_FAIL);
this.batchType = batchType;
}
示例13: SchemaInsert
import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public SchemaInsert(Timer timer, StressSettings settings, PartitionGenerator generator, SeedManager seedManager, Distribution batchSize, RatioDistribution useRatio, RatioDistribution rowPopulation, Integer thriftId, PreparedStatement statement, ConsistencyLevel cl, BatchStatement.Type batchType)
{
super(timer, settings, new DataSpec(generator, seedManager, batchSize, useRatio, rowPopulation), statement, thriftId, cl);
this.batchType = batchType;
}
示例14: SchemaInsert
import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public SchemaInsert(Timer timer, PartitionGenerator generator, StressSettings settings, Distribution batchSize, RatioDistribution selectChance, Integer thriftId, PreparedStatement statement, ConsistencyLevel cl, BatchStatement.Type batchType)
{
super(timer, generator, settings, batchSize, statement, thriftId, cl, ValidationType.NOT_FAIL);
this.batchType = batchType;
this.selectChance = selectChance;
}
示例15: getCassandraBatchType
import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public BatchStatement.Type getCassandraBatchType() {
return cassandraBatchType;
}