コード例 #1
0
 @Override
 public void remoteQueue(
     RpcController controller,
     TransactionPrefetchResult request,
     RpcCallback<TransactionPrefetchAcknowledgement> callback) {
   if (debug.get())
     LOG.debug(
         String.format(
             "Executing %s using remote handler for txn #%d",
             request.getClass().getSimpleName(), request.getTransactionId()));
   this.remoteHandler(controller, request, callback);
 }
コード例 #2
0
  @Override
  public void remoteHandler(
      RpcController controller,
      TransactionPrefetchResult request,
      RpcCallback<TransactionPrefetchAcknowledgement> callback) {
    assert (request.hasTransactionId())
        : "Got " + request.getClass().getSimpleName() + " without a txn id!";
    Long txn_id = Long.valueOf(request.getTransactionId());
    if (debug.get())
      LOG.debug(
          String.format(
              "Got %s for txn #%d [remotePartition=%d]",
              request.getClass().getSimpleName(), txn_id, request.getSourcePartition()));

    // We should never a get a TransactionPrefetchResult for a transaction that
    // we don't know about.
    // XXX: No I think it's ok because we
    LocalTransaction ts = hstore_site.getTransaction(txn_id);
    if (ts == null) {
      String msg =
          String.format(
              "Unexpected transaction id %d for incoming %s",
              txn_id, request.getClass().getSimpleName());
      throw new ServerFaultException(msg, txn_id);
    }

    // We want to store this before sending back the acknowledgment so that the transaction can get
    // access to it right away
    PartitionExecutor executor = hstore_site.getPartitionExecutor(ts.getBasePartition());
    WorkResult result = request.getResult();

    if (result.getStatus() != Status.OK) {
      // TODO: Process error!
    } else {
      for (int i = 0, cnt = result.getDepIdCount(); i < cnt; i++) {
        int fragmentId = request.getFragmentId(i);
        int paramsHash = request.getParamHash(i);

        VoltTable vt = null;
        try {
          this.fds.setBuffer(result.getDepData(i).asReadOnlyByteBuffer());
          vt = this.fds.readObject(VoltTable.class);
        } catch (IOException ex) {
          throw new RuntimeException(ex);
        }

        executor.addPrefetchResult(
            txn_id, fragmentId, request.getSourcePartition(), paramsHash, vt);
      } // FOR
    }

    // I don't think we even need to bother wasting our time sending an acknowledgement
    // We would like to cancel but we can't do that on the "server" side
    // controller.startCancel();

    //        TransactionPrefetchAcknowledgement response =
    // TransactionPrefetchAcknowledgement.newBuilder()
    //
    // .setTransactionId(txn_id.longValue())
    //
    // .setTargetPartition(request.getSourcePartition())
    //                                                            .build();
    //        callback.run(response);
  }