@InterfaceAudience.Public @InterfaceStability.Evolving public class KuduSession extends Object implements SessionConfiguration
AsyncKuduSession.
Offers the same API but with blocking methods.This class is not thread-safe.
A major difference with AsyncKuduSession is that the time spent waiting on operations is
defined by setTimeoutMillis(long) which defaults to getting it from
KuduClient.getDefaultOperationTimeoutMs().
SessionConfiguration.FlushMode| Modifier and Type | Field and Description |
|---|---|
static org.slf4j.Logger |
LOG |
| Modifier and Type | Method and Description |
|---|---|
OperationResponse |
apply(Operation operation)
Blocking call with a different behavior based on the flush mode.
|
List<OperationResponse> |
close()
Blocking call that flushes the buffers (see
flush() and closes the sessions. |
int |
countPendingErrors()
Return the number of errors which are pending.
|
List<OperationResponse> |
flush()
Blocking call that force flushes this session's buffers.
|
SessionConfiguration.FlushMode |
getFlushMode()
Get the current flush mode.
|
RowErrorsAndOverflowStatus |
getPendingErrors()
Return any errors from previous calls.
|
long |
getTimeoutMillis()
Get the current timeout.
|
boolean |
hasPendingOperations()
Check if there are operations that haven't been completely applied.
|
boolean |
isClosed()
Returns true if this session has already been closed.
|
boolean |
isIgnoreAllDuplicateRows()
Tells if the session is currently ignoring row errors when the whole list returned by a tablet
server is of the AlreadyPresent type.
|
void |
setExternalConsistencyMode(ExternalConsistencyMode consistencyMode)
Set the new external consistency mode for this session.
|
void |
setFlushInterval(int interval)
Set the flush interval, which will be used for the next scheduling decision.
|
void |
setFlushMode(SessionConfiguration.FlushMode flushMode)
Set the new flush mode for this session.
|
void |
setIgnoreAllDuplicateRows(boolean ignoreAllDuplicateRows)
Configures the option to ignore all the row errors if they are all of the AlreadyPresent type.
|
void |
setMutationBufferLowWatermark(float mutationBufferLowWatermarkPercentage)
Set the low watermark for this session.
|
void |
setMutationBufferSpace(int size)
Set the number of operations that can be buffered.
|
void |
setTimeoutMillis(long timeout)
Sets the timeout for the next applied operations.
|
public OperationResponse apply(Operation operation) throws KuduException
AsyncKuduSession.apply(org.apache.kudu.client.Operation).
countPendingErrors() and can be retrieved by calling
getPendingErrors().
operation - operation to applyKuduException - if anything went wrongpublic List<OperationResponse> flush() throws KuduException
KuduException - if anything went wrongpublic List<OperationResponse> close() throws KuduException
flush() and closes the sessions.KuduException - if anything went wrongpublic SessionConfiguration.FlushMode getFlushMode()
SessionConfigurationgetFlushMode in interface SessionConfigurationpublic void setFlushMode(SessionConfiguration.FlushMode flushMode)
SessionConfigurationsetFlushMode in interface SessionConfigurationflushMode - new flush mode, can be the same as the previous one.public void setMutationBufferSpace(int size)
SessionConfigurationsetMutationBufferSpace in interface SessionConfigurationsize - number of ops.public void setMutationBufferLowWatermark(float mutationBufferLowWatermarkPercentage)
SessionConfigurationsetMutationBufferLowWatermark in interface SessionConfigurationmutationBufferLowWatermarkPercentage - a new low watermark as a percentage,
has to be between 0 and 1 (inclusive). A value of 1 disables
the low watermark since it's the same as the high onepublic void setFlushInterval(int interval)
SessionConfigurationsetFlushInterval in interface SessionConfigurationinterval - interval in milliseconds.public long getTimeoutMillis()
SessionConfigurationgetTimeoutMillis in interface SessionConfigurationpublic void setTimeoutMillis(long timeout)
SessionConfigurationsetTimeoutMillis in interface SessionConfigurationtimeout - Timeout in milliseconds.public boolean isClosed()
SessionConfigurationisClosed in interface SessionConfigurationpublic boolean hasPendingOperations()
SessionConfigurationhasPendingOperations in interface SessionConfigurationpublic void setExternalConsistencyMode(ExternalConsistencyMode consistencyMode)
SessionConfigurationsetExternalConsistencyMode in interface SessionConfigurationconsistencyMode - new external consistency mode, can the same as the previous one.public boolean isIgnoreAllDuplicateRows()
SessionConfigurationisIgnoreAllDuplicateRows in interface SessionConfigurationpublic void setIgnoreAllDuplicateRows(boolean ignoreAllDuplicateRows)
SessionConfigurationsetIgnoreAllDuplicateRows in interface SessionConfigurationignoreAllDuplicateRows - true if this session should enforce this, else falsepublic int countPendingErrors()
SessionConfigurationcountPendingErrors in interface SessionConfigurationpublic RowErrorsAndOverflowStatus getPendingErrors()
SessionConfigurationgetPendingErrors in interface SessionConfigurationCopyright © 2016 The Apache Software Foundation. All rights reserved.