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


Java RpcChannel类代码示例

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


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

示例1: coprocessorService

import com.google.protobuf.RpcChannel; //导入依赖的package包/类
private <S, R> CompletableFuture<R> coprocessorService(Function<RpcChannel, S> stubMaker,
    ServiceCaller<S, R> callable, RegionInfo region, byte[] row) {
  RegionCoprocessorRpcChannelImpl channel = new RegionCoprocessorRpcChannelImpl(conn, tableName,
      region, row, rpcTimeoutNs, operationTimeoutNs);
  S stub = stubMaker.apply(channel);
  CompletableFuture<R> future = new CompletableFuture<>();
  ClientCoprocessorRpcController controller = new ClientCoprocessorRpcController();
  callable.call(stub, controller, resp -> {
    if (controller.failed()) {
      future.completeExceptionally(controller.getFailed());
    } else {
      future.complete(resp);
    }
  });
  return future;
}
 
开发者ID:apache,项目名称:hbase,代码行数:17,代码来源:RawAsyncTableImpl.java

示例2: coprocessorService

import com.google.protobuf.RpcChannel; //导入依赖的package包/类
@Override
public <S, R> CompletableFuture<R> coprocessorService(Function<RpcChannel, S> stubMaker,
    ServiceCaller<S, R> callable) {
  MasterCoprocessorRpcChannelImpl channel =
      new MasterCoprocessorRpcChannelImpl(this.<Message> newMasterCaller());
  S stub = stubMaker.apply(channel);
  CompletableFuture<R> future = new CompletableFuture<>();
  ClientCoprocessorRpcController controller = new ClientCoprocessorRpcController();
  callable.call(stub, controller, resp -> {
    if (controller.failed()) {
      future.completeExceptionally(controller.getFailed());
    } else {
      future.complete(resp);
    }
  });
  return future;
}
 
开发者ID:apache,项目名称:hbase,代码行数:18,代码来源:RawAsyncHBaseAdmin.java

示例3: testAsyncConnectionSetup

