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

uber / cadence-java-client / 2632

07 Nov 2024 12:17AM UTC coverage: 78.326% (-1.5%) from 79.78%
2632

Pull #951

buildkite

fimanishi
Add tests for PollerOptions.java
Pull Request #951: Add tests for PollerOptions.java

15185 of 19387 relevant lines covered (78.33%)

0.78 hits per line

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

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

18
package com.uber.cadence.serviceclient;
19

20
import static com.uber.cadence.internal.metrics.MetricsTagValue.REQUEST_TYPE_LONG_POLL;
21
import static com.uber.cadence.internal.metrics.MetricsTagValue.REQUEST_TYPE_NORMAL;
22

23
import com.google.common.base.Strings;
24
import com.google.common.collect.ImmutableMap;
25
import com.google.gson.Gson;
26
import com.google.gson.GsonBuilder;
27
import com.uber.cadence.*;
28
import com.uber.cadence.WorkflowService.GetWorkflowExecutionHistory_result;
29
import com.uber.cadence.internal.Version;
30
import com.uber.cadence.internal.common.CheckedExceptionWrapper;
31
import com.uber.cadence.internal.common.InternalUtils;
32
import com.uber.cadence.internal.metrics.MetricsTag;
33
import com.uber.cadence.internal.metrics.MetricsType;
34
import com.uber.cadence.internal.metrics.ServiceMethod;
35
import com.uber.cadence.internal.tracing.TracingPropagator;
36
import com.uber.m3.tally.Scope;
37
import com.uber.m3.tally.Stopwatch;
38
import com.uber.tchannel.api.ResponseCode;
39
import com.uber.tchannel.api.SubChannel;
40
import com.uber.tchannel.api.TChannel;
41
import com.uber.tchannel.api.TFuture;
42
import com.uber.tchannel.api.errors.TChannelError;
43
import com.uber.tchannel.errors.ErrorType;
44
import com.uber.tchannel.messages.ThriftRequest;
45
import com.uber.tchannel.messages.ThriftResponse;
46
import com.uber.tchannel.messages.generated.Meta;
47
import io.opentelemetry.api.GlobalOpenTelemetry;
48
import io.opentelemetry.context.Context;
49
import io.opentelemetry.context.propagation.TextMapPropagator;
50
import io.opentelemetry.context.propagation.TextMapSetter;
51
import io.opentracing.Span;
52
import io.opentracing.Tracer;
53
import java.net.InetAddress;
54
import java.net.InetSocketAddress;
55
import java.net.UnknownHostException;
56
import java.nio.charset.StandardCharsets;
57
import java.util.ArrayList;
58
import java.util.HashMap;
59
import java.util.Map;
60
import java.util.UUID;
61
import java.util.concurrent.CompletableFuture;
62
import java.util.concurrent.ExecutionException;
63
import org.apache.thrift.TException;
64
import org.apache.thrift.async.AsyncMethodCallback;
65
import org.apache.thrift.transport.TTransportException;
66
import org.slf4j.Logger;
67
import org.slf4j.LoggerFactory;
68

69
public class WorkflowServiceTChannel implements IWorkflowService {
70
  private static final Logger log = LoggerFactory.getLogger(WorkflowServiceTChannel.class);
1✔
71

72
  private static final String INTERFACE_NAME = "WorkflowService";
73

74
  private final ClientOptions options;
75
  private final Map<String, String> thriftHeaders;
76
  private final TChannel tChannel;
77
  private final TracingPropagator tracingPropagator;
78
  private final Tracer tracer;
79
  private final SubChannel subChannel;
80

81
  /**
82
   * Creates Cadence client that connects to the specified host and port using specified options.
83
   *
84
   * @param options configuration options like rpc timeouts.
85
   */
86
  public WorkflowServiceTChannel(ClientOptions options) {
1✔
87
    this.options = options;
1✔
88
    this.thriftHeaders = getThriftHeaders(options);
1✔
89
    this.tChannel = new TChannel.Builder(options.getClientAppName()).build();
1✔
90
    this.tracingPropagator = new TracingPropagator(options.getTracer());
1✔
91
    this.tracer = options.getTracer();
1✔
92

93
    InetAddress address;
94
    try {
95
      address = InetAddress.getByName(options.getHost());
1✔
96
    } catch (UnknownHostException e) {
×
97
      tChannel.shutdown();
×
98
      throw new RuntimeException("Unable to get name of host " + options.getHost(), e);
×
99
    }
1✔
100

101
    ArrayList<InetSocketAddress> peers = new ArrayList<>();
1✔
102
    peers.add(new InetSocketAddress(address, options.getPort()));
1✔
103
    this.subChannel = tChannel.makeSubChannel(options.getServiceName()).setPeers(peers);
1✔
104
    log.info(
1✔
105
        "Initialized TChannel for service "
106
            + this.subChannel.getServiceName()
1✔
107
            + ", LibraryVersion: "
108
            + Version.LIBRARY_VERSION
109
            + ", FeatureVersion: "
110
            + Version.FEATURE_VERSION);
111
  }
1✔
112

113
  public void resetSubchannelPeers() throws UnknownHostException {
114
    InetAddress address = InetAddress.getByName(options.getHost());
×
115
    ArrayList<InetSocketAddress> peers = new ArrayList<>();
×
116
    peers.add(new InetSocketAddress(address, options.getPort()));
×
117
    this.subChannel.setPeers(peers);
×
118
  }
×
119

120
  /**
121
   * Creates Cadence client with specified sub channel and options.
122
   *
123
   * @param subChannel sub channel for communicating with cadence frontend service.
124
   * @param options configuration options like rpc timeouts.
125
   */
126
  public WorkflowServiceTChannel(SubChannel subChannel, ClientOptions options) {
1✔
127
    this.options = options;
1✔
128
    this.thriftHeaders = getThriftHeaders(options);
1✔
129
    this.tChannel = null;
1✔
130
    this.subChannel = subChannel;
1✔
131
    this.tracingPropagator = new TracingPropagator(options.getTracer());
1✔
132
    this.tracer = options.getTracer();
1✔
133
  }
1✔
134

135
  private static Map<String, String> getThriftHeaders(ClientOptions options) {
136
    String envUserName = System.getProperty("user.name");
1✔
137
    String envHostname;
138
    try {
139
      envHostname = InetAddress.getLocalHost().getHostName();
1✔
140
    } catch (UnknownHostException e) {
×
141
      envHostname = "localhost";
×
142
    }
1✔
143

144
    ImmutableMap.Builder<String, String> builder =
145
        ImmutableMap.<String, String>builder()
1✔
146
            .put("user-name", envUserName)
1✔
147
            .put("host-name", envHostname)
1✔
148
            .put("cadence-client-library-version", Version.LIBRARY_VERSION)
1✔
149
            .put("cadence-client-feature-version", Version.FEATURE_VERSION)
1✔
150
            .put("cadence-client-name", "uber-java");
1✔
151

152
    if (options.getHeaders() != null) {
1✔
153
      for (Map.Entry<String, String> entry : options.getHeaders().entrySet()) {
1✔
154
        builder.put(entry.getKey(), entry.getValue());
×
155
      }
×
156
    }
157

158
    if (options.getFeatureFlags() != null) {
1✔
159
      GsonBuilder gsonBuilder = new GsonBuilder();
1✔
160
      Gson gson = gsonBuilder.create();
1✔
161
      String serialized = gson.toJson(options.getFeatureFlags());
1✔
162
      builder.put("cadence-client-feature-flags", serialized);
1✔
163
    }
164

165
    if (!Strings.isNullOrEmpty(options.getIsolationGroup())) {
1✔
166
      builder.put("cadence-client-isolation-group", options.getIsolationGroup());
×
167
    }
168

169
    return builder.build();
1✔
170
  }
171

172
  /** Returns the endpoint in the format service::method" */
173
  private static String getEndpoint(String service, String method) {
174
    return String.format("%s::%s", service, method);
1✔
175
  }
176

177
  private <T> ThriftRequest<T> buildThriftRequest(String apiName, T body) {
178
    return buildThriftRequest(apiName, body, null);
1✔
179
  }
180

181
  @Override
182
  public ClientOptions getOptions() {
183
    return options;
1✔
184
  }
185

186
  /**
187
   * Checks if we have a valid connection to the Cadence cluster, and potentially resets the peer
188
   * list
189
   */
190
  @Override
191
  public CompletableFuture<Boolean> isHealthy() {
192
    final ThriftRequest<Meta.health_args> req =
1✔
193
        new ThriftRequest.Builder<Meta.health_args>(options.getServiceName(), "Meta::health")
1✔
194
            .setBody(new Meta.health_args())
1✔
195
            .build();
1✔
196
    final CompletableFuture<Boolean> result = new CompletableFuture<>();
1✔
197
    try {
198

199
      final TFuture<ThriftResponse<Meta.health_result>> future = this.subChannel.send(req);
1✔
200
      future.addCallback(
1✔
201
          response -> {
202
            req.releaseQuietly();
1✔
203
            if (response.isError()) {
1✔
204
              try {
205
                this.resetSubchannelPeers();
×
206
              } catch (final Exception inner_e) {
×
207
              }
×
208
              result.completeExceptionally(new TException("Rpc error:" + response.getError()));
×
209
            } else {
210
              result.complete(response.getBody(Meta.health_result.class).getSuccess().isOk());
1✔
211
            }
212
            try {
213
              response.release();
1✔
214
            } catch (final Exception e) {
×
215
              // ignore
216
            }
1✔
217
          });
1✔
218
    } catch (final TChannelError e) {
×
219
      req.releaseQuietly();
×
220
      try {
221
        this.resetSubchannelPeers();
×
222
      } catch (final Exception inner_e) {
×
223
      }
×
224
      result.complete(Boolean.FALSE);
×
225
    }
1✔
226
    return result;
1✔
227
  }
228

229
  protected <T> ThriftRequest<T> buildThriftRequest(
230
      String apiName, T body, Long rpcTimeoutOverride) {
231
    String endpoint = getEndpoint(INTERFACE_NAME, apiName);
1✔
232
    ThriftRequest.Builder<T> builder =
1✔
233
        new ThriftRequest.Builder<>(options.getServiceName(), endpoint);
1✔
234
    // Create a mutable hashmap for headers, as tchannel.tracing.PrefixedHeadersCarrier assumes
235
    // that it can call put directly to add new stuffs (e.g. traces).
236
    final HashMap<String, String> headers = new HashMap<>(thriftHeaders);
1✔
237
    TextMapPropagator textMapPropagator =
238
        GlobalOpenTelemetry.getPropagators().getTextMapPropagator();
1✔
239

240
    String tracingHeadersPrefix = "$tracing$";
1✔
241
    TextMapSetter<Map<String, String>> setter =
1✔
242
        (carrier, key, value) -> {
243
          if (carrier != null) {
×
244
            carrier.put(tracingHeadersPrefix + key, value);
×
245
          }
246
        };
×
247

248
    textMapPropagator.inject(Context.current(), headers, setter);
1✔
249

250
    if (this.options.getAuthProvider() != null) {
1✔
251
      headers.put(
×
252
          "cadence-authorization",
253
          new String(options.getAuthProvider().getAuthToken(), StandardCharsets.UTF_8));
×
254
    }
255
    builder.setHeaders(headers);
1✔
256

257
    if (rpcTimeoutOverride != null) {
1✔
258
      builder.setTimeout(rpcTimeoutOverride);
1✔
259
    } else {
260
      builder.setTimeout(this.options.getRpcTimeoutMillis());
1✔
261
    }
262
    for (Map.Entry<String, String> header : this.options.getTransportHeaders().entrySet()) {
1✔
263
      builder.setTransportHeader(header.getKey(), header.getValue());
×
264
    }
×
265
    builder.setBody(body);
1✔
266
    return builder.build();
1✔
267
  }
268

269
  private <T> ThriftResponse<T> doRemoteCall(ThriftRequest<?> request) throws TException {
270
    ThriftResponse<T> response = null;
1✔
271
    try {
272
      TFuture<ThriftResponse<T>> future = subChannel.send(request);
1✔
273
      response = future.get();
1✔
274
    } catch (InterruptedException e) {
1✔
275
      Thread.currentThread().interrupt();
1✔
276
      throw new TException(e);
1✔
277
    } catch (ExecutionException e) {
×
278
      throw new TException(e);
×
279
    } catch (TChannelError e) {
×
280
      throw new TException("Rpc error", e);
×
281
    }
1✔
282
    this.throwOnRpcError(response);
1✔
283
    return response;
1✔
284
  }
285

286
  private <T> CompletableFuture<ThriftResponse<T>> doRemoteCallAsync(ThriftRequest<?> request) {
287
    final CompletableFuture<ThriftResponse<T>> result = new CompletableFuture<>();
1✔
288
    TFuture<ThriftResponse<T>> future = null;
1✔
289
    try {
290
      future = subChannel.send(request);
1✔
291
    } catch (TChannelError tChannelError) {
×
292
      result.completeExceptionally(new TException(tChannelError));
×
293
    }
1✔
294
    future.addCallback(
1✔
295
        response -> {
296
          if (response.isError()) {
1✔
297
            result.completeExceptionally(new TException("Rpc error:" + response.getError()));
×
298
          } else {
299
            result.complete(response);
1✔
300
          }
301
        });
1✔
302
    return result;
1✔
303
  }
304

305
  private void throwOnRpcError(ThriftResponse<?> response) throws TException {
306
    if (response.isError()) {
1✔
307
      if (response.getError().getErrorType() == ErrorType.Timeout) {
×
308
        throw new TTransportException(
×
309
            TTransportException.TIMED_OUT, response.getError().getMessage());
×
310
      } else {
311
        throw new TException("Rpc error:" + response.getError());
×
312
      }
313
    }
314
  }
1✔
315

316
  @Override
317
  public void close() {
318
    if (tChannel != null) {
1✔
319
      tChannel.shutdown();
1✔
320
    }
321
  }
1✔
322

323
  interface RemoteCall<T> {
324
    T apply() throws TException;
325
  }
326

327
  private <T> T measureRemoteCall(String scopeName, RemoteCall<T> call) throws TException {
328
    return measureRemoteCallWithTags(scopeName, call, null);
1✔
329
  }
330

331
  private <T> T measureRemoteCallWithTags(
332
      String scopeName, RemoteCall<T> call, Map<String, String> tags) throws TException {
333
    Scope scope = options.getMetricsScope().subScope(scopeName);
1✔
334
    if (tags != null) {
1✔
335
      scope = scope.tagged(tags);
1✔
336
    }
337
    scope.counter(MetricsType.CADENCE_REQUEST).inc(1);
1✔
338
    Stopwatch sw = scope.timer(MetricsType.CADENCE_LATENCY).start();
1✔
339

340
    Span span = tracingPropagator.spanByServiceMethod(scopeName);
1✔
341
    try (io.opentracing.Scope tracingScope = tracer.activateSpan(span)) {
1✔
342
      T resp = call.apply();
1✔
343
      sw.stop();
1✔
344
      return resp;
1✔
345
    } catch (EntityNotExistsError
1✔
346
        | WorkflowExecutionAlreadyCompletedError
347
        | BadRequestError
348
        | DomainAlreadyExistsError
349
        | WorkflowExecutionAlreadyStartedError
350
        | QueryFailedError e) {
351
      sw.stop();
1✔
352
      scope.counter(MetricsType.CADENCE_INVALID_REQUEST).inc(1);
1✔
353
      throw e;
1✔
354
    } catch (TException e) {
1✔
355
      sw.stop();
1✔
356
      scope.counter(MetricsType.CADENCE_ERROR).inc(1);
1✔
357
      throw e;
1✔
358
    } finally {
359
      span.finish();
1✔
360
    }
361
  }
362

363
  interface RemoteProc {
364
    void apply() throws TException;
365
  }
366

367
  private void measureRemoteProc(String scopeName, RemoteProc proc) throws TException {
368
    measureRemoteCall(
1✔
369
        scopeName,
370
        () -> {
371
          proc.apply();
1✔
372
          return null;
1✔
373
        });
374
  }
1✔
375

376
  @Override
377
  public void RegisterDomain(RegisterDomainRequest request) throws TException {
378
    measureRemoteProc(ServiceMethod.REGISTER_DOMAIN, () -> registerDomain(request));
1✔
379
  }
1✔
380

381
  private void registerDomain(RegisterDomainRequest registerRequest) throws TException {
382
    ThriftResponse<WorkflowService.RegisterDomain_result> response = null;
1✔
383
    try {
384
      ThriftRequest<WorkflowService.RegisterDomain_args> request =
1✔
385
          buildThriftRequest(
1✔
386
              "RegisterDomain", new WorkflowService.RegisterDomain_args(registerRequest));
387
      response = doRemoteCall(request);
1✔
388
      WorkflowService.RegisterDomain_result result =
1✔
389
          response.getBody(WorkflowService.RegisterDomain_result.class);
1✔
390
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
391
        return;
1✔
392
      }
393
      if (result.isSetBadRequestError()) {
1✔
394
        throw result.getBadRequestError();
1✔
395
      }
396
      if (result.isSetDomainExistsError()) {
1✔
397
        throw result.getDomainExistsError();
1✔
398
      }
399
      if (result.isSetServiceBusyError()) {
1✔
400
        throw result.getServiceBusyError();
1✔
401
      }
402
      throw new TException("RegisterDomain failed with unknown error:" + result);
1✔
403
    } finally {
404
      if (response != null) {
1✔
405
        response.release();
1✔
406
      }
407
    }
408
  }
