本文整理汇总了Java中io.grpc.ClientCall.cancel方法的典型用法代码示例。如果您正苦于以下问题:Java ClientCall.cancel方法的具体用法?Java ClientCall.cancel怎么用?Java ClientCall.cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.grpc.ClientCall
的用法示例。
在下文中一共展示了ClientCall.cancel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyServiceUri
import io.grpc.ClientCall; //导入方法依赖的package包/类
@Test
public void verifyServiceUri() throws IOException {
ClientCall<String, Integer> interceptedCall;
doReturn("example.com:443").when(channel).authority();
interceptedCall = interceptor.interceptCall(descriptor, CallOptions.DEFAULT, channel);
interceptedCall.start(listener, new Metadata());
verify(credentials).getRequestMetadata(URI.create("https://example.com/a.service"));
interceptedCall.cancel("Cancel for test", null);
doReturn("example.com:123").when(channel).authority();
interceptedCall = interceptor.interceptCall(descriptor, CallOptions.DEFAULT, channel);
interceptedCall.start(listener, new Metadata());
verify(credentials).getRequestMetadata(URI.create("https://example.com:123/a.service"));
interceptedCall.cancel("Cancel for test", null);
}
示例2: channelStat_callEndFail_oob
import io.grpc.ClientCall; //导入方法依赖的package包/类
@Test
public void channelStat_callEndFail_oob() throws Exception {
createChannel(new FakeNameResolverFactory(true), NO_INTERCEPTOR);
OobChannel oob1 = (OobChannel) helper.createOobChannel(addressGroup, "oob1authority");
ClientCall<String, Integer> call = oob1.newCall(method, CallOptions.DEFAULT);
call.start(mockCallListener, new Metadata());
call.cancel("msg", null);
assertEquals(0, getStats(channel).callsSucceeded);
assertEquals(0, getStats(channel).callsFailed);
oobExecutor.runDueTasks();
// only oob channel stats updated
verify(mockCallListener).onClose(any(Status.class), any(Metadata.class));
assertEquals(0, getStats(oob1).callsSucceeded);
assertEquals(1, getStats(oob1).callsFailed);
assertEquals(0, getStats(channel).callsSucceeded);
assertEquals(0, getStats(channel).callsFailed);
}
示例3: delayedTransportHoldsOffIdleness
import io.grpc.ClientCall; //导入方法依赖的package包/类
@Test
public void delayedTransportHoldsOffIdleness() throws Exception {
ClientCall<String, Integer> call = channel.newCall(method, CallOptions.DEFAULT);
call.start(mockCallListener, new Metadata());
assertTrue(channel.inUseStateAggregator.isInUse());
// As long as the delayed transport is in-use (by the pending RPC), the channel won't go idle.
timer.forwardTime(IDLE_TIMEOUT_SECONDS * 2, TimeUnit.SECONDS);
assertTrue(channel.inUseStateAggregator.isInUse());
// Cancelling the only RPC will reset the in-use state.
assertEquals(0, executor.numPendingTasks());
call.cancel("In test", null);
assertEquals(1, executor.runDueTasks());
assertFalse(channel.inUseStateAggregator.isInUse());
// And allow the channel to go idle.
timer.forwardTime(IDLE_TIMEOUT_SECONDS - 1, TimeUnit.SECONDS);
verify(mockLoadBalancer, never()).shutdown();
timer.forwardTime(1, TimeUnit.SECONDS);
verify(mockLoadBalancer).shutdown();
}
示例4: channelStat_callEndFail
import io.grpc.ClientCall; //导入方法依赖的package包/类
@Test
public void channelStat_callEndFail() throws Exception {
createChannel(new FakeNameResolverFactory(true), NO_INTERCEPTOR);
ClientCall<String, Integer> call = channel.newCall(method, CallOptions.DEFAULT);
call.start(mockCallListener, new Metadata());
call.cancel("msg", null);
assertEquals(0, getStats(channel).callsSucceeded);
assertEquals(0, getStats(channel).callsFailed);
executor.runDueTasks();
verify(mockCallListener).onClose(any(Status.class), any(Metadata.class));
assertEquals(0, getStats(channel).callsSucceeded);
assertEquals(1, getStats(channel).callsFailed);
}
示例5: newCallRefreshesIdlenessTimer
import io.grpc.ClientCall; //导入方法依赖的package包/类
@Test
public void newCallRefreshesIdlenessTimer() throws Exception {
// First call to exit the initial idleness, then immediately cancel the call.
ClientCall<String, Integer> call = channel.newCall(method, CallOptions.DEFAULT);
call.start(mockCallListener, new Metadata());
call.cancel("For testing", null);
// Verify that we have exited the idle mode
verify(mockLoadBalancerFactory).newLoadBalancer(any(Helper.class));
assertFalse(channel.inUseStateAggregator.isInUse());
// Move closer to idleness, but not yet.
timer.forwardTime(IDLE_TIMEOUT_SECONDS - 1, TimeUnit.SECONDS);
verify(mockLoadBalancer, never()).shutdown();
assertFalse(channel.inUseStateAggregator.isInUse());
// A new call would refresh the timer
call = channel.newCall(method, CallOptions.DEFAULT);
call.start(mockCallListener, new Metadata());
call.cancel("For testing", null);
assertFalse(channel.inUseStateAggregator.isInUse());
// ... so that passing the same length of time will not trigger idle mode
timer.forwardTime(IDLE_TIMEOUT_SECONDS - 1, TimeUnit.SECONDS);
verify(mockLoadBalancer, never()).shutdown();
assertFalse(channel.inUseStateAggregator.isInUse());
// ... until the time since last call has reached the timeout
timer.forwardTime(1, TimeUnit.SECONDS);
verify(mockLoadBalancer).shutdown();
assertFalse(channel.inUseStateAggregator.isInUse());
// Drain the app executor, which runs the call listeners
verify(mockCallListener, never()).onClose(any(Status.class), any(Metadata.class));
assertEquals(2, executor.runDueTasks());
verify(mockCallListener, times(2)).onClose(any(Status.class), any(Metadata.class));
}
示例6: cancel
import io.grpc.ClientCall; //导入方法依赖的package包/类
private void cancel(final ClientCall<MSG_SubscriptionRequest, MSG_Notification> call) {
call.cancel("Client is no longer interested", null);
}