import com.google.protobuf.RpcChannel; //导入依赖的package包/类
@Test
public void testAsyncConnectionSetup() throws Exception {
  TestRpcServer rpcServer = new TestRpcServer();
  AsyncRpcClient client = createRpcClient(CONF);
  try {
    rpcServer.start();
    InetSocketAddress address = rpcServer.getListenerAddress();
    if (address == null) {
      throw new IOException("Listener channel is closed");
    }
    MethodDescriptor md = SERVICE.getDescriptorForType().findMethodByName("echo");
    EchoRequestProto param = EchoRequestProto.newBuilder().setMessage("hello").build();

    RpcChannel channel =
        client.createRpcChannel(ServerName.valueOf(address.getHostName(), address.getPort(),
          System.currentTimeMillis()), User.getCurrent(), 0);

    final AtomicBoolean done = new AtomicBoolean(false);

    channel.callMethod(md, new PayloadCarryingRpcController(), param, md.getOutputType()
        .toProto(), new RpcCallback<Message>() {
      @Override
      public void run(Message parameter) {
        done.set(true);
      }
    });

    TEST_UTIL.waitFor(1000, new Waiter.Predicate<Exception>() {
      @Override
      public boolean evaluate() throws Exception {
        return done.get();
      }
    });
  } finally {
    client.close();
    rpcServer.stop();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:39,代码来源:TestAsyncIPC.java

示例4: doTest

import com.google.protobuf.RpcChannel; //导入依赖的package包/类
private void doTest(RpcServer rpcServer) throws InterruptedException,
    ServiceException, IOException {
  BlockingRpcChannel blockingChannel = RpcChannels
      .newBlockingRpcChannel(clientConnectionFactory);
  RpcChannel channel = RpcChannels.newRpcChannel(clientConnectionFactory,
      threadPool);
  BlockingInterface blockingStub = TestService
      .newBlockingStub(blockingChannel);
  TestService stub = TestService.newStub(channel);

  try {
    rpcServer.startServer();
    Thread.sleep(500);

    doRpc(stub);
    doBlockingRpc(blockingStub);
    doBlockingRpc(blockingStub);
    doRpc(stub);
  } finally {
    Thread.sleep(500);
    System.out.println("Closing Client");
    if (clientConnectionFactory instanceof Closeable) {
      ((PersistentRpcConnectionFactory) clientConnectionFactory).close();
    }
    Thread.sleep(100);
    System.out.println("Closing Server");
    rpcServer.shutDown();
  }
}
 
开发者ID:sdeo,项目名称:protobuf-socket-rpc,代码行数:30,代码来源:IntegrationTest.java

示例5: onLocateComplete

import com.google.protobuf.RpcChannel; //导入依赖的package包/类
private <S, R> void onLocateComplete(Function<RpcChannel, S> stubMaker,
    ServiceCaller<S, R> callable, CoprocessorCallback<R> callback,
    List<HRegionLocation> locs, byte[] endKey, boolean endKeyInclusive,
    AtomicBoolean locateFinished, AtomicInteger unfinishedRequest, HRegionLocation loc,
    Throwable error) {
  if (error != null) {
    callback.onError(error);
    return;
  }
  unfinishedRequest.incrementAndGet();
  RegionInfo region = loc.getRegion();
  if (locateFinished(region, endKey, endKeyInclusive)) {
    locateFinished.set(true);
  } else {
    conn.getLocator()
        .getRegionLocation(tableName, region.getEndKey(), RegionLocateType.CURRENT,
          operationTimeoutNs)
        .whenComplete((l, e) -> onLocateComplete(stubMaker, callable, callback, locs, endKey,
          endKeyInclusive, locateFinished, unfinishedRequest, l, e));
  }
  coprocessorService(stubMaker, callable, region, region.getStartKey()).whenComplete((r, e) -> {
    if (e != null) {
      callback.onRegionError(region, e);
    } else {
      callback.onRegionComplete(region, r);
    }
    if (unfinishedRequest.decrementAndGet() == 0 && locateFinished.get()) {
      callback.onComplete();
    }
  });
}
 
开发者ID:apache,项目名称:hbase,代码行数:32,代码来源:RawAsyncTableImpl.java

示例6: connectExportedProtobufAddress

import com.google.protobuf.RpcChannel; //导入依赖的package包/类
private AddressBookProtos.AddressBookService connectExportedProtobufAddress(ExportDeclaration declaration) throws EndpointException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, BinderException {
    ProtobufferExportDeclarationWrapper pojo = ProtobufferExportDeclarationWrapper.create(declaration);
    Bus cxfbus = BusFactory.getThreadDefaultBus();
    BindingFactoryManager mgr = cxfbus.getExtension(BindingFactoryManager.class);
    mgr.registerBindingFactory(ProtobufBindingFactory.PROTOBUF_BINDING_ID, new ProtobufBindingFactory(cxfbus));
    Class<?> bufferService = AddressBookProtos.AddressBookService.class;
    Class<?> bufferMessage = AddressBookProtos.AddressBookServiceMessage.class;
    Class<? extends Message> generic = bufferMessage.asSubclass(Message.class);
    RpcChannel channel = new SimpleRpcChannel(pojo.getAddress(), generic);
    Method method = bufferService.getMethod("newStub", RpcChannel.class);
    Object service = method.invoke(bufferService, channel);
    AddressBookProtos.AddressBookService addressBook = (AddressBookProtos.AddressBookService) service;
    return addressBook;
}
 
开发者ID:ow2-chameleon,项目名称:fuchsia,代码行数:15,代码来源:ProtobufferExporterTest.java

示例7: testRTEDuringAsyncConnectionSetup

import com.google.protobuf.RpcChannel; //导入依赖的package包/类
@Test
public void testRTEDuringAsyncConnectionSetup() throws Exception {
  TestRpcServer rpcServer = new TestRpcServer();
  AsyncRpcClient client = createRpcClientRTEDuringConnectionSetup(CONF);
  try {
    rpcServer.start();
    InetSocketAddress address = rpcServer.getListenerAddress();
    if (address == null) {
      throw new IOException("Listener channel is closed");
    }
    MethodDescriptor md = SERVICE.getDescriptorForType().findMethodByName("echo");
    EchoRequestProto param = EchoRequestProto.newBuilder().setMessage("hello").build();

    RpcChannel channel =
        client.createRpcChannel(ServerName.valueOf(address.getHostName(), address.getPort(),
          System.currentTimeMillis()), User.getCurrent(), 0);

    final AtomicBoolean done = new AtomicBoolean(false);

    PayloadCarryingRpcController controller = new PayloadCarryingRpcController();
    controller.notifyOnFail(new RpcCallback<IOException>() {
      @Override
      public void run(IOException e) {
        done.set(true);
        LOG.info("Caught expected exception: " + e.toString());
        assertTrue(StringUtils.stringifyException(e).contains("Injected fault"));
      }
    });

    channel.callMethod(md, controller, param, md.getOutputType().toProto(),
      new RpcCallback<Message>() {
        @Override
        public void run(Message parameter) {
          done.set(true);
          fail("Expected an exception to have been thrown!");
        }
      });

    TEST_UTIL.waitFor(1000, new Waiter.Predicate<Exception>() {
      @Override
      public boolean evaluate() throws Exception {
        return done.get();
      }
    });
  } finally {
    client.close();
    rpcServer.stop();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:50,代码来源:TestAsyncIPC.java

示例8: newServiceStub

import com.google.protobuf.RpcChannel; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <T extends Service> T newServiceStub(Class<T> service, RpcChannel channel)
    throws Exception {
  return (T)Methods.call(service, null, "newStub",
      new Class[]{ RpcChannel.class }, new Object[]{ channel });
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:7,代码来源:ProtobufUtil.java

示例9: CoprocessorServiceBuilderImpl

import com.google.protobuf.RpcChannel; //导入依赖的package包/类
public CoprocessorServiceBuilderImpl(Function<RpcChannel, S> stubMaker,
    ServiceCaller<S, R> callable, CoprocessorCallback<R> callback) {
  this.stubMaker = Preconditions.checkNotNull(stubMaker, "stubMaker is null");
  this.callable = Preconditions.checkNotNull(callable, "callable is null");
  this.callback = Preconditions.checkNotNull(callback, "callback is null");
}
 
开发者ID:apache,项目名称:hbase,代码行数:7,代码来源:RawAsyncTableImpl.java

示例10: coprocessorService

import com.google.protobuf.RpcChannel; //导入依赖的package包/类
@Override
public <S, R> CompletableFuture<R> coprocessorService(Function<RpcChannel, S> stubMaker,
    ServiceCaller<S, R> callable) {
  return wrap(rawAdmin.coprocessorService(stubMaker, callable));
}
 
开发者ID:apache,项目名称:hbase,代码行数:6,代码来源:AsyncHBaseAdmin.java

示例11: coprocessorService

import com.google.protobuf.RpcChannel; //导入依赖的package包/类
@Override
public <S, R> CompletableFuture<R> coprocessorService(Function<RpcChannel, S> stubMaker,
    ServiceCaller<S, R> callable, byte[] row) {
  return wrap(rawTable.coprocessorService(stubMaker, callable, row));
}
 
开发者ID:apache,项目名称:hbase,代码行数:6,代码来源:AsyncTableImpl.java

示例12: createRpcChannel

import com.google.protobuf.RpcChannel; //导入依赖的package包/类
/**
 * Creates a "channel" that can be used by a protobuf service.  Useful setting up
 * protobuf stubs.
 *
 * @param sn server name describing location of server
 * @param user which is to use the connection
 * @param rpcTimeout default rpc operation timeout
 *
 * @return A rpc channel that goes via this rpc client instance.
 */
public RpcChannel createRpcChannel(final ServerName sn, final User user, int rpcTimeout) {
  return new RpcChannelImplementation(this, sn, user, rpcTimeout);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:14,代码来源:AsyncRpcClient.java

示例13: newRpcChannel

import com.google.protobuf.RpcChannel; //导入依赖的package包/类
/**
 * Create a {@link RpcChannel} that uses the given
 * {@link RpcConnectionFactory} to connect to the RPC server and the given
 * {@link Executor} to listen for the RPC response after sending the request.
 * RPCs made using this {@link RpcChannel} will not block the thread calling
 * the RPC method. Use {@link #newBlockingRpcChannel(RpcConnectionFactory)} if
 * you want the RPC method to block.
 * <p>
 * This channel doesn't call the callback if the server-side implementation
 * did not call the callback. If any error occurs, it will call the callback
 * with null and update the controller with the error.
 */
public static RpcChannel newRpcChannel(
    RpcConnectionFactory connectionFactory, Executor executor) {
  return new RpcChannelImpl(connectionFactory, executor);
}
 
开发者ID:sdeo,项目名称:protobuf-socket-rpc,代码行数:17,代码来源:RpcChannels.java

示例14: coprocessorService

import com.google.protobuf.RpcChannel; //导入依赖的package包/类
/**
 * Execute the given coprocessor call on the region which contains the given {@code row}.
 * <p>
 * The {@code stubMaker} is just a delegation to the {@code newStub} call. Usually it is only a
 * one line lambda expression, like:
 *
 * <pre>
 * <code>
 * channel -> xxxService.newStub(channel)
 * </code>
 * </pre>
 *
 * @param stubMaker a delegation to the actual {@code newStub} call.
 * @param callable a delegation to the actual protobuf rpc call. See the comment of
 *          {@link ServiceCaller} for more details.
 * @param row The row key used to identify the remote region location
 * @param <S> the type of the asynchronous stub
 * @param <R> the type of the return value
 * @return the return value of the protobuf rpc call, wrapped by a {@link CompletableFuture}.
 * @see ServiceCaller
 */
<S, R> CompletableFuture<R> coprocessorService(Function<RpcChannel, S> stubMaker,
    ServiceCaller<S, R> callable, byte[] row);
 
开发者ID:apache,项目名称:hbase,代码行数:24,代码来源:AsyncTable.java

示例15: coprocessorService

import com.google.protobuf.RpcChannel; //导入依赖的package包/类
/**
 * Execute the given coprocessor call on the master.
 * <p>
 * The {@code stubMaker} is just a delegation to the {@code newStub} call. Usually it is only a
 * one line lambda expression, like:
 *
 * <pre>
 * <code>
 * channel -> xxxService.newStub(channel)
 * </code>
 * </pre>
 * @param stubMaker a delegation to the actual {@code newStub} call.
 * @param callable a delegation to the actual protobuf rpc call. See the comment of
 *          {@link ServiceCaller} for more details.
 * @param <S> the type of the asynchronous stub
 * @param <R> the type of the return value
 * @return the return value of the protobuf rpc call, wrapped by a {@link CompletableFuture}.
 * @see ServiceCaller
 */
<S, R> CompletableFuture<R> coprocessorService(Function<RpcChannel, S> stubMaker,
    ServiceCaller<S, R> callable);
 
开发者ID:apache,项目名称:hbase,代码行数:22,代码来源:AsyncAdmin.java


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