K - Key type.V - Value type.T - Command output type.public class Command<K,V,T> extends AbstractFuture<T> implements RedisCommand<K,V,T>
CommandOutput object.| Modifier and Type | Field and Description |
|---|---|
protected CommandArgs<K,V> |
args |
protected CountDownLatch |
latch |
protected CommandOutput<K,V,T> |
output |
| Constructor and Description |
|---|
Command(ProtocolKeyword type,
CommandOutput<K,V,T> output,
CommandArgs<K,V> args)
Create a new command with the supplied type and args.
|
Command(ProtocolKeyword type,
CommandOutput<K,V,T> output,
CommandArgs<K,V> args,
boolean multi)
Create a new command with the supplied type and args.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
await(long timeout,
TimeUnit unit)
Wait up to the specified time for the command output to become available.
|
void |
complete()
Mark this command complete and notify all waiting threads.
|
void |
encode(ByteBuf buf)
Encode and write this command to the supplied buffer using the new Unified
Request Protocol.
|
T |
get()
Get the command output and if the command hasn't completed yet, wait until it does.
|
T |
get(long timeout,
TimeUnit unit)
Get the command output and if the command hasn't completed yet, wait up to the specified time until it does.
|
CommandArgs<K,V> |
getArgs() |
String |
getError() |
Throwable |
getException() |
CommandOutput<K,V,T> |
getOutput()
Get the object that holds this command's output.
|
ProtocolKeyword |
getType() |
protected void |
interruptTask() |
boolean |
isCancelled()
Check if the command has been cancelled.
|
boolean |
isDone()
Check if the command has completed.
|
boolean |
isMulti() |
boolean |
setException(Throwable exception)
Subclasses should invoke this method to set the result of the computation to an error,
throwable. |
void |
setMulti(boolean multi) |
void |
setOutput(CommandOutput<K,V,T> output) |
String |
toString() |
protected static void |
writeInt(ByteBuf buf,
int value)
Write the textual value of a positive integer to the supplied buffer.
|
addListener, cancel, set, wasInterruptedclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddListenerprotected CommandArgs<K,V> args
protected CommandOutput<K,V,T> output
protected CountDownLatch latch
public Command(ProtocolKeyword type, CommandOutput<K,V,T> output, CommandArgs<K,V> args)
type - Command type.output - Command output.args - Command args, if any.public Command(ProtocolKeyword type, CommandOutput<K,V,T> output, CommandArgs<K,V> args, boolean multi)
type - Command type.output - Command output.args - Command args, if any.multi - Flag indicating if MULTI active.public void setMulti(boolean multi)
public boolean isMulti()
protected void interruptTask()
interruptTask in class AbstractFuture<T>public boolean isCancelled()
isCancelled in interface Future<T>isCancelled in class AbstractFuture<T>public boolean isDone()
public T get() throws ExecutionException
get in interface Future<T>get in class AbstractFuture<T>ExecutionExceptionpublic T get(long timeout, TimeUnit unit) throws TimeoutException, ExecutionException
get in interface Future<T>get in class AbstractFuture<T>timeout - Maximum time to wait for a result.unit - Unit of time for the timeout.TimeoutException - if the wait timed out.ExecutionExceptionpublic boolean await(long timeout,
TimeUnit unit)
await in interface RedisFuture<T>timeout - Maximum time to wait for a result.unit - Unit of time for the timeout.public CommandOutput<K,V,T> getOutput()
getOutput in interface RedisCommand<K,V,T>public void complete()
complete in interface RedisCommand<K,V,T>public void encode(ByteBuf buf)
encode in interface RedisCommand<K,V,T>buf - Buffer to write to.protected static void writeInt(ByteBuf buf, int value)
buf - Buffer to write to.value - Value to write.public String getError()
getError in interface RedisFuture<T>public CommandArgs<K,V> getArgs()
getArgs in interface RedisCommand<K,V,T>public void setOutput(CommandOutput<K,V,T> output)
public Throwable getException()
public boolean setException(Throwable exception)
RedisCommandthrowable. This will set
the state of the future to COMPLETED and invoke the listeners if the state was successfully changed.setException in interface RedisCommand<K,V,T>setException in class AbstractFuture<T>exception - the exception that the task failed with.public ProtocolKeyword getType()
getType in interface RedisCommand<K,V,T>Copyright © 2016. All rights reserved.