409

410
  @Override
411
  public DescribeDomainResponse DescribeDomain(DescribeDomainRequest describeRequest)
412
      throws TException {
413
    return measureRemoteCall(ServiceMethod.DESCRIBE_DOMAIN, () -> describeDomain(describeRequest));
1✔
414
  }
415

416
  private DescribeDomainResponse describeDomain(DescribeDomainRequest describeRequest)
417
      throws TException {
418
    ThriftResponse<WorkflowService.DescribeDomain_result> response = null;
1✔
419
    try {
420
      ThriftRequest<WorkflowService.DescribeDomain_args> request =
1✔
421
          buildThriftRequest(
1✔
422
              "DescribeDomain", new WorkflowService.DescribeDomain_args(describeRequest));
423
      response = doRemoteCall(request);
1✔
424
      WorkflowService.DescribeDomain_result result =
1✔
425
          response.getBody(WorkflowService.DescribeDomain_result.class);
1✔
426
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
427
        return result.getSuccess();
1✔
428
      }
429
      if (result.isSetBadRequestError()) {
1✔
430
        throw result.getBadRequestError();
1✔
431
      }
432
      if (result.isSetEntityNotExistError()) {
1✔
433
        throw result.getEntityNotExistError();
1✔
434
      }
435
      if (result.isSetServiceBusyError()) {
1✔
436
        throw result.getServiceBusyError();
1✔
437
      }
438
      throw new TException("DescribeDomain failed with unknown error:" + result);
1✔
439
    } finally {
440
      if (response != null) {
1✔
441
        response.release();
1✔
442
      }
443
    }
444
  }
445

446
  @Override
447
  public ListDomainsResponse ListDomains(ListDomainsRequest listRequest)
448
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
449
          TException {
450
    return measureRemoteCall(ServiceMethod.LIST_DOMAINS, () -> listDomains(listRequest));
1✔
451
  }
452

453
  private ListDomainsResponse listDomains(ListDomainsRequest describeRequest) throws TException {
454
    ThriftResponse<WorkflowService.ListDomains_result> response = null;
1✔
455
    try {
456
      ThriftRequest<WorkflowService.ListDomains_args> request =
1✔
457
          buildThriftRequest("ListDomains", new WorkflowService.ListDomains_args(describeRequest));
1✔
458
      response = doRemoteCall(request);
1✔
459
      WorkflowService.ListDomains_result result =
1✔
460
          response.getBody(WorkflowService.ListDomains_result.class);
1✔
461
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
462
        return result.getSuccess();
1✔
463
      }
464
      if (result.isSetBadRequestError()) {
1✔
465
        throw result.getBadRequestError();
1✔
466
      }
467
      if (result.isSetEntityNotExistError()) {
1✔
468
        throw result.getEntityNotExistError();
×
469
      }
470
      if (result.isSetServiceBusyError()) {
1✔
471
        throw result.getServiceBusyError();
1✔
472
      }
473
      throw new TException("ListDomains failed with unknown error:" + result);
1✔
474
    } finally {
475
      if (response != null) {
1✔
476
        response.release();
1✔
477
      }
478
    }
479
  }
480

481
  @Override
482
  public UpdateDomainResponse UpdateDomain(UpdateDomainRequest updateRequest) throws TException {
483
    return measureRemoteCall(ServiceMethod.UPDATE_DOMAIN, () -> updateDomain(updateRequest));
1✔
484
  }
485

486
  private UpdateDomainResponse updateDomain(UpdateDomainRequest updateRequest) throws TException {
487
    ThriftResponse<WorkflowService.UpdateDomain_result> response = null;
1✔
488
    try {
489
      ThriftRequest<WorkflowService.UpdateDomain_args> request =
1✔
490
          buildThriftRequest("UpdateDomain", new WorkflowService.UpdateDomain_args(updateRequest));
1✔
491
      response = doRemoteCall(request);
1✔
492
      WorkflowService.UpdateDomain_result result =
1✔
493
          response.getBody(WorkflowService.UpdateDomain_result.class);
1✔
494
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
495
        return result.getSuccess();
1✔
496
      }
497
      if (result.isSetBadRequestError()) {
1✔
498
        throw result.getBadRequestError();
1✔
499
      }
500
      if (result.isSetEntityNotExistError()) {
1✔
501
        throw result.getEntityNotExistError();
1✔
502
      }
503
      if (result.isSetServiceBusyError()) {
1✔
504
        throw result.getServiceBusyError();
1✔
505
      }
506
      if (result.isSetDomainNotActiveError()) {
1✔
507
        throw result.getDomainNotActiveError();
1✔
508
      }
509
      throw new TException("UpdateDomain failed with unknown error:" + result);
1✔
510
    } finally {
511
      if (response != null) {
1✔
512
        response.release();
1✔
513
      }
514
    }
515
  }
516

517
  @Override
518
  public void DeprecateDomain(DeprecateDomainRequest deprecateRequest) throws TException {
519
    measureRemoteProc(ServiceMethod.DEPRECATE_DOMAIN, () -> deprecateDomain(deprecateRequest));
1✔
520
  }
1✔
521

522
  @Override
523
  public RestartWorkflowExecutionResponse RestartWorkflowExecution(
524
      RestartWorkflowExecutionRequest restartRequest)
525
      throws BadRequestError, ServiceBusyError, DomainNotActiveError, LimitExceededError,
526
          EntityNotExistsError, ClientVersionNotSupportedError, TException {
527
    throw new UnsupportedOperationException("unimplemented");
×
528
  }
529

530
  private void deprecateDomain(DeprecateDomainRequest deprecateRequest) throws TException {
531
    ThriftResponse<WorkflowService.DeprecateDomain_result> response = null;
1✔
532
    try {
533
      ThriftRequest<WorkflowService.DeprecateDomain_args> request =
1✔
534
          buildThriftRequest(
1✔
535
              "DeprecateDomain", new WorkflowService.DeprecateDomain_args(deprecateRequest));
536
      response = doRemoteCall(request);
1✔
537
      WorkflowService.DeprecateDomain_result result =
1✔
538
          response.getBody(WorkflowService.DeprecateDomain_result.class);
1✔
539
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
540
        return;
1✔
541
      }
542
      if (result.isSetBadRequestError()) {
1✔
543
        throw result.getBadRequestError();
1✔
544
      }
545
      if (result.isSetEntityNotExistError()) {
1✔
546
        throw result.getEntityNotExistError();
1✔
547
      }
548
      if (result.isSetServiceBusyError()) {
1✔
549
        throw result.getServiceBusyError();
1✔
550
      }
551
      if (result.isSetDomainNotActiveError()) {
1✔
552
        throw result.getDomainNotActiveError();
1✔
553
      }
554
      throw new TException("DeprecateDomain failed with unknown error:" + result);
1✔
555
    } finally {
556
      if (response != null) {
1✔
557
        response.release();
1✔
558
      }
559
    }
560
  }
561

562
  @Override
563
  public GetTaskListsByDomainResponse GetTaskListsByDomain(
564
      GetTaskListsByDomainRequest getTaskListsByDomainRequest) throws TException {
565
    return measureRemoteCall(
1✔
566
        ServiceMethod.GET_TASK_LISTS_BY_DOMAIN,
567
        () -> getTaskListsByDomain(getTaskListsByDomainRequest));
1✔
568
  }
569

570
  private GetTaskListsByDomainResponse getTaskListsByDomain(
571
      GetTaskListsByDomainRequest getTaskListsByDomainRequest) throws TException {
572
    ThriftResponse<WorkflowService.GetTaskListsByDomain_result> response = null;
1✔
573
    try {
574
      ThriftRequest<WorkflowService.GetTaskListsByDomain_args> request =
1✔
575
          buildThriftRequest(
1✔
576
              "GetTaskListsByDomain",
577
              new WorkflowService.GetTaskListsByDomain_args(getTaskListsByDomainRequest));
578
      response = doRemoteCall(request);
1✔
579
      WorkflowService.GetTaskListsByDomain_result result =
1✔
580
          response.getBody(WorkflowService.GetTaskListsByDomain_result.class);
1✔
581
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
582
        return result.getSuccess();
1✔
583
      }
584
      if (result.isSetBadRequestError()) {
1✔
585
        throw result.getBadRequestError();
1✔
586
      }
587
      if (result.isSetEntityNotExistError()) {
1✔
588
        throw result.getEntityNotExistError();
1✔
589
      }
590
      if (result.isSetLimitExceededError()) {
1✔
591
        throw result.getLimitExceededError();
1✔
592
      }
593
      if (result.isSetServiceBusyError()) {
1✔
594
        throw result.getServiceBusyError();
1✔
595
      }
596
      if (result.isSetClientVersionNotSupportedError()) {
1✔
597
        throw result.getClientVersionNotSupportedError();
1✔
598
      }
599
      throw new TException("GetTaskListsByDomain failed with unknown error:" + result);
1✔
600
    } finally {
601
      if (response != null) {
1✔
602
        response.release();
1✔
603
      }
604
    }
605
  }
606

607
  @Override
608
  public StartWorkflowExecutionResponse StartWorkflowExecution(
609
      StartWorkflowExecutionRequest request) throws TException {
610
    return measureRemoteCall(
1✔
611
        ServiceMethod.START_WORKFLOW_EXECUTION, () -> startWorkflowExecution(request));
1✔
612
  }
613

614
  private StartWorkflowExecutionResponse startWorkflowExecution(
615
      StartWorkflowExecutionRequest startRequest) throws TException {
616
    ThriftResponse<WorkflowService.StartWorkflowExecution_result> response = null;
1✔
617
    try {
618
      initializeStartWorkflowRequest(startRequest);
1✔
619

620
      ThriftRequest<WorkflowService.StartWorkflowExecution_args> request =
1✔
621
          buildThriftRequest(
1✔
622
              "StartWorkflowExecution",
623
              new WorkflowService.StartWorkflowExecution_args(startRequest));
624

625
      response = doRemoteCall(request);
1✔
626
      WorkflowService.StartWorkflowExecution_result result =
1✔
627
          response.getBody(WorkflowService.StartWorkflowExecution_result.class);
1✔
628
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
629
        return result.getSuccess();
1✔
630
      }
631
      if (result.isSetBadRequestError()) {
1✔
632
        throw result.getBadRequestError();
1✔
633
      }
634
      if (result.isSetSessionAlreadyExistError()) {
1✔
635
        throw result.getSessionAlreadyExistError();
1✔
636
      }
637
      if (result.isSetServiceBusyError()) {
1✔
638
        throw result.getServiceBusyError();
1✔
639
      }
640
      if (result.isSetDomainNotActiveError()) {
1✔
641
        throw result.getDomainNotActiveError();
1✔
642
      }
643
      if (result.isSetLimitExceededError()) {
1✔
644
        throw result.getLimitExceededError();
1✔
645
      }
646
      if (result.isSetEntityNotExistError()) {
1✔
647
        throw result.getEntityNotExistError();
1✔
648
      }
649
      if (result.isSetClientVersionNotSupportedError()) {
1✔
650
        throw result.getClientVersionNotSupportedError();
1✔
651
      }
652
      throw new TException("StartWorkflowExecution failed with unknown error:" + result);
1✔
653
    } finally {
654
      if (response != null) {
1✔
655
        response.release();
1✔
656
      }
657
    }
658
  }
659

660
  @Override
661
  public StartWorkflowExecutionAsyncResponse StartWorkflowExecutionAsync(
662
      StartWorkflowExecutionAsyncRequest startAsyncRequest) throws TException {
663
    return measureRemoteCall(
1✔
664
        ServiceMethod.START_WORKFLOW_EXECUTION_ASYNC,
665
        () -> startWorkflowExecutionAsync(startAsyncRequest));
1✔
666
  }
667

668
  private StartWorkflowExecutionAsyncResponse startWorkflowExecutionAsync(
669
      StartWorkflowExecutionAsyncRequest startAsyncRequest) throws TException {
670
    ThriftResponse<WorkflowService.StartWorkflowExecutionAsync_result> response = null;
1✔
671
    try {
672
      initializeStartWorkflowRequest(startAsyncRequest.getRequest());
1✔
673

674
      ThriftRequest<WorkflowService.StartWorkflowExecutionAsync_args> request =
1✔
675
          buildThriftRequest(
1✔
676
              "StartWorkflowExecutionAsync",
677
              new WorkflowService.StartWorkflowExecutionAsync_args(startAsyncRequest));
678

679
      response = doRemoteCall(request);
1✔
680
      WorkflowService.StartWorkflowExecutionAsync_result result =
1✔
681
          response.getBody(WorkflowService.StartWorkflowExecutionAsync_result.class);
1✔
682
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
683
        return result.getSuccess();
1✔
684
      }
685
      if (result.isSetBadRequestError()) {
1✔
686
        throw result.getBadRequestError();
1✔
687
      }
688
      if (result.isSetSessionAlreadyExistError()) {
1✔
689
        throw result.getSessionAlreadyExistError();
1✔
690
      }
691
      if (result.isSetServiceBusyError()) {
1✔
692
        throw result.getServiceBusyError();
1✔
693
      }
694
      if (result.isSetDomainNotActiveError()) {
1✔
695
        throw result.getDomainNotActiveError();
1✔
696
      }
697
      if (result.isSetLimitExceededError()) {
1✔
698
        throw result.getLimitExceededError();
1✔
699
      }
700
      if (result.isSetEntityNotExistError()) {
1✔
701
        throw result.getEntityNotExistError();
1✔
702
      }
703
      if (result.isSetClientVersionNotSupportedError()) {
1✔
704
        throw result.getClientVersionNotSupportedError();
1✔
705
      }
706
      throw new TException("StartWorkflowExecution failed with unknown error:" + result);
1✔
707
    } finally {
708
      if (response != null) {
1✔
709
        response.release();
1✔
710
      }
711
    }
712
  }
713

714
  private void initializeStartWorkflowRequest(StartWorkflowExecutionRequest startRequest) {
715
    if (!startRequest.isSetRequestId()) {
1✔
716
      startRequest.setRequestId(UUID.randomUUID().toString());
1✔
717
    }
718
    // Write span context to header
719
    if (!startRequest.isSetHeader()) {
1✔
720
      startRequest.setHeader(new Header());
1✔
721
    }
722
    tracingPropagator.inject(startRequest.getHeader());
1✔
723
  }
1✔
724

725
  @Override
726
  public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistoryWithTimeout(
727
      GetWorkflowExecutionHistoryRequest request, Long timeoutInMillis) throws TException {
728
    Map<String, String> tags =
1✔
729
        ImmutableMap.of(
1✔
730
            MetricsTag.REQUEST_TYPE,
731
            request.isWaitForNewEvent() ? REQUEST_TYPE_LONG_POLL : REQUEST_TYPE_NORMAL);
1✔
732
    return measureRemoteCallWithTags(
1✔
733
        ServiceMethod.GET_WORKFLOW_EXECUTION_HISTORY,
734
        () -> getWorkflowExecutionHistory(request, timeoutInMillis),
1✔
735
        tags);
736
  }
737

738
  @Override
739
  public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistory(
740
      GetWorkflowExecutionHistoryRequest request) throws TException {
741
    Map<String, String> tags =
×
742
        ImmutableMap.of(
×
743
            MetricsTag.REQUEST_TYPE,
744
            request.isWaitForNewEvent() ? REQUEST_TYPE_LONG_POLL : REQUEST_TYPE_NORMAL);
×
745
    return measureRemoteCallWithTags(
×
746
        ServiceMethod.GET_WORKFLOW_EXECUTION_HISTORY,
747
        () -> getWorkflowExecutionHistory(request, null),
×
748
        tags);
749
  }
750

