@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.
SessionConfiguration.FlushMode| Modifier and Type | Method and Description |
|---|---|
OperationResponse |
apply(Operation operation)
Apply a given
Operation to Kudu as part of this session. |
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.
|
ResourceMetrics |
getWriteOpMetrics()
Return cumulative write operation metrics since the beginning of the session.
|
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.
|
boolean |
isIgnoreAllNotFoundRows()
Tells if the session is currently ignoring row errors when the whole list returned by a tablet
server is of the NotFound type.
|
void |
setErrorCollectorSpace(int size)
Set the number of errors that can be collected.
|
void |
setExternalConsistencyMode(ExternalConsistencyMode consistencyMode)
Set the new external consistency mode for this session.
|
void |
setFlushInterval(int intervalMillis)
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 |
setIgnoreAllNotFoundRows(boolean ignoreAllNotFoundRows)
Configures the option to ignore all the row errors if they are all of the NotFound type.
|
void |
setMutationBufferLowWatermark(float mutationBufferLowWatermarkPercentage)
Deprecated.
|
void |
setMutationBufferSpace(int numOps,
long maxSize)
Set the number and the maximum byte size of operations that can be buffered.
|
void |
setTimeoutMillis(long timeout)
Sets the timeout for the next applied operations.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsetMutationBufferSpacepublic OperationResponse apply(Operation operation) throws KuduException
Operation to Kudu as part of this session.
This is a blocking call that has different behavior based on the configured flush mode:
AUTO_FLUSH_SYNC:
the call returns when the operation is persisted, else it throws an exception.
AUTO_FLUSH_BACKGROUND:
the call returns when the operation has been added to the buffer.
This call should normally perform only fast in-memory operations but
it may have to wait when the buffer is full and there's another buffer being flushed. Row
errors can be checked by calling countPendingErrors() and can be retrieved by calling
getPendingErrors().
MANUAL_FLUSH:
the call returns when the operation has been added to the buffer, else it throws a
KuduException if the buffer is full.
Note: PleaseThrottleException is handled by this method and will not be thrown, unlike
with AsyncKuduSession.apply().
operation - operation to applyKuduException - if anything went wrongFlushModepublic 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 SessionConfigurationAUTO_FLUSH_SYNC by defaultpublic void setFlushMode(SessionConfiguration.FlushMode flushMode)
SessionConfigurationsetFlushMode in interface SessionConfigurationflushMode - new flush mode, can be the same as the previous one.public void setMutationBufferSpace(int numOps,
long maxSize)
SessionConfigurationsetMutationBufferSpace in interface SessionConfigurationnumOps - number of ops.maxSize - max byte size of ops.public void setErrorCollectorSpace(int size)
SessionConfigurationsetErrorCollectorSpace in interface SessionConfigurationsize - number of errors.@Deprecated 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 intervalMillis)
SessionConfigurationsetFlushInterval in interface SessionConfigurationintervalMillis - 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)
SessionConfigurationDisabled by default.
setIgnoreAllDuplicateRows in interface SessionConfigurationignoreAllDuplicateRows - true if this session should enforce this, else falsepublic boolean isIgnoreAllNotFoundRows()
SessionConfigurationisIgnoreAllNotFoundRows in interface SessionConfigurationpublic void setIgnoreAllNotFoundRows(boolean ignoreAllNotFoundRows)
SessionConfigurationDisabled by default.
setIgnoreAllNotFoundRows in interface SessionConfigurationignoreAllNotFoundRows - true if this session should enforce this, else falsepublic int countPendingErrors()
SessionConfigurationAUTO_FLUSH_BACKGROUND mode.countPendingErrors in interface SessionConfigurationpublic RowErrorsAndOverflowStatus getPendingErrors()
SessionConfigurationClears the pending errors.
getPendingErrors in interface SessionConfigurationpublic ResourceMetrics getWriteOpMetrics()
SessionConfigurationgetWriteOpMetrics in interface SessionConfiguration