当前位置: 首页>>代码示例>>Java>>正文


Java RpcCallback类代码示例

本文整理汇总了Java中com.google.protobuf.RpcCallback的典型用法代码示例。如果您正苦于以下问题:Java RpcCallback类的具体用法?Java RpcCallback怎么用?Java RpcCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RpcCallback类属于com.google.protobuf包,在下文中一共展示了RpcCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeLocalTransaction

import com.google.protobuf.RpcCallback; //导入依赖的package包/类
static LocalTransaction makeLocalTransaction(HStoreSite hstore_site) {
    long txnId = hstore_site.getTransactionIdManager(0).getNextUniqueTransactionId();
    long clientHandle = -1;
    
    CatalogContext catalogContext = hstore_site.getCatalogContext();
    int base_partition = CollectionUtil.random(hstore_site.getLocalPartitionIds());
    PartitionSet predict_touchedPartitions = catalogContext.getAllPartitionIds();
    boolean predict_readOnly = false;
    boolean predict_canAbort = true;
    Procedure catalog_proc = catalogContext.procedures.getIgnoreCase("@NoOp");
    ParameterSet params = new ParameterSet();
    RpcCallback<ClientResponseImpl> client_callback = null;
    
    LocalTransaction ts = new LocalTransaction(hstore_site);
    long batchId = -1;
    ts.init(batchId, txnId, EstTime.currentTimeMillis(), clientHandle, base_partition,
            predict_touchedPartitions, predict_readOnly, predict_canAbort,
            catalog_proc, params, client_callback);
    EstTimeUpdater.update(System.currentTimeMillis());
    return (ts);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:22,代码来源:MockHStoreSite.java

示例2: transactionMap

import com.google.protobuf.RpcCallback; //导入依赖的package包/类
/**
 * Tell all remote partitions to start the map phase for this txn
 * @param ts
 */
public void transactionMap(LocalTransaction ts, RpcCallback<TransactionMapResponse> callback) {
    ByteString paramBytes = null;
    try {
        ByteBuffer b = ByteBuffer.wrap(FastSerializer.serialize(ts.getProcedureParameters()));
        paramBytes = ByteString.copyFrom(b.array()); 
    } catch (Exception ex) {
        throw new RuntimeException("Unexpected error when serializing StoredProcedureInvocation", ex);
    }
    
    TransactionMapRequest request = TransactionMapRequest.newBuilder()
                                                 .setTransactionId(ts.getTransactionId())
                                                 .setClientHandle(ts.getClientHandle())
                                                 .setBasePartition(ts.getBasePartition())
                                                 .setProcedureId(ts.getProcedure().getId())
                                                 .setParams(paramBytes)
                                                 .build();
    
    PartitionSet partitions = ts.getPredictTouchedPartitions();
    if (debug.val){
        LOG.debug(String.format("Notifying partitions %s that %s is in Map Phase", partitions, ts));
        if (trace.val) LOG.trace("<HStoreCoordinator.TransactionMap> is executing to sendMessages to all partitions");
    }
    this.transactionMap_handler.sendMessages(ts, request, callback, partitions);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:29,代码来源:HStoreCoordinator.java

示例3: prepareBulkLoad

import com.google.protobuf.RpcCallback; //导入依赖的package包/类
@Override
public void prepareBulkLoad(RpcController controller,
                                               PrepareBulkLoadRequest request,
                                               RpcCallback<PrepareBulkLoadResponse> done){
  try {
    List<BulkLoadObserver> bulkLoadObservers = getBulkLoadObservers();

    if(bulkLoadObservers != null) {
      ObserverContext<RegionCoprocessorEnvironment> ctx =
                                         new ObserverContext<RegionCoprocessorEnvironment>();
      ctx.prepare(env);

      for(BulkLoadObserver bulkLoadObserver : bulkLoadObservers) {
        bulkLoadObserver.prePrepareBulkLoad(ctx, request);
      }
    }

    String bulkToken = createStagingDir(baseStagingDir,
        getActiveUser(), ProtobufUtil.toTableName(request.getTableName())).toString();
    done.run(PrepareBulkLoadResponse.newBuilder().setBulkToken(bulkToken).build());
  } catch (IOException e) {
    ResponseConverter.setControllerException(controller, e);
  }
  done.run(null);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:26,代码来源:SecureBulkLoadEndpoint.java

示例4: responseError

import com.google.protobuf.RpcCallback; //导入依赖的package包/类
/**
 * Convenience method for sending an error ClientResponse back to the client
 * @param client_handle
 * @param status
 * @param message
 * @param clientCallback
 * @param initiateTime
 */
public void responseError(long client_handle,
                          Status status,
                          String message,
                          RpcCallback<ClientResponseImpl> clientCallback,
                          long batchId,
                          long initiateTime) {
    ClientResponseImpl cresponse = new ClientResponseImpl(
                                        -1,
                                        client_handle,
                                        -1,
                                        status,
                                        HStoreConstants.EMPTY_RESULT,
                                        message);
    this.responseSend(cresponse, clientCallback, batchId, initiateTime, 0);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:24,代码来源:HStoreSite.java

示例5: remoteQueue

import com.google.protobuf.RpcCallback; //导入依赖的package包/类
@Override
public void remoteQueue(RpcController controller, TransactionFinishRequest request,
                        RpcCallback<TransactionFinishResponse> callback) {
    if (this.finishDispatcher != null && request.getStatus() == Status.ABORT_RESTART) {
        if (debug.val)
            LOG.debug(String.format("Queuing %s for txn #%d [status=%s]",
                      request.getClass().getSimpleName(), request.getTransactionId(), request.getStatus()));
        Object o[] = { controller, request, callback };
        this.finishDispatcher.queue(o);
    } else {
        if (debug.val)
            LOG.debug(String.format("Sending %s to remote handler for txn #%d [status=%s]",
                      request.getClass().getSimpleName(), request.getTransactionId(), request.getStatus()));
        this.remoteHandler(controller, request, callback);
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:17,代码来源:TransactionFinishHandler.java

示例6: transactionWork

import com.google.protobuf.RpcCallback; //导入依赖的package包/类
/**
 * Send the TransactionWorkRequest to the target remote site
 * @param builders
 * @param callback
 */
public void transactionWork(LocalTransaction ts, int site_id, TransactionWorkRequest request, RpcCallback<TransactionWorkResponse> callback) {
    if (debug.val)
        LOG.debug(String.format("%s - Sending TransactionWorkRequest to remote site %d " +
                  "[numFragments=%d, txnId=%d]",
                  ts, site_id, request.getFragmentsCount(), request.getTransactionId()));
    
    assert(request.getFragmentsCount() > 0) :
        String.format("No WorkFragments for Site %d in %s", site_id, ts);
    assert(site_id != this.local_site_id) :
        String.format("Trying to send %s for %s to local site %d",
                      request.getClass().getSimpleName(), ts, site_id); 
    assert(ts.getTransactionId().longValue() == request.getTransactionId()) :
        String.format("%s is for txn #%d but the %s has txn #%d",
                      ts.getClass().getSimpleName(), ts.getTransactionId(),
                      request.getClass().getSimpleName(), request.getTransactionId());
    
    this.channels[site_id].transactionWork(ts.getTransactionWorkController(site_id), request, callback);
}
 
开发者ID:s-store,项目名称:s-store,代码行数:24,代码来源:HStoreCoordinator.java

示例7: callMethod

import com.google.protobuf.RpcCallback; //导入依赖的package包/类
@Override
@InterfaceAudience.Private
public void callMethod(Descriptors.MethodDescriptor method,
                       RpcController controller,
                       Message request, Message responsePrototype,
                       RpcCallback<Message> callback) {
  Message response = null;
  try {
    response = callExecService(controller, method, request, responsePrototype);
  } catch (IOException ioe) {
    LOG.warn("Call failed on IOException", ioe);
    ResponseConverter.setControllerException(controller, ioe);
  }
  if (callback != null) {
    callback.run(response);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:18,代码来源:CoprocessorRpcChannel.java

示例8: startRpc

import com.google.protobuf.RpcCallback; //导入依赖的package包/类
public void startRpc(EventLoop eventLoop, Message.Builder builder, RpcCallback<Message> callback) {
    if (this.callback != null) {
        throw new IllegalStateException(
                "ProtoRpcController already in use by another RPC call; " +
                "wait for callback before reusing.");
    }
    if (callback == null) {
        throw new NullPointerException("callback cannot be null");
    }
    assert this.eventLoop == null;
    assert eventLoop != null;
    assert this.builder == null;
    assert builder != null;

    this.eventLoop = eventLoop;
    this.builder = builder;
    this.callback = callback;
    status = Protocol.Status.INVALID;
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:20,代码来源:ProtoRpcController.java

示例9: process

import com.google.protobuf.RpcCallback; //导入依赖的package包/类
/**
 * Pass a processor to region to process multiple rows atomically.
 * 
 * The RowProcessor implementations should be the inner classes of your
 * RowProcessorEndpoint. This way the RowProcessor can be class-loaded with
 * the Coprocessor endpoint together.
 *
 * See {@code TestRowProcessorEndpoint} for example.
 *
 * The request contains information for constructing processor 
 * (see {@link #constructRowProcessorFromRequest}. The processor object defines
 * the read-modify-write procedure.
 */
@Override
public void process(RpcController controller, ProcessRequest request,
    RpcCallback<ProcessResponse> done) {
  ProcessResponse resultProto = null;
  try {
    RowProcessor<S,T> processor = constructRowProcessorFromRequest(request);
    Region region = env.getRegion();
    long nonceGroup = request.hasNonceGroup() ? request.getNonceGroup() : HConstants.NO_NONCE;
    long nonce = request.hasNonce() ? request.getNonce() : HConstants.NO_NONCE;
    region.processRowsWithLocks(processor, nonceGroup, nonce);
    T result = processor.getResult();
    ProcessResponse.Builder b = ProcessResponse.newBuilder();
    b.setRowProcessorResult(result.toByteString());
    resultProto = b.build();
  } catch (Exception e) {
    ResponseConverter.setControllerException(controller, new IOException(e));
  }
  done.run(resultProto);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:33,代码来源:BaseRowProcessorEndpoint.java

示例10: transactionInit

import com.google.protobuf.RpcCallback; //导入依赖的package包/类
@Override
public void transactionInit(RpcController controller, TransactionInitRequest request, RpcCallback<TransactionInitResponse> callback) {
    try {
        transactionInit_handler.remoteQueue(controller, request, callback);
    } catch (Throwable ex) {
        shutdownCluster(ex);
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:9,代码来源:HStoreCoordinator.java

示例11: invocationQueue

import com.google.protobuf.RpcCallback; //导入依赖的package包/类
/**
 * This is legacy method needed for using Evan's VoltProcedureListener.
 */
@Override
@Deprecated
public void invocationQueue(ByteBuffer buffer, final RpcCallback<byte[]> clientCallback) {
    // XXX: This is a big hack. We should just deal with the ClientResponseImpl directly
    RpcCallback<ClientResponseImpl> wrapperCallback = new RpcCallback<ClientResponseImpl>() {
        @Override
        public void run(ClientResponseImpl parameter) {
            if (trace.val) LOG.trace("Serializing ClientResponse to byte array:\n" + parameter);
            
            FastSerializer fs = new FastSerializer();
            try {
                parameter.writeExternal(fs);
                clientCallback.run(fs.getBBContainer().b.array());
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            } finally {
                fs.clear();
            }
        }
    };
    
    if (this.preProcessorQueue != null) {
        this.preProcessorQueue.add(Pair.of(buffer, wrapperCallback));
    } else {
        this.invocationProcess(buffer, wrapperCallback);
    }
}
 
开发者ID:s-store,项目名称:s-store,代码行数:31,代码来源:HStoreSite.java

示例12: sendLocal

import com.google.protobuf.RpcCallback; //导入依赖的package包/类
@Override
public void sendLocal(Long txn_id, TransactionPrepareRequest request, PartitionSet partitions, RpcCallback<TransactionPrepareResponse> callback) {
    // We don't care whether we actually updated anybody locally, so we don't need to
    // pass in a set to get the partitions that were updated here.
    LocalTransaction ts = this.hstore_site.getTransaction(txn_id);
    assert(ts != null) : "Unexpected null transaction handle for txn #" + txn_id;
    this.hstore_site.transactionPrepare(ts, partitions, ts.getPrepareCallback());
}
 
开发者ID:s-store,项目名称:s-store,代码行数:9,代码来源:TransactionPrepareHandler.java

示例13: transactionPrepare

import com.google.protobuf.RpcCallback; //导入依赖的package包/类
@Override
public void transactionPrepare(RpcController controller, TransactionPrepareRequest request, RpcCallback<TransactionPrepareResponse> callback) {
    try {
        transactionPrepare_handler.remoteQueue(controller, request, callback);
    } catch (Throwable ex) {
        shutdownCluster(ex);
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:9,代码来源:HStoreCoordinator.java

示例14: timeSync

import com.google.protobuf.RpcCallback; //导入依赖的package包/类
@Override
public void timeSync(RpcController controller, TimeSyncRequest request, RpcCallback<TimeSyncResponse> done) {
    if (debug.val)
        LOG.debug(String.format("Received %s from HStoreSite %s",
                  request.getClass().getSimpleName(),
                  HStoreThreadManager.formatSiteName(request.getSenderSite())));
    TimeSyncResponse.Builder builder = TimeSyncResponse.newBuilder()
                                            .setT0R(System.currentTimeMillis())
                                            .setT0S(request.getT0S())
                                            .setSenderSite(local_site_id);
    ThreadUtil.sleep(10);
    done.run(builder.setT1S(System.currentTimeMillis()).build());
}
 
开发者ID:s-store,项目名称:s-store,代码行数:14,代码来源:HStoreCoordinator.java

示例15: notifyOnCancel

import com.google.protobuf.RpcCallback; //导入依赖的package包/类
@Override
public void notifyOnCancel(RpcCallback<Object> cancellationCb) {
  this.cancellationCb.set(cancellationCb);
  if (this.cancelled) {
    cancellationCb.run(null);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:8,代码来源:TimeLimitedRpcController.java


注:本文中的com.google.protobuf.RpcCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。