當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。