751
  private GetWorkflowExecutionHistoryResponse getWorkflowExecutionHistory(
752
      GetWorkflowExecutionHistoryRequest getRequest, Long timeoutInMillis) throws TException {
753
    ThriftResponse<WorkflowService.GetWorkflowExecutionHistory_result> response = null;
1✔
754
    try {
755
      ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args> request =
1✔
756
          buildGetWorkflowExecutionHistoryThriftRequest(getRequest, timeoutInMillis);
1✔
757
      response = doRemoteCall(request);
1✔
758
      WorkflowService.GetWorkflowExecutionHistory_result result =
1✔
759
          response.getBody(WorkflowService.GetWorkflowExecutionHistory_result.class);
1✔
760
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
761
        GetWorkflowExecutionHistoryResponse res = result.getSuccess();
1✔
762
        if (res.getRawHistory() != null) {
1✔
763
          History history =
×
764
              InternalUtils.DeserializeFromBlobDataToHistory(
×
765
                  res.getRawHistory(), getRequest.getHistoryEventFilterType());
×
766
          res.setHistory(history);
×
767
        }
768
        return res;
1✔
769
      }
770
      if (result.isSetBadRequestError()) {
1✔
771
        throw result.getBadRequestError();
1✔
772
      }
773
      if (result.isSetEntityNotExistError()) {
1✔
774
        throw result.getEntityNotExistError();
1✔
775
      }
776
      if (result.isSetServiceBusyError()) {
1✔
777
        throw result.getServiceBusyError();
1✔
778
      }
779
      if (result.isSetClientVersionNotSupportedError()) {
1✔
780
        throw result.getClientVersionNotSupportedError();
1✔
781
      }
782
      throw new TException("GetWorkflowExecutionHistory failed with unknown error:" + result);
1✔
783
    } finally {
784
      if (response != null) {
1✔
785
        response.release();
1✔
786
      }
787
    }
788
  }
789

790
  private ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args>
791
      buildGetWorkflowExecutionHistoryThriftRequest(
792
          GetWorkflowExecutionHistoryRequest getRequest, Long timeoutInMillis) {
793

794
    if (getRequest.isWaitForNewEvent()) {
1✔
795
      timeoutInMillis =
×
796
          validateAndUpdateTimeout(timeoutInMillis, options.getRpcLongPollTimeoutMillis());
×
797
    } else {
798
      timeoutInMillis = validateAndUpdateTimeout(timeoutInMillis, options.getRpcTimeoutMillis());
1✔
799
    }
800

801
    return buildThriftRequest(
1✔
802
        "GetWorkflowExecutionHistory",
803
        new WorkflowService.GetWorkflowExecutionHistory_args(getRequest),
804
        timeoutInMillis);
805
  }
806

807
  @Override
808
  public PollForDecisionTaskResponse PollForDecisionTask(PollForDecisionTaskRequest request)
809
      throws TException {
810
    return measureRemoteCall(
1✔
811
        ServiceMethod.POLL_FOR_DECISION_TASK, () -> pollForDecisionTask(request));
1✔
812
  }
813

814
  private PollForDecisionTaskResponse pollForDecisionTask(PollForDecisionTaskRequest pollRequest)
815
      throws TException {
816
    ThriftResponse<WorkflowService.PollForDecisionTask_result> response = null;
1✔
817
    try {
818
      ThriftRequest<WorkflowService.PollForDecisionTask_args> request =
1✔
819
          buildThriftRequest(
1✔
820
              "PollForDecisionTask",
821
              new WorkflowService.PollForDecisionTask_args(pollRequest),
822
              options.getRpcLongPollTimeoutMillis());
1✔
823
      response = doRemoteCall(request);
1✔
824
      WorkflowService.PollForDecisionTask_result result =
1✔
825
          response.getBody(WorkflowService.PollForDecisionTask_result.class);
1✔
826
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
827
        return result.getSuccess();
1✔
828
      }
829
      if (result.isSetBadRequestError()) {
1✔
830
        throw result.getBadRequestError();
1✔
831
      }
832
      if (result.isSetServiceBusyError()) {
1✔
833
        throw result.getServiceBusyError();
1✔
834
      }
835
      if (result.isSetDomainNotActiveError()) {
1✔
836
        throw result.getDomainNotActiveError();
×
837
      }
838
      if (result.isSetLimitExceededError()) {
1✔
839
        throw result.getLimitExceededError();
×
840
      }
841
      if (result.isSetEntityNotExistError()) {
1✔
842
        throw result.getEntityNotExistError();
1✔
843
      }
844
      if (result.isSetClientVersionNotSupportedError()) {
1✔
845
        throw result.getClientVersionNotSupportedError();
×
846
      }
847
      throw new TException("PollForDecisionTask failed with unknown error:" + result);
1✔
848
    } finally {
849
      if (response != null) {
1✔
850
        response.release();
1✔
851
      }
852
    }
853
  }
854

855
  @Override
856
  public RespondDecisionTaskCompletedResponse RespondDecisionTaskCompleted(
857
      RespondDecisionTaskCompletedRequest completedRequest) throws TException {
858
    return measureRemoteCall(
1✔
859
        ServiceMethod.RESPOND_DECISION_TASK_COMPLETED,
860
        () -> respondDecisionTaskCompleted(completedRequest));
1✔
861
  }
862

863
  private RespondDecisionTaskCompletedResponse respondDecisionTaskCompleted(
864
      RespondDecisionTaskCompletedRequest completedRequest) throws TException {
865
    ThriftResponse<WorkflowService.RespondDecisionTaskCompleted_result> response = null;
1✔
866
    try {
867
      ThriftRequest<WorkflowService.RespondDecisionTaskCompleted_args> request =
1✔
868
          buildThriftRequest(
1✔
869
              "RespondDecisionTaskCompleted",
870
              new WorkflowService.RespondDecisionTaskCompleted_args(completedRequest));
871
      response = doRemoteCall(request);
1✔
872
      WorkflowService.RespondDecisionTaskCompleted_result result =
1✔
873
          response.getBody(WorkflowService.RespondDecisionTaskCompleted_result.class);
1✔
874
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
875
        return result.getSuccess();
1✔
876
      }
877
      if (result.isSetBadRequestError()) {
1✔
878
        throw result.getBadRequestError();
1✔
879
      }
880
      if (result.isSetServiceBusyError()) {
1✔
881
        throw result.getServiceBusyError();
1✔
882
      }
883
      if (result.isSetDomainNotActiveError()) {
1✔
884
        throw result.getDomainNotActiveError();
×
885
      }
886
      if (result.isSetLimitExceededError()) {
1✔
887
        throw result.getLimitExceededError();
×
888
      }
889
      if (result.isSetEntityNotExistError()) {
1✔
890
        throw result.getEntityNotExistError();
1✔
891
      }
892
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
1✔
893
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
894
      }
895
      if (result.isSetClientVersionNotSupportedError()) {
1✔
896
        throw result.getClientVersionNotSupportedError();
×
897
      }
898
      throw new TException("RespondDecisionTaskCompleted failed with unknown error:" + result);
1✔
899
    } finally {
900
      if (response != null) {
1✔
901
        response.release();
1✔
902
      }
903
    }
904
  }
905

906
  @Override
907
  public void RespondDecisionTaskFailed(RespondDecisionTaskFailedRequest request)
908
      throws TException {
909
    measureRemoteProc(
1✔
910
        ServiceMethod.RESPOND_DECISION_TASK_FAILED, () -> respondDecisionTaskFailed(request));
1✔
911
  }
1✔
912

913
  private void respondDecisionTaskFailed(RespondDecisionTaskFailedRequest failedRequest)
914
      throws TException {
915
    ThriftResponse<WorkflowService.RespondDecisionTaskFailed_result> response = null;
1✔
916
    try {
917
      ThriftRequest<WorkflowService.RespondDecisionTaskFailed_args> request =
1✔
918
          buildThriftRequest(
1✔
919
              "RespondDecisionTaskFailed",
920
              new WorkflowService.RespondDecisionTaskFailed_args(failedRequest));
921
      response = doRemoteCall(request);
1✔
922
      WorkflowService.RespondDecisionTaskFailed_result result =
1✔
923
          response.getBody(WorkflowService.RespondDecisionTaskFailed_result.class);
1✔
924
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
925
        return;
1✔
926
      }
927
      if (result.isSetBadRequestError()) {
1✔
928
        throw result.getBadRequestError();
1✔
929
      }
930
      if (result.isSetEntityNotExistError()) {
1✔
931
        throw result.getEntityNotExistError();
1✔
932
      }
933
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
1✔
934
        throw result.getWorkflowExecutionAlreadyCompletedError();
1✔
935
      }
936
      if (result.isSetServiceBusyError()) {
1✔
937
        throw result.getServiceBusyError();
1✔
938
      }
939
      if (result.isSetDomainNotActiveError()) {
1✔
940
        throw result.getDomainNotActiveError();
×
941
      }
942
      if (result.isSetLimitExceededError()) {
1✔
943
        throw result.getLimitExceededError();
×
944
      }
945
      if (result.isSetClientVersionNotSupportedError()) {
1✔
946
        throw result.getClientVersionNotSupportedError();
×
947
      }
948
      throw new TException("RespondDecisionTaskFailed failed with unknown error:" + result);
1✔
949
    } finally {
950
      if (response != null) {
1✔
951
        response.release();
1✔
952
      }
953
    }
954
  }
955

956
  @Override
957
  public PollForActivityTaskResponse PollForActivityTask(PollForActivityTaskRequest request)
958
      throws TException {
959
    return measureRemoteCall(
1✔
960
        ServiceMethod.POLL_FOR_ACTIVITY_TASK, () -> pollForActivityTask(request));
1✔
961
  }
962

963
  private PollForActivityTaskResponse pollForActivityTask(PollForActivityTaskRequest pollRequest)
964
      throws TException {
965
    ThriftResponse<WorkflowService.PollForActivityTask_result> response = null;
1✔
966
    try {
967
      ThriftRequest<WorkflowService.PollForActivityTask_args> request =
1✔
968
          buildThriftRequest(
1✔
969
              "PollForActivityTask",
970
              new WorkflowService.PollForActivityTask_args(pollRequest),
971
              options.getRpcLongPollTimeoutMillis());
1✔
972
      response = doRemoteCall(request);
1✔
973
      WorkflowService.PollForActivityTask_result result =
1✔
974
          response.getBody(WorkflowService.PollForActivityTask_result.class);
1✔
975
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
976
        return result.getSuccess();
1✔
977
      }
978
      if (result.isSetBadRequestError()) {
1✔
979
        throw result.getBadRequestError();
1✔
980
      }
981
      if (result.isSetServiceBusyError()) {
1✔
982
        throw result.getServiceBusyError();
1✔
983
      }
984
      if (result.isSetEntityNotExistError()) {
1✔
985
        throw result.getEntityNotExistError();
1✔
986
      }
987
      if (result.isSetDomainNotActiveError()) {
1✔
988
        throw result.getDomainNotActiveError();
×
989
      }
990
      if (result.isSetLimitExceededError()) {
1✔
991
        throw result.getLimitExceededError();
×
992
      }
993
      if (result.isSetClientVersionNotSupportedError()) {
1✔
994
        throw result.getClientVersionNotSupportedError();
×
995
      }
996
      throw new TException("PollForActivityTask failed with unknown error:" + result);
1✔
997
    } finally {
998
      if (response != null) {
1✔
999
        response.release();
1✔
1000
      }
1001
    }
1002
  }
1003

1004
  @Override
1005
  public RecordActivityTaskHeartbeatResponse RecordActivityTaskHeartbeat(
1006
      RecordActivityTaskHeartbeatRequest request) throws TException {
1007
    return measureRemoteCall(
1✔
1008
        ServiceMethod.RECORD_ACTIVITY_TASK_HEARTBEAT, () -> recordActivityTaskHeartbeat(request));
1✔
1009
  }
1010

1011
  private RecordActivityTaskHeartbeatResponse recordActivityTaskHeartbeat(
1012
      RecordActivityTaskHeartbeatRequest heartbeatRequest) throws TException {
1013
    ThriftResponse<WorkflowService.RecordActivityTaskHeartbeat_result> response = null;
1✔
1014
    try {
1015
      ThriftRequest<WorkflowService.RecordActivityTaskHeartbeat_args> request =
1✔
1016
          buildThriftRequest(
1✔
1017
              "RecordActivityTaskHeartbeat",
1018
              new WorkflowService.RecordActivityTaskHeartbeat_args(heartbeatRequest));
1019
      response = doRemoteCall(request);
1✔
1020
      WorkflowService.RecordActivityTaskHeartbeat_result result =
1✔
1021
          response.getBody(WorkflowService.RecordActivityTaskHeartbeat_result.class);
1✔
1022
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1023
        return result.getSuccess();
1✔
1024
      }
1025
      if (result.isSetBadRequestError()) {
1✔
1026
        throw result.getBadRequestError();
1✔
1027
      }
1028
      if (result.isSetEntityNotExistError()) {
1✔
1029
        throw result.getEntityNotExistError();
1✔
1030
      }
1031
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
1✔
1032
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1033
      }
1034
      if (result.isSetServiceBusyError()) {
1✔
1035
        throw result.getServiceBusyError();
1✔
1036
      }
1037
      if (result.isSetDomainNotActiveError()) {
1✔
1038
        throw result.getDomainNotActiveError();
×
1039
      }
1040
      if (result.isSetLimitExceededError()) {
1✔
1041
        throw result.getLimitExceededError();
×
1042
      }
1043
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1044
        throw result.getClientVersionNotSupportedError();
×
1045
      }
1046
      throw new TException("RecordActivityTaskHeartbeat failed with unknown error:" + result);
1✔
1047
    } finally {
1048
      if (response != null) {
1✔
1049
        response.release();
1✔
1050
      }
1051
    }
1052
  }
1053

1054
  @Override
1055
  public RecordActivityTaskHeartbeatResponse RecordActivityTaskHeartbeatByID(
1056
      RecordActivityTaskHeartbeatByIDRequest heartbeatRequest)
1057
      throws BadRequestError, InternalServiceError, EntityNotExistsError, DomainNotActiveError,
1058
          WorkflowExecutionAlreadyCompletedError, LimitExceededError, ServiceBusyError, TException {
1059
    return measureRemoteCall(
1✔
1060
        ServiceMethod.RECORD_ACTIVITY_TASK_HEARTBEAT_BY_ID,
1061
        () -> recordActivityTaskHeartbeatByID(heartbeatRequest));
1✔
1062
  }
1063

1064
  private RecordActivityTaskHeartbeatResponse recordActivityTaskHeartbeatByID(
1065
      RecordActivityTaskHeartbeatByIDRequest heartbeatRequest) throws TException {
1066
    ThriftResponse<WorkflowService.RecordActivityTaskHeartbeatByID_result> response = null;
1✔
1067
    try {
1068
      ThriftRequest<WorkflowService.RecordActivityTaskHeartbeatByID_args> request =
1✔
1069
          buildThriftRequest(
1✔
1070
              "RecordActivityTaskHeartbeatByID",
1071
              new WorkflowService.RecordActivityTaskHeartbeatByID_args(heartbeatRequest));
1072
      response = doRemoteCall(request);
1✔
1073
      WorkflowService.RecordActivityTaskHeartbeatByID_result result =
1✔
1074
          response.getBody(WorkflowService.RecordActivityTaskHeartbeatByID_result.class);
1✔
1075
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1076
        return result.getSuccess();
1✔
1077
      }
1078
      if (result.isSetBadRequestError()) {
1✔
1079
        throw result.getBadRequestError();
1✔
1080
      }
1081
      if (result.isSetEntityNotExistError()) {
1✔
1082
        throw result.getEntityNotExistError();
1✔
1083
      }
1084
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
1✔
1085
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1086
      }
1087
      if (result.isSetServiceBusyError()) {
1✔
1088
        throw result.getServiceBusyError();
1✔
1089
      }
1090
      if (result.isSetDomainNotActiveError()) {
1✔
1091
        throw result.getDomainNotActiveError();
×
1092
      }
1093
      if (result.isSetLimitExceededError()) {
1✔
1094
        throw result.getLimitExceededError();
×
1095
      }
1096
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1097
        throw result.getClientVersionNotSupportedError();
×
1098
      }
1099
      throw new TException("RecordActivityTaskHeartbeatByID failed with unknown error:" + result);
1✔
1100
    } finally {
1101
      if (response != null) {
1✔
1102
        response.release();
1✔
1103
      }
1104
    }
1105
  }
1106

1107
  @Override
1108
  public void RespondActivityTaskCompleted(RespondActivityTaskCompletedRequest request)
1109
      throws TException {
1110
    measureRemoteProc(
1✔
1111
        ServiceMethod.RESPOND_ACTIVITY_TASK_COMPLETED, () -> respondActivityTaskCompleted(request));
1✔
1112
  }
1✔
1113

1114
  private void respondActivityTaskCompleted(RespondActivityTaskCompletedRequest completeRequest)
