Exemplo n.º 1
0
  public void consume(byte[] buffer, int offset, int length) throws IOException {
    DataInputStream in = new DataInputStream(new ByteArrayInputStream(buffer, offset, length));
    do {
      processOne(in);

    } while (in.readBoolean());
  }
Exemplo n.º 2
0
  private void processRequest(DataInputStream in) throws IOException {

    long serverId = in.readLong();

    ServerObject server = servingById.get(serverId);

    long requestId = in.readLong();
    Request r = new Request(this, server.getObject());
    r.deserialize(in);
    r.invoke();
    if (requestId != -1) {
      sendResponse(requestId, r.getResult(), r.getResultDeclaredType());
    }
  }
    public TreeRequest deserialize(DataInputStream dis, int version) throws IOException {
      String sessId = dis.readUTF();
      InetAddress endpoint = CompactEndpointSerializationHelper.deserialize(dis);
      CFPair cfpair = new CFPair(dis.readUTF(), dis.readUTF());
      Range range;
      if (version > MessagingService.VERSION_07)
        range = (Range) AbstractBounds.serializer().deserialize(dis);
      else
        range =
            new Range(
                StorageService.getPartitioner().getMinimumToken(),
                StorageService.getPartitioner().getMinimumToken());

      return new TreeRequest(sessId, endpoint, range, cfpair);
    }
Exemplo n.º 4
0
  private void processResponse(DataInputStream in) throws IOException {
    long requestId = in.readLong();
    Request r = requests.remove(requestId);

    if (r == null) {
      throw new IllegalStateException(
          "Request " + requestId + " is unknown (last request generated was " + nextRequest.get());
    }

    Object o = null;
    if (in.readBoolean()) {
      o = serializerFor(classForName(in.readUTF()), r.getResultDeclaredType()).deserialize(in);
    }
    r.set(o);
  }
Exemplo n.º 5
0
  private void processOne(DataInputStream in) throws IOException {

    byte op = in.readByte();

    switch (op) {
      case REQUEST:
        processRequest(in);
        break;

      case RESPONSE:
        processResponse(in);
        break;

      default:
        throw new RuntimeException("Unknown operation: " + op);
    }
  }