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


Java RpcCallback.run方法代码示例

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


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

示例1: shutdown

import com.google.protobuf.RpcCallback; //导入方法依赖的package包/类
@Override
public void shutdown(RpcController controller, ShutdownRequest request, RpcCallback<ShutdownResponse> done) {
    String originName = HStoreThreadManager.formatSiteName(request.getSenderSite());
    if (debug.val) LOG.warn(String.format("Got %s from %s", request.getClass().getSimpleName(), originName));
    LOG.warn(String.format("Shutting down %s [status=%d]",
             hstore_site.getSiteName(), request.getExitStatus()));

    // Then send back the acknowledgment right away
    ShutdownResponse response = ShutdownResponse.newBuilder()
                                           .setSenderSite(HStoreCoordinator.this.local_site_id)
                                           .build();
    done.run(response);
    HStoreCoordinator.this.hstore_site.shutdown();
    if (debug.val) LOG.debug(String.format("ForwardDispatcher Queue Idle Time: %.2fms",
                     transactionRedirect_dispatcher.getIdleTime().getTotalThinkTimeMS()));
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:17,代码来源:HStoreCoordinator.java

示例2: 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

示例3: 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

示例4: initialize

import com.google.protobuf.RpcCallback; //导入方法依赖的package包/类
@Override
public void initialize(RpcController controller, InitializeRequest request, RpcCallback<InitializeResponse> done) {
    if (debug.val) LOG.debug(String.format("Received %s from HStoreSite %s [instanceId=%d]",
                     request.getClass().getSimpleName(),
                     HStoreThreadManager.formatSiteName(request.getSenderSite()),
                     request.getInstanceId()));
    
    hstore_site.setInstanceId(request.getInstanceId());
    InitializeResponse response = InitializeResponse.newBuilder()
                                        .setSenderSite(local_site_id)
                                        .setStatus(Status.OK)
                                        .build();
    done.run(response);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:15,代码来源:HStoreCoordinator.java

示例5: notifyOnFail

import com.google.protobuf.RpcCallback; //导入方法依赖的package包/类
/**
 * Notify a callback on error.
 * For use in async rpc clients
 *
 * @param failureCb the callback to call on error
 */
public void notifyOnFail(RpcCallback<IOException> failureCb) {
  this.failureCb.set(failureCb);
  if (this.exception != null) {
    failureCb.run(this.exception);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:13,代码来源:TimeLimitedRpcController.java

示例6: heartbeat

import com.google.protobuf.RpcCallback; //导入方法依赖的package包/类
@Override
public void heartbeat(RpcController controller, HeartbeatRequest request, RpcCallback<HeartbeatResponse> done) {
    if (debug.val)
        LOG.debug(String.format("Received %s from HStoreSite %s",
                  request.getClass().getSimpleName(),
                  HStoreThreadManager.formatSiteName(request.getSenderSite())));
    HeartbeatResponse.Builder builder = HeartbeatResponse.newBuilder()
                                            .setSenderSite(local_site_id)
                                            .setStatus(Status.OK);
    done.run(builder.build());            
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:12,代码来源:HStoreCoordinator.java

示例7: 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,项目名称:sstore-soft,代码行数:14,代码来源:HStoreCoordinator.java

示例8: getRowCount

import com.google.protobuf.RpcCallback; //导入方法依赖的package包/类
/**
 * Returns a count of the rows in the region where this coprocessor is loaded.
 */
@Override
public void getRowCount(RpcController controller, ExampleProtos.CountRequest request,
                        RpcCallback<ExampleProtos.CountResponse> done) {
  Scan scan = new Scan();
  scan.setFilter(new FirstKeyOnlyFilter());
  ExampleProtos.CountResponse response = null;
  InternalScanner scanner = null;
  try {
    scanner = env.getRegion().getScanner(scan);
    List<Cell> results = new ArrayList<Cell>();
    boolean hasMore = false;
    byte[] lastRow = null;
    long count = 0;
    do {
      hasMore = scanner.next(results);
      for (Cell kv : results) {
        byte[] currentRow = CellUtil.cloneRow(kv);
        if (lastRow == null || !Bytes.equals(lastRow, currentRow)) {
          lastRow = currentRow;
          count++;
        }
      }
      results.clear();
    } while (hasMore);

    response = ExampleProtos.CountResponse.newBuilder()
        .setCount(count).build();
  } catch (IOException ioe) {
    ResponseConverter.setControllerException(controller, ioe);
  } finally {
    if (scanner != null) {
      try {
        scanner.close();
      } catch (IOException ignored) {}
    }
  }
  done.run(response);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:42,代码来源:RowCountEndpoint.java

示例9: 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

示例10: requestVote

import com.google.protobuf.RpcCallback; //导入方法依赖的package包/类
@Override
public void requestVote(@Nonnull RpcController controller, @Nonnull RequestVote request, @Nonnull RpcCallback<RequestVoteResponse> done) {
    try {
        done.run(ctx.requestVote(request));
    } catch (Exception e) {
        LOGGER.debug("Exception caught servicing RequestVote", e);
        controller.setFailed(nullToEmpty(e.getMessage()));
        done.run(null);
    }
}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:11,代码来源:RaftServiceEndpoint.java

示例11: getAuthenticationToken

import com.google.protobuf.RpcCallback; //导入方法依赖的package包/类
@Override
public void getAuthenticationToken(RpcController controller,
                                   AuthenticationProtos.GetAuthenticationTokenRequest request,
                                   RpcCallback<AuthenticationProtos.GetAuthenticationTokenResponse> done) {
  AuthenticationProtos.GetAuthenticationTokenResponse.Builder response =
      AuthenticationProtos.GetAuthenticationTokenResponse.newBuilder();

  try {
    if (secretManager == null) {
      throw new IOException(
          "No secret manager configured for token authentication");
    }

    User currentUser = RpcServer.getRequestUser();
    UserGroupInformation ugi = null;
    if (currentUser != null) {
      ugi = currentUser.getUGI();
    }
    if (currentUser == null) {
      throw new AccessDeniedException("No authenticated user for request!");
    } else if (!isAllowedDelegationTokenOp(ugi)) {
      LOG.warn("Token generation denied for user="+currentUser.getName()
          +", authMethod="+ugi.getAuthenticationMethod());
      throw new AccessDeniedException(
          "Token generation only allowed for Kerberos authenticated clients");
    }

    Token<AuthenticationTokenIdentifier> token =
        secretManager.generateToken(currentUser.getName());
    response.setToken(ProtobufUtil.toToken(token)).build();
  } catch (IOException ioe) {
    ResponseConverter.setControllerException(controller, ioe);
  }
  done.run(response.build());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:36,代码来源:TokenProvider.java

示例12: bidding

import com.google.protobuf.RpcCallback; //导入方法依赖的package包/类
@Override
public void bidding(RpcController controller, BiddingReq request, RpcCallback<BiddingRsp> done) {
	try {
		done.run(bidding(controller, request));
	} catch (ServiceException ex) {
	}
}
 
开发者ID:javagossip,项目名称:opendsp,代码行数:8,代码来源:BiddingService.java

示例13: count

import com.google.protobuf.RpcCallback; //导入方法依赖的package包/类
@Override
public void count(RpcController controller, CountRequest request,
    RpcCallback<CountResponse> callback) {
  callback.run(CountResponse.newBuilder().build());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:6,代码来源:TestAccessController.java

示例14: getSum

import com.google.protobuf.RpcCallback; //导入方法依赖的package包/类
/**
 * Gives the sum for a given combination of column qualifier and column
 * family, in the given row range as defined in the Scan object. In its
 * current implementation, it takes one column family and one column qualifier
 * (if provided). In case of null column qualifier, sum for the entire column
 * family will be returned.
 */
@Override
public void getSum(RpcController controller, AggregateRequest request,
    RpcCallback<AggregateResponse> done) {
  AggregateResponse response = null;
  InternalScanner scanner = null;
  long sum = 0l;
  try {
    ColumnInterpreter<T, S, P, Q, R> ci = constructColumnInterpreterFromRequest(request);
    S sumVal = null;
    T temp;
    Scan scan = ProtobufUtil.toScan(request.getScan());
    scanner = env.getRegion().getScanner(scan);
    byte[] colFamily = scan.getFamilies()[0];
    NavigableSet<byte[]> qualifiers = scan.getFamilyMap().get(colFamily);
    byte[] qualifier = null;
    if (qualifiers != null && !qualifiers.isEmpty()) {
      qualifier = qualifiers.pollFirst();
    }
    List<Cell> results = new ArrayList<Cell>();
    boolean hasMoreRows = false;
    do {
      hasMoreRows = scanner.next(results);
      int listSize = results.size();
      for (int i = 0; i < listSize; i++) {
        temp = ci.getValue(colFamily, qualifier, results.get(i));
        if (temp != null)
          sumVal = ci.add(sumVal, ci.castToReturnType(temp));
      }
      results.clear();
    } while (hasMoreRows);
    if (sumVal != null) {
      response = AggregateResponse.newBuilder().addFirstPart( 
        ci.getProtoForPromotedType(sumVal).toByteString()).build();
    }
  } catch (IOException e) {
    ResponseConverter.setControllerException(controller, e);
  } finally {
    if (scanner != null) {
      try {
        scanner.close();
      } catch (IOException ignored) {}
    }
  }
  log.debug("Sum from this region is "
      + env.getRegion().getRegionInfo().getRegionNameAsString() + ": " + sum);
  done.run(response);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:55,代码来源:AggregateImplementation.java

示例15: get

import com.google.protobuf.RpcCallback; //导入方法依赖的package包/类
@Override
public void get(RpcController controller, GetRequest request,
        RpcCallback<Value> done) {
    System.out.println("get = " + counter);
    done.run(Value.newBuilder().setValue(counter).build());
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:7,代码来源:CounterExample.java


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