1115
      throws TException {
1116
    ThriftResponse<WorkflowService.RespondActivityTaskCompleted_result> response = null;
1✔
1117
    try {
1118
      ThriftRequest<WorkflowService.RespondActivityTaskCompleted_args> request =
1✔
1119
          buildThriftRequest(
1✔
1120
              "RespondActivityTaskCompleted",
1121
              new WorkflowService.RespondActivityTaskCompleted_args(completeRequest));
1122
      response = doRemoteCall(request);
1✔
1123
      WorkflowService.RespondActivityTaskCompleted_result result =
1✔
1124
          response.getBody(WorkflowService.RespondActivityTaskCompleted_result.class);
1✔
1125
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1126
        return;
1✔
1127
      }
1128
      if (result.isSetBadRequestError()) {
1✔
1129
        throw result.getBadRequestError();
1✔
1130
      }
1131
      if (result.isSetEntityNotExistError()) {
1✔
1132
        throw result.getEntityNotExistError();
1✔
1133
      }
1134
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
1✔
1135
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1136
      }
1137
      if (result.isSetServiceBusyError()) {
1✔
1138
        throw result.getServiceBusyError();
1✔
1139
      }
1140
      if (result.isSetDomainNotActiveError()) {
1✔
1141
        throw result.getDomainNotActiveError();
×
1142
      }
1143
      if (result.isSetLimitExceededError()) {
1✔
1144
        throw result.getLimitExceededError();
×
1145
      }
1146
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1147
        throw result.getClientVersionNotSupportedError();
×
1148
      }
1149
      throw new TException("RespondActivityTaskCompleted failed with unknown error:" + result);
1✔
1150
    } finally {
1151
      if (response != null) {
1✔
1152
        response.release();
1✔
1153
      }
1154
    }
1155
  }
1156

1157
  @Override
1158
  public void RespondActivityTaskCompletedByID(RespondActivityTaskCompletedByIDRequest request)
1159
      throws TException {
1160
    measureRemoteProc(
1✔
1161
        ServiceMethod.RESPOND_ACTIVITY_TASK_COMPLETED_BY_ID,
1162
        () -> respondActivityTaskCompletedByID(request));
1✔
1163
  }
1✔
1164

1165
  private void respondActivityTaskCompletedByID(
1166
      RespondActivityTaskCompletedByIDRequest completeRequest) throws TException {
1167
    ThriftResponse<WorkflowService.RespondActivityTaskCompletedByID_result> response = null;
1✔
1168
    try {
1169
      ThriftRequest<WorkflowService.RespondActivityTaskCompletedByID_args> request =
1✔
1170
          buildThriftRequest(
1✔
1171
              "RespondActivityTaskCompletedByID",
1172
              new WorkflowService.RespondActivityTaskCompletedByID_args(completeRequest));
1173
      response = doRemoteCall(request);
1✔
1174
      WorkflowService.RespondActivityTaskCompletedByID_result result =
1✔
1175
          response.getBody(WorkflowService.RespondActivityTaskCompletedByID_result.class);
1✔
1176
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1177
        return;
1✔
1178
      }
1179
      if (result.isSetBadRequestError()) {
1✔
1180
        throw result.getBadRequestError();
1✔
1181
      }
1182
      if (result.isSetEntityNotExistError()) {
1✔
1183
        throw result.getEntityNotExistError();
1✔
1184
      }
1185
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
1✔
1186
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1187
      }
1188
      if (result.isSetServiceBusyError()) {
1✔
1189
        throw result.getServiceBusyError();
1✔
1190
      }
1191
      if (result.isSetDomainNotActiveError()) {
1✔
1192
        throw result.getDomainNotActiveError();
×
1193
      }
1194
      if (result.isSetLimitExceededError()) {
1✔
1195
        throw result.getLimitExceededError();
×
1196
      }
1197
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1198
        throw result.getClientVersionNotSupportedError();
×
1199
      }
1200
      throw new TException("RespondActivityTaskCompletedByID failed with unknown error:" + result);
1✔
1201
    } finally {
1202
      if (response != null) {
1✔
1203
        response.release();
1✔
1204
      }
1205
    }
1206
  }
1207

1208
  @Override
1209
  public void RespondActivityTaskFailed(RespondActivityTaskFailedRequest request)
1210
      throws TException {
1211
    measureRemoteProc(
1✔
1212
        ServiceMethod.RESPOND_ACTIVITY_TASK_FAILED, () -> respondActivityTaskFailed(request));
1✔
1213
  }
1✔
1214

1215
  private void respondActivityTaskFailed(RespondActivityTaskFailedRequest failRequest)
1216
      throws TException {
1217
    ThriftResponse<WorkflowService.RespondActivityTaskFailed_result> response = null;
1✔
1218
    try {
1219
      ThriftRequest<WorkflowService.RespondActivityTaskFailed_args> request =
1✔
1220
          buildThriftRequest(
1✔
1221
              "RespondActivityTaskFailed",
1222
              new WorkflowService.RespondActivityTaskFailed_args(failRequest));
1223
      response = doRemoteCall(request);
1✔
1224
      WorkflowService.RespondActivityTaskFailed_result result =
1✔
1225
          response.getBody(WorkflowService.RespondActivityTaskFailed_result.class);
1✔
1226
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1227
        return;
1✔
1228
      }
1229
      if (result.isSetBadRequestError()) {
1✔
1230
        throw result.getBadRequestError();
1✔
1231
      }
1232
      if (result.isSetEntityNotExistError()) {
1✔
1233
        throw result.getEntityNotExistError();
1✔
1234
      }
1235
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
1✔
1236
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1237
      }
1238
      if (result.isSetServiceBusyError()) {
1✔
1239
        throw result.getServiceBusyError();
1✔
1240
      }
1241
      if (result.isSetDomainNotActiveError()) {
1✔
1242
        throw result.getDomainNotActiveError();
×
1243
      }
1244
      if (result.isSetLimitExceededError()) {
1✔
1245
        throw result.getLimitExceededError();
×
1246
      }
1247
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1248
        throw result.getClientVersionNotSupportedError();
×
1249
      }
1250
      throw new TException("RespondActivityTaskFailed failed with unknown error:" + result);
1✔
1251
    } finally {
1252
      if (response != null) {
1✔
1253
        response.release();
1✔
1254
      }
1255
    }
1256
  }
1257

1258
  @Override
1259
  public void RespondActivityTaskFailedByID(RespondActivityTaskFailedByIDRequest request)
1260
      throws TException {
1261
    measureRemoteProc(
1✔
1262
        ServiceMethod.RESPOND_ACTIVITY_TASK_FAILED_BY_ID,
1263
        () -> respondActivityTaskFailedByID(request));
1✔
1264
  }
1✔
1265

1266
  private void respondActivityTaskFailedByID(RespondActivityTaskFailedByIDRequest failRequest)
1267
      throws TException {
1268
    ThriftResponse<WorkflowService.RespondActivityTaskFailedByID_result> response = null;
1✔
1269
    try {
1270
      ThriftRequest<WorkflowService.RespondActivityTaskFailedByID_args> request =
1✔
1271
          buildThriftRequest(
1✔
1272
              "RespondActivityTaskFailedByID",
1273
              new WorkflowService.RespondActivityTaskFailedByID_args(failRequest));
1274
      response = doRemoteCall(request);
1✔
1275
      WorkflowService.RespondActivityTaskFailedByID_result result =
1✔
1276
          response.getBody(WorkflowService.RespondActivityTaskFailedByID_result.class);
1✔
1277
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1278
        return;
1✔
1279
      }
1280
      if (result.isSetBadRequestError()) {
1✔
1281
        throw result.getBadRequestError();
1✔
1282
      }
1283
      if (result.isSetEntityNotExistError()) {
1✔
1284
        throw result.getEntityNotExistError();
1✔
1285
      }
1286
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
1✔
1287
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1288
      }
1289
      if (result.isSetServiceBusyError()) {
1✔
1290
        throw result.getServiceBusyError();
1✔
1291
      }
1292
      if (result.isSetDomainNotActiveError()) {
1✔
1293
        throw result.getDomainNotActiveError();
×
1294
      }
1295
      if (result.isSetLimitExceededError()) {
1✔
1296
        throw result.getLimitExceededError();
×
1297
      }
1298
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1299
        throw result.getClientVersionNotSupportedError();
×
1300
      }
1301
      throw new TException("RespondActivityTaskFailedByID failedByID with unknown error:" + result);
1✔
1302
    } finally {
1303
      if (response != null) {
1✔
1304
        response.release();
1✔
1305
      }
1306
    }
1307
  }
1308

1309
  @Override
1310
  public void RespondActivityTaskCanceled(RespondActivityTaskCanceledRequest request)
1311
      throws TException {
1312
    measureRemoteProc(
1✔
1313
        ServiceMethod.RESPOND_ACTIVITY_TASK_CANCELED, () -> respondActivityTaskCanceled(request));
1✔
1314
  }
1✔
1315

1316
  private void respondActivityTaskCanceled(RespondActivityTaskCanceledRequest canceledRequest)
1317
      throws TException {
1318
    ThriftResponse<WorkflowService.RespondActivityTaskCanceled_result> response = null;
1✔
1319
    try {
1320
      ThriftRequest<WorkflowService.RespondActivityTaskCanceled_args> request =
1✔
1321
          buildThriftRequest(
1✔
1322
              "RespondActivityTaskCanceled",
1323
              new WorkflowService.RespondActivityTaskCanceled_args(canceledRequest));
1324
      response = doRemoteCall(request);
1✔
1325
      WorkflowService.RespondActivityTaskCanceled_result result =
1✔
1326
          response.getBody(WorkflowService.RespondActivityTaskCanceled_result.class);
1✔
1327
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1328
        return;
1✔
1329
      }
1330
      if (result.isSetBadRequestError()) {
1✔
1331
        throw result.getBadRequestError();
1✔
1332
      }
1333
      if (result.isSetEntityNotExistError()) {
1✔
1334
        throw result.getEntityNotExistError();
1✔
1335
      }
1336
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
1✔
1337
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1338
      }
1339
      if (result.isSetServiceBusyError()) {
1✔
1340
        throw result.getServiceBusyError();
1✔
1341
      }
1342
      if (result.isSetDomainNotActiveError()) {
1✔
1343
        throw result.getDomainNotActiveError();
×
1344
      }
1345
      if (result.isSetLimitExceededError()) {
1✔
1346
        throw result.getLimitExceededError();
×
1347
      }
1348
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1349
        throw result.getClientVersionNotSupportedError();
×
1350
      }
1351
      throw new TException("RespondActivityTaskCanceled failed with unknown error:" + result);
1✔
1352
    } finally {
1353
      if (response != null) {
1✔
1354
        response.release();
1✔
1355
      }
1356
    }
1357
  }
1358

1359
  @Override
1360
  public void RespondActivityTaskCanceledByID(RespondActivityTaskCanceledByIDRequest request)
1361
      throws TException {
1362
    measureRemoteProc(
1✔
1363
        ServiceMethod.RESPOND_ACTIVITY_TASK_CANCELED_BY_ID,
1364
        () -> respondActivityTaskCanceledByID(request));
1✔
1365
  }
1✔
1366

1367
  private void respondActivityTaskCanceledByID(
1368
      RespondActivityTaskCanceledByIDRequest canceledByIDRequest) throws TException {
1369
    ThriftResponse<WorkflowService.RespondActivityTaskCanceledByID_result> response = null;
1✔
1370
    try {
1371
      ThriftRequest<WorkflowService.RespondActivityTaskCanceledByID_args> request =
1✔
1372
          buildThriftRequest(
1✔
1373
              "RespondActivityTaskCanceledByID",
1374
              new WorkflowService.RespondActivityTaskCanceledByID_args(canceledByIDRequest));
1375
      response = doRemoteCall(request);
1✔
1376
      WorkflowService.RespondActivityTaskCanceledByID_result result =
1✔
1377
          response.getBody(WorkflowService.RespondActivityTaskCanceledByID_result.class);
1✔
1378
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1379
        return;
1✔
1380
      }
1381
      if (result.isSetBadRequestError()) {
1✔
1382
        throw result.getBadRequestError();
1✔
1383
      }
1384
      if (result.isSetEntityNotExistError()) {
1✔
1385
        throw result.getEntityNotExistError();
1✔
1386
      }
1387
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
1✔
1388
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1389
      }
1390
      if (result.isSetServiceBusyError()) {
1✔
1391
        throw result.getServiceBusyError();
1✔
1392
      }
1393
      if (result.isSetDomainNotActiveError()) {
1✔
1394
        throw result.getDomainNotActiveError();
×
1395
      }
1396
      if (result.isSetLimitExceededError()) {
1✔
1397
        throw result.getLimitExceededError();
×
1398
      }
1399
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1400
        throw result.getClientVersionNotSupportedError();
×
1401
      }
1402
      throw new TException("RespondActivityTaskCanceledByID failed with unknown error:" + result);
1✔
1403
    } finally {
1404
      if (response != null) {
1✔
1405
        response.release();
1✔
1406
      }
1407
    }
1408
  }
1409

1410
  @Override
1411
  public void RequestCancelWorkflowExecution(RequestCancelWorkflowExecutionRequest request)
1412
      throws TException {
1413
    measureRemoteProc(
1✔
1414
        ServiceMethod.REQUEST_CANCEL_WORKFLOW_EXECUTION,
1415
        () -> requestCancelWorkflowExecution(request));
1✔
1416
  }
1✔
1417

1418
  private void requestCancelWorkflowExecution(RequestCancelWorkflowExecutionRequest cancelRequest)
1419
      throws TException {
1420
    if (!cancelRequest.isSetRequestId()) {
1✔
1421
      cancelRequest.setRequestId(UUID.randomUUID().toString());
1✔
1422
    }
1423
    ThriftResponse<WorkflowService.RequestCancelWorkflowExecution_result> response = null;
1✔
1424
    try {
1425
      ThriftRequest<WorkflowService.RequestCancelWorkflowExecution_args> request =
1✔
1426
          buildThriftRequest(
1✔
1427
              "RequestCancelWorkflowExecution",
1428
              new WorkflowService.RequestCancelWorkflowExecution_args(cancelRequest));
1429
      response = doRemoteCall(request);
1✔
1430
      WorkflowService.RequestCancelWorkflowExecution_result result =
1✔
1431
          response.getBody(WorkflowService.RequestCancelWorkflowExecution_result.class);
1✔
1432
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1433
        return;
1✔
1434
      }
1435
      if (result.isSetBadRequestError()) {
1✔
1436
        throw result.getBadRequestError();
1✔
1437
      }
1438
      if (result.isSetEntityNotExistError()) {
1✔
1439
        throw result.getEntityNotExistError();
1✔
1440
      }
1441
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
1✔
1442
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1443
      }
1444
      if (result.isSetCancellationAlreadyRequestedError()) {
1✔
1445
        throw result.getCancellationAlreadyRequestedError();
×
1446
      }
1447
      if (result.isSetServiceBusyError()) {
1✔
1448
        throw result.getServiceBusyError();
1✔
1449
      }
1450
      if (result.isSetDomainNotActiveError()) {
1✔
1451
        throw result.getDomainNotActiveError();
×
1452
      }
1453
      if (result.isSetLimitExceededError()) {
1✔
1454
        throw result.getLimitExceededError();
×
1455
      }
1456
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1457
        throw result.getClientVersionNotSupportedError();
×
1458
      }
1459
      throw new TException("RequestCancelWorkflowExecution failed with unknown error:" + result);
1✔
1460
    } finally {
1461
      if (response != null) {
1✔
1462
        response.release();
1✔
1463
      }
1464
    }
1465
  }
1466

1467
  @Override
1468
  public void SignalWorkflowExecution(SignalWorkflowExecutionRequest request) throws TException {
1469
    measureRemoteProc(
1✔
1470
        ServiceMethod.SIGNAL_WORKFLOW_EXECUTION, () -> signalWorkflowExecution(request));
1✔
1471
  }
1✔
1472

1473
  private void signalWorkflowExecution(SignalWorkflowExecutionRequest signalRequest)
1474
      throws TException {
1475
    ThriftResponse<WorkflowService.SignalWorkflowExecution_result> response = null;
1✔
1476
    try {
1477
      ThriftRequest<WorkflowService.SignalWorkflowExecution_args> request =
1✔
1478
          buildThriftRequest(
1✔
1479
              "SignalWorkflowExecution",
1480
              new WorkflowService.SignalWorkflowExecution_args(signalRequest));
1481
      response = doRemoteCall(request);
1✔
1482
      WorkflowService.SignalWorkflowExecution_result result =
1✔
1483
          response.getBody(WorkflowService.SignalWorkflowExecution_result.class);
1✔
1484
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1485
        return;
1✔
1486
      }
1487
      if (result.isSetBadRequestError()) {
1✔
1488
        throw result.getBadRequestError();
1✔
1489
      }
1490
      if (result.isSetEntityNotExistError()) {
1✔
1491
        throw result.getEntityNotExistError();
1✔
1492
      }
1493
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
1✔
1494
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1495
      }
1496
      if (result.isSetServiceBusyError()) {
1✔
1497
        throw result.getServiceBusyError();
1✔
1498
      }
