本文整理汇总了Java中org.apache.hadoop.ipc.protobuf.TestProtos.EmptyRequestProto类的典型用法代码示例。如果您正苦于以下问题:Java EmptyRequestProto类的具体用法?Java EmptyRequestProto怎么用?Java EmptyRequestProto使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EmptyRequestProto类属于org.apache.hadoop.ipc.protobuf.TestProtos包,在下文中一共展示了EmptyRequestProto类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testProtoBufRpc
import org.apache.hadoop.ipc.protobuf.TestProtos.EmptyRequestProto; //导入依赖的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
示例2: testProtoBufRpc2
import org.apache.hadoop.ipc.protobuf.TestProtos.EmptyRequestProto; //导入依赖的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
示例3: testProtoBufRandomException
import org.apache.hadoop.ipc.protobuf.TestProtos.EmptyRequestProto; //导入依赖的package包/类
@Test (timeout=5000)
public void testProtoBufRandomException() throws Exception {
TestRpcService client = getClient();
EmptyRequestProto emptyRequest = EmptyRequestProto.newBuilder().build();
try {
client.error2(null, emptyRequest);
} catch (ServiceException se) {
Assert.assertTrue(se.getCause() instanceof RemoteException);
RemoteException re = (RemoteException) se.getCause();
Assert.assertTrue(re.getClassName().equals(
URISyntaxException.class.getName()));
Assert.assertTrue(re.getMessage().contains("testException"));
Assert.assertTrue(
re.getErrorCode().equals(RpcErrorCodeProto.ERROR_APPLICATION));
}
}
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestProtoBufRpc.java
示例4: ping
import org.apache.hadoop.ipc.protobuf.TestProtos.EmptyRequestProto; //导入依赖的package包/类
@Override
public EmptyResponseProto ping(RpcController unused,
EmptyRequestProto request) throws ServiceException {
// Ensure clientId is received
byte[] clientId = Server.getClientId();
Assert.assertNotNull(Server.getClientId());
Assert.assertEquals(16, clientId.length);
return EmptyResponseProto.newBuilder().build();
}
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:10,代码来源:TestProtoBufRPCCompatibility.java
示例5: echo
import org.apache.hadoop.ipc.protobuf.TestProtos.EmptyRequestProto; //导入依赖的package包/类
@Override
public EmptyResponseProto echo(RpcController unused,
EmptyRequestProto request) throws ServiceException {
// Ensure clientId is received
byte[] clientId = Server.getClientId();
Assert.assertNotNull(Server.getClientId());
Assert.assertEquals(16, clientId.length);
return EmptyResponseProto.newBuilder().build();
}
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:10,代码来源:TestProtoBufRPCCompatibility.java
示例6: testLogSlowRPC
import org.apache.hadoop.ipc.protobuf.TestProtos.EmptyRequestProto; //导入依赖的package包/类
@Test(timeout = 12000)
public void testLogSlowRPC() throws IOException, ServiceException {
TestRpcService2 client = getClient2();
// make 10 K fast calls
for (int x = 0; x < 10000; x++) {
try {
EmptyRequestProto emptyRequest = EmptyRequestProto.newBuilder().build();
client.ping2(null, emptyRequest);
} catch (Exception ex) {
throw ex;
}
}
// Ensure RPC metrics are updated
RpcMetrics rpcMetrics = server.getRpcMetrics();
assertTrue(rpcMetrics.getProcessingSampleCount() > 999L);
long before = rpcMetrics.getRpcSlowCalls();
// make a really slow call. Sleep sleeps for 1000ms
TestProtos.SleepRequestProto sleepRequest =
TestProtos.SleepRequestProto.newBuilder()
.setMilliSeconds(SLEEP_DURATION * 3).build();
TestProtos.SleepResponseProto Response = client.sleep(null, sleepRequest);
long after = rpcMetrics.getRpcSlowCalls();
// Ensure slow call is logged.
Assert.assertEquals(before + 1L, after);
}
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:29,代码来源:TestProtoBufRpc.java
示例7: testEnsureNoLogIfDisabled
import org.apache.hadoop.ipc.protobuf.TestProtos.EmptyRequestProto; //导入依赖的package包/类
@Test(timeout = 12000)
public void testEnsureNoLogIfDisabled() throws IOException, ServiceException {
// disable slow RPC logging
server.setLogSlowRPC(false);
TestRpcService2 client = getClient2();
// make 10 K fast calls
for (int x = 0; x < 10000; x++) {
EmptyRequestProto emptyRequest = EmptyRequestProto.newBuilder().build();
client.ping2(null, emptyRequest);
}
// Ensure RPC metrics are updated
RpcMetrics rpcMetrics = server.getRpcMetrics();
assertTrue(rpcMetrics.getProcessingSampleCount() > 999L);
long before = rpcMetrics.getRpcSlowCalls();
// make a really slow call. Sleep sleeps for 1000ms
TestProtos.SleepRequestProto sleepRequest =
TestProtos.SleepRequestProto.newBuilder()
.setMilliSeconds(SLEEP_DURATION).build();
TestProtos.SleepResponseProto Response = client.sleep(null, sleepRequest);
long after = rpcMetrics.getRpcSlowCalls();
// make sure we never called into Log slow RPC routine.
assertEquals(before, after);
}
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:29,代码来源:TestProtoBufRpc.java
注:本文中的org.apache.hadoop.ipc.protobuf.TestProtos.EmptyRequestProto类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论