@Override public void clear() { this.batch.clear(); }
@Override public ResultSet commit() { ResultSet rs = this.session.execute(this.batch); // Clear batch if execute() successfully (retained if failed) this.batch.clear(); return rs; }
public void commitAsync() { Collection<Statement> statements = this.batch.getStatements(); int count = 0; int processors = Math.min(statements.size(), 1023); List<ResultSetFuture> results = new ArrayList<>(processors + 1); for (Statement s : statements) { ResultSetFuture future = this.session.executeAsync(s); results.add(future); if (++count > processors) { results.forEach(ResultSetFuture::getUninterruptibly); results.clear(); count = 0; } } for (ResultSetFuture future : results) { future.getUninterruptibly(); } // Clear batch if execute() successfully (retained if failed) this.batch.clear(); }
@Override public void rollbackTransaction() { batchCommand.clear(); inTransaction = false; }
@Override public void rollbackTransaction() { batchCommand.clear(); inTransaction = false; }
@Override public void clear() { this.batch.clear(); }
@Override public void commitTransaction() { session.execute(batchCommand); batchCommand.clear(); inTransaction = false; }
@Override public void commitTransaction() { session.execute(batchCommand); batchCommand.clear(); inTransaction = false; }
@Override public ResultSet commit() { ResultSet rs = this.session.execute(this.batch); // Clear batch if execute() successfully (retained if failed) this.batch.clear(); return rs; }
private void writeBatch(final BatchStatement batch) { try { executeAsync(batch); batch.clear(); } catch (final InterruptedException e) { LOGGER.warn("async batch write semaphore interrupted", e); writeSemaphore.release(); } }
@Override public void executePendingMutations() throws DataAccessLayerException { try { _session.execute(_batchStatements.get()); _batchStatements.get().clear(); } catch (final Exception exception) { throw new DataAccessLayerException(exception); } }
@Override public void executePendingMutations() throws DataAccessLayerException { try { _session.execute(_batchStatements.get()); _batchStatements.get().clear(); } catch (final Exception exception) { throw new DataAccessLayerException(exception); } }
public void commitAsync() { Collection<Statement> statements = this.batch.getStatements(); int count = 0; int processors = Math.min(statements.size(), 1023); List<ResultSetFuture> results = new ArrayList<>(processors + 1); for (Statement s : statements) { ResultSetFuture future = this.session.executeAsync(s); results.add(future); if (++count > processors) { results.forEach(ResultSetFuture::getUninterruptibly); results.clear(); count = 0; } } for (ResultSetFuture future : results) { future.getUninterruptibly(); } // Clear batch if execute() successfully (retained if failed) this.batch.clear(); }
@Override public String writeSingle(String key) throws Exception { BatchStatement batch = new BatchStatement(); for (int i = 0; i < config.getBatchSize(); i++) { BoundStatement bStmt; if(config.getUseMultiPartition()) { if(randomObj.nextBoolean()) { bStmt = getBStmtTable1(key); } else { bStmt = getBStmtTable2(key); } } else { bStmt = getBStmtTable1(key); } bStmt.setConsistencyLevel(ConsistencyLevel.valueOf(config.getWriteConsistencyLevel())); batch.add(bStmt); } if(config.getUseTimestamp()) { batch.setDefaultTimestamp(Instant.now().toEpochMilli()*1000); } session.execute(batch); batch.clear(); return ResultOK; }
@Override public String writeSingle(String key) throws Exception { BatchStatement batch = new BatchStatement(); for (int i = 0; i < config.getBatchSize(); i++) { BoundStatement bStmt; if(config.getUseMultiPartition()) { if(randomObj.nextBoolean()) { bStmt = getBStmtTable1(key); } else { bStmt = getBStmtTable2(key); } } else { bStmt = getBStmtTable1(key); } bStmt.setConsistencyLevel(ConsistencyLevel.valueOf(config.getWriteConsistencyLevel())); batch.add(bStmt); } if(config.getUseTimestamp()) { batch.setDefaultTimestamp(Instant.now().toEpochMilli()*1000); } session.execute(batch); batch.clear(); return ResultOK; }
@Override public String writeSingle(String key) { if(config.getRowsPerPartition() > 1) { BatchStatement batch = new BatchStatement(BatchStatement.Type.UNLOGGED); batch.setConsistencyLevel(ConsistencyLevel.valueOf(config.getWriteConsistencyLevel())); for (int i = 0; i < config.getRowsPerPartition(); i++) { batch.add(getWriteBStmt(key,i)); } session.execute(batch); batch.clear(); } else { session.execute(getWriteBStmt(key, 1) .setConsistencyLevel(ConsistencyLevel.valueOf(config.getWriteConsistencyLevel()))); } return ResultOK; }
@Override public String writeSingle(String key) { if(config.getRowsPerPartition() > 1) { BatchStatement batch = new BatchStatement(BatchStatement.Type.UNLOGGED); batch.setConsistencyLevel(ConsistencyLevel.valueOf(config.getWriteConsistencyLevel())); for (int i = 0; i < config.getRowsPerPartition(); i++) { batch.add(getWriteBStmt(key,i)); } session.execute(batch); batch.clear(); } else { session.execute(getWriteBStmt(key, 1) .setConsistencyLevel(ConsistencyLevel.valueOf(config.getWriteConsistencyLevel()))); } return ResultOK; }
public void write(Object[] args) { PersonRegister person = PersonRegister.getInstance(args); Statement query = QueryBuilder.insertInto("PersonRegister").value("MSDIN", person.getMsdin()) .value("firstName", person.getFirstName()).value("lastName", person.getLastName()) .value("birthDate", person.getBirthDate()).value("gender", person.getGender()) .setConsistencyLevel(ConsistencyLevel.QUORUM);; batchStatement.add(query); numStatement++; if (numStatement == NUM_BATCH_STATEMENT) { LOGGER.info("Execute batch query PersonRegister: "+ numIteration++); session.execute(batchStatement); batchStatement.clear(); numStatement = 0; } }
public void write(Object[] args) { Register register = Register.getInstance(args); Statement query = QueryBuilder.insertInto("Register").value("id", register.getId()) .value("MSDIN", register.getMsdin()).value("firstName", register.getFirstName()) .value("lastName", register.getLastName()).value("birthDate", register.getBirthDate()) .value("gender", register.getGender()).value("codPacote", register.getCodPacote()) .value("dateTime", register.getDateTime()).value("value", register.getValue()) .value("type", register.getType()).value("country",register.getCountry()) .setConsistencyLevel(ConsistencyLevel.QUORUM); batchStatement.add(query); numStatement++; if (numStatement == NUM_BATCH_STATEMENT) { LOGGER.info("Execute batch query PersonRegister: " + numIteration++); session.execute(batchStatement); batchStatement.clear(); numStatement = 0; } } }