1499
      if (result.isSetDomainNotActiveError()) {
1✔
1500
        throw result.getDomainNotActiveError();
×
1501
      }
1502
      if (result.isSetLimitExceededError()) {
1✔
1503
        throw result.getLimitExceededError();
×
1504
      }
1505
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1506
        throw result.getClientVersionNotSupportedError();
×
1507
      }
1508
      throw new TException("SignalWorkflowExecution failed with unknown error:" + result);
1✔
1509
    } finally {
1510
      if (response != null) {
1✔
1511
        response.release();
1✔
1512
      }
1513
    }
1514
  }
1515

1516
  @Override
1517
  public StartWorkflowExecutionResponse SignalWithStartWorkflowExecution(
1518
      SignalWithStartWorkflowExecutionRequest signalWithStartRequest) throws TException {
1519
    return measureRemoteCall(
1✔
1520
        ServiceMethod.SIGNAL_WITH_START_WORKFLOW_EXECUTION,
1521
        () -> signalWithStartWorkflowExecution(signalWithStartRequest));
1✔
1522
  }
1523

1524
  @Override
1525
  public SignalWithStartWorkflowExecutionAsyncResponse SignalWithStartWorkflowExecutionAsync(
1526
      SignalWithStartWorkflowExecutionAsyncRequest signalWithStartRequest) throws TException {
1527
    return measureRemoteCall(
1✔
1528
        ServiceMethod.SIGNAL_WITH_START_WORKFLOW_EXECUTION_ASYNC,
1529
        () -> signalWithStartWorkflowExecutionAsync(signalWithStartRequest));
1✔
1530
  }
1531

1532
  private SignalWithStartWorkflowExecutionAsyncResponse signalWithStartWorkflowExecutionAsync(
1533
      SignalWithStartWorkflowExecutionAsyncRequest signalWithStartRequest) throws TException {
1534
    ThriftResponse<WorkflowService.SignalWithStartWorkflowExecutionAsync_result> response = null;
1✔
1535
    try {
1536
      initializeSignalWithStartWorkflowRequest(signalWithStartRequest.getRequest());
1✔
1537

1538
      ThriftRequest<WorkflowService.SignalWithStartWorkflowExecutionAsync_args> request =
1✔
1539
          buildThriftRequest(
1✔
1540
              "SignalWithStartWorkflowExecutionAsync",
1541
              new WorkflowService.SignalWithStartWorkflowExecutionAsync_args(
1542
                  signalWithStartRequest));
1543

1544
      response = doRemoteCall(request);
1✔
1545
      WorkflowService.SignalWithStartWorkflowExecutionAsync_result result =
1✔
1546
          response.getBody(WorkflowService.SignalWithStartWorkflowExecutionAsync_result.class);
1✔
1547
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1548
        return result.getSuccess();
1✔
1549
      }
1550
      if (result.isSetBadRequestError()) {
1✔
1551
        throw result.getBadRequestError();
1✔
1552
      }
1553
      if (result.isSetEntityNotExistError()) {
1✔
1554
        throw result.getEntityNotExistError();
1✔
1555
      }
1556
      if (result.isSetServiceBusyError()) {
1✔
1557
        throw result.getServiceBusyError();
1✔
1558
      }
1559
      if (result.isSetDomainNotActiveError()) {
1✔
1560
        throw result.getDomainNotActiveError();
×
1561
      }
1562
      if (result.isSetLimitExceededError()) {
1✔
1563
        throw result.getLimitExceededError();
×
1564
      }
1565
      if (result.isSetDomainNotActiveError()) {
1✔
1566
        throw result.getDomainNotActiveError();
×
1567
      }
1568
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1569
        throw result.getClientVersionNotSupportedError();
×
1570
      }
1571
      throw new TException(
1✔
1572
          "SignalWithStartWorkflowExecutionAsync failed with unknown error:" + result);
1573
    } finally {
1574
      if (response != null) {
1✔
1575
        response.release();
1✔
1576
      }
1577
    }
1578
  }
1579

1580
  @Override
1581
  public ResetWorkflowExecutionResponse ResetWorkflowExecution(
1582
      ResetWorkflowExecutionRequest resetRequest)
1583
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1584
          DomainNotActiveError, LimitExceededError, ClientVersionNotSupportedError, TException {
1585
    return measureRemoteCall(
1✔
1586
        ServiceMethod.RESET_WORKFLOW_EXECUTION, () -> resetWorkflowExecution(resetRequest));
1✔
1587
  }
1588

1589
  private ResetWorkflowExecutionResponse resetWorkflowExecution(
1590
      ResetWorkflowExecutionRequest resetRequest) throws TException {
1591
    ThriftResponse<WorkflowService.ResetWorkflowExecution_result> response = null;
1✔
1592
    try {
1593
      ThriftRequest<WorkflowService.ResetWorkflowExecution_args> request =
1✔
1594
          buildThriftRequest(
1✔
1595
              "ResetWorkflowExecution",
1596
              new WorkflowService.ResetWorkflowExecution_args(resetRequest));
1597
      response = doRemoteCall(request);
1✔
1598
      WorkflowService.ResetWorkflowExecution_result result =
1✔
1599
          response.getBody(WorkflowService.ResetWorkflowExecution_result.class);
1✔
1600
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1601
        return result.getSuccess();
1✔
1602
      }
1603
      if (result.isSetBadRequestError()) {
1✔
1604
        throw result.getBadRequestError();
1✔
1605
      }
1606
      if (result.isSetEntityNotExistError()) {
1✔
1607
        throw result.getEntityNotExistError();
×
1608
      }
1609
      if (result.isSetServiceBusyError()) {
1✔
1610
        throw result.getServiceBusyError();
1✔
1611
      }
1612
      if (result.isSetDomainNotActiveError()) {
1✔
1613
        throw result.getDomainNotActiveError();
×
1614
      }
1615
      if (result.isSetLimitExceededError()) {
1✔
1616
        throw result.getLimitExceededError();
×
1617
      }
1618
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1619
        throw result.getClientVersionNotSupportedError();
×
1620
      }
1621
      throw new TException("ResetWorkflowExecution failed with unknown error:" + result);
1✔
1622
    } finally {
1623
      if (response != null) {
1✔
1624
        response.release();
1✔
1625
      }
1626
    }
1627
  }
1628

1629
  private StartWorkflowExecutionResponse signalWithStartWorkflowExecution(
1630
      SignalWithStartWorkflowExecutionRequest signalWithStartRequest) throws TException {
1631
    ThriftResponse<WorkflowService.SignalWithStartWorkflowExecution_result> response = null;
1✔
1632
    try {
1633
      initializeSignalWithStartWorkflowRequest(signalWithStartRequest);
1✔
1634

1635
      ThriftRequest<WorkflowService.SignalWithStartWorkflowExecution_args> request =
1✔
1636
          buildThriftRequest(
1✔
1637
              "SignalWithStartWorkflowExecution",
1638
              new WorkflowService.SignalWithStartWorkflowExecution_args(signalWithStartRequest));
1639

1640
      response = doRemoteCall(request);
1✔
1641
      WorkflowService.SignalWithStartWorkflowExecution_result result =
1✔
1642
          response.getBody(WorkflowService.SignalWithStartWorkflowExecution_result.class);
1✔
1643
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1644
        return result.getSuccess();
1✔
1645
      }
1646
      if (result.isSetBadRequestError()) {
1✔
1647
        throw result.getBadRequestError();
1✔
1648
      }
1649
      if (result.isSetEntityNotExistError()) {
1✔
1650
        throw result.getEntityNotExistError();
1✔
1651
      }
1652
      if (result.isSetServiceBusyError()) {
1✔
1653
        throw result.getServiceBusyError();
1✔
1654
      }
1655
      if (result.isSetDomainNotActiveError()) {
1✔
1656
        throw result.getDomainNotActiveError();
×
1657
      }
1658
      if (result.isSetLimitExceededError()) {
1✔
1659
        throw result.getLimitExceededError();
×
1660
      }
1661
      if (result.isSetDomainNotActiveError()) {
1✔
1662
        throw result.getDomainNotActiveError();
×
1663
      }
1664
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1665
        throw result.getClientVersionNotSupportedError();
×
1666
      }
1667
      throw new TException("SignalWithStartWorkflowExecution failed with unknown error:" + result);
1✔
1668
    } finally {
1669
      if (response != null) {
1✔
1670
        response.release();
1✔
1671
      }
1672
    }
1673
  }
1674

1675
  private void initializeSignalWithStartWorkflowRequest(
1676
      SignalWithStartWorkflowExecutionRequest request) {
1677
    if (!request.isSetRequestId()) {
1✔
1678
      request.setRequestId(UUID.randomUUID().toString());
1✔
1679
    }
1680
    // Write span context to header
1681
    if (!request.isSetHeader()) {
1✔
1682
      request.setHeader(new Header());
1✔
1683
    }
1684
    tracingPropagator.inject(request.getHeader());
1✔
1685
  }
1✔
1686

1687
  @Override
1688
  public void TerminateWorkflowExecution(TerminateWorkflowExecutionRequest request)
1689
      throws TException {
1690
    measureRemoteProc(
1✔
1691
        ServiceMethod.TERMINATE_WORKFLOW_EXECUTION, () -> terminateWorkflowExecution(request));
1✔
1692
  }
1✔
1693

1694
  private void terminateWorkflowExecution(TerminateWorkflowExecutionRequest terminateRequest)
1695
      throws TException {
1696
    ThriftResponse<WorkflowService.TerminateWorkflowExecution_result> response = null;
1✔
1697
    try {
1698
      ThriftRequest<WorkflowService.TerminateWorkflowExecution_args> request =
1✔
1699
          buildThriftRequest(
1✔
1700
              "TerminateWorkflowExecution",
1701
              new WorkflowService.TerminateWorkflowExecution_args(terminateRequest));
1702
      response = doRemoteCall(request);
1✔
1703
      WorkflowService.TerminateWorkflowExecution_result result =
1✔
1704
          response.getBody(WorkflowService.TerminateWorkflowExecution_result.class);
1✔
1705
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1706
        return;
1✔
1707
      }
1708
      if (result.isSetBadRequestError()) {
1✔
1709
        throw result.getBadRequestError();
1✔
1710
      }
1711
      if (result.isSetEntityNotExistError()) {
1✔
1712
        throw result.getEntityNotExistError();
×
1713
      }
1714
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
1✔
1715
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1716
      }
1717
      if (result.isSetServiceBusyError()) {
1✔
1718
        throw result.getServiceBusyError();
1✔
1719
      }
1720
      if (result.isSetDomainNotActiveError()) {
1✔
1721
        throw result.getDomainNotActiveError();
×
1722
      }
1723
      if (result.isSetLimitExceededError()) {
1✔
1724
        throw result.getLimitExceededError();
×
1725
      }
1726
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1727
        throw result.getClientVersionNotSupportedError();
×
1728
      }
1729
      throw new TException("TerminateWorkflowExecution failed with unknown error:" + result);
1✔
1730
    } finally {
1731
      if (response != null) {
1✔
1732
        response.release();
1✔
1733
      }
1734
    }
1735
  }
1736

1737
  @Override
1738
  public ListOpenWorkflowExecutionsResponse ListOpenWorkflowExecutions(
1739
      ListOpenWorkflowExecutionsRequest request) throws TException {
1740
    return measureRemoteCall(
1✔
1741
        ServiceMethod.LIST_OPEN_WORKFLOW_EXECUTIONS, () -> listOpenWorkflowExecutions(request));
1✔
1742
  }
1743

1744
  private ListOpenWorkflowExecutionsResponse listOpenWorkflowExecutions(
1745
      ListOpenWorkflowExecutionsRequest listRequest) throws TException {
1746
    ThriftResponse<WorkflowService.ListOpenWorkflowExecutions_result> response = null;
1✔
1747
    try {
1748
      ThriftRequest<WorkflowService.ListOpenWorkflowExecutions_args> request =
1✔
1749
          buildThriftRequest(
1✔
1750
              "ListOpenWorkflowExecutions",
1751
              new WorkflowService.ListOpenWorkflowExecutions_args(listRequest));
1752
      response = doRemoteCall(request);
1✔
1753
      WorkflowService.ListOpenWorkflowExecutions_result result =
1✔
1754
          response.getBody(WorkflowService.ListOpenWorkflowExecutions_result.class);
1✔
1755
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1756
        return result.getSuccess();
1✔
1757
      }
1758
      if (result.isSetBadRequestError()) {
1✔
1759
        throw result.getBadRequestError();
1✔
1760
      }
1761
      if (result.isSetEntityNotExistError()) {
1✔
1762
        throw result.getEntityNotExistError();
×
1763
      }
1764
      if (result.isSetServiceBusyError()) {
1✔
1765
        throw result.getServiceBusyError();
1✔
1766
      }
1767
      if (result.isSetLimitExceededError()) {
1✔
1768
        throw result.getLimitExceededError();
×
1769
      }
1770
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1771
        throw result.getClientVersionNotSupportedError();
×
1772
      }
1773
      throw new TException("ListOpenWorkflowExecutions failed with unknown error:" + result);
1✔
1774
    } finally {
1775
      if (response != null) {
1✔
1776
        response.release();
1✔
1777
      }
1778
    }
1779
  }
1780

1781
  @Override
1782
  public ListClosedWorkflowExecutionsResponse ListClosedWorkflowExecutions(
1783
      ListClosedWorkflowExecutionsRequest request) throws TException {
1784
    return measureRemoteCall(
1✔
1785
        ServiceMethod.LIST_CLOSED_WORKFLOW_EXECUTIONS, () -> listClosedWorkflowExecutions(request));
1✔
1786
  }
1787

1788
  private ListClosedWorkflowExecutionsResponse listClosedWorkflowExecutions(
1789
      ListClosedWorkflowExecutionsRequest listRequest) throws TException {
1790
    ThriftResponse<WorkflowService.ListClosedWorkflowExecutions_result> response = null;
1✔
1791
    try {
1792
      ThriftRequest<WorkflowService.ListClosedWorkflowExecutions_args> request =
1✔
1793
          buildThriftRequest(
1✔
1794
              "ListClosedWorkflowExecutions",
1795
              new WorkflowService.ListClosedWorkflowExecutions_args(listRequest));
1796
      response = doRemoteCall(request);
1✔
1797
      WorkflowService.ListClosedWorkflowExecutions_result result =
1✔
1798
          response.getBody(WorkflowService.ListClosedWorkflowExecutions_result.class);
1✔
1799
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1800
        return result.getSuccess();
1✔
1801
      }
1802
      if (result.isSetBadRequestError()) {
1✔
1803
        throw result.getBadRequestError();
1✔
1804
      }
1805
      if (result.isSetEntityNotExistError()) {
1✔
1806
        throw result.getEntityNotExistError();
×
1807
      }
1808
      if (result.isSetServiceBusyError()) {
1✔
1809
        throw result.getServiceBusyError();
1✔
1810
      }
1811
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1812
        throw result.getClientVersionNotSupportedError();
×
1813
      }
1814
      throw new TException("ListClosedWorkflowExecutions failed with unknown error:" + result);
1✔
1815
    } finally {
1816
      if (response != null) {
1✔
1817
        response.release();
1✔
1818
      }
1819
    }
1820
  }
1821

1822
  @Override
1823
  public ListWorkflowExecutionsResponse ListWorkflowExecutions(
1824
      ListWorkflowExecutionsRequest request)
1825
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1826
          ClientVersionNotSupportedError, TException {
1827
    return measureRemoteCall(
1✔
1828
        ServiceMethod.LIST_WORKFLOW_EXECUTIONS, () -> listWorkflowExecutions(request));
1✔
1829
  }
1830

1831
  private ListWorkflowExecutionsResponse listWorkflowExecutions(
1832
      ListWorkflowExecutionsRequest listRequest) throws TException {
1833
    ThriftResponse<WorkflowService.ListWorkflowExecutions_result> response = null;
1✔
1834
    try {
1835
      ThriftRequest<WorkflowService.ListWorkflowExecutions_args> request =
1✔
1836
          buildThriftRequest(
1✔
1837
              "ListWorkflowExecutions",
1838
              new WorkflowService.ListWorkflowExecutions_args(listRequest));
1839
      response = doRemoteCall(request);
1✔
1840
      WorkflowService.ListWorkflowExecutions_result result =
1✔
1841
          response.getBody(WorkflowService.ListWorkflowExecutions_result.class);
1✔
1842
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1843
        return result.getSuccess();
1✔
1844
      }
1845
      if (result.isSetBadRequestError()) {
1✔
1846
        throw result.getBadRequestError();
1✔
1847
      }
1848
      if (result.isSetEntityNotExistError()) {
1✔
1849
        throw result.getEntityNotExistError();
×
1850
      }
1851
      if (result.isSetServiceBusyError()) {
1✔
1852
        throw result.getServiceBusyError();
1✔
1853
      }
1854
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1855
        throw result.getClientVersionNotSupportedError();
×
1856
      }
