本文整理汇总了Java中com.lambdaworks.redis.protocol.Command类的典型用法代码示例。如果您正苦于以下问题:Java Command类的具体用法?Java Command怎么用?Java Command使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Command类属于com.lambdaworks.redis.protocol包,在下文中一共展示了Command类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: requestPing
import com.lambdaworks.redis.protocol.Command; //导入依赖的package包/类
public Requests requestPing() {
Requests requests = new Requests();
for (Map.Entry<RedisURI, StatefulRedisConnection<String, String>> entry : connections.entrySet()) {
CommandArgs<String, String> args = new CommandArgs<>(StringCodec.ASCII).add(CommandKeyword.NODES);
Command<String, String, String> command = new Command<>(CommandType.PING, new StatusOutput<>(StringCodec.ASCII),
args);
TimedAsyncCommand<String, String, String> timedCommand = new TimedAsyncCommand<>(command);
entry.getValue().dispatch(timedCommand);
requests.addRequest(entry.getKey(), timedCommand);
}
return requests;
}
示例2: requestTopology
import com.lambdaworks.redis.protocol.Command; //导入依赖的package包/类
public Requests requestTopology() {
Requests requests = new Requests();
for (Map.Entry<RedisURI, StatefulRedisConnection<String, String>> entry : connections.entrySet()) {
CommandArgs<String, String> args = new CommandArgs<>(StringCodec.UTF8).add(CommandKeyword.NODES);
Command<String, String, String> command = new Command<>(CommandType.CLUSTER, new StatusOutput<>(StringCodec.UTF8),
args);
TimedAsyncCommand<String, String, String> timedCommand = new TimedAsyncCommand<>(command);
entry.getValue().dispatch(timedCommand);
requests.addRequest(entry.getKey(), timedCommand);
}
return requests;
}
示例3: requestClients
import com.lambdaworks.redis.protocol.Command; //导入依赖的package包/类
public Requests requestClients() {
Requests requests = new Requests();
for (Map.Entry<RedisURI, StatefulRedisConnection<String, String>> entry : connections.entrySet()) {
CommandArgs<String, String> args = new CommandArgs<>(StringCodec.UTF8).add(CommandKeyword.LIST);
Command<String, String, String> command = new Command<>(CommandType.CLIENT, new StatusOutput<>(StringCodec.UTF8),
args);
TimedAsyncCommand<String, String, String> timedCommand = new TimedAsyncCommand<>(command);
entry.getValue().dispatch(timedCommand);
requests.addRequest(entry.getKey(), timedCommand);
}
return requests;
}
示例4: shouldObtainConnectionReadFromSlave
import com.lambdaworks.redis.protocol.Command; //导入依赖的package包/类
@Test
public void shouldObtainConnectionReadFromSlave() {
when(clientMock.connectToNodeAsync(eq(CODEC), eq("localhost:2"), any(), any())).thenReturn(
Futures.createConnectionFuture(socketAddressMock, CompletableFuture.completedFuture(nodeConnectionMock)));
AsyncCommand<String, String, String> async = new AsyncCommand<>(new Command<String, String, String>(
CommandType.READONLY, null, null));
async.complete();
when(asyncCommandsMock.readOnly()).thenReturn(async);
sut.setReadFrom(ReadFrom.SLAVE);
StatefulRedisConnection<String, String> connection = sut.getConnection(Intent.READ, 1);
assertThat(connection).isSameAs(nodeConnectionMock);
verify(connection).async();
verify(asyncCommandsMock).readOnly();
verify(connection).setAutoFlushCommands(true);
}
示例5: shouldCloseConnectionOnConnectFailure
import com.lambdaworks.redis.protocol.Command; //导入依赖的package包/类
@Test
public void shouldCloseConnectionOnConnectFailure() {
when(clientMock.connectToNodeAsync(eq(CODEC), eq("localhost:2"), any(), any())).thenReturn(
Futures.createConnectionFuture(socketAddressMock, CompletableFuture.completedFuture(nodeConnectionMock)));
AsyncCommand<String, String, String> async = new AsyncCommand<>(new Command<String, String, String>(
CommandType.READONLY, null, null));
async.completeExceptionally(new RuntimeException());
when(asyncCommandsMock.readOnly()).thenReturn(async);
sut.setReadFrom(ReadFrom.SLAVE);
try {
sut.getConnection(Intent.READ, 1);
fail("Missing RedisException");
} catch (RedisException e) {
assertThat(e).hasRootCauseInstanceOf(RuntimeException.class);
}
verify(nodeConnectionMock).close();
verify(clientMock).connectToNodeAsync(eq(CODEC), eq("localhost:2"), any(), any());
}
示例6: addjob
import com.lambdaworks.redis.protocol.Command; //导入依赖的package包/类
public Command<K, V, String> addjob(K queue, V job, long commandTimeout, TimeUnit timeUnit, AddJobArgs addJobArgs) {
DisqueCommandArgs<K, V> args = new DisqueCommandArgs<K, V>(codec).addKey(queue).addValue(job);
if (timeUnit != null) {
args.add(timeUnit.toMillis(commandTimeout));
} else {
args.add(0);
}
if (addJobArgs != null) {
addJobArgs.build(args);
}
return createCommand(ADDJOB, new StatusOutput<K, V>(codec), args);
}
示例7: clientKill
import com.lambdaworks.redis.protocol.Command; //导入依赖的package包/类
public Command<K, V, Long> clientKill(KillArgs killArgs) {
DisqueCommandArgs<K, V> args = new DisqueCommandArgs<K, V>(codec)
.add(com.lambdaworks.redis.protocol.CommandKeyword.KILL);
// killArgs.build(args);
return createCommand(CLIENT, new IntegerOutput<K, V>(codec), args);
}
示例8: clusterReset
import com.lambdaworks.redis.protocol.Command; //导入依赖的package包/类
public Command<K, V, String> clusterReset(boolean hard) {
DisqueCommandArgs<K, V> args = new DisqueCommandArgs<K, V>(codec).add(RESET);
if (hard) {
args.add(HARD);
} else {
args.add(SOFT);
}
return createCommand(CLUSTER, new StatusOutput<K, V>(codec), args);
}
示例9: commandInfo
import com.lambdaworks.redis.protocol.Command; //导入依赖的package包/类
public Command<K, V, List<Object>> commandInfo(String... commands) {
DisqueCommandArgs<K, V> args = new DisqueCommandArgs<K, V>(codec);
args.add(INFO);
for (String command : commands) {
args.add(command);
}
return createCommand(COMMAND, new ArrayOutput<K, V>(codec), args);
}
示例10: jscan
import com.lambdaworks.redis.protocol.Command; //导入依赖的package包/类
public Command<K, V, KeyScanCursor<String>> jscan(ScanCursor scanCursor, JScanArgs<K> scanArgs) {
DisqueCommandArgs<K, V> args = new DisqueCommandArgs<K, V>(codec);
if (scanArgs != null) {
scanArgs.build(args);
}
if (scanCursor != null) {
args.add(scanCursor.getCursor());
}
args.add(CommandKeyword.REPLY).add("id");
return createCommand(JSCAN, new StringScanOutput<K, V>(codec), args);
}
示例11: qscan
import com.lambdaworks.redis.protocol.Command; //导入依赖的package包/类
public Command<K, V, KeyScanCursor<K>> qscan(ScanCursor scanCursor, QScanArgs scanArgs) {
DisqueCommandArgs<K, V> args = new DisqueCommandArgs<K, V>(codec);
if (scanArgs != null) {
scanArgs.build(args);
}
if (scanCursor != null) {
args.add(scanCursor.getCursor());
}
return createCommand(QSCAN, new KeyScanOutput<K, V>(codec), args);
}
示例12: pubsubNumsub
import com.lambdaworks.redis.protocol.Command; //导入依赖的package包/类
@SafeVarargs
final Command<K, V, Map<K, Long>> pubsubNumsub(K... patterns) {
LettuceAssert.notEmpty(patterns, "patterns " + MUST_NOT_BE_EMPTY);
CommandArgs<K, V> args = new PubSubCommandArgs<>(codec).add(NUMSUB).addKeys(patterns);
return createCommand(PUBSUB, new MapOutput<>((RedisCodec) codec), args);
}
示例13: clientKill
import com.lambdaworks.redis.protocol.Command; //导入依赖的package包/类
public Command<K, V, String> clientKill(String addr) {
LettuceAssert.notNull(addr, "Addr must not be null");
LettuceAssert.notEmpty(addr, "Addr must not be empty");
CommandArgs<K, V> args = new CommandArgs<>(codec).add(KILL).add(addr);
return createCommand(CLIENT, new StatusOutput<>(codec), args);
}
示例14: shutdown
import com.lambdaworks.redis.protocol.Command; //导入依赖的package包/类
@Override
public void shutdown(boolean save) {
executeOnNodes(commands -> {
commands.shutdown(save);
Command<K, V, Long> command = new Command<>(CommandType.SHUTDOWN, new IntegerOutput<>(codec), null);
AsyncCommand<K, V, Long> async = new AsyncCommand<>(command);
async.complete();
return async;
}, redisClusterNode -> true);
}
示例15: shouldRetryConnectionAttemptAfterConnectionAttemptWasBroken
import com.lambdaworks.redis.protocol.Command; //导入依赖的package包/类
@Test
public void shouldRetryConnectionAttemptAfterConnectionAttemptWasBroken() {
when(clientMock.connectToNodeAsync(eq(CODEC), eq("localhost:2"), any(), any())).thenReturn(
Futures.createConnectionFuture(socketAddressMock, CompletableFuture.completedFuture(nodeConnectionMock)));
AsyncCommand<String, String, String> async = new AsyncCommand<>(new Command<String, String, String>(
CommandType.READONLY, null, null));
async.completeExceptionally(new RuntimeException());
when(asyncCommandsMock.readOnly()).thenReturn(async);
sut.setReadFrom(ReadFrom.SLAVE);
try {
sut.getConnection(Intent.READ, 1);
fail("Missing RedisException");
} catch (RedisException e) {
assertThat(e).hasRootCauseInstanceOf(RuntimeException.class);
}
verify(nodeConnectionMock).close();
async = new AsyncCommand<>(new Command<String, String, String>(CommandType.READONLY, null, null));
async.complete();
when(asyncCommandsMock.readOnly()).thenReturn(async);
sut.getConnection(Intent.READ, 1);
verify(clientMock, times(2)).connectToNodeAsync(eq(CODEC), eq("localhost:2"), any(), any());
}