当前位置: 首页>>代码示例>>Java>>正文


Java Command类代码示例

本文整理汇总了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;
    }
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:18,代码来源:Connections.java

示例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;
    }
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:18,代码来源:Connections.java

示例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;
    }
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:18,代码来源:Connections.java

示例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);
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:22,代码来源:PooledClusterConnectionProviderTest.java

示例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());
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:25,代码来源:PooledClusterConnectionProviderTest.java

示例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);
}
 
开发者ID:mp911de,项目名称:spinach,代码行数:15,代码来源:DisqueCommandBuilder.java

示例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);
    }
 
开发者ID:mp911de,项目名称:spinach,代码行数:8,代码来源:DisqueCommandBuilder.java

示例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);
    }
 
开发者ID:mp911de,项目名称:spinach,代码行数:11,代码来源:DisqueCommandBuilder.java

示例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);
}
 
开发者ID:mp911de,项目名称:spinach,代码行数:11,代码来源:DisqueCommandBuilder.java

示例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);
    }
 
开发者ID:mp911de,项目名称:spinach,代码行数:16,代码来源:DisqueCommandBuilder.java

示例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);
}
 
开发者ID:mp911de,项目名称:spinach,代码行数:13,代码来源:DisqueCommandBuilder.java

示例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);
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:8,代码来源:PubSubCommandBuilder.java

示例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);
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:8,代码来源:SentinelCommandBuilder.java

示例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);
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:13,代码来源:RedisAdvancedClusterAsyncCommandsImpl.java

示例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());
}
 
开发者ID:lettuce-io,项目名称:lettuce-core,代码行数:32,代码来源:PooledClusterConnectionProviderTest.java


注:本文中的com.lambdaworks.redis.protocol.Command类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。