1857
      throw new TException("ListWorkflowExecutions failed with unknown error:" + result);
1✔
1858
    } finally {
1859
      if (response != null) {
1✔
1860
        response.release();
1✔
1861
      }
1862
    }
1863
  }
1864

1865
  @Override
1866
  public ListArchivedWorkflowExecutionsResponse ListArchivedWorkflowExecutions(
1867
      ListArchivedWorkflowExecutionsRequest listRequest)
1868
      throws BadRequestError, EntityNotExistsError, ServiceBusyError,
1869
          ClientVersionNotSupportedError, TException {
1870
    return measureRemoteCall(
1✔
1871
        ServiceMethod.LIST_ARCHIVED_WORKFLOW_EXECUTIONS,
1872
        () -> listArchivedWorkflowExecutions(listRequest));
1✔
1873
  }
1874

1875
  private ListArchivedWorkflowExecutionsResponse listArchivedWorkflowExecutions(
1876
      ListArchivedWorkflowExecutionsRequest listRequest) throws TException {
1877
    ThriftResponse<WorkflowService.ListArchivedWorkflowExecutions_result> response = null;
1✔
1878
    try {
1879
      ThriftRequest<WorkflowService.ListArchivedWorkflowExecutions_args> request =
1✔
1880
          buildThriftRequest(
1✔
1881
              "ListArchivedWorkflowExecutions",
1882
              new WorkflowService.ListArchivedWorkflowExecutions_args(listRequest),
1883
              options.getRpcListArchivedWorkflowTimeoutMillis());
1✔
1884
      response = doRemoteCall(request);
1✔
1885
      WorkflowService.ListArchivedWorkflowExecutions_result result =
1✔
1886
          response.getBody(WorkflowService.ListArchivedWorkflowExecutions_result.class);
1✔
1887
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1888
        return result.getSuccess();
1✔
1889
      }
1890
      if (result.isSetBadRequestError()) {
1✔
1891
        throw result.getBadRequestError();
1✔
1892
      }
1893
      if (result.isSetEntityNotExistError()) {
1✔
1894
        throw result.getEntityNotExistError();
×
1895
      }
1896
      if (result.isSetServiceBusyError()) {
1✔
1897
        throw result.getServiceBusyError();
1✔
1898
      }
1899
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1900
        throw result.getClientVersionNotSupportedError();
×
1901
      }
1902
      throw new TException("ListArchivedWorkflowExecutions failed with unknown error:" + result);
1✔
1903
    } finally {
1904
      if (response != null) {
1✔
1905
        response.release();
1✔
1906
      }
1907
    }
1908
  }
1909

1910
  @Override
1911
  public ListWorkflowExecutionsResponse ScanWorkflowExecutions(
1912
      ListWorkflowExecutionsRequest request)
1913
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1914
          ClientVersionNotSupportedError, TException {
1915
    return measureRemoteCall(
1✔
1916
        ServiceMethod.SCAN_WORKFLOW_EXECUTIONS, () -> scanWorkflowExecutions(request));
1✔
1917
  }
1918

1919
  private ListWorkflowExecutionsResponse scanWorkflowExecutions(
1920
      ListWorkflowExecutionsRequest listRequest) throws TException {
1921
    ThriftResponse<WorkflowService.ScanWorkflowExecutions_result> response = null;
1✔
1922
    try {
1923
      ThriftRequest<WorkflowService.ScanWorkflowExecutions_args> request =
1✔
1924
          buildThriftRequest(
1✔
1925
              "ScanWorkflowExecutions",
1926
              new WorkflowService.ScanWorkflowExecutions_args(listRequest));
1927
      response = doRemoteCall(request);
1✔
1928
      WorkflowService.ScanWorkflowExecutions_result result =
1✔
1929
          response.getBody(WorkflowService.ScanWorkflowExecutions_result.class);
1✔
1930
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1931
        return result.getSuccess();
1✔
1932
      }
1933
      if (result.isSetBadRequestError()) {
1✔
1934
        throw result.getBadRequestError();
1✔
1935
      }
1936
      if (result.isSetEntityNotExistError()) {
1✔
1937
        throw result.getEntityNotExistError();
×
1938
      }
1939
      if (result.isSetServiceBusyError()) {
1✔
1940
        throw result.getServiceBusyError();
1✔
1941
      }
1942
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1943
        throw result.getClientVersionNotSupportedError();
×
1944
      }
1945
      throw new TException("ScanWorkflowExecutions failed with unknown error:" + result);
1✔
1946
    } finally {
1947
      if (response != null) {
1✔
1948
        response.release();
1✔
1949
      }
1950
    }
1951
  }
1952

1953
  @Override
1954
  public CountWorkflowExecutionsResponse CountWorkflowExecutions(
1955
      CountWorkflowExecutionsRequest countRequest)
1956
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1957
          ClientVersionNotSupportedError, TException {
1958
    return measureRemoteCall(
1✔
1959
        ServiceMethod.COUNT_WORKFLOW_EXECUTIONS, () -> countWorkflowExecutions(countRequest));
1✔
1960
  }
1961

1962
  private CountWorkflowExecutionsResponse countWorkflowExecutions(
1963
      CountWorkflowExecutionsRequest countRequest) throws TException {
1964
    ThriftResponse<WorkflowService.CountWorkflowExecutions_result> response = null;
1✔
1965
    try {
1966
      ThriftRequest<WorkflowService.CountWorkflowExecutions_args> request =
1✔
1967
          buildThriftRequest(
1✔
1968
              "CountWorkflowExecutions",
1969
              new WorkflowService.CountWorkflowExecutions_args(countRequest));
1970
      response = doRemoteCall(request);
1✔
1971
      WorkflowService.CountWorkflowExecutions_result result =
1✔
1972
          response.getBody(WorkflowService.CountWorkflowExecutions_result.class);
1✔
1973
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
1974
        return result.getSuccess();
1✔
1975
      }
1976
      if (result.isSetBadRequestError()) {
1✔
1977
        throw result.getBadRequestError();
1✔
1978
      }
1979
      if (result.isSetEntityNotExistError()) {
1✔
1980
        throw result.getEntityNotExistError();
×
1981
      }
1982
      if (result.isSetServiceBusyError()) {
1✔
1983
        throw result.getServiceBusyError();
1✔
1984
      }
1985
      if (result.isSetClientVersionNotSupportedError()) {
1✔
1986
        throw result.getClientVersionNotSupportedError();
×
1987
      }
1988
      throw new TException("CountWorkflowExecutions failed with unknown error:" + result);
1✔
1989
    } finally {
1990
      if (response != null) {
1✔
1991
        response.release();
1✔
1992
      }
1993
    }
1994
  }
1995

1996
  @Override
1997
  public GetSearchAttributesResponse GetSearchAttributes()
1998
      throws InternalServiceError, ServiceBusyError, ClientVersionNotSupportedError, TException {
1999
    return measureRemoteCall(ServiceMethod.GET_SEARCH_ATTRIBUTES, () -> getSearchAttributes());
1✔
2000
  }
2001

2002
  private GetSearchAttributesResponse getSearchAttributes() throws TException {
2003
    ThriftResponse<WorkflowService.GetSearchAttributes_result> response = null;
1✔
2004
    try {
2005
      ThriftRequest<WorkflowService.GetSearchAttributes_args> request =
1✔
2006
          buildThriftRequest("GetSearchAttributes", new WorkflowService.GetSearchAttributes_args());
1✔
2007
      response = doRemoteCall(request);
1✔
2008
      WorkflowService.GetSearchAttributes_result result =
1✔
2009
          response.getBody(WorkflowService.GetSearchAttributes_result.class);
1✔
2010
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
2011
        return result.getSuccess();
1✔
2012
      }
2013
      if (result.isSetServiceBusyError()) {
1✔
2014
        throw result.getServiceBusyError();
1✔
2015
      }
2016
      if (result.isSetClientVersionNotSupportedError()) {
1✔
2017
        throw result.getClientVersionNotSupportedError();
1✔
2018
      }
2019
      throw new TException("GetSearchAttributes failed with unknown error:" + result);
1✔
2020
    } finally {
2021
      if (response != null) {
1✔
2022
        response.release();
1✔
2023
      }
2024
    }
2025
  }
2026

2027
  @Override
2028
  public void RespondQueryTaskCompleted(RespondQueryTaskCompletedRequest request)
2029
      throws TException {
2030
    measureRemoteProc(
1✔
2031
        ServiceMethod.RESPOND_QUERY_TASK_COMPLETED, () -> respondQueryTaskCompleted(request));
1✔
2032
  }
1✔
2033

2034
  private void respondQueryTaskCompleted(RespondQueryTaskCompletedRequest completeRequest)
2035
      throws TException {
2036
    ThriftResponse<WorkflowService.RespondQueryTaskCompleted_result> response = null;
1✔
2037
    try {
2038
      ThriftRequest<WorkflowService.RespondQueryTaskCompleted_args> request =
1✔
2039
          buildThriftRequest(
1✔
2040
              "RespondQueryTaskCompleted",
2041
              new WorkflowService.RespondQueryTaskCompleted_args(completeRequest));
2042
      response = doRemoteCall(request);
1✔
2043
      WorkflowService.RespondQueryTaskCompleted_result result =
1✔
2044
          response.getBody(WorkflowService.RespondQueryTaskCompleted_result.class);
1✔
2045
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
2046
        return;
1✔
2047
      }
2048
      if (result.isSetBadRequestError()) {
1✔
2049
        throw result.getBadRequestError();
1✔
2050
      }
2051
      if (result.isSetEntityNotExistError()) {
1✔
2052
        throw result.getEntityNotExistError();
×
2053
      }
2054
      if (result.isSetServiceBusyError()) {
1✔
2055
        throw result.getServiceBusyError();
1✔
2056
      }
2057
      if (result.isSetDomainNotActiveError()) {
1✔
2058
        throw result.getDomainNotActiveError();
×
2059
      }
2060
      if (result.isSetLimitExceededError()) {
1✔
2061
        throw result.getLimitExceededError();
×
2062
      }
2063
      if (result.isSetClientVersionNotSupportedError()) {
1✔
2064
        throw result.getClientVersionNotSupportedError();
×
2065
      }
2066
      throw new TException("RespondQueryTaskCompleted failed with unknown error:" + result);
1✔
2067
    } finally {
2068
      if (response != null) {
1✔
2069
        response.release();
1✔
2070
      }
2071
    }
2072
  }
2073

2074
  @Override
2075
  public QueryWorkflowResponse QueryWorkflow(QueryWorkflowRequest request) throws TException {
2076
    return measureRemoteCall(ServiceMethod.QUERY_WORKFLOW, () -> queryWorkflow(request));
1✔
2077
  }
2078

2079
  private QueryWorkflowResponse queryWorkflow(QueryWorkflowRequest queryRequest) throws TException {
2080
    ThriftResponse<WorkflowService.QueryWorkflow_result> response = null;
1✔
2081
    try {
2082
      ThriftRequest<WorkflowService.QueryWorkflow_args> request =
1✔
2083
          buildThriftRequest(
1✔
2084
              "QueryWorkflow",
2085
              new WorkflowService.QueryWorkflow_args(queryRequest),
2086
              options.getRpcQueryTimeoutMillis());
1✔
2087
      response = doRemoteCall(request);
1✔
2088
      WorkflowService.QueryWorkflow_result result =
1✔
2089
          response.getBody(WorkflowService.QueryWorkflow_result.class);
1✔
2090
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
2091
        return result.getSuccess();
1✔
2092
      }
2093
      if (result.isSetBadRequestError()) {
1✔
2094
        throw result.getBadRequestError();
1✔
2095
      }
2096
      if (result.isSetServiceBusyError()) {
1✔
2097
        throw result.getServiceBusyError();
1✔
2098
      }
2099
      if (result.isSetEntityNotExistError()) {
1✔
2100
        throw result.getEntityNotExistError();
×
2101
      }
2102
      if (result.isSetQueryFailedError()) {
1✔
2103
        throw result.getQueryFailedError();
×
2104
      }
2105
      if (result.isSetClientVersionNotSupportedError()) {
1✔
2106
        throw result.getClientVersionNotSupportedError();
×
2107
      }
2108
      throw new TException("QueryWorkflow failed with unknown error:" + result);
1✔
2109
    } finally {
2110
      if (response != null) {
1✔
2111
        response.release();
1✔
2112
      }
2113
    }
2114
  }
2115

2116
  @Override
2117
  public ResetStickyTaskListResponse ResetStickyTaskList(ResetStickyTaskListRequest resetRequest)
2118
      throws BadRequestError, InternalServiceError, EntityNotExistsError, LimitExceededError,
2119
          WorkflowExecutionAlreadyCompletedError, ServiceBusyError, DomainNotActiveError,
2120
          TException {
2121
    return measureRemoteCall(
1✔
2122
        ServiceMethod.RESET_STICKY_TASK_LIST, () -> resetStickyTaskList(resetRequest));
1✔
2123
  }
2124

2125
  private ResetStickyTaskListResponse resetStickyTaskList(ResetStickyTaskListRequest queryRequest)
2126
      throws TException {
2127
    ThriftResponse<WorkflowService.ResetStickyTaskList_result> response = null;
1✔
2128
    try {
2129
      ThriftRequest<WorkflowService.ResetStickyTaskList_args> request =
1✔
2130
          buildThriftRequest(
1✔
2131
              "ResetStickyTaskList",
2132
              new WorkflowService.ResetStickyTaskList_args(queryRequest),
2133
              options.getRpcQueryTimeoutMillis());
1✔
2134
      response = doRemoteCall(request);
1✔
2135
      WorkflowService.ResetStickyTaskList_result result =
1✔
2136
          response.getBody(WorkflowService.ResetStickyTaskList_result.class);
1✔
2137
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
2138
        return result.getSuccess();
1✔
2139
      }
2140
      if (result.isSetBadRequestError()) {
1✔
2141
        throw result.getBadRequestError();
1✔
2142
      }
2143
      if (result.isSetEntityNotExistError()) {
1✔
2144
        throw result.getEntityNotExistError();
×
2145
      }
2146
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
1✔
2147
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
2148
      }
2149
      if (result.isSetServiceBusyError()) {
1✔
2150
        throw result.getServiceBusyError();
1✔
2151
      }
2152
      if (result.isSetDomainNotActiveError()) {
1✔
2153
        throw result.getDomainNotActiveError();
×
2154
      }
2155
      if (result.isSetLimitExceededError()) {
1✔
2156
        throw result.getLimitExceededError();
×
2157
      }
2158
      if (result.isSetClientVersionNotSupportedError()) {
1✔
2159
        throw result.getClientVersionNotSupportedError();
×
2160
      }
2161
      throw new TException("ResetStickyTaskList failed with unknown error:" + result);
1✔
2162
    } finally {
2163
      if (response != null) {
1✔
2164
        response.release();
1✔
2165
      }
2166
    }
2167
  }
2168

2169
  @Override
2170
  public DescribeWorkflowExecutionResponse DescribeWorkflowExecution(
2171
      DescribeWorkflowExecutionRequest request) throws TException {
2172
    return measureRemoteCall(
1✔
2173
        ServiceMethod.DESCRIBE_WORKFLOW_EXECUTION, () -> describeWorkflowExecution(request));
1✔
2174
  }
2175

2176
  private DescribeWorkflowExecutionResponse describeWorkflowExecution(
2177
      DescribeWorkflowExecutionRequest describeRequest) throws TException {
2178
    ThriftResponse<WorkflowService.DescribeWorkflowExecution_result> response = null;
1✔
2179
    try {
2180
      ThriftRequest<WorkflowService.DescribeWorkflowExecution_args> request =
1✔
2181
          buildThriftRequest(
1✔
2182
              "DescribeWorkflowExecution",
2183
              new WorkflowService.DescribeWorkflowExecution_args(describeRequest));
2184
      response = doRemoteCall(request);
1✔
2185
      WorkflowService.DescribeWorkflowExecution_result result =
1✔
2186
          response.getBody(WorkflowService.DescribeWorkflowExecution_result.class);
1✔
2187
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
2188
        return result.getSuccess();
1✔
2189
      }
2190
      if (result.isSetBadRequestError()) {
1✔
2191
        throw result.getBadRequestError();
1✔
2192
      }
2193
      if (result.isSetEntityNotExistError()) {
1✔
2194
        throw result.getEntityNotExistError();
×
2195
      }
2196
      if (result.isSetServiceBusyError()) {
1✔
2197
        throw result.getServiceBusyError();
1✔
2198
      }
2199
      if (result.isSetLimitExceededError()) {
1✔
2200
        throw result.getLimitExceededError();
×
2201
      }
2202
      if (result.isSetClientVersionNotSupportedError()) {
1✔
2203
        throw result.getClientVersionNotSupportedError();
×
2204
      }
2205
      throw new TException("DescribeWorkflowExecution failed with unknown error:" + result);
1✔
2206
    } finally {
2207
      if (response != null) {
1✔
2208
        response.release();
1✔
2209
      }
2210
    }
2211
  }
2212

2213
  @Override
2214
  public DescribeTaskListResponse DescribeTaskList(DescribeTaskListRequest request)
2215
      throws TException {
2216
    return measureRemoteCall(ServiceMethod.DESCRIBE_TASK_LIST, () -> describeTaskList(request));
1✔
2217
  }
2218

2219
  private DescribeTaskListResponse describeTaskList(DescribeTaskListRequest describeRequest)
2220
      throws TException {
2221
    ThriftResponse<WorkflowService.DescribeTaskList_result> response = null;
1✔
2222
    try {
2223
      ThriftRequest<WorkflowService.DescribeTaskList_args> request =
1✔
2224
          buildThriftRequest(
1✔
2225
              "DescribeTaskList", new WorkflowService.DescribeTaskList_args(describeRequest));
2226
      response = doRemoteCall(request);
1✔
2227
      WorkflowService.DescribeTaskList_result result =
1✔
2228
          response.getBody(WorkflowService.DescribeTaskList_result.class);
1✔
2229
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
2230
        return result.getSuccess();
1✔
2231
      }
2232
      if (result.isSetBadRequestError()) {
1✔
2233
        throw result.getBadRequestError();
1✔
2234
      }
2235
      if (result.isSetEntityNotExistError()) {
1✔
2236
        throw result.getEntityNotExistError();
×
2237
      }
2238
      if (result.isSetServiceBusyError()) {
1✔
2239
        throw result.getServiceBusyError();
1✔
2240
      }
2241
      if (result.isSetLimitExceededError()) {
1✔
2242
        throw result.getLimitExceededError();
×
2243
      }
2244
      if (result.isSetClientVersionNotSupportedError()) {
1✔
2245
        throw result.getClientVersionNotSupportedError();
×
2246
      }
2247
      throw new TException("DescribeTaskList failed with unknown error:" + result);
1✔
2248
    } finally {
2249
      if (response != null) {
1✔
2250
        response.release();
1✔
2251
      }
2252
    }
2253
  }
2254

2255
  @Override
2256
  public ClusterInfo GetClusterInfo() throws InternalServiceError, ServiceBusyError, TException {
2257
    return measureRemoteCall(ServiceMethod.GET_CLUSTER_INFO, () -> getClusterInfo());
1✔
2258
  }
2259

2260
  private ClusterInfo getClusterInfo() throws TException {
2261
    ThriftResponse<WorkflowService.GetClusterInfo_result> response = null;
1✔
2262
    try {
2263
      ThriftRequest<WorkflowService.GetClusterInfo_args> request =
1✔
2264
          buildThriftRequest("GetClusterInfo", new WorkflowService.GetClusterInfo_args());
1✔
2265
      response = doRemoteCall(request);
1✔
2266
      WorkflowService.GetClusterInfo_result result =
1✔
2267
          response.getBody(WorkflowService.GetClusterInfo_result.class);
1✔
2268
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
2269
        return result.getSuccess();
1✔
2270
      }
2271
      if (result.isSetServiceBusyError()) {
1✔
2272
        throw result.getServiceBusyError();
1✔
2273
      }
2274
      if (result.isSetInternalServiceError()) {
1✔
2275
        throw result.getInternalServiceError();
1✔
2276
      }
2277
      throw new TException("GetClusterInfo failed with unknown error:" + result);
1✔
2278
    } finally {
2279
      if (response != null) {
1✔
2280
        response.release();
1✔
2281
      }
2282
    }
2283
  }
2284

2285
  @Override
2286
  public ListTaskListPartitionsResponse ListTaskListPartitions(
2287
      ListTaskListPartitionsRequest request)
2288
      throws BadRequestError, EntityNotExistsError, LimitExceededError, ServiceBusyError,
2289
          TException {
2290
    return measureRemoteCall(
1✔
2291
        ServiceMethod.LIST_TASK_LIST_PARTITIONS, () -> listTaskListPartitions(request));
1✔
2292
  }
2293

2294
  @Override
2295
  public void RefreshWorkflowTasks(RefreshWorkflowTasksRequest refreshWorkflowTasks)
2296
      throws BadRequestError, DomainNotActiveError, ServiceBusyError, EntityNotExistsError,
2297
          TException {
2298
    ThriftResponse<WorkflowService.RefreshWorkflowTasks_result> response = null;
1✔
2299
    try {
2300
      ThriftRequest<WorkflowService.RefreshWorkflowTasks_args> request =
1✔
2301
          buildThriftRequest(
1✔
2302
              "RefreshWorkflowTasks",
2303
              new WorkflowService.RefreshWorkflowTasks_args(refreshWorkflowTasks));
2304
      response = doRemoteCall(request);
1✔
2305
      WorkflowService.RefreshWorkflowTasks_result result =
1✔
2306
          response.getBody(WorkflowService.RefreshWorkflowTasks_result.class);
1✔
2307
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
2308
        return;
1✔
2309
      }
2310
      if (result.isSetBadRequestError()) {
1✔
2311
        throw result.getBadRequestError();
1✔
2312
      }
2313
      if (result.isSetDomainNotActiveError()) {
1✔
2314
        throw result.getDomainNotActiveError();
1✔
2315
      }
2316
      if (result.isSetServiceBusyError()) {
1✔
2317
        throw result.getServiceBusyError();
1✔
2318
      }
2319
      if (result.isSetEntityNotExistError()) {
1✔
2320
        throw result.getEntityNotExistError();
1✔
2321
      }
2322
      throw new TException("RefreshWorkflowTasks failed with unknown error:" + result);
1✔
2323
    } finally {
2324
      if (response != null) {
1✔
2325
        response.release();
1✔
2326
      }
2327
    }
2328
  }
2329

2330
  private ListTaskListPartitionsResponse listTaskListPartitions(
2331
      ListTaskListPartitionsRequest listRequest) throws TException {
2332
    ThriftResponse<WorkflowService.ListTaskListPartitions_result> response = null;
1✔
2333
    try {
2334
      ThriftRequest<WorkflowService.ListTaskListPartitions_args> request =
1✔
2335
          buildThriftRequest(
1✔
2336
              "ListTaskListPartitions",
2337
              new WorkflowService.ListTaskListPartitions_args(listRequest));
2338
      response = doRemoteCall(request);
1✔
2339
      WorkflowService.ListTaskListPartitions_result result =
1✔
2340
          response.getBody(WorkflowService.ListTaskListPartitions_result.class);
1✔
2341
      if (response.getResponseCode() == ResponseCode.OK) {
1✔
2342
        return result.getSuccess();
1✔
2343
      }
2344
      if (result.isSetBadRequestError()) {
1✔
2345
        throw result.getBadRequestError();
1✔
2346
      }
2347
      if (result.isSetEntityNotExistError()) {
1✔
2348
        throw result.getEntityNotExistError();
×
2349
      }
2350
      if (result.isSetServiceBusyError()) {
1✔
2351
        throw result.getServiceBusyError();
1✔
2352
      }
2353
      if (result.isSetLimitExceededError()) {
1✔
2354
        throw result.getLimitExceededError();
×
2355
      }
2356
      throw new TException("ListTaskListPartitions failed with unknown error:" + result);
1✔
2357
    } finally {
2358
      if (response != null) {
1✔
2359
        response.release();
1✔
2360
      }
2361
    }
2362
  }
2363

2364
  @Override
2365
  public void StartWorkflowExecution(
2366
      StartWorkflowExecutionRequest startRequest, AsyncMethodCallback resultHandler) {
2367
    startWorkflowExecution(startRequest, resultHandler, null);
1✔
2368
  }
1✔
2369

2370
  @Override
2371
  public void StartWorkflowExecutionWithTimeout(
2372
      StartWorkflowExecutionRequest startRequest,
2373
      AsyncMethodCallback resultHandler,
2374
      Long timeoutInMillis) {
2375
    startWorkflowExecution(startRequest, resultHandler, timeoutInMillis);
×
2376
  }
×
2377

2378
  private void startWorkflowExecution(
2379
      StartWorkflowExecutionRequest startRequest,
2380
      AsyncMethodCallback resultHandler,
2381
      Long timeoutInMillis) {
2382
    initializeStartWorkflowRequest(startRequest);
1✔
2383
    timeoutInMillis = validateAndUpdateTimeout(timeoutInMillis, options.getRpcTimeoutMillis());
1✔
2384
    ThriftRequest<WorkflowService.StartWorkflowExecution_args> request =
1✔
2385
        buildThriftRequest(
1✔
2386
            "StartWorkflowExecution",
2387
            new WorkflowService.StartWorkflowExecution_args(startRequest),
2388
            timeoutInMillis);
2389

2390
    CompletableFuture<ThriftResponse<WorkflowService.StartWorkflowExecution_result>> response =
1✔
2391
        doRemoteCallAsync(request);
1✔
2392
    response
1✔
2393
        .whenComplete(
1✔
2394
            (r, e) -> {
2395
              try {
2396
                if (e != null) {
1✔
2397
                  resultHandler.onError(CheckedExceptionWrapper.wrap(e));
×
2398
                  return;
×
2399
                }
2400
                WorkflowService.StartWorkflowExecution_result result =
1✔
2401
                    r.getBody(WorkflowService.StartWorkflowExecution_result.class);
1✔
2402
                if (r.getResponseCode() == ResponseCode.OK) {
1✔
2403
                  resultHandler.onComplete(result.getSuccess());
1✔
2404
                  return;
1✔
2405
                }
2406
                if (result.isSetBadRequestError()) {
1✔
2407
                  resultHandler.onError(result.getBadRequestError());
1✔
2408
                  return;
1✔
2409
                }
2410
                if (result.isSetSessionAlreadyExistError()) {
1✔
2411
                  resultHandler.onError(result.getSessionAlreadyExistError());
1✔
2412
                  return;
1✔
2413
                }
2414
                if (result.isSetServiceBusyError()) {
1✔
2415
                  resultHandler.onError(result.getServiceBusyError());
1✔
2416
                  return;
1✔
2417
                }
2418
                if (result.isSetDomainNotActiveError()) {
1✔
2419
                  resultHandler.onError(result.getDomainNotActiveError());
1✔
2420
                  return;
1✔
2421
                }
2422
                if (result.isSetLimitExceededError()) {
1✔
2423
                  resultHandler.onError(result.getLimitExceededError());
1✔
2424
                  return;
1✔
2425
                }
2426
                if (result.isSetEntityNotExistError()) {
1✔
2427
                  resultHandler.onError(result.getEntityNotExistError());
1✔
2428
                  return;
1✔
2429
                }
2430
                if (result.isSetClientVersionNotSupportedError()) {
1✔
2431
                  resultHandler.onError(result.getClientVersionNotSupportedError());
1✔
2432
                }
2433
                resultHandler.onError(
1✔
2434
                    new TException("StartWorkflowExecution failed with unknown error:" + result));
2435
              } finally {
2436
                if (r != null) {
1✔
2437
                  r.release();
1✔
2438
                }
2439
              }
2440
            })
1✔
2441
        .exceptionally(
1✔
2442
            (e) -> {
2443
              log.error("Unexpected error in StartWorkflowExecution", e);
1✔
2444
              return null;
1✔
2445
            });
2446
  }
1✔
2447

2448
  @Override
2449
  public void StartWorkflowExecutionAsync(
2450
      StartWorkflowExecutionAsyncRequest startRequest, AsyncMethodCallback resultHandler)
2451
      throws TException {
2452
    startWorkflowExecutionAsync(startRequest, resultHandler, null);
1✔
2453
  }
1✔
2454

2455
  @Override
2456
  public void StartWorkflowExecutionAsyncWithTimeout(
2457
      StartWorkflowExecutionAsyncRequest startAsyncRequest,
2458
      AsyncMethodCallback resultHandler,
2459
      Long timeoutInMillis)
2460
      throws TException {
2461
    startWorkflowExecutionAsync(startAsyncRequest, resultHandler, timeoutInMillis);
1✔
2462
  }
1✔
2463

2464
  private void startWorkflowExecutionAsync(
2465
      StartWorkflowExecutionAsyncRequest startAsyncRequest,
2466
      AsyncMethodCallback resultHandler,
2467
      Long timeoutInMillis)
2468
      throws TException {
2469
    initializeStartWorkflowRequest(startAsyncRequest.getRequest());
1✔
2470
    timeoutInMillis = validateAndUpdateTimeout(timeoutInMillis, options.getRpcTimeoutMillis());
1✔
2471
    ThriftRequest<WorkflowService.StartWorkflowExecutionAsync_args> request =
1✔
2472
        buildThriftRequest(
1✔
2473
            "StartWorkflowExecutionAsync",
2474
            new WorkflowService.StartWorkflowExecutionAsync_args(startAsyncRequest),
2475
            timeoutInMillis);
2476

2477
    CompletableFuture<ThriftResponse<WorkflowService.StartWorkflowExecutionAsync_result>> response =
1✔
2478
        doRemoteCallAsync(request);
1✔
2479
    response
1✔
2480
        .whenComplete(
1✔
2481
            (r, e) -> {
2482
              try {
2483
                if (e != null) {
1✔
2484
                  resultHandler.onError(CheckedExceptionWrapper.wrap(e));
×
2485
                  return;
×
2486
                }
2487
                WorkflowService.StartWorkflowExecutionAsync_result result =
1✔
2488
                    r.getBody(WorkflowService.StartWorkflowExecutionAsync_result.class);
1✔
2489
                if (r.getResponseCode() == ResponseCode.OK) {
1✔
2490
                  resultHandler.onComplete(result.getSuccess());
1✔
2491
                  return;
1✔
2492
                }
2493
                if (result.isSetBadRequestError()) {
1✔
2494
                  resultHandler.onError(result.getBadRequestError());
1✔
2495
                  return;
1✔
2496
                }
2497
                if (result.isSetSessionAlreadyExistError()) {
1✔
2498
                  resultHandler.onError(result.getSessionAlreadyExistError());
1✔
2499
                  return;
1✔
2500
                }
2501
                if (result.isSetServiceBusyError()) {
1✔
2502
                  resultHandler.onError(result.getServiceBusyError());
1✔
2503
                  return;
1✔
2504
                }
2505
                if (result.isSetDomainNotActiveError()) {
1✔
2506
                  resultHandler.onError(result.getDomainNotActiveError());
1✔
2507
                  return;
1✔
2508
                }
2509
                if (result.isSetLimitExceededError()) {
1✔
2510
                  resultHandler.onError(result.getLimitExceededError());
1✔
2511
                  return;
1✔
2512
                }
2513
                if (result.isSetEntityNotExistError()) {
1✔
2514
                  resultHandler.onError(result.getEntityNotExistError());
1✔
2515
                  return;
1✔
2516
                }
2517
                if (result.isSetClientVersionNotSupportedError()) {
1✔
2518
                  resultHandler.onError(result.getClientVersionNotSupportedError());
1✔
2519
                }
2520
                resultHandler.onError(
1✔
2521
                    new TException(
2522
                        "StartWorkflowExecutionAsync failed with unknown error:" + result));
2523
              } finally {
2524
                if (r != null) {
1✔
2525
                  r.release();
1✔
2526
                }
2527
              }
2528
            })
1✔
2529
        .exceptionally(
1✔
2530
            (e) -> {
2531
              log.error("Unexpected error in StartWorkflowExecutionAsync", e);
1✔
2532
              return null;
1✔
2533
            });
2534
  }
1✔
2535

2536
  private Long validateAndUpdateTimeout(Long timeoutInMillis, Long defaultTimeoutInMillis) {
2537
    if (timeoutInMillis == null || timeoutInMillis <= 0 || timeoutInMillis == Long.MAX_VALUE) {
1✔
2538
      timeoutInMillis = defaultTimeoutInMillis;
1✔
2539
    } else {
2540
      timeoutInMillis = Math.min(timeoutInMillis, defaultTimeoutInMillis);
1✔
2541
    }
2542
    return timeoutInMillis;
1✔
2543
  }
2544

2545
  @SuppressWarnings({"unchecked", "FutureReturnValueIgnored"})
2546
  @Override
2547
  public void GetWorkflowExecutionHistoryWithTimeout(
2548
      GetWorkflowExecutionHistoryRequest getRequest,
2549
      AsyncMethodCallback resultHandler,
2550
      Long timeoutInMillis) {
2551

2552
    getWorkflowExecutionHistory(getRequest, resultHandler, timeoutInMillis);
1✔
2553
  }
1✔
2554

2555
  @SuppressWarnings({"unchecked", "FutureReturnValueIgnored"})
2556
  @Override
2557
  public void GetWorkflowExecutionHistory(
2558
      GetWorkflowExecutionHistoryRequest getRequest, AsyncMethodCallback resultHandler) {
2559

2560
    getWorkflowExecutionHistory(getRequest, resultHandler, null);
×
2561
  }
×
2562

2563
  private void getWorkflowExecutionHistory(
2564
      GetWorkflowExecutionHistoryRequest getRequest,
2565
      AsyncMethodCallback resultHandler,
2566
      Long timeoutInMillis) {
2567

2568
    ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args> request =
1✔
2569
        buildGetWorkflowExecutionHistoryThriftRequest(getRequest, timeoutInMillis);
1✔
2570

2571
    CompletableFuture<ThriftResponse<GetWorkflowExecutionHistory_result>> response =
1✔
2572
        doRemoteCallAsync(request);
1✔
2573
    response
1✔
2574
        .whenComplete(
1✔
2575
            (r, e) -> {
2576
              try {
2577
                if (e != null) {
1✔
2578
                  resultHandler.onError(CheckedExceptionWrapper.wrap(e));
×
2579
                  return;
×
2580
                }
2581
                WorkflowService.GetWorkflowExecutionHistory_result result =
1✔
2582
                    r.getBody(WorkflowService.GetWorkflowExecutionHistory_result.class);
1✔
2583

2584
                if (r.getResponseCode() == ResponseCode.OK) {
1✔
2585
                  GetWorkflowExecutionHistoryResponse res = result.getSuccess();
1✔
2586
                  if (res.getRawHistory() != null) {
1✔
2587
                    History history =
×
2588
                        InternalUtils.DeserializeFromBlobDataToHistory(
×
2589
                            res.getRawHistory(), getRequest.getHistoryEventFilterType());
×
2590
                    res.setHistory(history);
×
2591
                  }
2592
                  resultHandler.onComplete(res);
1✔
2593
                  return;
1✔
2594
                }
2595
                if (result.isSetBadRequestError()) {
1✔
2596
                  resultHandler.onError(result.getBadRequestError());
1✔
2597
                  return;
1✔
2598
                }
2599
                if (result.isSetEntityNotExistError()) {
1✔
2600
                  resultHandler.onError(result.getEntityNotExistError());
1✔
2601
                  return;
1✔
2602
                }
2603
                if (result.isSetServiceBusyError()) {
1✔
2604
                  resultHandler.onError(result.getServiceBusyError());
1✔
2605
                  return;
1✔
2606
                }
2607
                resultHandler.onError(
1✔
2608
                    new TException(
2609
                        "GetWorkflowExecutionHistory failed with unknown " + "error:" + result));
2610
              } catch (TException tException) {
×
2611
                resultHandler.onError(tException);
×
2612
              } finally {
2613
                if (r != null) {
1✔
2614
                  r.release();
1✔
2615
                }
2616
              }
2617
            })
1✔
2618
        .exceptionally(
1✔
2619
            (e) -> {
2620
              log.error("Unexpected error in GetWorkflowExecutionHistory", e);
1✔
2621
              return null;
1✔
2622
            });
2623
  }
1✔
2624

2625
  @Override
2626
  public void PollForDecisionTask(
2627
      PollForDecisionTaskRequest pollRequest, AsyncMethodCallback resultHandler) throws TException {
2628
    throw new UnsupportedOperationException("not implemented");
1✔
2629
  }
2630

2631
  @Override
2632
  public void RespondDecisionTaskCompleted(
2633
      RespondDecisionTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
2634
      throws TException {
2635
    throw new UnsupportedOperationException("not implemented");
1✔
2636
  }
2637

2638
  @Override
2639
  public void RespondDecisionTaskFailed(
2640
      RespondDecisionTaskFailedRequest failedRequest, AsyncMethodCallback resultHandler)
2641
      throws TException {
2642
    throw new UnsupportedOperationException("not implemented");
1✔
2643
  }
2644

2645
  @Override
2646
  public void PollForActivityTask(
2647
      PollForActivityTaskRequest pollRequest, AsyncMethodCallback resultHandler) throws TException {
2648
    throw new UnsupportedOperationException("not implemented");
1✔
2649
  }
2650

2651
  @Override
2652
  public void RecordActivityTaskHeartbeat(
2653
      RecordActivityTaskHeartbeatRequest heartbeatRequest, AsyncMethodCallback resultHandler)
2654
      throws TException {
2655
    throw new UnsupportedOperationException("not implemented");
1✔
2656
  }
2657

2658
  @Override
2659
  public void RecordActivityTaskHeartbeatByID(
2660
      RecordActivityTaskHeartbeatByIDRequest heartbeatRequest, AsyncMethodCallback resultHandler)
2661
      throws TException {
2662
    throw new UnsupportedOperationException("not implemented");
1✔
2663
  }
2664

2665
  @Override
2666
  public void RespondActivityTaskCompleted(
2667
      RespondActivityTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
2668
      throws TException {
2669
    throw new UnsupportedOperationException("not implemented");
1✔
2670
  }
2671

2672
  @Override
2673
  public void RespondActivityTaskCompletedByID(
2674
      RespondActivityTaskCompletedByIDRequest completeRequest, AsyncMethodCallback resultHandler)
2675
      throws TException {
2676
    throw new UnsupportedOperationException("not implemented");
1✔
2677
  }
2678

2679
  @Override
2680
  public void RespondActivityTaskFailed(
2681
      RespondActivityTaskFailedRequest failRequest, AsyncMethodCallback resultHandler)
2682
      throws TException {
2683
    throw new UnsupportedOperationException("not implemented");
1✔
2684
  }
2685

2686
  @Override
2687
  public void RespondActivityTaskFailedByID(
2688
      RespondActivityTaskFailedByIDRequest failRequest, AsyncMethodCallback resultHandler)
2689
      throws TException {
2690
    throw new UnsupportedOperationException("not implemented");
1✔
2691
  }
2692

2693
  @Override
2694
  public void RespondActivityTaskCanceled(
2695
      RespondActivityTaskCanceledRequest canceledRequest, AsyncMethodCallback resultHandler)
2696
      throws TException {
2697
    throw new UnsupportedOperationException("not implemented");
1✔
2698
  }
2699

2700
  @Override
2701
  public void RespondActivityTaskCanceledByID(
2702
      RespondActivityTaskCanceledByIDRequest canceledRequest, AsyncMethodCallback resultHandler)
2703
      throws TException {
2704
    throw new UnsupportedOperationException("not implemented");
1✔
2705
  }
2706

2707
  @Override
2708
  public void RequestCancelWorkflowExecution(
2709
      RequestCancelWorkflowExecutionRequest cancelRequest, AsyncMethodCallback resultHandler)
2710
      throws TException {
2711
    throw new UnsupportedOperationException("not implemented");
1✔
2712
  }
2713

2714
  @Override
2715
  public void SignalWorkflowExecution(
2716
      SignalWorkflowExecutionRequest signalRequest, AsyncMethodCallback resultHandler) {
2717
    signalWorkflowExecution(signalRequest, resultHandler, null);
1✔
2718
  }
1✔
2719

2720
  @Override
2721
  public void SignalWorkflowExecutionWithTimeout(
2722
      SignalWorkflowExecutionRequest signalRequest,
2723
      AsyncMethodCallback resultHandler,
2724
      Long timeoutInMillis) {
2725
    signalWorkflowExecution(signalRequest, resultHandler, timeoutInMillis);
×
2726
  }
×
2727

2728
  private void signalWorkflowExecution(
2729
      SignalWorkflowExecutionRequest signalRequest,
2730
      AsyncMethodCallback resultHandler,
2731
      Long timeoutInMillis) {
2732

2733
    timeoutInMillis = validateAndUpdateTimeout(timeoutInMillis, options.getRpcTimeoutMillis());
1✔
2734
    ThriftRequest<WorkflowService.SignalWorkflowExecution_args> request =
1✔
2735
        buildThriftRequest(
1✔
2736
            "SignalWorkflowExecution",
2737
            new WorkflowService.SignalWorkflowExecution_args(signalRequest),
2738
            timeoutInMillis);
2739
    CompletableFuture<ThriftResponse<WorkflowService.SignalWorkflowExecution_result>> response =
1✔
2740
        doRemoteCallAsync(request);
1✔
2741
    response
1✔
2742
        .whenComplete(
1✔
2743
            (r, e) -> {
2744
              try {
2745
                if (e != null) {
1✔
2746
                  resultHandler.onError(CheckedExceptionWrapper.wrap(e));
×
2747
                  return;
×
2748
                }
2749
                WorkflowService.SignalWorkflowExecution_result result =
1✔
2750
                    r.getBody(WorkflowService.SignalWorkflowExecution_result.class);
1✔
2751
                if (r.getResponseCode() == ResponseCode.OK) {
1✔
2752
                  resultHandler.onComplete(null);
1✔
2753
                  return;
1✔
2754
                }
2755
                if (result.isSetBadRequestError()) {
1✔
2756
                  resultHandler.onError(result.getBadRequestError());
1✔
2757
                  return;
1✔
2758
                }
2759
                if (result.isSetEntityNotExistError()) {
1✔
2760
                  resultHandler.onError(result.getEntityNotExistError());
1✔
2761
                  return;
1✔
2762
                }
2763
                if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
1✔
2764
                  resultHandler.onError(result.getWorkflowExecutionAlreadyCompletedError());
×
2765
                  return;
×
2766
                }
2767
                if (result.isSetServiceBusyError()) {
1✔
2768
                  resultHandler.onError(result.getServiceBusyError());
1✔
2769
                  return;
1✔
2770
                }
2771
                if (result.isSetDomainNotActiveError()) {
1✔
2772
                  resultHandler.onError(result.getDomainNotActiveError());
×
2773
                  return;
×
2774
                }
2775
                if (result.isSetLimitExceededError()) {
1✔
2776
                  resultHandler.onError(result.getLimitExceededError());
×
2777
                  return;
×
2778
                }
2779
                if (result.isSetClientVersionNotSupportedError()) {
1✔
2780
                  resultHandler.onError(result.getClientVersionNotSupportedError());
×
2781
                  return;
×
2782
                }
2783
                resultHandler.onError(
1✔
2784
                    new TException("SignalWorkflowExecution failed with unknown error:" + result));
2785
              } finally {
2786
                if (r != null) {
1✔
2787
                  r.release();
1✔
2788
                }
2789
              }
2790
            })
1✔
2791
        .exceptionally(
1✔
2792
            (e) -> {
2793
              log.error("Unexpected error in SignalWorkflowExecution", e);
1✔
2794
              return null;
1✔
2795
            });
2796
  }
1✔
2797

2798
  @Override
2799
  public void SignalWithStartWorkflowExecution(
2800
      SignalWithStartWorkflowExecutionRequest signalWithStartRequest,
2801
      AsyncMethodCallback resultHandler)
2802
      throws TException {
2803
    throw new UnsupportedOperationException("not implemented");
1✔
2804
  }
2805

2806
  @Override
2807
  public void SignalWithStartWorkflowExecutionAsync(
2808
      SignalWithStartWorkflowExecutionAsyncRequest signalWithStartRequest,
2809
      AsyncMethodCallback resultHandler)
2810
      throws TException {
2811
    throw new UnsupportedOperationException("unimplemented");
1✔
2812
  }
2813

2814
  @Override
2815
  public void ResetWorkflowExecution(
2816
      ResetWorkflowExecutionRequest resetRequest, AsyncMethodCallback resultHandler)
2817
      throws TException {
2818
    throw new UnsupportedOperationException("not implemented");
×
2819
  }
2820

2821
  @Override
2822
  public void TerminateWorkflowExecution(
2823
      TerminateWorkflowExecutionRequest terminateRequest, AsyncMethodCallback resultHandler)
2824
      throws TException {
2825
    throw new UnsupportedOperationException("not implemented");
1✔
2826
  }
2827

2828
  @Override
2829
  public void ListOpenWorkflowExecutions(
2830
      ListOpenWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2831
      throws TException {
2832
    throw new UnsupportedOperationException("not implemented");
1✔
2833
  }
2834

2835
  @Override
2836
  public void ListClosedWorkflowExecutions(
2837
      ListClosedWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2838
      throws TException {
2839
    throw new UnsupportedOperationException("not implemented");
1✔
2840
  }
2841

2842
  @Override
2843
  public void ListWorkflowExecutions(
2844
      ListWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2845
      throws TException {
2846
    throw new UnsupportedOperationException("not implemented");
1✔
2847
  }
2848

2849
  @Override
2850
  public void ListArchivedWorkflowExecutions(
2851
      ListArchivedWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2852
      throws TException {
2853
    throw new UnsupportedOperationException("not implemented");
1✔
2854
  }
2855

2856
  @Override
2857
  public void ScanWorkflowExecutions(
2858
      ListWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2859
      throws TException {
2860
    throw new UnsupportedOperationException("not implemented");
1✔
2861
  }
2862

2863
  @Override
2864
  public void CountWorkflowExecutions(
2865
      CountWorkflowExecutionsRequest countRequest, AsyncMethodCallback resultHandler)
2866
      throws TException {
2867
    throw new UnsupportedOperationException("not implemented");
1✔
2868
  }
2869

2870
  @Override
2871
  public void GetSearchAttributes(AsyncMethodCallback resultHandler) throws TException {
2872
    throw new UnsupportedOperationException("not implemented");
1✔
2873
  }
2874

2875
  @Override
2876
  public void RespondQueryTaskCompleted(
2877
      RespondQueryTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
2878
      throws TException {
2879
    throw new UnsupportedOperationException("not implemented");
1✔
2880
  }
2881

2882
  @Override
2883
  public void ResetStickyTaskList(
2884
      ResetStickyTaskListRequest resetRequest, AsyncMethodCallback resultHandler)
2885
      throws TException {
2886
    throw new UnsupportedOperationException("not implemented");
1✔
2887
  }
2888

2889
  @Override
2890
  public void QueryWorkflow(QueryWorkflowRequest queryRequest, AsyncMethodCallback resultHandler)
2891
      throws TException {
2892
    throw new UnsupportedOperationException("not implemented");
1✔
2893
  }
2894

2895
  @Override
2896
  public void DescribeWorkflowExecution(
2897
      DescribeWorkflowExecutionRequest describeRequest, AsyncMethodCallback resultHandler)
2898
      throws TException {
2899
    throw new UnsupportedOperationException("not implemented");
1✔
2900
  }
2901

2902
  @Override
2903
  public void DescribeTaskList(DescribeTaskListRequest request, AsyncMethodCallback resultHandler)
2904
      throws TException {
2905
    throw new UnsupportedOperationException("not implemented");
1✔
2906
  }
2907

2908
  @Override
2909
  public void GetClusterInfo(AsyncMethodCallback resultHandler) throws TException {}
1✔
2910

2911
  @Override
2912
  public void ListTaskListPartitions(
2913
      ListTaskListPartitionsRequest request, AsyncMethodCallback resultHandler) throws TException {}
1✔
2914

2915
  @Override
2916
  public void RefreshWorkflowTasks(
2917
      RefreshWorkflowTasksRequest request, AsyncMethodCallback resultHandler) throws TException {}
1✔
2918

2919
  @Override
2920
  public void RegisterDomain(
2921
      RegisterDomainRequest registerRequest, AsyncMethodCallback resultHandler) throws TException {
2922
    throw new UnsupportedOperationException("not implemented");
×
2923
  }
2924

2925
  @Override
2926
  public void DescribeDomain(
2927
      DescribeDomainRequest describeRequest, AsyncMethodCallback resultHandler) throws TException {
2928
    throw new UnsupportedOperationException("not implemented");
1✔
2929
  }
2930

2931
  @Override
2932
  public void ListDomains(ListDomainsRequest listRequest, AsyncMethodCallback resultHandler)
2933
      throws TException {
2934
    throw new UnsupportedOperationException("not implemented");
1✔
2935
  }
2936

2937
  @Override
2938
  public void UpdateDomain(UpdateDomainRequest updateRequest, AsyncMethodCallback resultHandler)
2939
      throws TException {
2940
    throw new UnsupportedOperationException("not implemented");
1✔
2941
  }
2942

2943
  @Override
2944
  public void DeprecateDomain(
2945
      DeprecateDomainRequest deprecateRequest, AsyncMethodCallback resultHandler)
2946
      throws TException {
2947
    throw new UnsupportedOperationException("not implemented");
1✔
2948
  }
2949

2950
  @Override
2951
  public void RestartWorkflowExecution(
2952
      RestartWorkflowExecutionRequest restartRequest, AsyncMethodCallback resultHandler)
2953
      throws TException {
2954
    throw new UnsupportedOperationException("unimplemented");
×
2955
  }
2956

2957
  @Override
2958
  public void GetTaskListsByDomain(
2959
      GetTaskListsByDomainRequest request, AsyncMethodCallback resultHandler)
2960
      throws org.apache.thrift.TException {
2961
    throw new UnsupportedOperationException("not implemented");
1✔
2962
  }
2963
}
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