• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

uber / cadence-java-client / 2630

07 Nov 2024 12:07AM CUT coverage: 82.827% (+3.2%) from 79.634%
2630

Pull #950

buildkite

natemort
Fix Error handling and add test coverage for Thrift2ProtoAdapter
Pull Request #950: Fix Error handling and add test coverage for Thrift2ProtoAdapter

11 of 13 new or added lines in 1 file covered. (84.62%)

2 existing lines in 2 files now uncovered.

16042 of 19368 relevant lines covered (82.83%)

0.83 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.0
/src/main/java/com/uber/cadence/internal/compatibility/Thrift2ProtoAdapter.java
1
/*
2
 *  Modifications Copyright (c) 2017-2021 Uber Technologies Inc.
3
 *  Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
 *
5
 *  Licensed under the Apache License, Version 2.0 (the "License"). You may not
6
 *  use this file except in compliance with the License. A copy of the License is
7
 *  located at
8
 *
9
 *  http://aws.amazon.com/apache2.0
10
 *
11
 *  or in the "license" file accompanying this file. This file is distributed on
12
 *  an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13
 *  express or implied. See the License for the specific language governing
14
 *  permissions and limitations under the License.
15
 */
16
package com.uber.cadence.internal.compatibility;
17

18
import com.google.common.util.concurrent.FutureCallback;
19
import com.google.common.util.concurrent.Futures;
20
import com.google.common.util.concurrent.ListenableFuture;
21
import com.uber.cadence.BadRequestError;
22
import com.uber.cadence.CancellationAlreadyRequestedError;
23
import com.uber.cadence.ClientVersionNotSupportedError;
24
import com.uber.cadence.ClusterInfo;
25
import com.uber.cadence.CountWorkflowExecutionsRequest;
26
import com.uber.cadence.CountWorkflowExecutionsResponse;
27
import com.uber.cadence.DeprecateDomainRequest;
28
import com.uber.cadence.DescribeDomainRequest;
29
import com.uber.cadence.DescribeDomainResponse;
30
import com.uber.cadence.DescribeTaskListRequest;
31
import com.uber.cadence.DescribeTaskListResponse;
32
import com.uber.cadence.DescribeWorkflowExecutionRequest;
33
import com.uber.cadence.DescribeWorkflowExecutionResponse;
34
import com.uber.cadence.DomainAlreadyExistsError;
35
import com.uber.cadence.DomainNotActiveError;
36
import com.uber.cadence.EntityNotExistsError;
37
import com.uber.cadence.GetSearchAttributesResponse;
38
import com.uber.cadence.GetTaskListsByDomainRequest;
39
import com.uber.cadence.GetTaskListsByDomainResponse;
40
import com.uber.cadence.GetWorkflowExecutionHistoryRequest;
41
import com.uber.cadence.GetWorkflowExecutionHistoryResponse;
42
import com.uber.cadence.InternalServiceError;
43
import com.uber.cadence.LimitExceededError;
44
import com.uber.cadence.ListArchivedWorkflowExecutionsRequest;
45
import com.uber.cadence.ListArchivedWorkflowExecutionsResponse;
46
import com.uber.cadence.ListClosedWorkflowExecutionsRequest;
47
import com.uber.cadence.ListClosedWorkflowExecutionsResponse;
48
import com.uber.cadence.ListDomainsRequest;
49
import com.uber.cadence.ListDomainsResponse;
50
import com.uber.cadence.ListOpenWorkflowExecutionsRequest;
51
import com.uber.cadence.ListOpenWorkflowExecutionsResponse;
52
import com.uber.cadence.ListTaskListPartitionsRequest;
53
import com.uber.cadence.ListTaskListPartitionsResponse;
54
import com.uber.cadence.ListWorkflowExecutionsRequest;
55
import com.uber.cadence.ListWorkflowExecutionsResponse;
56
import com.uber.cadence.PollForActivityTaskRequest;
57
import com.uber.cadence.PollForActivityTaskResponse;
58
import com.uber.cadence.PollForDecisionTaskRequest;
59
import com.uber.cadence.PollForDecisionTaskResponse;
60
import com.uber.cadence.QueryFailedError;
61
import com.uber.cadence.QueryWorkflowRequest;
62
import com.uber.cadence.QueryWorkflowResponse;
63
import com.uber.cadence.RecordActivityTaskHeartbeatByIDRequest;
64
import com.uber.cadence.RecordActivityTaskHeartbeatRequest;
65
import com.uber.cadence.RecordActivityTaskHeartbeatResponse;
66
import com.uber.cadence.RefreshWorkflowTasksRequest;
67
import com.uber.cadence.RegisterDomainRequest;
68
import com.uber.cadence.RequestCancelWorkflowExecutionRequest;
69
import com.uber.cadence.ResetStickyTaskListRequest;
70
import com.uber.cadence.ResetStickyTaskListResponse;
71
import com.uber.cadence.ResetWorkflowExecutionRequest;
72
import com.uber.cadence.ResetWorkflowExecutionResponse;
73
import com.uber.cadence.RespondActivityTaskCanceledByIDRequest;
74
import com.uber.cadence.RespondActivityTaskCanceledRequest;
75
import com.uber.cadence.RespondActivityTaskCompletedByIDRequest;
76
import com.uber.cadence.RespondActivityTaskCompletedRequest;
77
import com.uber.cadence.RespondActivityTaskFailedByIDRequest;
78
import com.uber.cadence.RespondActivityTaskFailedRequest;
79
import com.uber.cadence.RespondDecisionTaskCompletedRequest;
80
import com.uber.cadence.RespondDecisionTaskCompletedResponse;
81
import com.uber.cadence.RespondDecisionTaskFailedRequest;
82
import com.uber.cadence.RespondQueryTaskCompletedRequest;
83
import com.uber.cadence.RestartWorkflowExecutionRequest;
84
import com.uber.cadence.RestartWorkflowExecutionResponse;
85
import com.uber.cadence.ServiceBusyError;
86
import com.uber.cadence.SignalWithStartWorkflowExecutionAsyncRequest;
87
import com.uber.cadence.SignalWithStartWorkflowExecutionAsyncResponse;
88
import com.uber.cadence.SignalWithStartWorkflowExecutionRequest;
89
import com.uber.cadence.SignalWorkflowExecutionRequest;
90
import com.uber.cadence.StartWorkflowExecutionAsyncRequest;
91
import com.uber.cadence.StartWorkflowExecutionAsyncResponse;
92
import com.uber.cadence.StartWorkflowExecutionRequest;
93
import com.uber.cadence.StartWorkflowExecutionResponse;
94
import com.uber.cadence.TerminateWorkflowExecutionRequest;
95
import com.uber.cadence.UpdateDomainRequest;
96
import com.uber.cadence.UpdateDomainResponse;
97
import com.uber.cadence.WorkflowExecutionAlreadyCompletedError;
98
import com.uber.cadence.WorkflowExecutionAlreadyStartedError;
99
import com.uber.cadence.api.v1.GetSearchAttributesRequest;
100
import com.uber.cadence.api.v1.HealthRequest;
101
import com.uber.cadence.api.v1.HealthResponse;
102
import com.uber.cadence.internal.compatibility.proto.RequestMapper;
103
import com.uber.cadence.internal.compatibility.proto.serviceclient.IGrpcServiceStubs;
104
import com.uber.cadence.internal.compatibility.thrift.ErrorMapper;
105
import com.uber.cadence.internal.compatibility.thrift.ResponseMapper;
106
import com.uber.cadence.serviceclient.ClientOptions;
107
import com.uber.cadence.serviceclient.IWorkflowService;
108
import io.grpc.Deadline;
109
import io.grpc.StatusRuntimeException;
110
import java.util.UUID;
111
import java.util.concurrent.CompletableFuture;
112
import java.util.concurrent.ExecutionException;
113
import java.util.concurrent.ForkJoinPool;
114
import java.util.concurrent.TimeUnit;
115
import org.apache.thrift.TException;
116
import org.apache.thrift.async.AsyncMethodCallback;
117

