redis.clients.jedis.Protocol.Command Java Examples

The following examples show how to use redis.clients.jedis.Protocol.Command. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConnectionTest.java    From cachecloud with Apache License 2.0 6 votes vote down vote up
@Test
public void getErrorAfterConnectionReset() throws Exception {
  class TestConnection extends Connection {
    public TestConnection() {
      super("localhost", 6379);
    }

    @Override
    protected Connection sendCommand(ProtocolCommand cmd, byte[]... args) {
      return super.sendCommand(cmd, args);
    }
  }

  TestConnection conn = new TestConnection();

  try {
    conn.sendCommand(Command.HMSET, new byte[1024 * 1024 + 1][0]);
    fail("Should throw exception");
  } catch (JedisConnectionException jce) {
    assertEquals("ERR Protocol error: invalid multibulk length", jce.getMessage());
  }
}
 
Example #2
Source File: JedisAgentIntercept.java    From java-specialagent with Apache License 2.0 5 votes vote down vote up
public static void sendCommand(final Object command, final byte[][] args) {
  final Command cmd = (Command)command;
  final Span span = GlobalTracer.get()
    .buildSpan(cmd.name())
    .withTag(Tags.COMPONENT.getKey(), "java-redis")
    .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
    .withTag(Tags.DB_TYPE.getKey(), "redis")
    .start();

  final String redisCommand = convert(args);
  if (redisCommand != null)
    span.setTag(Tags.DB_STATEMENT, redisCommand);

  spanHolder.get().add(span);
}
 
Example #3
Source File: JedisConnectionIT.java    From uavstack with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked" })
public Object doSendCommandStart(Object[] args) {

    Command cmd = (Command) args[0];
    String host = (String) args[2];
    Integer port = (Integer) args[3];
    String targetURL = "redis://" + host + ":" + port;
    String redisAction = cmd.name();

    if (logger.isDebugable()) {
        logger.debug("REDIS INVOKE START: " + targetURL + " action: " + redisAction, null);
    }

    Map<String, Object> params = new HashMap<String, Object>();

    params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, targetURL);
    params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, redisAction);
    params.put(CaptureConstants.INFO_CLIENT_APPID, appid);
    params.put(CaptureConstants.INFO_CLIENT_TYPE, "redis.client.Jedis");

    UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT,
            Monitor.CapturePhase.PRECAP, params);

    // register adapter
    UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "registerAdapter",
            JedisClientAdapter.class);

    ivcContextParams = (Map<String, Object>) UAVServer.instance().runSupporter(
            "com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap",
            InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.PRECAP, params,
            JedisClientAdapter.class, args);
    return null;
}
 
Example #4
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Object eval(String script, String key) {
  Span span = helper.buildSpan(Command.EVAL.name(), key);
  span.setTag("script", script);
  try {
    return super.eval(script, key);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #5
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Object evalsha(String script, String key) {
  Span span = helper.buildSpan(Command.EVALSHA.name(), key);
  span.setTag("script", script);
  try {
    return super.evalsha(script, key);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #6
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Object eval(String script, String key) {
  Span span = helper.buildSpan(Command.EVAL.name(), key);
  span.setTag("script", script);
  try {
    return super.eval(script, key);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #7
Source File: TracingJedisCluster.java    From java-redis-client with Apache License 2.0 5 votes vote down vote up
@Override
public Object evalsha(String script, String key) {
  Span span = helper.buildSpan(Command.EVALSHA.name(), key);
  span.setTag("script", script);
  try {
    return super.evalsha(script, key);
  } catch (Exception e) {
    onError(e, span);
    throw e;
  } finally {
    span.finish();
  }
}
 
Example #8
Source File: BinaryClient.java    From cachecloud with Apache License 2.0 4 votes vote down vote up
public void ping() {
  sendCommand(Command.PING);
}
 
Example #9
Source File: BinaryClient.java    From cachecloud with Apache License 2.0 4 votes vote down vote up
public void set(final byte[] key, final byte[] value) {
  sendCommand(Command.SET, key, value);
}
 
Example #10
Source File: BinaryClient.java    From cachecloud with Apache License 2.0 4 votes vote down vote up
public void set(final byte[] key, final byte[] value, final SetParams params) {
  sendCommand(Command.SET, params.getByteParams(key, value));
}
 
Example #11
Source File: BinaryClient.java    From cachecloud with Apache License 2.0 4 votes vote down vote up
public void get(final byte[] key) {
  sendCommand(Command.GET, key);
}
 
Example #12
Source File: BinaryClient.java    From cachecloud with Apache License 2.0 4 votes vote down vote up
public void asking() {
  sendCommand(Command.ASKING);
}
 
Example #13
Source File: BinaryClient.java    From cachecloud with Apache License 2.0 3 votes vote down vote up
private void sendEvalCommand(Command command, byte[] script, byte[] keyCount, byte[][] params) {

    final byte[][] allArgs = new byte[params.length + 2][];

    allArgs[0] = script;
    allArgs[1] = keyCount;

    for (int i = 0; i < params.length; i++)
      allArgs[i + 2] = params[i];

    sendCommand(command, allArgs);
  }