• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java EchoRequestProto类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testProtoBufRpc

import org.apache.hadoop.ipc.protobuf.TestProtos.EchoRequestProto; //导入依赖的package包/类
public static void testProtoBufRpc(TestRpcService client) throws Exception {  
  // Test ping method
  client.ping(null, newEmptyRequest());
  
  // Test echo method
  EchoRequestProto echoRequest = EchoRequestProto.newBuilder()
      .setMessage("hello").build();
  EchoResponseProto echoResponse = client.echo(null, echoRequest);
  Assert.assertEquals(echoResponse.getMessage(), "hello");
  
  // Test error method - error should be thrown as RemoteException
  try {
    client.error(null, newEmptyRequest());
    Assert.fail("Expected exception is not thrown");
  } catch (ServiceException e) {
    RemoteException re = (RemoteException)e.getCause();
    RpcServerException rse = (RpcServerException) re
        .unwrapRemoteException(RpcServerException.class);
    Assert.assertNotNull(rse);
    Assert.assertTrue(re.getErrorCode().equals(
        RpcErrorCodeProto.ERROR_RPC_SERVER));
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:24,代码来源:TestProtoBufRpc.java


示例2: testProtoBufRpc

import org.apache.hadoop.ipc.protobuf.TestProtos.EchoRequestProto; //导入依赖的package包/类
public static void testProtoBufRpc(TestRpcService client) throws Exception {  
  // Test ping method
  EmptyRequestProto emptyRequest = EmptyRequestProto.newBuilder().build();
  client.ping(null, emptyRequest);
  
  // Test echo method
  EchoRequestProto echoRequest = EchoRequestProto.newBuilder()
      .setMessage("hello").build();
  EchoResponseProto echoResponse = client.echo(null, echoRequest);
  Assert.assertEquals(echoResponse.getMessage(), "hello");
  
  // Test error method - error should be thrown as RemoteException
  try {
    client.error(null, emptyRequest);
    Assert.fail("Expected exception is not thrown");
  } catch (ServiceException e) {
    RemoteException re = (RemoteException)e.getCause();
    RpcServerException rse = (RpcServerException) re
        .unwrapRemoteException(RpcServerException.class);
    Assert.assertNotNull(rse);
    Assert.assertTrue(re.getErrorCode().equals(
        RpcErrorCodeProto.ERROR_RPC_SERVER));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestProtoBufRpc.java


示例3: testProtoBufRpc2

import org.apache.hadoop.ipc.protobuf.TestProtos.EchoRequestProto; //导入依赖的package包/类
@Test (timeout=5000)
public void testProtoBufRpc2() throws Exception {
  TestRpcService2 client = getClient2();
  
  // Test ping method
  EmptyRequestProto emptyRequest = EmptyRequestProto.newBuilder().build();
  client.ping2(null, emptyRequest);
  
  // Test echo method
  EchoRequestProto echoRequest = EchoRequestProto.newBuilder()
      .setMessage("hello").build();
  EchoResponseProto echoResponse = client.echo2(null, echoRequest);
  Assert.assertEquals(echoResponse.getMessage(), "hello");
  
  // Ensure RPC metrics are updated
  MetricsRecordBuilder rpcMetrics = getMetrics(server.getRpcMetrics().name());
  assertCounterGt("RpcQueueTimeNumOps", 0L, rpcMetrics);
  assertCounterGt("RpcProcessingTimeNumOps", 0L, rpcMetrics);
  
  MetricsRecordBuilder rpcDetailedMetrics = 
      getMetrics(server.getRpcDetailedMetrics().name());
  assertCounterGt("Echo2NumOps", 0L, rpcDetailedMetrics);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestProtoBufRpc.java


示例4: testExtraLongRpc

import org.apache.hadoop.ipc.protobuf.TestProtos.EchoRequestProto; //导入依赖的package包/类
@Test(timeout=6000)
public void testExtraLongRpc() throws Exception {
  TestRpcService2 client = getClient2();
  final String shortString = StringUtils.repeat("X", 4);
  EchoRequestProto echoRequest = EchoRequestProto.newBuilder()
      .setMessage(shortString).build();
  // short message goes through
  EchoResponseProto echoResponse = client.echo2(null, echoRequest);
  Assert.assertEquals(shortString, echoResponse.getMessage());
  
  final String longString = StringUtils.repeat("X", 4096);
  echoRequest = EchoRequestProto.newBuilder()
      .setMessage(longString).build();
  try {
    echoResponse = client.echo2(null, echoRequest);
    Assert.fail("expected extra-long RPC to fail");
  } catch (ServiceException se) {
    // expected
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestProtoBufRpc.java


示例5: testProtobufWrapper

import org.apache.hadoop.ipc.protobuf.TestProtos.EchoRequestProto; //导入依赖的package包/类
@Test
public void testProtobufWrapper() throws IOException {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  message1.writeDelimitedTo(baos);
  ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());

  Message actual = RpcWritable.wrap(EchoRequestProto.getDefaultInstance())
      .readFrom(bb);
  Assert.assertEquals(message1, actual);
  Assert.assertEquals(0, bb.remaining());
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:12,代码来源:TestRpcWritable.java


示例6: testBufferWrapper

import org.apache.hadoop.ipc.protobuf.TestProtos.EchoRequestProto; //导入依赖的package包/类
@Test
public void testBufferWrapper() throws IOException {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  DataOutputStream dos = new DataOutputStream(baos);
  message1.writeDelimitedTo(dos);
  message2.writeDelimitedTo(dos);
  writable.write(dos);

  ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());
  RpcWritable.Buffer buf = RpcWritable.Buffer.wrap(bb);
  Assert.assertEquals(baos.size(), bb.remaining());
  Assert.assertEquals(baos.size(), buf.remaining());

  Object actual = buf.getValue(EchoRequestProto.getDefaultInstance());
  Assert.assertEquals(message1, actual);
  Assert.assertTrue(bb.remaining() > 0);
  Assert.assertEquals(bb.remaining(), buf.remaining());

  actual = buf.getValue(EchoRequestProto.getDefaultInstance());
  Assert.assertEquals(message2, actual);
  Assert.assertTrue(bb.remaining() > 0);
  Assert.assertEquals(bb.remaining(), buf.remaining());

  actual = buf.newInstance(LongWritable.class, null);
  Assert.assertEquals(writable, actual);
  Assert.assertEquals(0, bb.remaining());
  Assert.assertEquals(0, buf.remaining());
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:29,代码来源:TestRpcWritable.java


示例7: testBufferWrapperNested

import org.apache.hadoop.ipc.protobuf.TestProtos.EchoRequestProto; //导入依赖的package包/类
@Test
public void testBufferWrapperNested() throws IOException {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  DataOutputStream dos = new DataOutputStream(baos);
  writable.write(dos);
  message1.writeDelimitedTo(dos);
  message2.writeDelimitedTo(dos);
  ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());
  RpcWritable.Buffer buf1 = RpcWritable.Buffer.wrap(bb);
  Assert.assertEquals(baos.size(), bb.remaining());
  Assert.assertEquals(baos.size(), buf1.remaining());

  Object actual = buf1.newInstance(LongWritable.class, null);
  Assert.assertEquals(writable, actual);
  int left = bb.remaining();
  Assert.assertTrue(left > 0);
  Assert.assertEquals(left, buf1.remaining());

  // original bb now appears empty, but rpc writable has a slice of the bb.
  RpcWritable.Buffer buf2 = buf1.newInstance(RpcWritable.Buffer.class, null);
  Assert.assertEquals(0, bb.remaining());
  Assert.assertEquals(0, buf1.remaining());
  Assert.assertEquals(left, buf2.remaining());

  actual = buf2.getValue(EchoRequestProto.getDefaultInstance());
  Assert.assertEquals(message1, actual);
  Assert.assertTrue(buf2.remaining() > 0);

  actual = buf2.getValue(EchoRequestProto.getDefaultInstance());
  Assert.assertEquals(message2, actual);
  Assert.assertEquals(0, buf2.remaining());
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:33,代码来源:TestRpcWritable.java


示例8: echo2

import org.apache.hadoop.ipc.protobuf.TestProtos.EchoRequestProto; //导入依赖的package包/类
@Override
public EchoResponseProto echo2(RpcController unused, EchoRequestProto request)
    throws ServiceException {
  return EchoResponseProto.newBuilder().setMessage(request.getMessage())
      .build();
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:7,代码来源:TestProtoBufRpc.java


示例9: echo

import org.apache.hadoop.ipc.protobuf.TestProtos.EchoRequestProto; //导入依赖的package包/类
@Override
public EchoResponseProto echo(RpcController unused, EchoRequestProto request)
    throws ServiceException {
  return EchoResponseProto.newBuilder().setMessage(request.getMessage())
      .build();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:7,代码来源:TestProtoBufRpc.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FlowerPot类代码示例发布时间:2022-05-22
下一篇:
Java Pooled类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap