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

uber / cadence-java-client / 2566

29 Oct 2024 05:25PM UTC coverage: 66.637% (+0.01%) from 66.627%
2566

Pull #928

buildkite

natemort
Report child workflow started synchronously

By reporting child workflow started asynchronously we can observe a child workflow attempting to complete prior to its state machine registering that it started. This is an invalid state transition and causes test failures.

See https://github.com/temporalio/sdk-java/pull/1289 , we have the same test case still and it has similarly been flakey.
Pull Request #928: Report child workflow started synchronously in Test Implementation

2 of 5 new or added lines in 1 file covered. (40.0%)

2 existing lines in 1 file now uncovered.

12911 of 19375 relevant lines covered (66.64%)

0.67 hits per line

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

16.93
/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) {
×
127
    this.options = options;
×
128
    this.thriftHeaders = getThriftHeaders(options);
×
129
    this.tChannel = null;
×
130
    this.subChannel = subChannel;
×
131
    this.tracingPropagator = new TracingPropagator(options.getTracer());
×
132
    this.tracer = options.getTracer();
×
133
  }
×
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 =
×
193
        new ThriftRequest.Builder<Meta.health_args>(options.getServiceName(), "Meta::health")
×
194
            .setBody(new Meta.health_args())
×
195
            .build();
×
196
    final CompletableFuture<Boolean> result = new CompletableFuture<>();
×
197
    try {
198

199
      final TFuture<ThriftResponse<Meta.health_result>> future = this.subChannel.send(req);
×
200
      future.addCallback(
×
201
          response -> {
202
            req.releaseQuietly();
×
203
            if (response.isError()) {
×
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());
×
211
            }
212
            try {
213
              response.release();
×
214
            } catch (final Exception e) {
×
215
              // ignore
216
            }
×
217
          });
×
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
    }
×
226
    return result;
×
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✔
UNCOV
307
      if (response.getError().getErrorType() == ErrorType.Timeout) {
×
308
        throw new TTransportException(
×
309
            TTransportException.TIMED_OUT, response.getError().getMessage());
×
310
      } else {
UNCOV
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);
×
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
×
346
        | WorkflowExecutionAlreadyCompletedError
347
        | BadRequestError
348
        | DomainAlreadyExistsError
349
        | WorkflowExecutionAlreadyStartedError
350
        | QueryFailedError e) {
351
      sw.stop();
×
352
      scope.counter(MetricsType.CADENCE_INVALID_REQUEST).inc(1);
×
353
      throw e;
×
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));
×
379
  }
×
380

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

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

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

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

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

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

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

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

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

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

570
  private GetTaskListsByDomainResponse getTaskListsByDomain(
571
      GetTaskListsByDomainRequest getTaskListsByDomainRequest) throws TException {
572
    ThriftResponse<WorkflowService.GetTaskListsByDomain_result> response = null;
×
573
    try {
574
      ThriftRequest<WorkflowService.GetTaskListsByDomain_args> request =
×
575
          buildThriftRequest(
×
576
              "GetTaskListsByDomain",
577
              new WorkflowService.GetTaskListsByDomain_args(getTaskListsByDomainRequest));
578
      response = doRemoteCall(request);
×
579
      WorkflowService.GetTaskListsByDomain_result result =
×
580
          response.getBody(WorkflowService.GetTaskListsByDomain_result.class);
×
581
      if (response.getResponseCode() == ResponseCode.OK) {
×
582
        return result.getSuccess();
×
583
      }
584
      if (result.isSetBadRequestError()) {
×
585
        throw result.getBadRequestError();
×
586
      }
587
      if (result.isSetEntityNotExistError()) {
×
588
        throw result.getEntityNotExistError();
×
589
      }
590
      if (result.isSetLimitExceededError()) {
×
591
        throw result.getLimitExceededError();
×
592
      }
593
      if (result.isSetServiceBusyError()) {
×
594
        throw result.getServiceBusyError();
×
595
      }
596
      if (result.isSetClientVersionNotSupportedError()) {
×
597
        throw result.getClientVersionNotSupportedError();
×
598
      }
599
      throw new TException("GetTaskListsByDomain failed with unknown error:" + result);
×
600
    } finally {
601
      if (response != null) {
×
602
        response.release();
×
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();
×
633
      }
634
      if (result.isSetSessionAlreadyExistError()) {
1✔
635
        throw result.getSessionAlreadyExistError();
×
636
      }
637
      if (result.isSetServiceBusyError()) {
1✔
638
        throw result.getServiceBusyError();
1✔
639
      }
640
      if (result.isSetDomainNotActiveError()) {
×
641
        throw result.getDomainNotActiveError();
×
642
      }
643
      if (result.isSetLimitExceededError()) {
×
644
        throw result.getLimitExceededError();
×
645
      }
646
      if (result.isSetEntityNotExistError()) {
×
647
        throw result.getEntityNotExistError();
×
648
      }
649
      if (result.isSetClientVersionNotSupportedError()) {
×
650
        throw result.getClientVersionNotSupportedError();
×
651
      }
652
      throw new TException("StartWorkflowExecution failed with unknown error:" + result);
×
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();
×
687
      }
688
      if (result.isSetSessionAlreadyExistError()) {
1✔
689
        throw result.getSessionAlreadyExistError();
×
690
      }
691
      if (result.isSetServiceBusyError()) {
1✔
692
        throw result.getServiceBusyError();
1✔
693
      }
694
      if (result.isSetDomainNotActiveError()) {
×
695
        throw result.getDomainNotActiveError();
×
696
      }
697
      if (result.isSetLimitExceededError()) {
×
698
        throw result.getLimitExceededError();
×
699
      }
700
      if (result.isSetEntityNotExistError()) {
×
701
        throw result.getEntityNotExistError();
×
702
      }
703
      if (result.isSetClientVersionNotSupportedError()) {
×
704
        throw result.getClientVersionNotSupportedError();
×
705
      }
706
      throw new TException("StartWorkflowExecution failed with unknown error:" + result);
×
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());
×
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 =
×
729
        ImmutableMap.of(
×
730
            MetricsTag.REQUEST_TYPE,
731
            request.isWaitForNewEvent() ? REQUEST_TYPE_LONG_POLL : REQUEST_TYPE_NORMAL);
×
732
    return measureRemoteCallWithTags(
×
733
        ServiceMethod.GET_WORKFLOW_EXECUTION_HISTORY,
734
        () -> getWorkflowExecutionHistory(request, timeoutInMillis),
×
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;
×
754
    try {
755
      ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args> request =
×
756
          buildGetWorkflowExecutionHistoryThriftRequest(getRequest, timeoutInMillis);
×
757
      response = doRemoteCall(request);
×
758
      WorkflowService.GetWorkflowExecutionHistory_result result =
×
759
          response.getBody(WorkflowService.GetWorkflowExecutionHistory_result.class);
×
760
      if (response.getResponseCode() == ResponseCode.OK) {
×
761
        GetWorkflowExecutionHistoryResponse res = result.getSuccess();
×
762
        if (res.getRawHistory() != null) {
×
763
          History history =
×
764
              InternalUtils.DeserializeFromBlobDataToHistory(
×
765
                  res.getRawHistory(), getRequest.getHistoryEventFilterType());
×
766
          res.setHistory(history);
×
767
        }
768
        return res;
×
769
      }
770
      if (result.isSetBadRequestError()) {
×
771
        throw result.getBadRequestError();
×
772
      }
773
      if (result.isSetEntityNotExistError()) {
×
774
        throw result.getEntityNotExistError();
×
775
      }
776
      if (result.isSetServiceBusyError()) {
×
777
        throw result.getServiceBusyError();
×
778
      }
779
      throw new TException("GetWorkflowExecutionHistory failed with unknown error:" + result);
×
780
    } finally {
781
      if (response != null) {
×
782
        response.release();
×
783
      }
784
    }
785
  }
786

787
  private ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args>
788
      buildGetWorkflowExecutionHistoryThriftRequest(
789
          GetWorkflowExecutionHistoryRequest getRequest, Long timeoutInMillis) {
790

791
    if (getRequest.isWaitForNewEvent()) {
×
792
      timeoutInMillis =
×
793
          validateAndUpdateTimeout(timeoutInMillis, options.getRpcLongPollTimeoutMillis());
×
794
    } else {
795
      timeoutInMillis = validateAndUpdateTimeout(timeoutInMillis, options.getRpcTimeoutMillis());
×
796
    }
797

798
    return buildThriftRequest(
×
799
        "GetWorkflowExecutionHistory",
800
        new WorkflowService.GetWorkflowExecutionHistory_args(getRequest),
801
        timeoutInMillis);
802
  }
803

804
  @Override
805
  public PollForDecisionTaskResponse PollForDecisionTask(PollForDecisionTaskRequest request)
806
      throws TException {
807
    return measureRemoteCall(
×
808
        ServiceMethod.POLL_FOR_DECISION_TASK, () -> pollForDecisionTask(request));
×
809
  }
810

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

852
  @Override
853
  public RespondDecisionTaskCompletedResponse RespondDecisionTaskCompleted(
854
      RespondDecisionTaskCompletedRequest completedRequest) throws TException {
855
    return measureRemoteCall(
×
856
        ServiceMethod.RESPOND_DECISION_TASK_COMPLETED,
857
        () -> respondDecisionTaskCompleted(completedRequest));
×
858
  }
859

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

903
  @Override
904
  public void RespondDecisionTaskFailed(RespondDecisionTaskFailedRequest request)
905
      throws TException {
906
    measureRemoteProc(
×
907
        ServiceMethod.RESPOND_DECISION_TASK_FAILED, () -> respondDecisionTaskFailed(request));
×
908
  }
×
909

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

953
  @Override
954
  public PollForActivityTaskResponse PollForActivityTask(PollForActivityTaskRequest request)
955
      throws TException {
956
    return measureRemoteCall(
×
957
        ServiceMethod.POLL_FOR_ACTIVITY_TASK, () -> pollForActivityTask(request));
×
958
  }
959

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

1001
  @Override
1002
  public RecordActivityTaskHeartbeatResponse RecordActivityTaskHeartbeat(
1003
      RecordActivityTaskHeartbeatRequest request) throws TException {
1004
    return measureRemoteCall(
×
1005
        ServiceMethod.RECORD_ACTIVITY_TASK_HEARTBEAT, () -> recordActivityTaskHeartbeat(request));
×
1006
  }
1007

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

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

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

1104
  @Override
1105
  public void RespondActivityTaskCompleted(RespondActivityTaskCompletedRequest request)
1106
      throws TException {
1107
    measureRemoteProc(
×
1108
        ServiceMethod.RESPOND_ACTIVITY_TASK_COMPLETED, () -> respondActivityTaskCompleted(request));
×
1109
  }
×
1110

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

1154
  @Override
1155
  public void RespondActivityTaskCompletedByID(RespondActivityTaskCompletedByIDRequest request)
1156
      throws TException {
1157
    measureRemoteProc(
×
1158
        ServiceMethod.RESPOND_ACTIVITY_TASK_COMPLETED_BY_ID,
1159
        () -> respondActivityTaskCompletedByID(request));
×
1160
  }
×
1161

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

1205
  @Override
1206
  public void RespondActivityTaskFailed(RespondActivityTaskFailedRequest request)
1207
      throws TException {
1208
    measureRemoteProc(
×
1209
        ServiceMethod.RESPOND_ACTIVITY_TASK_FAILED, () -> respondActivityTaskFailed(request));
×
1210
  }
×
1211

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

1255
  @Override
1256
  public void RespondActivityTaskFailedByID(RespondActivityTaskFailedByIDRequest request)
1257
      throws TException {
1258
    measureRemoteProc(
×
1259
        ServiceMethod.RESPOND_ACTIVITY_TASK_FAILED_BY_ID,
1260
        () -> respondActivityTaskFailedByID(request));
×
1261
  }
×
1262

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

1306
  @Override
1307
  public void RespondActivityTaskCanceled(RespondActivityTaskCanceledRequest request)
1308
      throws TException {
1309
    measureRemoteProc(
×
1310
        ServiceMethod.RESPOND_ACTIVITY_TASK_CANCELED, () -> respondActivityTaskCanceled(request));
×
1311
  }
×
1312

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

1356
  @Override
1357
  public void RespondActivityTaskCanceledByID(RespondActivityTaskCanceledByIDRequest request)
1358
      throws TException {
1359
    measureRemoteProc(
×
1360
        ServiceMethod.RESPOND_ACTIVITY_TASK_CANCELED_BY_ID,
1361
        () -> respondActivityTaskCanceledByID(request));
×
1362
  }
×
1363

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

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

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

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

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

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

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

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

1535
      ThriftRequest<WorkflowService.SignalWithStartWorkflowExecutionAsync_args> request =
1✔
1536
          buildThriftRequest(
1✔
1537
              "SignalWithStartWorkflowExecutionAsync",
1538
              new WorkflowService.SignalWithStartWorkflowExecutionAsync_args(
1539
                  signalWithStartRequest));
1540

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

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

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

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

1632
      ThriftRequest<WorkflowService.SignalWithStartWorkflowExecution_args> request =
1✔
1633
          buildThriftRequest(
1✔
1634
              "SignalWithStartWorkflowExecution",
1635
              new WorkflowService.SignalWithStartWorkflowExecution_args(signalWithStartRequest));
1636

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

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

1684
  @Override
1685
  public void TerminateWorkflowExecution(TerminateWorkflowExecutionRequest request)
1686
      throws TException {
1687
    measureRemoteProc(
×
1688
        ServiceMethod.TERMINATE_WORKFLOW_EXECUTION, () -> terminateWorkflowExecution(request));
×
1689
  }
×
1690

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

1734
  @Override
1735
  public ListOpenWorkflowExecutionsResponse ListOpenWorkflowExecutions(
1736
      ListOpenWorkflowExecutionsRequest request) throws TException {
1737
    return measureRemoteCall(
×
1738
        ServiceMethod.LIST_OPEN_WORKFLOW_EXECUTIONS, () -> listOpenWorkflowExecutions(request));
×
1739
  }
1740

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

1778
  @Override
1779
  public ListClosedWorkflowExecutionsResponse ListClosedWorkflowExecutions(
1780
      ListClosedWorkflowExecutionsRequest request) throws TException {
1781
    return measureRemoteCall(
×
1782
        ServiceMethod.LIST_CLOSED_WORKFLOW_EXECUTIONS, () -> listClosedWorkflowExecutions(request));
×
1783
  }
1784

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

1819
  @Override
1820
  public ListWorkflowExecutionsResponse ListWorkflowExecutions(
1821
      ListWorkflowExecutionsRequest request)
1822
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1823
          ClientVersionNotSupportedError, TException {
1824
    return measureRemoteCall(
×
1825
        ServiceMethod.LIST_WORKFLOW_EXECUTIONS, () -> listWorkflowExecutions(request));
×
1826
  }
1827

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

1862
  @Override
1863
  public ListArchivedWorkflowExecutionsResponse ListArchivedWorkflowExecutions(
1864
      ListArchivedWorkflowExecutionsRequest listRequest)
1865
      throws BadRequestError, EntityNotExistsError, ServiceBusyError,
1866
          ClientVersionNotSupportedError, TException {
1867
    return measureRemoteCall(
×
1868
        ServiceMethod.LIST_ARCHIVED_WORKFLOW_EXECUTIONS,
1869
        () -> listArchivedWorkflowExecutions(listRequest));
×
1870
  }
1871

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

1907
  @Override
1908
  public ListWorkflowExecutionsResponse ScanWorkflowExecutions(
1909
      ListWorkflowExecutionsRequest request)
1910
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1911
          ClientVersionNotSupportedError, TException {
1912
    return measureRemoteCall(
×
1913
        ServiceMethod.SCAN_WORKFLOW_EXECUTIONS, () -> scanWorkflowExecutions(request));
×
1914
  }
1915

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

1950
  @Override
1951
  public CountWorkflowExecutionsResponse CountWorkflowExecutions(
1952
      CountWorkflowExecutionsRequest countRequest)
1953
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1954
          ClientVersionNotSupportedError, TException {
1955
    return measureRemoteCall(
×
1956
        ServiceMethod.COUNT_WORKFLOW_EXECUTIONS, () -> countWorkflowExecutions(countRequest));
×
1957
  }
1958

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

1993
  @Override
1994
  public GetSearchAttributesResponse GetSearchAttributes()
1995
      throws InternalServiceError, ServiceBusyError, ClientVersionNotSupportedError, TException {
1996
    return measureRemoteCall(ServiceMethod.GET_SEARCH_ATTRIBUTES, () -> getSearchAttributes());
×
1997
  }
1998

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

2024
  @Override
2025
  public void RespondQueryTaskCompleted(RespondQueryTaskCompletedRequest request)
2026
      throws TException {
2027
    measureRemoteProc(
×
2028
        ServiceMethod.RESPOND_QUERY_TASK_COMPLETED, () -> respondQueryTaskCompleted(request));
×
2029
  }
×
2030

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

2071
  @Override
2072
  public QueryWorkflowResponse QueryWorkflow(QueryWorkflowRequest request) throws TException {
2073
    return measureRemoteCall(ServiceMethod.QUERY_WORKFLOW, () -> queryWorkflow(request));
×
2074
  }
2075

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

2110
  @Override
2111
  public ResetStickyTaskListResponse ResetStickyTaskList(ResetStickyTaskListRequest resetRequest)
2112
      throws BadRequestError, InternalServiceError, EntityNotExistsError, LimitExceededError,
2113
          WorkflowExecutionAlreadyCompletedError, ServiceBusyError, DomainNotActiveError,
2114
          TException {
2115
    return measureRemoteCall(
×
2116
        ServiceMethod.RESET_STICKY_TASK_LIST, () -> resetStickyTaskList(resetRequest));
×
2117
  }
2118

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

2163
  @Override
2164
  public DescribeWorkflowExecutionResponse DescribeWorkflowExecution(
2165
      DescribeWorkflowExecutionRequest request) throws TException {
2166
    return measureRemoteCall(
×
2167
        ServiceMethod.DESCRIBE_WORKFLOW_EXECUTION, () -> describeWorkflowExecution(request));
×
2168
  }
2169

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

2207
  @Override
2208
  public DescribeTaskListResponse DescribeTaskList(DescribeTaskListRequest request)
2209
      throws TException {
2210
    return measureRemoteCall(ServiceMethod.DESCRIBE_TASK_LIST, () -> describeTaskList(request));
×
2211
  }
2212

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

2249
  @Override
2250
  public ClusterInfo GetClusterInfo() throws InternalServiceError, ServiceBusyError, TException {
2251
    return measureRemoteCall(ServiceMethod.GET_CLUSTER_INFO, () -> getClusterInfo());
×
2252
  }
2253

2254
  private ClusterInfo getClusterInfo() throws TException {
2255
    ThriftResponse<WorkflowService.GetClusterInfo_result> response = null;
×
2256
    try {
2257
      ThriftRequest<WorkflowService.GetClusterInfo_args> request =
×
2258
          buildThriftRequest("GetClusterInfo", new WorkflowService.GetClusterInfo_args());
×
2259
      response = doRemoteCall(request);
×
2260
      WorkflowService.GetClusterInfo_result result =
×
2261
          response.getBody(WorkflowService.GetClusterInfo_result.class);
×
2262
      if (response.getResponseCode() == ResponseCode.OK) {
×
2263
        return result.getSuccess();
×
2264
      }
2265
      if (result.isSetServiceBusyError()) {
×
2266
        throw result.getServiceBusyError();
×
2267
      }
2268
      throw new TException("GetClusterInfo failed with unknown error:" + result);
×
2269
    } finally {
2270
      if (response != null) {
×
2271
        response.release();
×
2272
      }
2273
    }
2274
  }
2275

2276
  @Override
2277
  public ListTaskListPartitionsResponse ListTaskListPartitions(
2278
      ListTaskListPartitionsRequest request)
2279
      throws BadRequestError, EntityNotExistsError, LimitExceededError, ServiceBusyError,
2280
          TException {
2281
    return measureRemoteCall(
×
2282
        ServiceMethod.LIST_TASK_LIST_PARTITIONS, () -> listTaskListPartitions(request));
×
2283
  }
2284

2285
  @Override
2286
  public void RefreshWorkflowTasks(RefreshWorkflowTasksRequest refreshWorkflowTasks)
2287
      throws BadRequestError, DomainNotActiveError, ServiceBusyError, EntityNotExistsError,
2288
          TException {
2289
    ThriftResponse<WorkflowService.RefreshWorkflowTasks_result> response = null;
×
2290
    try {
2291
      ThriftRequest<WorkflowService.RefreshWorkflowTasks_args> request =
×
2292
          buildThriftRequest(
×
2293
              "RefreshWorkflowTasks",
2294
              new WorkflowService.RefreshWorkflowTasks_args(refreshWorkflowTasks));
2295
      response = doRemoteCall(request);
×
2296
      WorkflowService.RefreshWorkflowTasks_result result =
×
2297
          response.getBody(WorkflowService.RefreshWorkflowTasks_result.class);
×
2298
      if (result.isSetBadRequestError()) {
×
2299
        throw result.getBadRequestError();
×
2300
      }
2301
      if (result.isSetDomainNotActiveError()) {
×
2302
        throw result.getDomainNotActiveError();
×
2303
      }
2304
      if (result.isSetServiceBusyError()) {
×
2305
        throw result.getServiceBusyError();
×
2306
      }
2307
      if (result.isSetEntityNotExistError()) {
×
2308
        throw result.getEntityNotExistError();
×
2309
      }
2310
    } finally {
2311
      if (response != null) {
×
2312
        response.release();
×
2313
      }
2314
    }
2315
  }
×
2316

2317
  private ListTaskListPartitionsResponse listTaskListPartitions(
2318
      ListTaskListPartitionsRequest listRequest) throws TException {
2319
    ThriftResponse<WorkflowService.ListTaskListPartitions_result> response = null;
×
2320
    try {
2321
      ThriftRequest<WorkflowService.ListTaskListPartitions_args> request =
×
2322
          buildThriftRequest(
×
2323
              "ListTaskListPartitions",
2324
              new WorkflowService.ListTaskListPartitions_args(listRequest));
2325
      response = doRemoteCall(request);
×
2326
      WorkflowService.ListTaskListPartitions_result result =
×
2327
          response.getBody(WorkflowService.ListTaskListPartitions_result.class);
×
2328
      if (response.getResponseCode() == ResponseCode.OK) {
×
2329
        return result.getSuccess();
×
2330
      }
2331
      if (result.isSetBadRequestError()) {
×
2332
        throw result.getBadRequestError();
×
2333
      }
2334
      if (result.isSetEntityNotExistError()) {
×
2335
        throw result.getEntityNotExistError();
×
2336
      }
2337
      if (result.isSetServiceBusyError()) {
×
2338
        throw result.getServiceBusyError();
×
2339
      }
2340
      if (result.isSetLimitExceededError()) {
×
2341
        throw result.getLimitExceededError();
×
2342
      }
2343
      throw new TException("ListTaskListPartitions failed with unknown error:" + result);
×
2344
    } finally {
2345
      if (response != null) {
×
2346
        response.release();
×
2347
      }
2348
    }
2349
  }
2350

2351
  @Override
2352
  public void StartWorkflowExecution(
2353
      StartWorkflowExecutionRequest startRequest, AsyncMethodCallback resultHandler) {
2354
    startWorkflowExecution(startRequest, resultHandler, null);
×
2355
  }
×
2356

2357
  @Override
2358
  public void StartWorkflowExecutionWithTimeout(
2359
      StartWorkflowExecutionRequest startRequest,
2360
      AsyncMethodCallback resultHandler,
2361
      Long timeoutInMillis) {
2362
    startWorkflowExecution(startRequest, resultHandler, timeoutInMillis);
×
2363
  }
×
2364

