public class GroupImpl extends GroupStatementImpl<Void,VoidFuture,Void> implements Group, ParentStatementImpl
GroupImpl class defines support for a statement that can
execute a set of statements in parallel returning the result from the first
one that fails. Basically, a group will sends multiple requests to Cassandra
at the same time up to either its parallel factor or until it reaches a
sequence statement and then wait for all results before continuing to the
next set of statements to be sent in parallel.
The group's algorithm will allow the distributed nature of Cassandra to work for you and distribute the writes to the optimal destination which leads to not only fastest inserts/updates (assuming different partitions are being updated), but it’ll cause the least load on the cluster.
bridge, CI_PREFIX, idempotent, isCounterOp, mgr, MK_PREFIX, resultClass, simpleSize, UDT_C_PREFIX| Constructor and Description |
|---|
GroupImpl(Optional<Recorder> recorder,
GroupableStatement<?,?>[] statements,
StatementManagerImpl mgr,
StatementBridge bridge)
Instantiates a new
GroupImpl object. |
GroupImpl(Optional<Recorder> recorder,
Iterable<GroupableStatement<?,?>> statements,
StatementManagerImpl mgr,
StatementBridge bridge)
Instantiates a new
GroupImpl object. |
| Modifier and Type | Method and Description |
|---|---|
<R,F extends com.google.common.util.concurrent.ListenableFuture<R>> |
add(BatchableStatement<R,F> statement) |
<R,F extends com.google.common.util.concurrent.ListenableFuture<R>> |
add(GroupableStatement<R,F> statement) |
Group |
add(com.datastax.driver.core.RegularStatement statement) |
Group |
addErrorHandler(ERunnable<?> run) |
protected List<StatementImpl<?,?,?>> |
buildGroupedStatements()
Gets all underlying grouped statements recursively in the proper order
for this statement.
|
void |
clear() |
String |
getKeyspace() |
Optional<Recorder> |
getRecorder() |
boolean |
isEmpty() |
Boolean |
isIdempotent() |
java.util.stream.Stream<ObjectStatement<?>> |
objectStatements()
Gets all object statements contained recursively in this parent statement.
|
void |
recorded(ObjectStatement<?> statement,
ParentStatement pstatement)
Notifies the registered recorder and parent of the specified object statement.
|
void |
runErrorHandlers() |
protected void |
setDirty(boolean recurse)
Sets the dirty bit for the cached query string and clear the number of
statements potentially recursively for all contained statement.
|
Group |
setParallelFactor(int factor)
Sets the number of simultaneous statements to send to the Cassandra cluster
at the same time before starting to wait for all responses before proceeding
to the next set (assuming a sequence is not reached before that).
|
void |
setParent(ParentStatementImpl parent)
Sets the parent for this statement.
|
int |
size() |
java.util.stream.Stream<GenericStatement<?,?>> |
statements()
Gets all statements contained recursively in this parent statement including
parent statements (and this one).
|
appendGroupType, buildQueryStrings, buildStatements, executeAsyncRaw0, getParallelFactor, setDirty, simpleSizeappendGroupSubType, appendOptions, buildQueryString, clearKeyspace, disable, disableErrorTracing, disableTracing, enable, enableErrorTracing, enableErrorTracing, enableTracing, enableTracing, execute, executeAsync, executeAsync0, executeAsyncRaw, executeRaw, getClassInfo, getClassInfoImpl, getConsistencyLevel, getContext, getDefaultTimestamp, getFetchSize, getObject, getObjectClass, getPOJOContext, getQueryString, getReadTimeoutMillis, getRetryPolicy, getSerialConsistencyLevel, getUserData, init, init, isCounterOp, isDirty, isEnabled, isErrorTracing, isTracing, setConsistencyLevel, setCounterOp, setDefaultTimestamp, setFetchSize, setIdempotent, setReadTimeoutMillis, setRetryPolicy, setSerialConsistencyLevel, setUserData, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitexecute, executeAsync, executeAsyncRaw, executeRaw, getParallelFactor, getQueryStringdisable, disableErrorTracing, disableTracing, enable, enableErrorTracing, enableErrorTracing, enableTracing, enableTracing, getConsistencyLevel, getDefaultTimestamp, getFetchSize, getReadTimeoutMillis, getRetryPolicy, getSerialConsistencyLevel, getUserData, isEnabled, isErrorTracing, isTracing, setConsistencyLevel, setDefaultTimestamp, setFetchSize, setIdempotent, setReadTimeoutMillis, setRetryPolicy, setSerialConsistencyLevel, setUserDataresetIfErrors, setAndResetIfErrorspublic GroupImpl(Optional<Recorder> recorder, GroupableStatement<?,?>[] statements, StatementManagerImpl mgr, StatementBridge bridge)
GroupImpl object.recorder - the optional recorder to register with this groupstatements - the statements to groupmgr - the non-null statement managerbridge - the non-null statement bridgeNullPointerException - if statement or any of the
statements are nullpublic GroupImpl(Optional<Recorder> recorder, Iterable<GroupableStatement<?,?>> statements, StatementManagerImpl mgr, StatementBridge bridge)
GroupImpl object.recorder - the optional recorder to register with this groupstatements - the statements to groupmgr - the non-null statement managerbridge - the non-null statement bridgeNullPointerException - if statement or any of the
statements are nullprotected List<StatementImpl<?,?,?>> buildGroupedStatements()
buildGroupedStatements in class GroupStatementImpl<Void,VoidFuture,Void>null list of all underlying statements from this
statementGroupStatementImpl.buildGroupedStatements()protected void setDirty(boolean recurse)
setDirty in class StatementImpl<Void,VoidFuture,Void>recurse - true to recursively set the dirty bit;
false to simply set this statement dirty bitStatementImpl.setDirty(boolean)public void setParent(ParentStatementImpl parent)
setParent in interface ParentStatementImplparent - the parent for this statementParentStatementImpl.setParent(org.helenus.driver.impl.ParentStatementImpl)public void recorded(ObjectStatement<?> statement, ParentStatement pstatement)
recorded in interface ParentStatementImplstatement - the non-null object statement that was recordedpstatement - the non-null parent where the statement was definedParentStatementImpl.recorded(org.helenus.driver.ObjectStatement, org.helenus.driver.ParentStatement)public java.util.stream.Stream<ObjectStatement<?>> objectStatements()
objectStatements in interface ParentStatementImplParentStatementImpl.objectStatements()public java.util.stream.Stream<GenericStatement<?,?>> statements()
statements in interface ParentStatementImplParentStatementImpl.statements()public String getKeyspace()
Gets the keyspace of the first statement in this sequence.
getKeyspace in interface GenericStatement<Void,VoidFuture>getKeyspace in interface GroupgetKeyspace in class StatementImpl<Void,VoidFuture,Void>null if the batch is emptyStatementImpl.getKeyspace()public Optional<Recorder> getRecorder()
getRecorder in interface ParentStatementImplgetRecorder in interface ParentStatementParentStatement.getRecorder()public boolean isEmpty()
isEmpty in interface ParentStatementParentStatement.isEmpty()public int size()
size in interface ParentStatementParentStatement.size()public void clear()
clear in interface ParentStatementParentStatement.clear()public <R,F extends com.google.common.util.concurrent.ListenableFuture<R>> Group add(GroupableStatement<R,F> statement)
add in interface GroupGroup.add(org.helenus.driver.GroupableStatement)public <R,F extends com.google.common.util.concurrent.ListenableFuture<R>> Group add(BatchableStatement<R,F> statement)
add in interface Groupadd in interface ParentStatementGroup.add(org.helenus.driver.BatchableStatement)public Group add(com.datastax.driver.core.RegularStatement statement)
add in interface Groupadd in interface ParentStatementGroup.add(com.datastax.driver.core.RegularStatement)public Group addErrorHandler(ERunnable<?> run)
addErrorHandler in interface GroupaddErrorHandler in interface ParentStatementGroup.addErrorHandler(org.helenus.util.function.ERunnable)public void runErrorHandlers()
runErrorHandlers in interface ParentStatementParentStatement.runErrorHandlers()public Group setParallelFactor(int factor)
By default, the parallel factor will be based on the number of nodes in the Cassandra cluster multiplied by 32 (default number of threads in the write pool of a Cassandra node).
Note: This value will be adjusted based on the maximum replication factor used by any of the statements. It will also be automatically limited to 32 if any of the statements affects all nodes such as schema, table, type, or index creation or alteration statements.
setParallelFactor in interface GroupsetParallelFactor in class GroupStatementImpl<Void,VoidFuture,Void>factor - the new parallel factor to use when sending simultaneous
statementsGroupStatementImpl.setParallelFactor(int)public Boolean isIdempotent()
isIdempotent in interface GenericStatement<Void,VoidFuture>isIdempotent in class GroupStatementImpl<Void,VoidFuture,Void>GroupStatementImpl.isIdempotent()Copyright (C) 2015-2017 The Helenus Driver Project Authors.