@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.
|
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)
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
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 wrongFlushMode
public 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()
SessionConfiguration
getFlushMode
in interface SessionConfiguration
AUTO_FLUSH_SYNC
by defaultpublic void setFlushMode(SessionConfiguration.FlushMode flushMode)
SessionConfiguration
setFlushMode
in interface SessionConfiguration
flushMode
- new flush mode, can be the same as the previous one.public void setMutationBufferSpace(int numOps)
SessionConfiguration
setMutationBufferSpace
in interface SessionConfiguration
numOps
- number of ops.public void setErrorCollectorSpace(int size)
SessionConfiguration
setErrorCollectorSpace
in interface SessionConfiguration
size
- number of errors.@Deprecated public void setMutationBufferLowWatermark(float mutationBufferLowWatermarkPercentage)
SessionConfiguration
setMutationBufferLowWatermark
in interface SessionConfiguration
mutationBufferLowWatermarkPercentage
- 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)
SessionConfiguration
setFlushInterval
in interface SessionConfiguration
intervalMillis
- interval in milliseconds.public long getTimeoutMillis()
SessionConfiguration
getTimeoutMillis
in interface SessionConfiguration
public void setTimeoutMillis(long timeout)
SessionConfiguration
setTimeoutMillis
in interface SessionConfiguration
timeout
- Timeout in milliseconds.public boolean isClosed()
SessionConfiguration
isClosed
in interface SessionConfiguration
public boolean hasPendingOperations()
SessionConfiguration
hasPendingOperations
in interface SessionConfiguration
public void setExternalConsistencyMode(ExternalConsistencyMode consistencyMode)
SessionConfiguration
setExternalConsistencyMode
in interface SessionConfiguration
consistencyMode
- new external consistency mode, can the same as the previous one.public boolean isIgnoreAllDuplicateRows()
SessionConfiguration
isIgnoreAllDuplicateRows
in interface SessionConfiguration
public void setIgnoreAllDuplicateRows(boolean ignoreAllDuplicateRows)
SessionConfiguration
Disabled by default.
setIgnoreAllDuplicateRows
in interface SessionConfiguration
ignoreAllDuplicateRows
- true if this session should enforce this, else falsepublic boolean isIgnoreAllNotFoundRows()
SessionConfiguration
isIgnoreAllNotFoundRows
in interface SessionConfiguration
public void setIgnoreAllNotFoundRows(boolean ignoreAllNotFoundRows)
SessionConfiguration
Disabled by default.
setIgnoreAllNotFoundRows
in interface SessionConfiguration
ignoreAllNotFoundRows
- true if this session should enforce this, else falsepublic int countPendingErrors()
SessionConfiguration
AUTO_FLUSH_BACKGROUND
mode.countPendingErrors
in interface SessionConfiguration
public RowErrorsAndOverflowStatus getPendingErrors()
SessionConfiguration
Clears the pending errors.
getPendingErrors
in interface SessionConfiguration