Examples of BatchStatement


Examples of com.datastax.driver.core.BatchStatement

    private volatile boolean submitted;
    private final List<BatchPartFutureImpl> futures = new ArrayList<BatchPartFutureImpl>();

    public BatchImpl(PersistenceSessionImpl persistenceSession, BatchStatement.Type type) {
        this.persistenceSession = persistenceSession;
        batchStatement = new BatchStatement(type);
        persistenceSession.statementOptions.applyWrite(batchStatement, null, null);
    }
View Full Code Here

Examples of com.datastax.driver.core.BatchStatement

        super.casResultListener = Optional.<CASResultListener>fromNullable(this.compositeCASResultListener);
        this.batchStatement = createBatchStatement(batchType, statementWrappers);
    }

    private BatchStatement createBatchStatement(BatchStatement.Type batchType, List<AbstractStatementWrapper> statementWrappers) {
        BatchStatement batch = new BatchStatement(batchType);
        boolean tracingEnabled = false;
        for (AbstractStatementWrapper statementWrapper : statementWrappers) {
            statementWrapper.activateQueryTracing();
            tracingEnabled |= statementWrapper.isTracingEnabled();

            if (statementWrapper.casResultListener.isPresent()) {
                this.compositeCASResultListener.addCASResultListener(statementWrapper.casResultListener.get());
            }

            if (statementWrapper instanceof NativeStatementWrapper) {
                batch.add(((NativeStatementWrapper) statementWrapper).buildParameterizedStatement());
            } else {
                batch.add(statementWrapper.getStatement());
            }
        }
        if (tracingEnabled) {
            batch.enableTracing();
        }
        if (consistencyLevelO.isPresent()) {
            batch.setConsistencyLevel(getCQLLevel(consistencyLevelO.get()));
        }
        // TODO Serial Consistency not supported for batch. Wait for C* 2.1
        if (serialConsistencyLevelO.isPresent()) {
           // batch.setSerialConsistencyLevel(serialConsistencyLevelO.get());
        }
View Full Code Here

Examples of com.datastax.driver.core.BatchStatement

  private BatchStatement getCachedPreparedStatement() {
   
    final List<CqlColumnListMutationImpl<?, ?>> colListMutations = getColumnMutations();

    if (colListMutations == null || colListMutations.size() == 0) {
      return new BatchStatement(Type.UNLOGGED);
    }
   
    ColListMutationType mutationType = colListMutations.get(0).getType();

    BatchStatement batch = new BatchStatement(Type.UNLOGGED);
    if (mutationType == ColListMutationType.CounterColumnsUpdate) {
      batch = new BatchStatement(Type.COUNTER);
    } else if (useAtomicBatch()) {
      batch = new BatchStatement(Type.LOGGED);
    }
   
    for (CqlColumnListMutationImpl<?, ?> colListMutation : colListMutations) {
     
      CFMutationQueryGen queryGen = colListMutation.getMutationQueryGen();
      queryGen.addColumnListMutationToBatch(batch, colListMutation, useCaching);
    }
   
    batch.setConsistencyLevel(ConsistencyLevelMapping.getCL(this.getConsistencyLevel()));
   
    return batch;
  }
View Full Code Here

Examples of com.taobao.tdhs.client.statement.BatchStatement

    public boolean isValid(int timeout) throws SQLException {
        if (isClosed()) {
            return false;
        }
        TDHSClient client = getClient();
        BatchStatement batchStatement = client.createBatchStatement();
        batchStatement.setTimeOut(timeout);
        try {
            batchStatement.commit();
            return true;
        } catch (TDHSException e) {
            logger.warn("valid failed", e);
            return false;
        }
View Full Code Here

Examples of com.taobao.tdhs.client.statement.BatchStatement

        batchStatement = null;
    }

    public int[] executeBatch() throws SQLException {
        checkclose();
        BatchStatement b = batchStatement;
        reset();

        TDHSResponse[] responses = null;
        try {
            responses = b.commit();
        } catch (TDHSException e) {
            throw new SQLException(e);
        }
        int[] result = new int[responses.length];
        StringBuilder expString = new StringBuilder();
View Full Code Here

Examples of com.taobao.tdhs.client.statement.BatchStatement

        client.query().use(db).from(table).where().greaterEqual("-1").delete();
    }

    @Test
    public void testBatchDone() throws TDHSException {
        BatchStatement batchStatement = client.createBatchStatement();
        batchStatement.insert().use(db).from(table)
                .value("id", "1")
                .value("name", "a")
                .value("level", "1").insert();
        batchStatement.insert().use(db).from(table)
                .value("id", "2")
                .value("name", "b")
                .value("level", "2").insert();
        batchStatement.insert().use(db).from(table)
                .value("id", "3")
                .value("name", "c")
                .value("level", "3").insert();
        TDHSResponse[] responses = batchStatement.commit();
        Assert.assertEquals(3, responses.length);
        for (TDHSResponse r : responses) {
            Assert.assertEquals(TDHSResponseEnum.ClientStatus.OK, r.getStatus());
        }
    }
View Full Code Here

Examples of com.taobao.tdhs.client.statement.BatchStatement

        }
    }

    @Test
    public void testBatchFailed() throws TDHSException {
        BatchStatement batchStatement = client.createBatchStatement();
        batchStatement.insert().use(db).from(table)
                .value("id", "1")
                .value("name", "a")
                .value("level", "1").insert();
        batchStatement.insert().use(db).from(table)
                .value("id", "2")
                .value("name", "b")
                .value("level", "2").insert();
        batchStatement.insert().use(db).from(table)
                .value("id", "1")
                .value("name", "c")
                .value("level", "1").insert();
        TDHSResponse[] responses = batchStatement.commit();
        Assert.assertEquals(3, responses.length);
        Assert.assertEquals(responses[0].getStatus(), TDHSResponseEnum.ClientStatus.SERVER_ERROR);
        Assert.assertEquals(responses[0].getErrorCode(), TDHSResponseEnum.ErrorCode.CLIENT_ERROR_CODE_FAILED_TO_COMMIT);
        Assert.assertEquals(responses[1].getStatus(), TDHSResponseEnum.ClientStatus.SERVER_ERROR);
        Assert.assertEquals(responses[1].getErrorCode(), TDHSResponseEnum.ErrorCode.CLIENT_ERROR_CODE_FAILED_TO_COMMIT);
View Full Code Here

Examples of org.apache.cassandra.cql3.statements.BatchStatement

                statements.add(mst);
            }

            // Note: It's ok at this point to pass a bogus value for the number of bound terms in the BatchState ctor
            // (and no value would be really correct, so we prefer passing a clearly wrong one).
            BatchStatement batch = new BatchStatement(-1, type, statements, Attributes.none());
            Message.Response response = QueryProcessor.processBatch(batch, consistency, state, values, queryOrIdList);

            if (tracingId != null)
                response.setTracingId(tracingId);
View Full Code Here

Examples of org.apache.cassandra.cql3.statements.BatchStatement

                statements.add(mst);
            }

            // Note: It's ok at this point to pass a bogus value for the number of bound terms in the BatchState ctor
            // (and no value would be really correct, so we prefer passing a clearly wrong one).
            BatchStatement batch = new BatchStatement(-1, type, statements, Attributes.none());
            Message.Response response = QueryProcessor.processBatch(batch, consistency, state, values, queryOrIdList);

            if (tracingId != null)
                response.setTracingId(tracingId);
View Full Code Here

Examples of org.apache.cassandra.cql3.statements.BatchStatement

                statements.add(mst);
            }

            // Note: It's ok at this point to pass a bogus value for the number of bound terms in the BatchState ctor
            // (and no value would be really correct, so we prefer passing a clearly wrong one).
            BatchStatement batch = new BatchStatement(-1, type, statements, Attributes.none());
            Message.Response response = handler.processBatch(batch, state, batchOptions);

            if (tracingId != null)
                response.setTracingId(tracingId);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.