com.google.protobuf.Empty Java Examples
The following examples show how to use
com.google.protobuf.Empty.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractSimpleServerClientTest.java From grpc-spring-boot-starter with MIT License | 6 votes |
/** * Test failing call. */ @Test @DirtiesContext public void testFailingCall() { log.info("--- Starting tests with failing call ---"); assertThrowsStatus(UNIMPLEMENTED, () -> TestServiceGrpc.newBlockingStub(this.channel).unimplemented(Empty.getDefaultInstance())); final StreamRecorder<SomeType> streamRecorder = StreamRecorder.create(); this.testServiceStub.unimplemented(Empty.getDefaultInstance(), streamRecorder); assertFutureThrowsStatus(UNIMPLEMENTED, streamRecorder.firstValue(), 5, TimeUnit.SECONDS); assertThrowsStatus(UNIMPLEMENTED, () -> this.testServiceBlockingStub.unimplemented(Empty.getDefaultInstance())); assertFutureThrowsStatus(UNIMPLEMENTED, this.testServiceFutureStub.unimplemented(Empty.getDefaultInstance()), 5, TimeUnit.SECONDS); log.info("--- Test completed ---"); }
Example #2
Source File: CloudPubSubSourceTaskTest.java From pubsub with Apache License 2.0 | 6 votes |
/** * Tests that when ackMessages() succeeds and the subsequent call to poll() has no messages, that * the subscriber does not invoke ackMessages because there should be no acks. */ @Test public void testPollInRegularCase() throws Exception { task.start(props); ReceivedMessage rm1 = createReceivedMessage(ACK_ID1, CPS_MESSAGE, new HashMap<String, String>()); PullResponse stubbedPullResponse = PullResponse.newBuilder().addReceivedMessages(rm1).build(); when(subscriber.pull(any(PullRequest.class)).get()).thenReturn(stubbedPullResponse); List<SourceRecord> result = task.poll(); assertEquals(1, result.size()); task.commitRecord(result.get(0)); stubbedPullResponse = PullResponse.newBuilder().build(); SettableApiFuture<Empty> goodFuture = SettableApiFuture.create(); goodFuture.set(Empty.getDefaultInstance()); when(subscriber.ackMessages(any(AcknowledgeRequest.class))).thenReturn(goodFuture); when(subscriber.pull(any(PullRequest.class)).get()).thenReturn(stubbedPullResponse); result = task.poll(); assertEquals(0, result.size()); result = task.poll(); assertEquals(0, result.size()); verify(subscriber, times(1)).ackMessages(any(AcknowledgeRequest.class)); }
Example #3
Source File: GrpcSimulatedMesosService.java From titus-control-plane with Apache License 2.0 | 6 votes |
@Override public void offerStream(Empty request, StreamObserver<SimulatedOfferEvent> responseObserver) { Subscription subscription = cloud.offers().subscribe( offerEvent -> { logger.info("Sending new offer event: offerId={}, rescinded={}", offerEvent.getOffer().getId().getValue(), offerEvent.isRescind()); responseObserver.onNext(toSimulatedOfferEvent(offerEvent)); }, e -> { logger.info("Offer subscription stream terminated with an error: {}", e.getMessage(), e); responseObserver.onError(e); }, () -> { logger.info("Offer subscription stream completed"); responseObserver.onCompleted(); } ); GrpcUtil.attachCancellingCallback(responseObserver, subscription); }
Example #4
Source File: AbstractBrokenServerClientTest.java From grpc-spring-boot-starter with MIT License | 6 votes |
/** * Test successful call with broken setup. */ @Test @DirtiesContext public void testSuccessfulCallWithBrokenSetup() { log.info("--- Starting tests with successful call with broken setup ---"); assertThrowsStatus(UNAVAILABLE, () -> TestServiceGrpc.newBlockingStub(this.channel).normal(Empty.getDefaultInstance())); final StreamRecorder<SomeType> streamRecorder = StreamRecorder.create(); this.testServiceStub.normal(Empty.getDefaultInstance(), streamRecorder); assertFutureThrowsStatus(UNAVAILABLE, streamRecorder.firstValue(), 5, TimeUnit.SECONDS); assertThrowsStatus(UNAVAILABLE, () -> this.testServiceBlockingStub.normal(Empty.getDefaultInstance())); assertFutureThrowsStatus(UNAVAILABLE, this.testServiceFutureStub.normal(Empty.getDefaultInstance()), 5, TimeUnit.SECONDS); log.info("--- Test completed ---"); }
Example #5
Source File: DaprClientGrpcTest.java From java-sdk with MIT License | 6 votes |
@Test public void saveStateNoConsistencyTest() { String key = "key1"; String etag = "ETag1"; String value = "State value"; SettableFuture<Empty> settableFuture = SettableFuture.create(); MockCallback<Empty> callback = new MockCallback<>(Empty.newBuilder().build()); addCallback(settableFuture, callback, directExecutor()); when(client.saveState(any(io.dapr.v1.DaprProtos.SaveStateRequest.class))).thenReturn(settableFuture); StateOptions options = buildStateOptions(null, StateOptions.Concurrency.FIRST_WRITE, Duration.ofDays(100), 1, StateOptions.RetryPolicy.Pattern.LINEAR); Mono<Void> result = adapter.saveState(STATE_STORE_NAME, key, etag, value, options); settableFuture.set(Empty.newBuilder().build()); result.block(); assertTrue(callback.wasCalled); }
Example #6
Source File: DaprClientGrpcTest.java From java-sdk with MIT License | 6 votes |
@Test public void deleteStateTest() { String etag = "ETag1"; String key = "key1"; StateOptions options = buildStateOptions(StateOptions.Consistency.STRONG, StateOptions.Concurrency.FIRST_WRITE, Duration.ofDays(100), 1, StateOptions.RetryPolicy.Pattern.LINEAR); SettableFuture<Empty> settableFuture = SettableFuture.create(); MockCallback<Empty> callback = new MockCallback<>(Empty.newBuilder().build()); addCallback(settableFuture, callback, directExecutor()); when(client.deleteState(any(io.dapr.v1.DaprProtos.DeleteStateRequest.class))) .thenReturn(settableFuture); State<String> stateKey = buildStateKey(null, key, etag, options); Mono<Void> result = adapter.deleteState(STATE_STORE_NAME, stateKey.getKey(), stateKey.getEtag(), stateKey.getOptions()); settableFuture.set(Empty.newBuilder().build()); result.block(); assertTrue(callback.wasCalled); }
Example #7
Source File: DaprClientGrpcTest.java From java-sdk with MIT License | 6 votes |
@Test public void saveStateRetryPolicyNoDurationTest() { String key = "key1"; String etag = "ETag1"; String value = "State value"; SettableFuture<Empty> settableFuture = SettableFuture.create(); MockCallback<Empty> callback = new MockCallback<>(Empty.newBuilder().build()); addCallback(settableFuture, callback, directExecutor()); when(client.saveState(any(io.dapr.v1.DaprProtos.SaveStateRequest.class))).thenReturn(settableFuture); StateOptions options = buildStateOptions(StateOptions.Consistency.STRONG, StateOptions.Concurrency.FIRST_WRITE, null, 1, StateOptions.RetryPolicy.Pattern.LINEAR); Mono<Void> result = adapter.saveState(STATE_STORE_NAME, key, etag, value, options); settableFuture.set(Empty.newBuilder().build()); result.block(); assertTrue(callback.wasCalled); }
Example #8
Source File: DaprClientGrpcTest.java From java-sdk with MIT License | 6 votes |
@Test public void saveStateRetryPolicyNoThresholdTest() { String key = "key1"; String etag = "ETag1"; String value = "State value"; SettableFuture<Empty> settableFuture = SettableFuture.create(); MockCallback<Empty> callback = new MockCallback<>(Empty.newBuilder().build()); addCallback(settableFuture, callback, directExecutor()); when(client.saveState(any(io.dapr.v1.DaprProtos.SaveStateRequest.class))).thenReturn(settableFuture); StateOptions options = buildStateOptions(StateOptions.Consistency.STRONG, StateOptions.Concurrency.FIRST_WRITE, Duration.ofDays(100), null, StateOptions.RetryPolicy.Pattern.LINEAR); Mono<Void> result = adapter.saveState(STATE_STORE_NAME, key, etag, value, options); settableFuture.set(Empty.newBuilder().build()); result.block(); assertTrue(callback.wasCalled); }
Example #9
Source File: QuickstartTest.java From java-docs-samples with Apache License 2.0 | 6 votes |
@After public void teardown() throws IOException, InterruptedException, ExecutionException { blob.delete(); bucket.delete(); ClusterControllerSettings clusterControllerSettings = ClusterControllerSettings.newBuilder().setEndpoint(ENDPOINT).build(); try (ClusterControllerClient clusterControllerClient = ClusterControllerClient.create(clusterControllerSettings)) { for (Cluster element : clusterControllerClient.listClusters(PROJECT_ID, REGION).iterateAll()) { if (element.getClusterName() == CLUSTER_NAME) { OperationFuture<Empty, ClusterOperationMetadata> deleteClusterAsyncRequest = clusterControllerClient.deleteClusterAsync(PROJECT_ID, REGION, CLUSTER_NAME); deleteClusterAsyncRequest.get(); break; } } } }
Example #10
Source File: DaprClientGrpcTest.java From java-sdk with MIT License | 6 votes |
@Test public void stateOptionsConsistencyValuesHaveValidGrpcEnumMappings() { String key = "key1"; String etag = "ETag1"; String value = "State value"; SettableFuture<Empty> settableFuture = SettableFuture.create(); MockCallback<Empty> callback = new MockCallback<>(Empty.newBuilder().build()); addCallback(settableFuture, callback, directExecutor()); when(client.saveState(any(io.dapr.v1.DaprProtos.SaveStateRequest.class))).thenReturn(settableFuture); settableFuture.set(Empty.newBuilder().build()); for (StateOptions.Consistency consistency : StateOptions.Consistency.values()) { StateOptions options = buildStateOptions(consistency, StateOptions.Concurrency.FIRST_WRITE, Duration.ofDays(100), null, StateOptions.RetryPolicy.Pattern.LINEAR); Mono<Void> result = adapter.saveState(STATE_STORE_NAME, key, etag, value, options); result.block(); } assertTrue(callback.wasCalled); }
Example #11
Source File: UndeployModel.java From java-docs-samples with Apache License 2.0 | 6 votes |
static void undeployModel(String projectId, String modelId) throws IOException, ExecutionException, InterruptedException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. After completing all of your requests, call // the "close" method on the client to safely clean up any remaining background resources. try (AutoMlClient client = AutoMlClient.create()) { // Get the full path of the model. ModelName modelFullId = ModelName.of(projectId, "us-central1", modelId); UndeployModelRequest request = UndeployModelRequest.newBuilder().setName(modelFullId.toString()).build(); OperationFuture<Empty, OperationMetadata> future = client.undeployModelAsync(request); future.get(); System.out.println("Model undeployment finished"); } }
Example #12
Source File: ForemenWorkManager.java From dremio-oss with Apache License 2.0 | 6 votes |
private void sendAllProfiles() { final List<ListenableFuture<Empty>> futures = Lists.newArrayList(); for (ManagedForeman managedForeman : externalIdToForeman.values()) { try { Optional<ListenableFuture<Empty>> future = managedForeman.foreman.sendPlanningProfile(); future.ifPresent(futures::add); } catch (final Exception e) { // Exception ignored. Profile sender thread should not die due to a random // exception } } // we'll wait to complete so we don't back up if the cluster is moving slowly. try { Futures.successfulAsList(futures).get(); } catch (final Exception ex) { logger.info("Failure while sending profile to JobTelemetryService", ex); } }
Example #13
Source File: CampaignExperimentServiceClientTest.java From google-ads-java with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings("all") public void createCampaignExperimentTest() throws Exception { Empty expectedResponse = Empty.newBuilder().build(); Operation resultOperation = Operation.newBuilder() .setName("createCampaignExperimentTest") .setDone(true) .setResponse(Any.pack(expectedResponse)) .build(); mockCampaignExperimentService.addResponse(resultOperation); String customerId = "customerId-1772061412"; CampaignExperiment campaignExperiment = CampaignExperiment.newBuilder().build(); boolean validateOnly = false; Empty actualResponse = client.createCampaignExperimentAsync(customerId, campaignExperiment, validateOnly).get(); Assert.assertEquals(expectedResponse, actualResponse); List<AbstractMessage> actualRequests = mockCampaignExperimentService.getRequests(); Assert.assertEquals(1, actualRequests.size()); CreateCampaignExperimentRequest actualRequest = (CreateCampaignExperimentRequest) actualRequests.get(0); Assert.assertEquals(customerId, actualRequest.getCustomerId()); Assert.assertEquals(campaignExperiment, actualRequest.getCampaignExperiment()); Assert.assertEquals(validateOnly, actualRequest.getValidateOnly()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
Example #14
Source File: LiiklusService.java From liiklus with MIT License | 5 votes |
public Mono<Empty> ack(Mono<AckRequest> request) { return request .flatMap(ack -> { String topic; GroupId groupId; int partition; @SuppressWarnings("deprecation") var hasAssignment = ack.hasAssignment(); if (hasAssignment) { @SuppressWarnings("deprecation") var assignment = ack.getAssignment(); var subscription = subscriptions.get(assignment.getSessionId()); if (subscription == null) { log.warn("Subscription is null, returning empty Publisher. Request: {}", ack.toString().replace("\n", "\\n")); return Mono.empty(); } topic = subscription.getTopic(); groupId = subscription.getGroupId(); partition = assignment.getPartition(); } else { topic = ack.getTopic(); groupId = GroupId.of(ack.getGroup(), ack.getGroupVersion()); partition = ack.getPartition(); } return Mono.fromCompletionStage(positionsStorage.update( topic, groupId, partition, ack.getOffset() )); }) .thenReturn(Empty.getDefaultInstance()) .log("ack", Level.SEVERE, SignalType.ON_ERROR); }
Example #15
Source File: CampaignExperimentServiceSettings.java From google-ads-java with Apache License 2.0 | 5 votes |
/** Returns the builder for the settings used for calls to promoteCampaignExperiment. */ @BetaApi( "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings.Builder<PromoteCampaignExperimentRequest, Empty, Empty> promoteCampaignExperimentOperationSettings() { return getStubSettingsBuilder().promoteCampaignExperimentOperationSettings(); }
Example #16
Source File: SimpleBenchmarkBase.java From armeria with Apache License 2.0 | 5 votes |
@Benchmark public void emptyNonBlocking(AsyncCounters counters) throws Exception { counters.incrementCurrentRequests(); Futures.addCallback( futureStub().empty(Empty.getDefaultInstance()), counterIncrementingFutureCallback(counters), MoreExecutors.directExecutor()); }
Example #17
Source File: TaskScenarioBuilder.java From titus-control-plane with Apache License 2.0 | 5 votes |
public TaskScenarioBuilder deleteTaskAttributes(List<String> keys) { String taskId = getTask().getId(); logger.info("[{}] Deleting attributes of task {} of job {}...", discoverActiveTest(), taskId, jobScenarioBuilder.getJobId()); Stopwatch stopWatch = Stopwatch.createStarted(); TestStreamObserver<Empty> responseObserver = new TestStreamObserver<>(); jobClient.deleteTaskAttributes(TaskAttributesDeleteRequest.newBuilder().setTaskId(taskId).addAllKeys(keys).build(), responseObserver); rethrow(() -> responseObserver.awaitDone(TIMEOUT_MS, TimeUnit.MILLISECONDS)); logger.info("[{}] Task {} updated in {}[ms]", discoverActiveTest(), taskId, stopWatch.elapsed(TimeUnit.MILLISECONDS)); return this; }
Example #18
Source File: ChatImpl.java From reactive-grpc with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Accept and broadcast ChatMessages. */ @Override public Single<Empty> postMessage(Single<ChatProto.ChatMessage> request) { return request // Side effect: publish message .doOnSuccess(broadcast::onNext) // Side effect: log message .doOnSuccess(message -> logger.info(message.getAuthor() + ": " + message.getMessage())) // Return empty .map(x -> Empty.getDefaultInstance()); }
Example #19
Source File: DefaultAutoScalingServiceGrpc.java From titus-control-plane with Apache License 2.0 | 5 votes |
@Override public void deleteAutoScalingPolicy(com.netflix.titus.grpc.protogen.DeletePolicyRequest request, io.grpc.stub.StreamObserver<com.google.protobuf.Empty> responseObserver) { Subscription subscription = autoScalingService.deleteAutoScalingPolicy(request, resolveCallMetadata()).subscribe( () -> { responseObserver.onNext(Empty.getDefaultInstance()); responseObserver.onCompleted(); }, e -> safeOnError(logger, e, responseObserver) ); attachCancellingCallback(responseObserver, subscription); }
Example #20
Source File: MutateJobServiceSettings.java From google-ads-java with Apache License 2.0 | 5 votes |
/** Returns the builder for the settings used for calls to runMutateJob. */ @BetaApi( "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings.Builder<RunMutateJobRequest, Empty, MutateJobMetadata> runMutateJobOperationSettings() { return getStubSettingsBuilder().runMutateJobOperationSettings(); }
Example #21
Source File: DefaultJobManagementServiceGrpc.java From titus-control-plane with Apache License 2.0 | 5 votes |
private static void streamCompletableResponse(Completable completable, StreamObserver<Empty> responseObserver) { Subscription subscription = completable.subscribe( () -> { responseObserver.onNext(Empty.getDefaultInstance()); responseObserver.onCompleted(); }, e -> safeOnError(logger, e, responseObserver) ); attachCancellingCallback(responseObserver, subscription); }
Example #22
Source File: TestServiceImpl.java From grpc-spring-boot-starter with MIT License | 5 votes |
@Override @Secured("ROLE_CLIENT1") public void secureSupply(final Empty request, final StreamObserver<SomeType> responseObserver) { final Authentication authentication = assertAuthenticated("secureListener"); assertSameAuthenticatedGrcContextCancellation("secureSupply-cancellation", authentication); responseObserver.onNext(SomeType.newBuilder().setVersion("1.2.3").build()); responseObserver.onNext(SomeType.newBuilder().setVersion("1.2.3").build()); responseObserver.onNext(SomeType.newBuilder().setVersion("1.2.3").build()); responseObserver.onCompleted(); }
Example #23
Source File: SubscriberServiceTest.java From kafka-pubsub-emulator with Apache License 2.0 | 5 votes |
@Test public void acknowledge() { List<String> ackIds = Arrays.asList("0-0", "0-1", "0-2"); when(mockSubscriptionManager3.acknowledge(ackIds)).thenReturn(ackIds); AcknowledgeRequest request = AcknowledgeRequest.newBuilder() .setSubscription(TestHelpers.PROJECT2_SUBSCRIPTION3) .addAllAckIds(ackIds) .build(); assertThat(blockingStub.acknowledge(request), Matchers.equalTo(Empty.getDefaultInstance())); verify(mockSubscriptionManager3).acknowledge(ackIds); }
Example #24
Source File: CampaignExperimentServiceSettings.java From google-ads-java with Apache License 2.0 | 5 votes |
/** Returns the object with the settings used for calls to promoteCampaignExperiment. */ @BetaApi( "The surface for long-running operations is not stable yet and may change in the future.") public OperationCallSettings<PromoteCampaignExperimentRequest, Empty, Empty> promoteCampaignExperimentOperationSettings() { return ((CampaignExperimentServiceStubSettings) getStubSettings()) .promoteCampaignExperimentOperationSettings(); }
Example #25
Source File: DefaultAgentManagementServiceGrpc.java From titus-control-plane with Apache License 2.0 | 5 votes |
@Override public void updateInstanceGroupTier(TierUpdate request, StreamObserver<Empty> responseObserver) { agentManagementService.updateInstanceGroupTier( request.getInstanceGroupId(), GrpcAgentModelConverters.toCoreTier(request.getTier()) ).subscribe( () -> { responseObserver.onNext(Empty.getDefaultInstance()); responseObserver.onCompleted(); }, responseObserver::onError ); }
Example #26
Source File: AggregatingJobServiceGateway.java From titus-control-plane with Apache License 2.0 | 5 votes |
@Override public Completable updateJobStatus(JobStatusUpdate request, CallMetadata callMetadata) { Observable<Empty> result = jobManagementServiceHelper.findJobInAllCells(request.getId(), callMetadata) .flatMap(response -> singleCellCall(response.getCell(), (client, streamObserver) -> client.updateJobStatus(request, streamObserver), callMetadata) ); return result.toCompletable(); }
Example #27
Source File: NodeGrpcServer.java From julongchain with Apache License 2.0 | 5 votes |
@Override public void getStatus(Empty request, StreamObserver<AdminPackage.ServerStatus> responseObserver) { if (adminServer != null) { responseObserver.onNext(adminServer.getStatus()); responseObserver.onCompleted(); } else { log.error("AdminServer is not ready, but client sent some message"); responseObserver.onError(new NodeException("adminServer is not ready")); responseObserver.onCompleted(); } }
Example #28
Source File: AdminClient.java From julongchain with Apache License 2.0 | 5 votes |
@Override public int getStatus() { managedChannel = NettyChannelBuilder.forAddress(host, port).maxInboundMessageSize(CommConstant .MAX_GRPC_MESSAGE_SIZE).usePlaintext().build(); AdminGrpc.AdminBlockingStub stub = AdminGrpc.newBlockingStub(managedChannel); return stub.getStatus(Empty.getDefaultInstance()).getStatusValue(); }
Example #29
Source File: DefaultAgentManagementServiceGrpc.java From titus-control-plane with Apache License 2.0 | 5 votes |
@Override public void updateInstanceGroupTier(TierUpdate request, StreamObserver<Empty> responseObserver) { Disposable subscription = agentManagementService.updateInstanceGroupTier(request).subscribe( next -> { // Never }, e -> safeOnError(logger, e, responseObserver), () -> emitEmptyReply(responseObserver) ); attachCancellingCallback(responseObserver, subscription); }
Example #30
Source File: AggregatingJobServiceGateway.java From titus-control-plane with Apache License 2.0 | 5 votes |
@Override public Completable updateTaskAttributes(TaskAttributesUpdate attributesUpdate, CallMetadata callMetadata) { Observable<Empty> result = findTaskInAllCells(attributesUpdate.getTaskId(), callMetadata) .flatMap(response -> singleCellCall(response.getCell(), (client, streamObserver) -> client.updateTaskAttributes(attributesUpdate, streamObserver), callMetadata)); return result.toCompletable(); }