118
public class Thrift2ProtoAdapter implements IWorkflowService {
119

120
  IGrpcServiceStubs grpcServiceStubs;
121

122
  public Thrift2ProtoAdapter(IGrpcServiceStubs grpcServiceStubs) {
1✔
123
    this.grpcServiceStubs = grpcServiceStubs;
1✔
124
  }
1✔
125

126
  @Override
127
  public ClientOptions getOptions() {
128
    return grpcServiceStubs.getOptions();
×
129
  }
130

131
  @Override
132
  public void RegisterDomain(RegisterDomainRequest registerRequest)
133
      throws BadRequestError, DomainAlreadyExistsError, ServiceBusyError,
134
          ClientVersionNotSupportedError, TException {
135
    try {
136
      grpcServiceStubs
1✔
137
          .domainBlockingStub()
1✔
138
          .registerDomain(RequestMapper.registerDomainRequest(registerRequest));
1✔
139
    } catch (StatusRuntimeException e) {
1✔
140
      throw ErrorMapper.Error(e);
1✔
141
    }
1✔
142
  }
1✔
143

144
  @Override
145
  public DescribeDomainResponse DescribeDomain(DescribeDomainRequest describeRequest)
146
      throws BadRequestError, EntityNotExistsError, ServiceBusyError,
147
          ClientVersionNotSupportedError, TException {
148
    try {
149
      com.uber.cadence.api.v1.DescribeDomainResponse response =
1✔
150
          grpcServiceStubs
151
              .domainBlockingStub()
1✔
152
              .describeDomain(RequestMapper.describeDomainRequest(describeRequest));
1✔
153
      return ResponseMapper.describeDomainResponse(response);
1✔
154
    } catch (StatusRuntimeException e) {
1✔
155
      throw ErrorMapper.Error(e);
1✔
156
    }
157
  }
158

159
  @Override
160
  public ListDomainsResponse ListDomains(ListDomainsRequest listRequest)
161
      throws BadRequestError, EntityNotExistsError, ServiceBusyError,
162
          ClientVersionNotSupportedError, TException {
163
    try {
164
      com.uber.cadence.api.v1.ListDomainsResponse response =
1✔
165
          grpcServiceStubs
166
              .domainBlockingStub()
1✔
167
              .listDomains(RequestMapper.listDomainsRequest(listRequest));
1✔
168
      return ResponseMapper.listDomainsResponse(response);
1✔
169
    } catch (StatusRuntimeException e) {
1✔
170
      throw ErrorMapper.Error(e);
1✔
171
    }
172
  }
173

174
  @Override
175
  public UpdateDomainResponse UpdateDomain(UpdateDomainRequest updateRequest)
176
      throws BadRequestError, EntityNotExistsError, ServiceBusyError, DomainNotActiveError,
177
          ClientVersionNotSupportedError, TException {
178
    try {
179
      com.uber.cadence.api.v1.UpdateDomainResponse response =
1✔
180
          grpcServiceStubs
181
              .domainBlockingStub()
1✔
182
              .updateDomain(RequestMapper.updateDomainRequest(updateRequest));
1✔
183
      return ResponseMapper.updateDomainResponse(response);
1✔
184
    } catch (StatusRuntimeException e) {
1✔
185
      throw ErrorMapper.Error(e);
1✔
186
    }
187
  }
188

189
  @Override
190
  public void DeprecateDomain(DeprecateDomainRequest deprecateRequest)
191
      throws BadRequestError, EntityNotExistsError, ServiceBusyError, DomainNotActiveError,
192
          ClientVersionNotSupportedError, TException {
193
    try {
194
      grpcServiceStubs
1✔
195
          .domainBlockingStub()
1✔
196
          .deprecateDomain(RequestMapper.deprecateDomainRequest(deprecateRequest));
1✔
197
    } catch (StatusRuntimeException e) {
1✔
198
      throw ErrorMapper.Error(e);
1✔
199
    }
1✔
200
  }
1✔
201

202
  @Override
203
  public RestartWorkflowExecutionResponse RestartWorkflowExecution(
204
      RestartWorkflowExecutionRequest restartRequest)
205
      throws BadRequestError, ServiceBusyError, DomainNotActiveError, LimitExceededError,
206
          EntityNotExistsError, ClientVersionNotSupportedError, TException {
NEW
207
    throw new UnsupportedOperationException("unimplemented");
×
208
  }
209

210
  @Override
211
  public StartWorkflowExecutionResponse StartWorkflowExecution(
212
      StartWorkflowExecutionRequest startRequest)
213
      throws BadRequestError, WorkflowExecutionAlreadyStartedError, ServiceBusyError,
214
          DomainNotActiveError, LimitExceededError, EntityNotExistsError,
215
          ClientVersionNotSupportedError, TException {
216
    return startWorkflowExecution(startRequest);
1✔
217
  }
218

219
  @Override
220
  public StartWorkflowExecutionAsyncResponse StartWorkflowExecutionAsync(
221
      StartWorkflowExecutionAsyncRequest startRequest)
222
      throws BadRequestError, WorkflowExecutionAlreadyStartedError, ServiceBusyError,
223
          DomainNotActiveError, LimitExceededError, EntityNotExistsError,
224
          ClientVersionNotSupportedError, TException {
225
    initializeStartWorkflowExecutionRequest(startRequest.getRequest());
1✔
226
    try {
227
      com.uber.cadence.api.v1.StartWorkflowExecutionAsyncResponse response =
1✔
228
          grpcServiceStubs
229
              .workflowBlockingStub()
1✔
230
              .startWorkflowExecutionAsync(
1✔
231
                  RequestMapper.startWorkflowExecutionAsyncRequest(startRequest));
1✔
232
      return ResponseMapper.startWorkflowExecutionAsyncResponse(response);
1✔
233
    } catch (StatusRuntimeException e) {
1✔
234
      throw ErrorMapper.Error(e);
1✔
235
    }
236
  }
237

238
  private StartWorkflowExecutionResponse startWorkflowExecution(
239
      StartWorkflowExecutionRequest startRequest)
240
      throws BadRequestError, WorkflowExecutionAlreadyStartedError, ServiceBusyError,
241
          DomainNotActiveError, LimitExceededError, EntityNotExistsError,
242
          ClientVersionNotSupportedError, TException {
243
    initializeStartWorkflowExecutionRequest(startRequest);
1✔
244
    try {
245
      com.uber.cadence.api.v1.StartWorkflowExecutionResponse response =
1✔
246
          grpcServiceStubs
247
              .workflowBlockingStub()
1✔
248
              .startWorkflowExecution(RequestMapper.startWorkflowExecutionRequest(startRequest));
1✔
249
      return ResponseMapper.startWorkflowExecutionResponse(response);
1✔
250
    } catch (StatusRuntimeException e) {
1✔
251
      throw ErrorMapper.Error(e);
1✔
252
    }
253
  }
254

255
  private void initializeStartWorkflowExecutionRequest(StartWorkflowExecutionRequest request) {
256
    if (!request.isSetRequestId()) {
1✔
257
      request.setRequestId(UUID.randomUUID().toString());
1✔
258
    }
259
  }
1✔
260

261
  @Override
262
  public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistory(
263
      GetWorkflowExecutionHistoryRequest getRequest)
264
      throws BadRequestError, EntityNotExistsError, ServiceBusyError,
265
          ClientVersionNotSupportedError, TException {
266
    try {
267
      com.uber.cadence.api.v1.GetWorkflowExecutionHistoryResponse response =
1✔
268
          grpcServiceStubs
269
              .workflowBlockingStub()
1✔
270
              .getWorkflowExecutionHistory(
1✔
271
                  RequestMapper.getWorkflowExecutionHistoryRequest(getRequest));
1✔
272
      return ResponseMapper.getWorkflowExecutionHistoryResponse(response);
1✔
273
    } catch (StatusRuntimeException e) {
1✔
274
      throw ErrorMapper.Error(e);
1✔
275
    }
276
  }
277

278
  @Override
279
  public PollForDecisionTaskResponse PollForDecisionTask(PollForDecisionTaskRequest pollRequest)
280
      throws BadRequestError, ServiceBusyError, LimitExceededError, EntityNotExistsError,
281
          DomainNotActiveError, ClientVersionNotSupportedError, TException {
282
    try {
283
      com.uber.cadence.api.v1.PollForDecisionTaskResponse response =
1✔
284
          grpcServiceStubs
285
              .workerBlockingStub()
1✔
286
              .pollForDecisionTask(RequestMapper.pollForDecisionTaskRequest(pollRequest));
1✔
287
      return ResponseMapper.pollForDecisionTaskResponse(response);
1✔
288
    } catch (StatusRuntimeException e) {
1✔
289
      throw ErrorMapper.Error(e);
1✔
290
    }
291
  }
292

293
  @Override
294
  public RespondDecisionTaskCompletedResponse RespondDecisionTaskCompleted(
295
      RespondDecisionTaskCompletedRequest completeRequest)
296
      throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError,
297
          ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError,
298
          TException {
299
    try {
300
      com.uber.cadence.api.v1.RespondDecisionTaskCompletedResponse response =
1✔
301
          grpcServiceStubs
302
              .workerBlockingStub()
1✔
303
              .respondDecisionTaskCompleted(
1✔
304
                  RequestMapper.respondDecisionTaskCompletedRequest(completeRequest));
1✔
305
      return ResponseMapper.respondDecisionTaskCompletedResponse(response);
1✔
306
    } catch (StatusRuntimeException e) {
1✔
307
      throw ErrorMapper.Error(e);
1✔
308
    }
309
  }
310

311
  @Override
312
  public void RespondDecisionTaskFailed(RespondDecisionTaskFailedRequest failedRequest)
313
      throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError,
314
          ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError,
315
          TException {
316
    try {
317
      grpcServiceStubs
1✔
318
          .workerBlockingStub()
1✔
319
          .respondDecisionTaskFailed(RequestMapper.respondDecisionTaskFailedRequest(failedRequest));
1✔
320
    } catch (StatusRuntimeException e) {
1✔
321
      throw ErrorMapper.Error(e);
1✔
322
    }
1✔
323
  }
1✔
324

325
  @Override
326
  public PollForActivityTaskResponse PollForActivityTask(PollForActivityTaskRequest pollRequest)
327
      throws BadRequestError, ServiceBusyError, LimitExceededError, EntityNotExistsError,
328
          DomainNotActiveError, ClientVersionNotSupportedError, TException {
329
    try {
330
      com.uber.cadence.api.v1.PollForActivityTaskResponse response =
1✔
331
          grpcServiceStubs
332
              .workerBlockingStub()
1✔
333
              .pollForActivityTask(RequestMapper.pollForActivityTaskRequest(pollRequest));
1✔
334
      return ResponseMapper.pollForActivityTaskResponse(response);
1✔
335
    } catch (StatusRuntimeException e) {
1✔
336
      throw ErrorMapper.Error(e);
1✔
337
    }
338
  }
339

340
  @Override
341
  public RecordActivityTaskHeartbeatResponse RecordActivityTaskHeartbeat(
342
      RecordActivityTaskHeartbeatRequest heartbeatRequest)
343
      throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError,
344
          ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError,
345
          TException {
346
    try {
347
      com.uber.cadence.api.v1.RecordActivityTaskHeartbeatResponse response =
1✔
348
          grpcServiceStubs
349
              .workerBlockingStub()
1✔
350
              .recordActivityTaskHeartbeat(
1✔
351
                  RequestMapper.recordActivityTaskHeartbeatRequest(heartbeatRequest));
1✔
352
      return ResponseMapper.recordActivityTaskHeartbeatResponse(response);
1✔
353
    } catch (StatusRuntimeException e) {
1✔
354
      throw ErrorMapper.Error(e);
1✔
355
    }
356
  }
357

358
  @Override
359
  public RecordActivityTaskHeartbeatResponse RecordActivityTaskHeartbeatByID(
360
      RecordActivityTaskHeartbeatByIDRequest heartbeatRequest)
361
      throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError,
362
          ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError,
363
          TException {
364
    try {
365
      com.uber.cadence.api.v1.RecordActivityTaskHeartbeatByIDResponse response =
1✔
366
          grpcServiceStubs
367
              .workerBlockingStub()
1✔
368
              .recordActivityTaskHeartbeatByID(
1✔
369
                  RequestMapper.recordActivityTaskHeartbeatByIdRequest(heartbeatRequest));
1✔
370
      return ResponseMapper.recordActivityTaskHeartbeatByIdResponse(response);
1✔
371
    } catch (StatusRuntimeException e) {
1✔
372
      throw ErrorMapper.Error(e);
1✔
373
    }
374
  }
375

376
  @Override
377
  public void RespondActivityTaskCompleted(RespondActivityTaskCompletedRequest completeRequest)
378
      throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError,
379
          ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError,
380
          TException {
381
    try {
382
      grpcServiceStubs
1✔
383
          .workerBlockingStub()
1✔
384
          .respondActivityTaskCompleted(
1✔
385
              RequestMapper.respondActivityTaskCompletedRequest(completeRequest));
1✔
386
    } catch (StatusRuntimeException e) {
1✔
387
      throw ErrorMapper.Error(e);
1✔
388
    }
1✔
389
  }
1✔
390

391
  @Override
392
  public void RespondActivityTaskCompletedByID(
393
      RespondActivityTaskCompletedByIDRequest completeRequest)
394
      throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError,
395
          ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError,
396
          TException {
397
    try {
398
      grpcServiceStubs
1✔
399
          .workerBlockingStub()
1✔
400
          .respondActivityTaskCompletedByID(
1✔
401
              RequestMapper.respondActivityTaskCompletedByIdRequest(completeRequest));
1✔
402
    } catch (StatusRuntimeException e) {
1✔
403
      throw ErrorMapper.Error(e);
1✔
404
    }
1✔
405
  }
1✔
406

407
  @Override
408
  public void RespondActivityTaskFailed(RespondActivityTaskFailedRequest failRequest)
409
      throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError,
410
          ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError,
411
          TException {
412
    try {
413
      grpcServiceStubs
1✔
414
          .workerBlockingStub()
1✔
415
          .respondActivityTaskFailed(RequestMapper.respondActivityTaskFailedRequest(failRequest));
1✔
416
    } catch (StatusRuntimeException e) {
1✔
417
      throw ErrorMapper.Error(e);
1✔
418
    }
1✔
419
  }
1✔
420

421
  @Override
422
  public void RespondActivityTaskFailedByID(RespondActivityTaskFailedByIDRequest failRequest)
423
      throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError,
424
          ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError,
425
          TException {
426
    try {
427
      grpcServiceStubs
1✔
428
          .workerBlockingStub()
1✔
429
          .respondActivityTaskFailedByID(
1✔
430
              RequestMapper.respondActivityTaskFailedByIdRequest(failRequest));
1✔
431
    } catch (StatusRuntimeException e) {
1✔
432
      throw ErrorMapper.Error(e);
1✔
433
    }
1✔
434
  }
1✔
435

436
  @Override
437
  public void RespondActivityTaskCanceled(RespondActivityTaskCanceledRequest canceledRequest)
438
      throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError,
439
          ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError,
440
          TException {
441
    try {
442
      grpcServiceStubs
1✔
443
          .workerBlockingStub()
1✔
444
          .respondActivityTaskCanceled(
1✔
445
              RequestMapper.respondActivityTaskCanceledRequest(canceledRequest));
1✔
446
    } catch (StatusRuntimeException e) {
1✔
447
      throw ErrorMapper.Error(e);
1✔
448
    }
1✔
449
  }
1✔
450

451
  @Override
452
  public void RespondActivityTaskCanceledByID(
453
      RespondActivityTaskCanceledByIDRequest canceledRequest)
454
      throws BadRequestError, EntityNotExistsError, DomainNotActiveError, LimitExceededError,
455
          ServiceBusyError, ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError,
456
          TException {
457
    try {
458
      grpcServiceStubs
1✔
459
          .workerBlockingStub()
1✔
460
          .respondActivityTaskCanceledByID(
1✔
461
              RequestMapper.respondActivityTaskCanceledByIdRequest(canceledRequest));
1✔
462
    } catch (StatusRuntimeException e) {
1✔
463
      throw ErrorMapper.Error(e);
1✔
464
    }
1✔
465
  }
1✔
466

467
  @Override
468
  public void RequestCancelWorkflowExecution(RequestCancelWorkflowExecutionRequest cancelRequest)
469
      throws BadRequestError, EntityNotExistsError, CancellationAlreadyRequestedError,
470
          ServiceBusyError, DomainNotActiveError, LimitExceededError,
471
          ClientVersionNotSupportedError, WorkflowExecutionAlreadyCompletedError, TException {
472
    if (!cancelRequest.isSetRequestId()) {
1✔
473
      cancelRequest.setRequestId(UUID.randomUUID().toString());
×
474
    }
475
    try {
476
      grpcServiceStubs
1✔
477
          .workflowBlockingStub()
1✔
478
          .requestCancelWorkflowExecution(
1✔
479
              RequestMapper.requestCancelWorkflowExecutionRequest(cancelRequest));
1✔
480
    } catch (StatusRuntimeException e) {
1✔
481
      throw ErrorMapper.Error(e);
1✔
482
    }
1✔
483
  }
1✔
484

485
  @Override
486
  public void SignalWorkflowExecution(SignalWorkflowExecutionRequest signalRequest)
487
      throws BadRequestError, EntityNotExistsError, ServiceBusyError, DomainNotActiveError,
488
          LimitExceededError, ClientVersionNotSupportedError,
489
          WorkflowExecutionAlreadyCompletedError, TException {
490
    if (!signalRequest.isSetRequestId()) {
1✔
491
      signalRequest.setRequestId(UUID.randomUUID().toString());
×
492
    }
493
    try {
494
      grpcServiceStubs
1✔
495
          .workflowBlockingStub()
1✔
496
          .signalWorkflowExecution(RequestMapper.signalWorkflowExecutionRequest(signalRequest));
1✔
497
    } catch (StatusRuntimeException e) {
1✔
498
      throw ErrorMapper.Error(e);
1✔
499
    }
1✔
500
  }
1✔
501

502
  @Override
503
  public StartWorkflowExecutionResponse SignalWithStartWorkflowExecution(
504
      SignalWithStartWorkflowExecutionRequest signalWithStartRequest)
505
      throws BadRequestError, EntityNotExistsError, ServiceBusyError, DomainNotActiveError,
506
          LimitExceededError, WorkflowExecutionAlreadyStartedError, ClientVersionNotSupportedError,
507
          TException {
508
    try {
509
      initializeSignalWithStartWorkflowExecution(signalWithStartRequest);
1✔
510
      com.uber.cadence.api.v1.SignalWithStartWorkflowExecutionResponse response =
1✔
511
          grpcServiceStubs
512
              .workflowBlockingStub()
1✔
513
              .signalWithStartWorkflowExecution(
1✔
514
                  RequestMapper.signalWithStartWorkflowExecutionRequest(signalWithStartRequest));
1✔
515
      return ResponseMapper.signalWithStartWorkflowExecutionResponse(response);
1✔
516
    } catch (StatusRuntimeException e) {
1✔
517
      throw ErrorMapper.Error(e);
1✔
518
    }
519
  }
520

521
  @Override
522
  public SignalWithStartWorkflowExecutionAsyncResponse SignalWithStartWorkflowExecutionAsync(
523
      SignalWithStartWorkflowExecutionAsyncRequest signalWithStartRequest)
524
      throws BadRequestError, WorkflowExecutionAlreadyStartedError, ServiceBusyError,
525
          DomainNotActiveError, LimitExceededError, EntityNotExistsError,
526
          ClientVersionNotSupportedError, TException {
527
    try {
528
      initializeSignalWithStartWorkflowExecution(signalWithStartRequest.getRequest());
1✔
529
      com.uber.cadence.api.v1.SignalWithStartWorkflowExecutionAsyncResponse response =
1✔
530
          grpcServiceStubs
531
              .workflowBlockingStub()
1✔
532
              .signalWithStartWorkflowExecutionAsync(
1✔
533
                  RequestMapper.signalWithStartWorkflowExecutionAsyncRequest(
1✔
534
                      signalWithStartRequest));
535
      return ResponseMapper.signalWithStartWorkflowExecutionAsyncResponse(response);
1✔
536
    } catch (StatusRuntimeException e) {
1✔
537
      throw ErrorMapper.Error(e);
1✔
538
    }
539
  }
540

541
  private void initializeSignalWithStartWorkflowExecution(
542
      SignalWithStartWorkflowExecutionRequest request) {
543
    if (!request.isSetRequestId()) {
1✔
544
      request.setRequestId(UUID.randomUUID().toString());
1✔
545
    }
546
  }
1✔
547

548
  @Override
549
  public ResetWorkflowExecutionResponse ResetWorkflowExecution(
550
      ResetWorkflowExecutionRequest resetRequest)
551
      throws BadRequestError, EntityNotExistsError, ServiceBusyError, DomainNotActiveError,
552
          LimitExceededError, ClientVersionNotSupportedError, TException {
553
    try {
554
      if (!resetRequest.isSetRequestId()) {
1✔
555
        resetRequest.setRequestId(UUID.randomUUID().toString());
×
556
      }
557
      com.uber.cadence.api.v1.ResetWorkflowExecutionResponse response =
1✔
558
          grpcServiceStubs
559
              .workflowBlockingStub()
1✔
560
              .resetWorkflowExecution(RequestMapper.resetWorkflowExecutionRequest(resetRequest));
1✔
561
      return ResponseMapper.resetWorkflowExecutionResponse(response);
1✔
562
    } catch (StatusRuntimeException e) {
1✔
563
      throw ErrorMapper.Error(e);
1✔
564
    }
565
  }
566

567
  @Override
568
  public void TerminateWorkflowExecution(TerminateWorkflowExecutionRequest terminateRequest)
569
      throws BadRequestError, EntityNotExistsError, ServiceBusyError, DomainNotActiveError,
570
          LimitExceededError, ClientVersionNotSupportedError,
571
          WorkflowExecutionAlreadyCompletedError, TException {
572
    try {
573
      grpcServiceStubs
1✔
574
          .workflowBlockingStub()
1✔
575
          .terminateWorkflowExecution(
1✔
576
              RequestMapper.terminateWorkflowExecutionRequest(terminateRequest));
1✔
577
    } catch (StatusRuntimeException e) {
1✔
578
      throw ErrorMapper.Error(e);
1✔
579
    }
1✔
580
  }
1✔
581

582
  @Override
583
  public ListOpenWorkflowExecutionsResponse ListOpenWorkflowExecutions(
584
      ListOpenWorkflowExecutionsRequest listRequest)
585
      throws BadRequestError, EntityNotExistsError, ServiceBusyError, LimitExceededError,
586
          ClientVersionNotSupportedError, TException {
587
    try {
588
      com.uber.cadence.api.v1.ListOpenWorkflowExecutionsResponse response =
1✔
589
          grpcServiceStubs
590
              .visibilityBlockingStub()
1✔
591
              .listOpenWorkflowExecutions(
1✔
592
                  RequestMapper.listOpenWorkflowExecutionsRequest(listRequest));
1✔
593
      return ResponseMapper.listOpenWorkflowExecutionsResponse(response);
1✔
594
    } catch (StatusRuntimeException e) {
1✔
595
      throw ErrorMapper.Error(e);
1✔
596
    }
597
  }
598

599
  @Override
600
  public ListClosedWorkflowExecutionsResponse ListClosedWorkflowExecutions(
601
      ListClosedWorkflowExecutionsRequest listRequest)
602
      throws BadRequestError, EntityNotExistsError, ServiceBusyError,
603
          ClientVersionNotSupportedError, TException {
604
    try {
605
      com.uber.cadence.api.v1.ListClosedWorkflowExecutionsResponse response =
1✔
606
          grpcServiceStubs
607
              .visibilityBlockingStub()
1✔
608
              .listClosedWorkflowExecutions(
1✔
609
                  RequestMapper.listClosedWorkflowExecutionsRequest(listRequest));
1✔
610
      return ResponseMapper.listClosedWorkflowExecutionsResponse(response);
1✔
611
    } catch (StatusRuntimeException e) {
1✔
612
      throw ErrorMapper.Error(e);
1✔
613
    }
614
  }
615

616
  @Override
617
  public ListWorkflowExecutionsResponse ListWorkflowExecutions(
618
      ListWorkflowExecutionsRequest listRequest)
619
      throws BadRequestError, EntityNotExistsError, ServiceBusyError,
620
          ClientVersionNotSupportedError, TException {
621
    try {
622
      com.uber.cadence.api.v1.ListWorkflowExecutionsResponse response =
1✔
623
          grpcServiceStubs
624
              .visibilityBlockingStub()
1✔
625
              .listWorkflowExecutions(RequestMapper.listWorkflowExecutionsRequest(listRequest));
1✔
626
      return ResponseMapper.listWorkflowExecutionsResponse(response);
1✔
627
    } catch (StatusRuntimeException e) {
1✔
628
      throw ErrorMapper.Error(e);
1✔
629
    }
630
  }
631

632
  @Override
633
  public ListArchivedWorkflowExecutionsResponse ListArchivedWorkflowExecutions(
634
      ListArchivedWorkflowExecutionsRequest listRequest)
635
      throws BadRequestError, EntityNotExistsError, ServiceBusyError,
636
          ClientVersionNotSupportedError, TException {
637
    try {
638
      com.uber.cadence.api.v1.ListArchivedWorkflowExecutionsResponse response =
1✔
639
          grpcServiceStubs
640
              .visibilityBlockingStub()
1✔
641
              .listArchivedWorkflowExecutions(
1✔
642
                  RequestMapper.listArchivedWorkflowExecutionsRequest(listRequest));
1✔
643
      return ResponseMapper.listArchivedWorkflowExecutionsResponse(response);
1✔
644
    } catch (StatusRuntimeException e) {
1✔
645
      throw ErrorMapper.Error(e);
1✔
646
    }
647
  }
648

649
  @Override
650
  public ListWorkflowExecutionsResponse ScanWorkflowExecutions(
651
      ListWorkflowExecutionsRequest listRequest)
652
      throws BadRequestError, EntityNotExistsError, ServiceBusyError,
653
          ClientVersionNotSupportedError, TException {
654
    try {
655
      com.uber.cadence.api.v1.ScanWorkflowExecutionsResponse response =
1✔
656
          grpcServiceStubs
657
              .visibilityBlockingStub()
1✔
658
              .scanWorkflowExecutions(RequestMapper.scanWorkflowExecutionsRequest(listRequest));
1✔
659
      return ResponseMapper.scanWorkflowExecutionsResponse(response);
1✔
660
    } catch (StatusRuntimeException e) {
1✔
661
      throw ErrorMapper.Error(e);
1✔
662
    }
663
  }
664

665
  @Override
666
  public CountWorkflowExecutionsResponse CountWorkflowExecutions(
667
      CountWorkflowExecutionsRequest countRequest)
668
      throws BadRequestError, EntityNotExistsError, ServiceBusyError,
669
          ClientVersionNotSupportedError, TException {
670
    try {
671
      com.uber.cadence.api.v1.CountWorkflowExecutionsResponse response =
1✔
672
          grpcServiceStubs
673
              .visibilityBlockingStub()
1✔
674
              .countWorkflowExecutions(RequestMapper.countWorkflowExecutionsRequest(countRequest));
1✔
675
      return ResponseMapper.countWorkflowExecutionsResponse(response);
1✔
676
    } catch (StatusRuntimeException e) {
1✔
677
      throw ErrorMapper.Error(e);
1✔
678
    }
679
  }
680

681
  @Override
682
  public GetSearchAttributesResponse GetSearchAttributes()
683
      throws ServiceBusyError, ClientVersionNotSupportedError, TException {
684
    try {
685
      com.uber.cadence.api.v1.GetSearchAttributesResponse response =
1✔
686
          grpcServiceStubs
687
              .visibilityBlockingStub()
1✔
688
              .getSearchAttributes(GetSearchAttributesRequest.newBuilder().build());
1✔
689
      return ResponseMapper.getSearchAttributesResponse(response);
1✔
690
    } catch (StatusRuntimeException e) {
1✔
691
      throw ErrorMapper.Error(e);
1✔
692
    }
693
  }
694

695
  @Override
696
  public void RespondQueryTaskCompleted(RespondQueryTaskCompletedRequest completeRequest)
697
      throws BadRequestError, EntityNotExistsError, LimitExceededError, ServiceBusyError,
698
          DomainNotActiveError, ClientVersionNotSupportedError, TException {
699
    try {
700
      grpcServiceStubs
1✔
701
          .workerBlockingStub()
1✔
702
          .respondQueryTaskCompleted(
1✔
703
              RequestMapper.respondQueryTaskCompletedRequest(completeRequest));
1✔
704
    } catch (StatusRuntimeException e) {
1✔
705
      throw ErrorMapper.Error(e);
1✔
706
    }
1✔
707
  }
1✔
708

709
  @Override
710
  public ResetStickyTaskListResponse ResetStickyTaskList(ResetStickyTaskListRequest resetRequest)
711
      throws BadRequestError, EntityNotExistsError, LimitExceededError, ServiceBusyError,
712
          DomainNotActiveError, ClientVersionNotSupportedError,
713
          WorkflowExecutionAlreadyCompletedError, TException {
714
    try {
715
      com.uber.cadence.api.v1.ResetStickyTaskListResponse response =
1✔
716
          grpcServiceStubs
717
              .workerBlockingStub()
1✔
718
              .resetStickyTaskList(RequestMapper.resetStickyTaskListRequest(resetRequest));
1✔
719
      return new ResetStickyTaskListResponse();
1✔
720
    } catch (StatusRuntimeException e) {
1✔
721
      throw ErrorMapper.Error(e);
1✔
722
    }
723
  }
724

725
  @Override
726
  public QueryWorkflowResponse QueryWorkflow(QueryWorkflowRequest queryRequest)
727
      throws BadRequestError, EntityNotExistsError, QueryFailedError, LimitExceededError,
728
          ServiceBusyError, ClientVersionNotSupportedError, TException {
729
    try {
730
      com.uber.cadence.api.v1.QueryWorkflowResponse response =
1✔
731
          grpcServiceStubs
732
              .workflowBlockingStub()
1✔
733
              .queryWorkflow(RequestMapper.queryWorkflowRequest(queryRequest));
1✔
734
      return ResponseMapper.queryWorkflowResponse(response);
1✔
735
    } catch (StatusRuntimeException e) {
1✔
736
      throw ErrorMapper.Error(e);
1✔
737
    }
738
  }
739

740
  @Override
741
  public DescribeWorkflowExecutionResponse DescribeWorkflowExecution(
742
      DescribeWorkflowExecutionRequest describeRequest)
743
      throws BadRequestError, EntityNotExistsError, LimitExceededError, ServiceBusyError,
744
          ClientVersionNotSupportedError, TException {
745
    try {
746
      com.uber.cadence.api.v1.DescribeWorkflowExecutionResponse response =
1✔
747
          grpcServiceStubs
748
              .workflowBlockingStub()
1✔
749
              .describeWorkflowExecution(
1✔
750
                  RequestMapper.describeWorkflowExecutionRequest(describeRequest));
1✔
751
      return ResponseMapper.describeWorkflowExecutionResponse(response);
1✔
752
    } catch (StatusRuntimeException e) {
1✔
753
      throw ErrorMapper.Error(e);
1✔
754
    }
755
  }
756

757
  @Override
758
  public DescribeTaskListResponse DescribeTaskList(DescribeTaskListRequest request)
759
      throws BadRequestError, EntityNotExistsError, LimitExceededError, ServiceBusyError,
760
          ClientVersionNotSupportedError, TException {
761
    try {
762
      com.uber.cadence.api.v1.DescribeTaskListResponse response =
1✔
763
          grpcServiceStubs
764
              .workflowBlockingStub()
1✔
765
              .describeTaskList(RequestMapper.describeTaskListRequest(request));
1✔
766
      return ResponseMapper.describeTaskListResponse(response);
1✔
767
    } catch (StatusRuntimeException e) {
1✔
768
      throw ErrorMapper.Error(e);
1✔
769
    }
770
  }
771

772
  @Override
773
  public ClusterInfo GetClusterInfo() throws InternalServiceError, ServiceBusyError, TException {
774
    try {
775
      com.uber.cadence.api.v1.GetClusterInfoResponse response =
1✔
776
          grpcServiceStubs
777
              .workflowBlockingStub()
1✔
778
              .getClusterInfo(com.uber.cadence.api.v1.GetClusterInfoRequest.newBuilder().build());
1✔
779
      return ResponseMapper.getClusterInfoResponse(response);
1✔
780
    } catch (StatusRuntimeException e) {
1✔
781
      throw ErrorMapper.Error(e);
1✔
782
    }
783
  }
784

785
  @Override
786
  public GetTaskListsByDomainResponse GetTaskListsByDomain(GetTaskListsByDomainRequest request) {
787
    throw new UnsupportedOperationException("not implemented");
×
788
  }
789

790
  @Override
791
  public ListTaskListPartitionsResponse ListTaskListPartitions(
792
      ListTaskListPartitionsRequest request)
793
      throws BadRequestError, EntityNotExistsError, LimitExceededError, ServiceBusyError,
794
          TException {
795
    try {
796
      com.uber.cadence.api.v1.ListTaskListPartitionsResponse response =
1✔
797
          grpcServiceStubs
798
              .workflowBlockingStub()
1✔
799
              .listTaskListPartitions(RequestMapper.listTaskListPartitionsRequest(request));
1✔
800
      return ResponseMapper.listTaskListPartitionsResponse(response);
1✔
801
    } catch (StatusRuntimeException e) {
1✔
802
      throw ErrorMapper.Error(e);
1✔
803
    }
804
  }
805

806
  @Override
807
  public void RefreshWorkflowTasks(RefreshWorkflowTasksRequest request)
808
      throws BadRequestError, DomainNotActiveError, ServiceBusyError, EntityNotExistsError,
809
          TException {
810
    try {
811
      grpcServiceStubs
1✔
812
          .workflowBlockingStub()
1✔
813
          .refreshWorkflowTasks(
1✔
814
              com.uber.cadence.api.v1.RefreshWorkflowTasksRequest.newBuilder().build());
1✔
815
    } catch (StatusRuntimeException e) {
1✔
816
      throw ErrorMapper.Error(e);
1✔
817
    }
1✔
818
  }
1✔
819

820
  @Override
821
  public void RegisterDomain(
822
      RegisterDomainRequest registerRequest, AsyncMethodCallback resultHandler) throws TException {
823
    throw new UnsupportedOperationException("not implemented");
1✔
824
  }
825

826
  @Override
827
  public void DescribeDomain(
828
      DescribeDomainRequest describeRequest, AsyncMethodCallback resultHandler) throws TException {
829
    throw new UnsupportedOperationException("not implemented");
1✔
830
  }
831

832
  @Override
833
  public void ListDomains(ListDomainsRequest listRequest, AsyncMethodCallback resultHandler)
834
      throws TException {
835
    throw new UnsupportedOperationException("not implemented");
1✔
836
  }
837

838
  @Override
839
  public void UpdateDomain(UpdateDomainRequest updateRequest, AsyncMethodCallback resultHandler)
840
      throws TException {
841
    throw new UnsupportedOperationException("not implemented");
1✔
842
  }
843

844
  @Override
845
  public void DeprecateDomain(
846
      DeprecateDomainRequest deprecateRequest, AsyncMethodCallback resultHandler)
847
      throws TException {
848
    throw new UnsupportedOperationException("not implemented");
1✔
849
  }
850

851
  @Override
852
  public void RestartWorkflowExecution(
853
      RestartWorkflowExecutionRequest restartRequest, AsyncMethodCallback resultHandler)
854
      throws TException {
855
    throw new UnsupportedOperationException("unimplemented");
1✔
856
  }
857

858
  @Override
859
  public void StartWorkflowExecution(
860
      StartWorkflowExecutionRequest startRequest, AsyncMethodCallback resultHandler)
861
      throws TException {
862
    throw new UnsupportedOperationException("not implemented");
1✔
863
  }
864

865
  @Override
866
  public void StartWorkflowExecutionAsync(
867
      StartWorkflowExecutionAsyncRequest startRequest, AsyncMethodCallback resultHandler)
868
      throws TException {
869
    try {
870
      initializeStartWorkflowExecutionRequest(startRequest.getRequest());
1✔
871
      ListenableFuture<com.uber.cadence.api.v1.StartWorkflowExecutionAsyncResponse> resultFuture =
1✔
872
          grpcServiceStubs
873
              .workflowFutureStub()
1✔
874
              .startWorkflowExecutionAsync(
1✔
875
                  RequestMapper.startWorkflowExecutionAsyncRequest(startRequest));
1✔
876
      resultFuture.addListener(
1✔
877
          () -> {
878
            try {
879
              com.uber.cadence.api.v1.StartWorkflowExecutionAsyncResponse response =
1✔
880
                  resultFuture.get();
1✔
881
              resultHandler.onComplete(
1✔
882
                  ResponseMapper.startWorkflowExecutionAsyncResponse(response));
1✔
883
            } catch (Exception e) {
1✔
884
              handleException(resultHandler, e);
1✔
885
            }
1✔
886
          },
1✔
887
          ForkJoinPool.commonPool());
1✔
888
    } catch (StatusRuntimeException e) {
×
889
      throw ErrorMapper.Error(e);
×
890
    }
1✔
891
  }
1✔
892

893
  @Override
894
  public void GetWorkflowExecutionHistory(
895
      GetWorkflowExecutionHistoryRequest getRequest, AsyncMethodCallback resultHandler)
896
      throws TException {
897
    throw new UnsupportedOperationException("not implemented");
1✔
898
  }
899

900
  @Override
901
  public void PollForDecisionTask(
902
      PollForDecisionTaskRequest pollRequest, AsyncMethodCallback resultHandler) throws TException {
903
    throw new UnsupportedOperationException("not implemented");
1✔
904
  }
905

906
  @Override
907
  public void RespondDecisionTaskCompleted(
908
      RespondDecisionTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
909
      throws TException {
910
    throw new UnsupportedOperationException("not implemented");
1✔
911
  }
912

913
  @Override
914
  public void RespondDecisionTaskFailed(
915
      RespondDecisionTaskFailedRequest failedRequest, AsyncMethodCallback resultHandler)
916
      throws TException {
917
    throw new UnsupportedOperationException("not implemented");
1✔
918
  }
919

920
  @Override
921
  public void PollForActivityTask(
922
      PollForActivityTaskRequest pollRequest, AsyncMethodCallback resultHandler) throws TException {
923
    throw new UnsupportedOperationException("not implemented");
1✔
924
  }
925

926
  @Override
927
  public void RecordActivityTaskHeartbeat(
928
      RecordActivityTaskHeartbeatRequest heartbeatRequest, AsyncMethodCallback resultHandler)
929
      throws TException {
930
    throw new UnsupportedOperationException("not implemented");
1✔
931
  }
932

933
  @Override
934
  public void RecordActivityTaskHeartbeatByID(
935
      RecordActivityTaskHeartbeatByIDRequest heartbeatRequest, AsyncMethodCallback resultHandler)
936
      throws TException {
937
    throw new UnsupportedOperationException("not implemented");
1✔
938
  }
939

940
  @Override
941
  public void RespondActivityTaskCompleted(
942
      RespondActivityTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
943
      throws TException {
944
    throw new UnsupportedOperationException("not implemented");
1✔
945
  }
946

947
  @Override
948
  public void RespondActivityTaskCompletedByID(
949
      RespondActivityTaskCompletedByIDRequest completeRequest, AsyncMethodCallback resultHandler)
950
      throws TException {
951
    throw new UnsupportedOperationException("not implemented");
1✔
952
  }
953

954
  @Override
955
  public void RespondActivityTaskFailed(
956
      RespondActivityTaskFailedRequest failRequest, AsyncMethodCallback resultHandler)
957
      throws TException {
958
    throw new UnsupportedOperationException("not implemented");
1✔
959
  }
960

961
  @Override
962
  public void RespondActivityTaskFailedByID(
963
      RespondActivityTaskFailedByIDRequest failRequest, AsyncMethodCallback resultHandler)
964
      throws TException {
965
    throw new UnsupportedOperationException("not implemented");
1✔
966
  }
967

968
  @Override
969
  public void RespondActivityTaskCanceled(
970
      RespondActivityTaskCanceledRequest canceledRequest, AsyncMethodCallback resultHandler)
971
      throws TException {
972
    throw new UnsupportedOperationException("not implemented");
1✔
973
  }
974

975
  @Override
976
  public void RespondActivityTaskCanceledByID(
977
      RespondActivityTaskCanceledByIDRequest canceledRequest, AsyncMethodCallback resultHandler)
978
      throws TException {
979
    throw new UnsupportedOperationException("not implemented");
1✔
980
  }
981

982
  @Override
983
  public void RequestCancelWorkflowExecution(
984
      RequestCancelWorkflowExecutionRequest cancelRequest, AsyncMethodCallback resultHandler)
985
      throws TException {
986
    throw new UnsupportedOperationException("not implemented");
1✔
987
  }
988

989
  @Override
990
  public void SignalWorkflowExecution(
991
      SignalWorkflowExecutionRequest signalRequest, AsyncMethodCallback resultHandler)
992
      throws TException {
993
    try {
994
      if (!signalRequest.isSetRequestId()) {
1✔
995
        signalRequest.setRequestId(UUID.randomUUID().toString());
×
996
      }
997
      ListenableFuture<com.uber.cadence.api.v1.SignalWorkflowExecutionResponse> resultFuture =
1✔
998
          grpcServiceStubs
999
              .workflowFutureStub()
1✔
1000
              .signalWorkflowExecution(RequestMapper.signalWorkflowExecutionRequest(signalRequest));
1✔
1001
      resultFuture.addListener(
1✔
1002
          () -> {
1003
            try {
1004
              com.uber.cadence.api.v1.SignalWorkflowExecutionResponse response = resultFuture.get();
1✔
1005
              resultHandler.onComplete(null);
1✔
1006
            } catch (Exception e) {
1✔
1007
              handleException(resultHandler, e);
1✔
1008
            }
1✔
1009
          },
1✔
1010
          ForkJoinPool.commonPool());
1✔
1011
    } catch (StatusRuntimeException e) {
×
1012
      throw ErrorMapper.Error(e);
×
1013
    }
1✔
1014
  }
1✔
1015

1016
  @Override
1017
  public void SignalWithStartWorkflowExecution(
1018
      SignalWithStartWorkflowExecutionRequest signalWithStartRequest,
1019
      AsyncMethodCallback resultHandler)
1020
      throws TException {
1021
    throw new UnsupportedOperationException("not implemented");
1✔
1022
  }
1023

1024
  @Override
1025
  public void SignalWithStartWorkflowExecutionAsync(
1026
      SignalWithStartWorkflowExecutionAsyncRequest signalWithStartRequest,
1027
      AsyncMethodCallback resultHandler)
1028
      throws TException {
1029
    throw new UnsupportedOperationException("unimplemented");
1✔
1030
  }
1031

1032
  @Override
1033
  public void ResetWorkflowExecution(
1034
      ResetWorkflowExecutionRequest resetRequest, AsyncMethodCallback resultHandler)
1035
      throws TException {
1036
    throw new UnsupportedOperationException("not implemented");
1✔
1037
  }
1038

1039
  @Override
1040
  public void TerminateWorkflowExecution(
1041
      TerminateWorkflowExecutionRequest terminateRequest, AsyncMethodCallback resultHandler)
1042
      throws TException {
1043
    throw new UnsupportedOperationException("not implemented");
1✔
1044
  }
1045

1046
  @Override
1047
  public void ListOpenWorkflowExecutions(
1048
      ListOpenWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
1049
      throws TException {
1050
    throw new UnsupportedOperationException("not implemented");
1✔
1051
  }
1052

1053
  @Override
1054
  public void ListClosedWorkflowExecutions(
1055
      ListClosedWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
1056
      throws TException {
1057
    throw new UnsupportedOperationException("not implemented");
1✔
1058
  }
1059

1060
  @Override
1061
  public void ListWorkflowExecutions(
1062
      ListWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
1063
      throws TException {
1064
    throw new UnsupportedOperationException("not implemented");
1✔
1065
  }
1066

1067
  @Override
1068
  public void ListArchivedWorkflowExecutions(
1069
      ListArchivedWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
1070
      throws TException {
1071
    throw new UnsupportedOperationException("not implemented");
1✔
1072
  }
1073

1074
  @Override
1075
  public void ScanWorkflowExecutions(
1076
      ListWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
1077
      throws TException {
1078
    throw new UnsupportedOperationException("not implemented");
1✔
1079
  }
1080

1081
  @Override
1082
  public void CountWorkflowExecutions(
1083
      CountWorkflowExecutionsRequest countRequest, AsyncMethodCallback resultHandler)
1084
      throws TException {
1085
    throw new UnsupportedOperationException("not implemented");
1✔
1086
  }
1087

1088
  @Override
1089
  public void GetSearchAttributes(AsyncMethodCallback resultHandler) throws TException {
1090
    throw new UnsupportedOperationException("not implemented");
×
1091
  }
1092

1093
  @Override
1094
  public void RespondQueryTaskCompleted(
1095
      RespondQueryTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
1096
      throws TException {
1097
    throw new UnsupportedOperationException("not implemented");
1✔
1098
  }
1099

1100
  @Override
1101
  public void ResetStickyTaskList(
1102
      ResetStickyTaskListRequest resetRequest, AsyncMethodCallback resultHandler)
1103
      throws TException {
1104
    throw new UnsupportedOperationException("not implemented");
1✔
1105
  }
1106

1107
  @Override
1108
  public void QueryWorkflow(QueryWorkflowRequest queryRequest, AsyncMethodCallback resultHandler)
1109
      throws TException {
1110
    throw new UnsupportedOperationException("not implemented");
1✔
1111
  }
1112

1113
  @Override
1114
  public void DescribeWorkflowExecution(
1115
      DescribeWorkflowExecutionRequest describeRequest, AsyncMethodCallback resultHandler)
1116
      throws TException {
1117
    throw new UnsupportedOperationException("not implemented");
1✔
1118
  }
1119

1120
  @Override
1121
  public void DescribeTaskList(DescribeTaskListRequest request, AsyncMethodCallback resultHandler)
1122
      throws TException {
1123
    throw new UnsupportedOperationException("not implemented");
1✔
1124
  }
1125

1126
  @Override
1127
  public void GetClusterInfo(AsyncMethodCallback resultHandler) throws TException {
1128
    throw new UnsupportedOperationException("not implemented");
×
1129
  }
1130

1131
  @Override
1132
  public void GetTaskListsByDomain(
1133
      GetTaskListsByDomainRequest request, AsyncMethodCallback resultHandler) throws TException {
1134
    throw new UnsupportedOperationException("not implemented");
1✔
1135
  }
1136

1137
  @Override
1138
  public void ListTaskListPartitions(
1139
      ListTaskListPartitionsRequest request, AsyncMethodCallback resultHandler) throws TException {
1140
    throw new UnsupportedOperationException("not implemented");
1✔
1141
  }
1142

1143
  @Override
1144
  public void RefreshWorkflowTasks(
1145
      RefreshWorkflowTasksRequest request, AsyncMethodCallback resultHandler) throws TException {
1146
    throw new UnsupportedOperationException("not implemented");
1✔
1147
  }
1148

1149
  @Override
1150
  public void close() {
1151
    grpcServiceStubs.shutdownNow();
×
1152
  }
×
1153

1154
  @Override
1155
  public CompletableFuture<Boolean> isHealthy() {
1156
    ListenableFuture<HealthResponse> listenableFuture =
1✔
1157
        grpcServiceStubs.metaFutureStub().health(HealthRequest.newBuilder().build());
1✔
1158
    CompletableFuture<Boolean> completable =
1✔
1159
        new CompletableFuture<Boolean>() {
1✔
1160
          @Override
1161
          public boolean cancel(boolean mayInterruptIfRunning) {
1162
            boolean result = listenableFuture.cancel(mayInterruptIfRunning);
×
1163
            super.cancel(mayInterruptIfRunning);
×
1164
            return result;
×
1165
          }
1166
        };
1167
    Futures.addCallback(
1✔
1168
        listenableFuture,
1169
        new FutureCallback<HealthResponse>() {
1✔
1170
          @Override
1171
          public void onSuccess(HealthResponse result) {
1172
            completable.complete(true);
1✔
1173
          }
1✔
1174

1175
          @Override
1176
          public void onFailure(Throwable t) {
1177
            completable.completeExceptionally(t);
×
1178
          }
×
1179
        },
1180
        ForkJoinPool.commonPool());
1✔
1181
    return completable;
1✔
1182
  }
1183

1184
  @Override
1185
  public void StartWorkflowExecutionWithTimeout(
1186
      StartWorkflowExecutionRequest startRequest,
1187
      AsyncMethodCallback resultHandler,
1188
      Long timeoutInMillis)
1189
      throws TException {
1190
    try {
1191
      initializeStartWorkflowExecutionRequest(startRequest);
1✔
1192
      ListenableFuture<com.uber.cadence.api.v1.StartWorkflowExecutionResponse> resultFuture =
1✔
1193
          grpcServiceStubs
1194
              .workflowFutureStub()
1✔
1195
              .withDeadline(Deadline.after(timeoutInMillis, TimeUnit.MILLISECONDS))
1✔
1196
              .startWorkflowExecution(RequestMapper.startWorkflowExecutionRequest(startRequest));
1✔
1197
      resultFuture.addListener(
1✔
1198
          () -> {
1199
            try {
1200
              com.uber.cadence.api.v1.StartWorkflowExecutionResponse response = resultFuture.get();
1✔
1201
              resultHandler.onComplete(ResponseMapper.startWorkflowExecutionResponse(response));
1✔
1202
            } catch (Exception e) {
1✔
1203
              handleException(resultHandler, e);
1✔
1204
            }
1✔
1205
          },
1✔
1206
          ForkJoinPool.commonPool());
1✔
1207
    } catch (StatusRuntimeException e) {
×
1208
      throw ErrorMapper.Error(e);
×
1209
    }
1✔
1210
  }
1✔
1211

1212
  @Override
1213
  public void StartWorkflowExecutionAsyncWithTimeout(
1214
      StartWorkflowExecutionAsyncRequest startAsyncRequest,
1215
      AsyncMethodCallback resultHandler,
1216
      Long timeoutInMillis)
1217
      throws TException {
1218
    try {
1219
      initializeStartWorkflowExecutionRequest(startAsyncRequest.getRequest());
1✔
1220
      ListenableFuture<com.uber.cadence.api.v1.StartWorkflowExecutionAsyncResponse> resultFuture =
1✔
1221
          grpcServiceStubs
1222
              .workflowFutureStub()
1✔
1223
              .withDeadline(Deadline.after(timeoutInMillis, TimeUnit.MILLISECONDS))
1✔
1224
              .startWorkflowExecutionAsync(
1✔
1225
                  RequestMapper.startWorkflowExecutionAsyncRequest(startAsyncRequest));
1✔
1226
      resultFuture.addListener(
1✔
1227
          () -> {
1228
            try {
1229
              com.uber.cadence.api.v1.StartWorkflowExecutionAsyncResponse response =
1✔
1230
                  resultFuture.get();
1✔
1231
              resultHandler.onComplete(
1✔
1232
                  ResponseMapper.startWorkflowExecutionAsyncResponse(response));
1✔
1233
            } catch (Exception e) {
1✔
1234
              handleException(resultHandler, e);
1✔
1235
            }
1✔
1236
          },
1✔
1237
          ForkJoinPool.commonPool());
1✔
1238
    } catch (StatusRuntimeException e) {
×
1239
      throw ErrorMapper.Error(e);
×
1240
    }
1✔
1241
  }
1✔
1242

1243
  @Override
1244
  public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistoryWithTimeout(
1245
      GetWorkflowExecutionHistoryRequest getRequest, Long timeoutInMillis) throws TException {
1246
    try {
1247
      com.uber.cadence.api.v1.GetWorkflowExecutionHistoryResponse response =
1✔
1248
          grpcServiceStubs
1249
              .workflowBlockingStub()
1✔
1250
              .withDeadline(Deadline.after(timeoutInMillis, TimeUnit.MILLISECONDS))
1✔
1251
              .getWorkflowExecutionHistory(
1✔
1252
                  RequestMapper.getWorkflowExecutionHistoryRequest(getRequest));
1✔
1253
      return ResponseMapper.getWorkflowExecutionHistoryResponse(response);
1✔
1254
    } catch (StatusRuntimeException e) {
1✔
1255
      throw ErrorMapper.Error(e);
1✔
1256
    }
1257
  }
1258

1259
  @Override
1260
  public void GetWorkflowExecutionHistoryWithTimeout(
1261
      GetWorkflowExecutionHistoryRequest getRequest,
1262
      AsyncMethodCallback resultHandler,
1263
      Long timeoutInMillis)
1264
      throws TException {
1265
    try {
1266
      ListenableFuture<com.uber.cadence.api.v1.GetWorkflowExecutionHistoryResponse> resultFuture =
1✔
1267
          grpcServiceStubs
1268
              .workflowFutureStub()
1✔
1269
              .withDeadline(Deadline.after(timeoutInMillis, TimeUnit.MILLISECONDS))
1✔
1270
              .getWorkflowExecutionHistory(
1✔
1271
                  RequestMapper.getWorkflowExecutionHistoryRequest(getRequest));
1✔
1272
      resultFuture.addListener(
1✔
1273
          () -> {
1274
            try {
1275
              com.uber.cadence.api.v1.GetWorkflowExecutionHistoryResponse response =
1✔
1276
                  resultFuture.get();
1✔
1277
              resultHandler.onComplete(
1✔
1278
                  ResponseMapper.getWorkflowExecutionHistoryResponse(response));
1✔
1279
            } catch (Exception e) {
1✔
1280
              handleException(resultHandler, e);
1✔
1281
            }
1✔
1282
          },
1✔
1283
          ForkJoinPool.commonPool());
1✔
1284
    } catch (StatusRuntimeException e) {
×
1285
      throw ErrorMapper.Error(e);
×
1286
    }
1✔
1287
  }
1✔
1288

1289
  @Override
1290
  public void SignalWorkflowExecutionWithTimeout(
1291
      SignalWorkflowExecutionRequest signalRequest,
1292
      AsyncMethodCallback resultHandler,
1293
      Long timeoutInMillis)
1294
      throws TException {
1295
    throw new UnsupportedOperationException("not implemented");
×
1296
  }
1297

1298
  private void handleException(AsyncMethodCallback callback, Exception exception) {
1299
    if (exception instanceof ExecutionException
1✔
1300
        && exception.getCause() instanceof StatusRuntimeException) {
1✔
1301
      callback.onError(ErrorMapper.Error(((StatusRuntimeException) exception.getCause())));
1✔
1302
    } else {
NEW
1303
      callback.onError(exception);
×
1304
    }
1305
  }
1✔
1306
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc