@InterfaceAudience.Public @InterfaceStability.Evolving public class KuduSession extends Object implements SessionConfiguration
AsyncKuduSession
. Offers the same API but with blocking methods.
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. |
List<OperationResponse> |
flush()
Blocking call that force flushes this session's buffers.
|
SessionConfiguration.FlushMode |
getFlushMode()
Get the current flush mode.
|
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 Exception
AsyncKuduSession.apply(org.kududb.client.Operation)
.
operation
- operation to applyException
- if anything went wrongpublic List<OperationResponse> flush() throws Exception
Exception
- if anything went wrong. If it's an issue with some or all batches,
it will be of type DeferredGroupException.public List<OperationResponse> close() throws Exception
flush()
and closes the sessions.Exception
- if anything went wrong. If it's an issue with some or all batches,
it will be of type DeferredGroupException.public SessionConfiguration.FlushMode getFlushMode()
SessionConfiguration
getFlushMode
in interface SessionConfiguration
public 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 size)
SessionConfiguration
setMutationBufferSpace
in interface SessionConfiguration
size
- number of ops.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 interval)
SessionConfiguration
setFlushInterval
in interface SessionConfiguration
interval
- 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
setIgnoreAllDuplicateRows
in interface SessionConfiguration
ignoreAllDuplicateRows
- true if this session should enforce this, else falseCopyright © 2015. All rights reserved.