2365
  private void startWorkflowExecution(
2366
      StartWorkflowExecutionRequest startRequest,
2367
      AsyncMethodCallback resultHandler,
2368
      Long timeoutInMillis) {
2369
    initializeStartWorkflowRequest(startRequest);
×
2370
    timeoutInMillis = validateAndUpdateTimeout(timeoutInMillis, options.getRpcTimeoutMillis());
×
2371
    ThriftRequest<WorkflowService.StartWorkflowExecution_args> request =
×
2372
        buildThriftRequest(
×
2373
            "StartWorkflowExecution",
2374
            new WorkflowService.StartWorkflowExecution_args(startRequest),
2375
            timeoutInMillis);
2376

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

2435
  @Override
2436
  public void StartWorkflowExecutionAsync(
2437
      StartWorkflowExecutionAsyncRequest startRequest, AsyncMethodCallback resultHandler)
2438
      throws TException {
2439
    startWorkflowExecutionAsync(startRequest, resultHandler, null);
×
2440
  }
×
2441

2442
  @Override
2443
  public void StartWorkflowExecutionAsyncWithTimeout(
2444
      StartWorkflowExecutionAsyncRequest startAsyncRequest,
2445
      AsyncMethodCallback resultHandler,
2446
      Long timeoutInMillis)
2447
      throws TException {
2448
    startWorkflowExecutionAsync(startAsyncRequest, resultHandler, timeoutInMillis);
1✔
2449
  }
1✔
2450

2451
  private void startWorkflowExecutionAsync(
2452
      StartWorkflowExecutionAsyncRequest startAsyncRequest,
2453
      AsyncMethodCallback resultHandler,
2454
      Long timeoutInMillis)
2455
      throws TException {
2456
    initializeStartWorkflowRequest(startAsyncRequest.getRequest());
1✔
2457
    timeoutInMillis = validateAndUpdateTimeout(timeoutInMillis, options.getRpcTimeoutMillis());
1✔
2458
    ThriftRequest<WorkflowService.StartWorkflowExecutionAsync_args> request =
1✔
2459
        buildThriftRequest(
1✔
2460
            "StartWorkflowExecutionAsync",
2461
            new WorkflowService.StartWorkflowExecutionAsync_args(startAsyncRequest),
2462
            timeoutInMillis);
2463

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

2523
  private Long validateAndUpdateTimeout(Long timeoutInMillis, Long defaultTimeoutInMillis) {
2524
    if (timeoutInMillis == null || timeoutInMillis <= 0 || timeoutInMillis == Long.MAX_VALUE) {
1✔
2525
      timeoutInMillis = defaultTimeoutInMillis;
1✔
2526
    } else {
2527
      timeoutInMillis = Math.min(timeoutInMillis, defaultTimeoutInMillis);
×
2528
    }
2529
    return timeoutInMillis;
1✔
2530
  }
2531

2532
  @SuppressWarnings({"unchecked", "FutureReturnValueIgnored"})
2533
  @Override
2534
  public void GetWorkflowExecutionHistoryWithTimeout(
2535
      GetWorkflowExecutionHistoryRequest getRequest,
2536
      AsyncMethodCallback resultHandler,
2537
      Long timeoutInMillis) {
2538

2539
    getWorkflowExecutionHistory(getRequest, resultHandler, timeoutInMillis);
×
2540
  }
×
2541

2542
  @SuppressWarnings({"unchecked", "FutureReturnValueIgnored"})
2543
  @Override
2544
  public void GetWorkflowExecutionHistory(
2545
      GetWorkflowExecutionHistoryRequest getRequest, AsyncMethodCallback resultHandler) {
2546

2547
    getWorkflowExecutionHistory(getRequest, resultHandler, null);
×
2548
  }
×
2549

2550
  private void getWorkflowExecutionHistory(
2551
      GetWorkflowExecutionHistoryRequest getRequest,
2552
      AsyncMethodCallback resultHandler,
2553
      Long timeoutInMillis) {
2554

2555
    ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args> request =
×
2556
        buildGetWorkflowExecutionHistoryThriftRequest(getRequest, timeoutInMillis);
×
2557

2558
    CompletableFuture<ThriftResponse<GetWorkflowExecutionHistory_result>> response =
×
2559
        doRemoteCallAsync(request);
×
2560
    response
×
2561
        .whenComplete(
×
2562
            (r, e) -> {
2563
              try {
2564
                if (e != null) {
×
2565
                  resultHandler.onError(CheckedExceptionWrapper.wrap(e));
×
2566
                  return;
×
2567
                }
2568
                WorkflowService.GetWorkflowExecutionHistory_result result =
×
2569
                    r.getBody(WorkflowService.GetWorkflowExecutionHistory_result.class);
×
2570

2571
                if (r.getResponseCode() == ResponseCode.OK) {
×
2572
                  GetWorkflowExecutionHistoryResponse res = result.getSuccess();
×
2573
                  if (res.getRawHistory() != null) {
×
2574
                    History history =
×
2575
                        InternalUtils.DeserializeFromBlobDataToHistory(
×
2576
                            res.getRawHistory(), getRequest.getHistoryEventFilterType());
×
2577
                    res.setHistory(history);
×
2578
                  }
2579
                  resultHandler.onComplete(res);
×
2580
                  return;
×
2581
                }
2582
                if (result.isSetBadRequestError()) {
×
2583
                  resultHandler.onError(result.getBadRequestError());
×
2584
                  return;
×
2585
                }
2586
                if (result.isSetEntityNotExistError()) {
×
2587
                  resultHandler.onError(result.getEntityNotExistError());
×
2588
                  return;
×
2589
                }
2590
                if (result.isSetServiceBusyError()) {
×
2591
                  resultHandler.onError(result.getServiceBusyError());
×
2592
                  return;
×
2593
                }
2594
                resultHandler.onError(
×
2595
                    new TException(
2596
                        "GetWorkflowExecutionHistory failed with unknown " + "error:" + result));
2597
              } catch (TException tException) {
×
2598
                resultHandler.onError(tException);
×
2599
              } finally {
2600
                if (r != null) {
×
2601
                  r.release();
×
2602
                }
2603
              }
2604
            })
×
2605
        .exceptionally(
×
2606
            (e) -> {
2607
              log.error("Unexpected error in GetWorkflowExecutionHistory", e);
×
2608
              return null;
×
2609
            });
2610
  }
×
2611

2612
  @Override
2613
  public void PollForDecisionTask(
2614
      PollForDecisionTaskRequest pollRequest, AsyncMethodCallback resultHandler) throws TException {
2615
    throw new UnsupportedOperationException("not implemented");
×
2616
  }
2617

2618
  @Override
2619
  public void RespondDecisionTaskCompleted(
2620
      RespondDecisionTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
2621
      throws TException {
2622
    throw new UnsupportedOperationException("not implemented");
×
2623
  }
2624

2625
  @Override
2626
  public void RespondDecisionTaskFailed(
2627
      RespondDecisionTaskFailedRequest failedRequest, AsyncMethodCallback resultHandler)
2628
      throws TException {
2629
    throw new UnsupportedOperationException("not implemented");
×
2630
  }
2631

2632
  @Override
2633
  public void PollForActivityTask(
2634
      PollForActivityTaskRequest pollRequest, AsyncMethodCallback resultHandler) throws TException {
2635
    throw new UnsupportedOperationException("not implemented");
×
2636
  }
2637

2638
  @Override
2639
  public void RecordActivityTaskHeartbeat(
2640
      RecordActivityTaskHeartbeatRequest heartbeatRequest, AsyncMethodCallback resultHandler)
2641
      throws TException {
2642
    throw new UnsupportedOperationException("not implemented");
×
2643
  }
2644

2645
  @Override
2646
  public void RecordActivityTaskHeartbeatByID(
2647
      RecordActivityTaskHeartbeatByIDRequest heartbeatRequest, AsyncMethodCallback resultHandler)
2648
      throws TException {
2649
    throw new UnsupportedOperationException("not implemented");
×
2650
  }
2651

2652
  @Override
2653
  public void RespondActivityTaskCompleted(
2654
      RespondActivityTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
2655
      throws TException {
2656
    throw new UnsupportedOperationException("not implemented");
×
2657
  }
2658

2659
  @Override
2660
  public void RespondActivityTaskCompletedByID(
2661
      RespondActivityTaskCompletedByIDRequest completeRequest, AsyncMethodCallback resultHandler)
2662
      throws TException {
2663
    throw new UnsupportedOperationException("not implemented");
×
2664
  }
2665

2666
  @Override
2667
  public void RespondActivityTaskFailed(
2668
      RespondActivityTaskFailedRequest failRequest, AsyncMethodCallback resultHandler)
2669
      throws TException {
2670
    throw new UnsupportedOperationException("not implemented");
×
2671
  }
2672

2673
  @Override
2674
  public void RespondActivityTaskFailedByID(
2675
      RespondActivityTaskFailedByIDRequest failRequest, AsyncMethodCallback resultHandler)
2676
      throws TException {
2677
    throw new UnsupportedOperationException("not implemented");
×
2678
  }
2679

2680
  @Override
2681
  public void RespondActivityTaskCanceled(
2682
      RespondActivityTaskCanceledRequest canceledRequest, AsyncMethodCallback resultHandler)
2683
      throws TException {
2684
    throw new UnsupportedOperationException("not implemented");
×
2685
  }
2686

2687
  @Override
2688
  public void RespondActivityTaskCanceledByID(
2689
      RespondActivityTaskCanceledByIDRequest canceledRequest, AsyncMethodCallback resultHandler)
2690
      throws TException {
2691
    throw new UnsupportedOperationException("not implemented");
×
2692
  }
2693

2694
  @Override
2695
  public void RequestCancelWorkflowExecution(
2696
      RequestCancelWorkflowExecutionRequest cancelRequest, AsyncMethodCallback resultHandler)
2697
      throws TException {
2698
    throw new UnsupportedOperationException("not implemented");
×
2699
  }
2700

2701
  @Override
2702
  public void SignalWorkflowExecution(
2703
      SignalWorkflowExecutionRequest signalRequest, AsyncMethodCallback resultHandler) {
2704
    signalWorkflowExecution(signalRequest, resultHandler, null);
×
2705
  }
×
2706

2707
  @Override
2708
  public void SignalWorkflowExecutionWithTimeout(
2709
      SignalWorkflowExecutionRequest signalRequest,
2710
      AsyncMethodCallback resultHandler,
2711
      Long timeoutInMillis) {
2712
    signalWorkflowExecution(signalRequest, resultHandler, timeoutInMillis);
×
2713
  }
×
2714

2715
  private void signalWorkflowExecution(
2716
      SignalWorkflowExecutionRequest signalRequest,
2717
      AsyncMethodCallback resultHandler,
2718
      Long timeoutInMillis) {
2719

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

2785
  @Override
2786
  public void SignalWithStartWorkflowExecution(
2787
      SignalWithStartWorkflowExecutionRequest signalWithStartRequest,
2788
      AsyncMethodCallback resultHandler)
2789
      throws TException {
2790
    throw new UnsupportedOperationException("not implemented");
×
2791
  }
2792

2793
  @Override
2794
  public void SignalWithStartWorkflowExecutionAsync(
2795
      SignalWithStartWorkflowExecutionAsyncRequest signalWithStartRequest,
2796
      AsyncMethodCallback resultHandler)
2797
      throws TException {
2798
    throw new IllegalArgumentException("unimplemented");
×
2799
  }
2800

2801
  @Override
2802
  public void ResetWorkflowExecution(
2803
      ResetWorkflowExecutionRequest resetRequest, AsyncMethodCallback resultHandler)
2804
      throws TException {
2805
    throw new UnsupportedOperationException("not implemented");
×
2806
  }
2807

2808
  @Override
2809
  public void TerminateWorkflowExecution(
2810
      TerminateWorkflowExecutionRequest terminateRequest, AsyncMethodCallback resultHandler)
2811
      throws TException {
2812
    throw new UnsupportedOperationException("not implemented");
×
2813
  }
2814

2815
  @Override
2816
  public void ListOpenWorkflowExecutions(
2817
      ListOpenWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2818
      throws TException {
2819
    throw new UnsupportedOperationException("not implemented");
×
2820
  }
2821

2822
  @Override
2823
  public void ListClosedWorkflowExecutions(
2824
      ListClosedWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2825
      throws TException {
2826
    throw new UnsupportedOperationException("not implemented");
×
2827
  }
2828

2829
  @Override
2830
  public void ListWorkflowExecutions(
2831
      ListWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2832
      throws TException {
2833
    throw new UnsupportedOperationException("not implemented");
×
2834
  }
2835

2836
  @Override
2837
  public void ListArchivedWorkflowExecutions(
2838
      ListArchivedWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2839
      throws TException {
2840
    throw new UnsupportedOperationException("not implemented");
×
2841
  }
2842

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

2850
  @Override
2851
  public void CountWorkflowExecutions(
2852
      CountWorkflowExecutionsRequest countRequest, AsyncMethodCallback resultHandler)
2853
      throws TException {
2854
    throw new UnsupportedOperationException("not implemented");
×
2855
  }
2856

2857
  @Override
2858
  public void GetSearchAttributes(AsyncMethodCallback resultHandler) throws TException {
2859
    throw new UnsupportedOperationException("not implemented");
×
2860
  }
2861

2862
  @Override
2863
  public void RespondQueryTaskCompleted(
2864
      RespondQueryTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
2865
      throws TException {
2866
    throw new UnsupportedOperationException("not implemented");
×
2867
  }
2868

2869
  @Override
2870
  public void ResetStickyTaskList(
2871
      ResetStickyTaskListRequest resetRequest, AsyncMethodCallback resultHandler)
2872
      throws TException {
2873
    throw new UnsupportedOperationException("not implemented");
×
2874
  }
2875

2876
  @Override
2877
  public void QueryWorkflow(QueryWorkflowRequest queryRequest, AsyncMethodCallback resultHandler)
2878
      throws TException {
2879
    throw new UnsupportedOperationException("not implemented");
×
2880
  }
2881

2882
  @Override
2883
  public void DescribeWorkflowExecution(
2884
      DescribeWorkflowExecutionRequest describeRequest, AsyncMethodCallback resultHandler)
2885
      throws TException {
2886
    throw new UnsupportedOperationException("not implemented");
×
2887
  }
2888

2889
  @Override
2890
  public void DescribeTaskList(DescribeTaskListRequest request, AsyncMethodCallback resultHandler)
2891
      throws TException {
2892
    throw new UnsupportedOperationException("not implemented");
×
2893
  }
2894

2895
  @Override
2896
  public void GetClusterInfo(AsyncMethodCallback resultHandler) throws TException {}
×
2897

2898
  @Override
2899
  public void ListTaskListPartitions(
2900
      ListTaskListPartitionsRequest request, AsyncMethodCallback resultHandler) throws TException {}
×
2901

2902
  @Override
2903
  public void RefreshWorkflowTasks(
2904
      RefreshWorkflowTasksRequest request, AsyncMethodCallback resultHandler) throws TException {}
×
2905

2906
  @Override
2907
  public void RegisterDomain(
2908
      RegisterDomainRequest registerRequest, AsyncMethodCallback resultHandler) throws TException {
2909
    throw new UnsupportedOperationException("not implemented");
×
2910
  }
2911

2912
  @Override
2913
  public void DescribeDomain(
2914
      DescribeDomainRequest describeRequest, AsyncMethodCallback resultHandler) throws TException {
2915
    throw new UnsupportedOperationException("not implemented");
×
2916
  }
2917

2918
  @Override
2919
  public void ListDomains(ListDomainsRequest listRequest, AsyncMethodCallback resultHandler)
2920
      throws TException {
2921
    throw new UnsupportedOperationException("not implemented");
×
2922
  }
2923

2924
  @Override
2925
  public void UpdateDomain(UpdateDomainRequest updateRequest, AsyncMethodCallback resultHandler)
2926
      throws TException {
2927
    throw new UnsupportedOperationException("not implemented");
×
2928
  }
2929

2930
  @Override
2931
  public void DeprecateDomain(
2932
      DeprecateDomainRequest deprecateRequest, AsyncMethodCallback resultHandler)
2933
      throws TException {
2934
    throw new UnsupportedOperationException("not implemented");
×
2935
  }
2936

2937
  @Override
2938
  public void RestartWorkflowExecution(
2939
      RestartWorkflowExecutionRequest restartRequest, AsyncMethodCallback resultHandler)
2940
      throws TException {
2941
    throw new IllegalArgumentException("unimplemented");
×
2942
  }
2943

2944
  @Override
2945
  public void GetTaskListsByDomain(
2946
      GetTaskListsByDomainRequest request, AsyncMethodCallback resultHandler)
2947
      throws org.apache.thrift.TException {
2948
    throw new UnsupportedOperationException("not implemented");
×
2949
  }
2950
}
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