Package org.jredis.protocol

Examples of org.jredis.protocol.ResponseStatus


       * So we have a Future<?> object, but is that the actual response?  No.  You need to wait
       * for it to actually complete.
       *
       * Here we're waiting using blocking semantics:  we wait until its done.
       */
          ResponseStatus response = fResp.get();
         
          /**
           * So we have our response at this point.  We can check it, etc.
           */
          if(response.isError()){
            Log.error("PING returned an ERR response -- is it an authorization issue?");
          }
        }
        catch (InterruptedException e) {
          /*
 
View Full Code Here


    Future<ResponseStatus> frStatus = null;
    cmd = Command.PING.code;
    Log.log("TEST: %s command", cmd);
    try {
      frStatus = provider.ping();
      ResponseStatus status = frStatus.get();
      assertTrue(!status.isError(), "ping return status");
    }
        catch (ExecutionException e) {
          e.printStackTrace();
          fail(cmd + " FAULT: " + e.getCause().getLocalizedMessage(), e);
        }
View Full Code Here

    Future<ResponseStatus> frStatus = null;
    cmd = Command.FLUSHDB.code;
    Log.log("TEST: %s command", cmd);
    try {
      frStatus = provider.flushdb();
      ResponseStatus status = frStatus.get();
      assertTrue(!status.isError(), "flushdb return status");
    }
        catch (ExecutionException e) {
          e.printStackTrace();
          fail(cmd + " FAULT: " + e.getCause().getLocalizedMessage(), e);
        }
View Full Code Here

          }
        }
     
        // check response status
        //
    ResponseStatus status = Assert.notNull (response.getStatus(), "status from response object", ProviderException.class);
    if(status.isError()) {
      Log.error ("Error response for " + cmd.code + " => " + status.message());
      throw new RedisException(cmd, status.message());
    }
    /* this is handled by the super class */
//    else if(status.code() == ResponseStatus.Code.CIAO) {
//      // normal for quit and shutdown commands.  we disconnect too.
//      disconnect();
View Full Code Here

        if(c == -1) {
          Log.error("-1 read count in readLine() while reading response line.");
          throw new UnexpectedEOFException ("Unexpected EOF (read -1) in readLine.  Command: " + cmd.code);
        }
        if((this.isError = buffer[0] == ProtocolBase.ERR_BYTE) == true)
          status = new ResponseStatus(ResponseStatus.Code.ERROR, new String(buffer, 1, offset-3));
        else
          status = ResponseStatus.STATUS_OK;
      }
      catch (SocketException e) {
        // on connection reset
View Full Code Here

     * @return
     */
    int readControlLine (InputStream in, boolean checkForError, byte ctlByte){
      seekToCRLF(in);
      if(checkForError && (this.isError = buffer[0] == ProtocolBase.ERR_BYTE) == true) {
        status = new ResponseStatus(ResponseStatus.Code.ERROR, new String(buffer, 1, offset-3));
        didRead = true// we're done - error's are only one line
        return -2;
      }
      if(buffer[0] != ctlByte) {
        throw new ProviderException ("Bug?  Expecting status code for size/count");
View Full Code Here

   
    if(!isConnected()) throw new NotConnectedException ("Not connected!");
   
    Request      request = null;
    Response    response = null;
    ResponseStatus  status = null;
   
    try {
      // 1 - Request
      //        Log.log("RedisConnection - requesting ..." + cmd.code);
     
      request = Assert.notNull(protocol.createRequest (cmd, args), "request object from handler", ProviderException.class);
      request.write(super.getOutputStream());

      // 2 - response
      //        Log.log("RedisConnection - read response ..." + cmd.code);
      response = Assert.notNull(protocol.createResponse(cmd), "response object from handler", ProviderException.class);
      response.read(super.getInputStream());

      //        break;
    }
    catch (ProviderException bug){
      Log.bug ("serviceRequest() -- ProviderException: " + bug.getLocalizedMessage());
      Log.log ("serviceRequest() -- closing connection ...");
      disconnect();
      throw bug;
    }
    catch (ClientRuntimeException cre) {
      Log.problem ("serviceRequest() -- ClientRuntimeException  => " + cre.getLocalizedMessage());
      reconnect();
     
      throw new ConnectionResetException ("Connection re-established but last request not processed:  " + cre.getCause().getLocalizedMessage());
    }
    catch (RuntimeException e){
      e.printStackTrace();
      Log.bug ("serviceRequest() -- *unexpected* RuntimeException: " + e.getLocalizedMessage());

      Log.log ("serviceRequest() -- closing connection ...");
      disconnect();

      throw new ClientRuntimeException("unexpected runtime exeption: " + e.getLocalizedMessage(), e);
    }
   
    // 3 - Status
    //
    status = Assert.notNull (response.getStatus(), "status from response object", ProviderException.class);
    if(status.isError()) {
      Log.error ("Error response for " + cmd.code + " => " + status.message());
      throw new RedisException(cmd, status.message());
    }
    else if(status.code() == ResponseStatus.Code.CIAO) {
      // normal for quit and shutdown commands.  we disconnect too.
      disconnect();
    }

    return response;
View Full Code Here

  {
    if(!isConnected()) throw new NotConnectedException ("Not connected!");
   
    Request      request = null;
    Response    response = null;
    ResponseStatus  status = null;
    Protocol    protocol = Assert.notNull(getProtocolHandler(), "thread protocol handler", ProviderException.class);

    try {
      // 1 - Request
      //        Log.log("RedisConnection - requesting ..." + cmd.code);
     
      request = Assert.notNull(protocol.createRequest (cmd, args), "request object from handler", ProviderException.class);
      request.write(super.getOutputStream());

      // 2 - response
      //        Log.log("RedisConnection - read response ..." + cmd.code);
      response = Assert.notNull(protocol.createResponse(cmd), "response object from handler", ProviderException.class);
      response.read(super.getInputStream());

      //        break;
    }
    catch (ProviderException bug){
      Log.bug ("serviceRequest() -- ProviderException: " + bug.getLocalizedMessage());
      Log.log ("serviceRequest() -- closing connection ...");
      disconnect();
      throw bug;
    }
    catch (ClientRuntimeException cre) {
      Log.problem ("serviceRequest() -- ClientRuntimeException  => " + cre.getLocalizedMessage());
      reconnect();
     
      throw new ConnectionReset ("Connection re-established but last request not processed:  " + cre.getLocalizedMessage());
    }
    catch (RuntimeException e){
      e.printStackTrace();
      Log.bug ("serviceRequest() -- *unexpected* RuntimeException: " + e.getLocalizedMessage());

      Log.log ("serviceRequest() -- closing connection ...");
      disconnect();

      throw new ClientRuntimeException("unexpected runtime exeption: " + e.getLocalizedMessage(), e);
    }
    // 3 - Status
    //
    status = Assert.notNull (response.getStatus(), "status from response object", ProviderException.class);
    if(status.isError()) {
      Log.error ("Error response for " + cmd.code + " => " + status.message());
      throw new RedisException(cmd, status.message());
    }
    else if(status.code() == ResponseStatus.Code.CIAO) {
      // normal for quit and shutdown commands.  we disconnect too.
      disconnect();
    }

    return response;
View Full Code Here

            futureStat = pipeline.ping();
            cnt++;
          }
          long reqDoneTime = timer.mark();
          assert futureStat != null;
        @SuppressWarnings("null")
        ResponseStatus rstat = futureStat.get();
          long respDoneTime = timer.mark();
//        System.out.format("JRedisPipeline: %d PINGs invoked   @ %5d  (%.2f ops/s)\n", cnt, reqDoneTime, timer.opsPerSecAtDelta(cnt, reqDoneTime));
        float throughput = timer.opsPerSecAtMark(cnt);
//        System.out.format("JRedisPipeline: %d PINGs completed @ %5d  (%.2f ops/s) [%d msecs to comp] \n", cnt, timer.deltaAtMark(), throughput, respDoneTime-reqDoneTime);
View Full Code Here

            futureLong = pipeline.lpush(key, data);
            cnt++;
          }
          long reqDoneTime = timer.mark();
          assert futureStat != null;
          @SuppressWarnings({ "null", "unused" })
        ResponseStatus rstat = futureStat.get();
          long respDoneTime = timer.mark();
        System.out.format("JRedisPipeline: %d LPUSHs invoked   @ %5d  (%.2f ops/s)\n", cnt, reqDoneTime, timer.opsPerSecAtDelta(cnt, reqDoneTime));
        System.out.format("JRedisPipeline: %d LPUSHs completed @ %5d  (%.2f ops/s) [%d msecs to comp] \n", cnt, timer.deltaAtMark(), timer.opsPerSecAtMark(cnt), respDoneTime-reqDoneTime);
        if(iters > 0){
View Full Code Here

TOP

Related Classes of org.jredis.protocol.ResponseStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.