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

uber / cadence-java-client / 2328

15 May 2024 06:53PM CUT coverage: 61.473% (+0.04%) from 61.437%
2328

Pull #897

buildkite

shijiesheng
lint
Pull Request #897: Refactor ActivityTaskExecutor to use ActivityTask interface

11962 of 19459 relevant lines covered (61.47%)

0.61 hits per line

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

10.99
/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 java.net.InetAddress;
53
import java.net.InetSocketAddress;
54
import java.net.UnknownHostException;
55
import java.nio.charset.StandardCharsets;
56
import java.util.ArrayList;
57
import java.util.HashMap;
58
import java.util.Map;
59
import java.util.UUID;
60
import java.util.concurrent.CompletableFuture;
61
import java.util.concurrent.ExecutionException;
62
import org.apache.thrift.TException;
63
import org.apache.thrift.async.AsyncMethodCallback;
64
import org.apache.thrift.transport.TTransportException;
65
import org.slf4j.Logger;
66
import org.slf4j.LoggerFactory;
67

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

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

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

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

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

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

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

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

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

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

148
    if (options.getHeaders() != null) {
1✔
149
      for (Map.Entry<String, String> entry : options.getHeaders().entrySet()) {
1✔
150
        builder.put(entry.getKey(), entry.getValue());
×
151
      }
×
152
    }
153

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

161
    if (!Strings.isNullOrEmpty(options.getIsolationGroup())) {
1✔
162
      builder.put("cadence-client-isolation-group", options.getIsolationGroup());
×
163
    }
164

165
    return builder.build();
1✔
166
  }
167

168
  /** Returns the endpoint in the format service::method" */
169
  private static String getEndpoint(String service, String method) {
170
    return String.format("%s::%s", service, method);
1✔
171
  }
172

173
  private <T> ThriftRequest<T> buildThriftRequest(String apiName, T body) {
174
    return buildThriftRequest(apiName, body, null);
1✔
175
  }
176

177
  @Override
178
  public ClientOptions getOptions() {
179
    return options;
1✔
180
  }
181

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

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

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

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

244
    textMapPropagator.inject(Context.current(), headers, setter);
1✔
245

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

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

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

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

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

312
  @Override
313
  public void close() {
314
    if (tChannel != null) {
1✔
315
      tChannel.shutdown();
1✔
316
    }
317
  }
1✔
318

319
  interface RemoteCall<T> {
320
    T apply() throws TException;
321
  }
322

323
  private <T> T measureRemoteCall(String scopeName, RemoteCall<T> call) throws TException {
324
    return measureRemoteCallWithTags(scopeName, call, null);
1✔
325
  }
326

327
  private <T> T measureRemoteCallWithTags(
328
      String scopeName, RemoteCall<T> call, Map<String, String> tags) throws TException {
329
    Span span = tracingPropagator.activateSpanByServiceMethod(scopeName);
1✔
330
    Scope scope = options.getMetricsScope().subScope(scopeName);
1✔
331
    if (tags != null) {
1✔
332
      scope = scope.tagged(tags);
×
333
    }
334
    scope.counter(MetricsType.CADENCE_REQUEST).inc(1);
1✔
335
    Stopwatch sw = scope.timer(MetricsType.CADENCE_LATENCY).start();
1✔
336
    try {
337
      T resp = call.apply();
1✔
338
      sw.stop();
1✔
339
      return resp;
1✔
340
    } catch (EntityNotExistsError
×
341
        | WorkflowExecutionAlreadyCompletedError
342
        | BadRequestError
343
        | DomainAlreadyExistsError
344
        | WorkflowExecutionAlreadyStartedError
345
        | QueryFailedError e) {
346
      sw.stop();
×
347
      scope.counter(MetricsType.CADENCE_INVALID_REQUEST).inc(1);
×
348
      throw e;
×
349
    } catch (TException e) {
1✔
350
      sw.stop();
1✔
351
      scope.counter(MetricsType.CADENCE_ERROR).inc(1);
1✔
352
      throw e;
1✔
353
    } finally {
354
      span.finish();
1✔
355
    }
356
  }
357

358
  interface RemoteProc {
359
    void apply() throws TException;
360
  }
361

362
  private void measureRemoteProc(String scopeName, RemoteProc proc) throws TException {
363
    measureRemoteCall(
×
364
        scopeName,
365
        () -> {
366
          proc.apply();
×
367
          return null;
×
368
        });
369
  }
×
370

371
  @Override
372
  public void RegisterDomain(RegisterDomainRequest request) throws TException {
373
    measureRemoteProc(ServiceMethod.REGISTER_DOMAIN, () -> registerDomain(request));
×
374
  }
×
375

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

405
  @Override
406
  public DescribeDomainResponse DescribeDomain(DescribeDomainRequest describeRequest)
407
      throws TException {
408
    return measureRemoteCall(ServiceMethod.DESCRIBE_DOMAIN, () -> describeDomain(describeRequest));
×
409
  }
410

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

441
  @Override
442
  public ListDomainsResponse ListDomains(ListDomainsRequest listRequest)
443
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
444
          TException {
445
    return measureRemoteCall(ServiceMethod.LIST_DOMAINS, () -> listDomains(listRequest));
×
446
  }
447

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

476
  @Override
477
  public UpdateDomainResponse UpdateDomain(UpdateDomainRequest updateRequest) throws TException {
478
    return measureRemoteCall(ServiceMethod.UPDATE_DOMAIN, () -> updateDomain(updateRequest));
×
479
  }
480

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

512
  @Override
513
  public void DeprecateDomain(DeprecateDomainRequest deprecateRequest) throws TException {
514
    measureRemoteProc(ServiceMethod.DEPRECATE_DOMAIN, () -> deprecateDomain(deprecateRequest));
×
515
  }
×
516

517
  @Override
518
  public RestartWorkflowExecutionResponse RestartWorkflowExecution(
519
      RestartWorkflowExecutionRequest restartRequest)
520
      throws BadRequestError, ServiceBusyError, DomainNotActiveError, LimitExceededError,
521
          EntityNotExistsError, ClientVersionNotSupportedError, TException {
522
    throw new IllegalArgumentException("unimplemented");
×
523
  }
524

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

557
  @Override
558
  public GetTaskListsByDomainResponse GetTaskListsByDomain(
559
      GetTaskListsByDomainRequest getTaskListsByDomainRequest) throws TException {
560
    return measureRemoteCall(
×
561
        ServiceMethod.GET_TASK_LISTS_BY_DOMAIN,
562
        () -> getTaskListsByDomain(getTaskListsByDomainRequest));
×
563
  }
564

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

602
  @Override
603
  public StartWorkflowExecutionResponse StartWorkflowExecution(
604
      StartWorkflowExecutionRequest request) throws TException {
605
    return measureRemoteCall(
×
606
        ServiceMethod.START_WORKFLOW_EXECUTION, () -> startWorkflowExecution(request));
×
607
  }
608

609
  private StartWorkflowExecutionResponse startWorkflowExecution(
610
      StartWorkflowExecutionRequest startRequest) throws TException {
611
    ThriftResponse<WorkflowService.StartWorkflowExecution_result> response = null;
×
612
    try {
613
      initializeStartWorkflowRequest(startRequest);
×
614

615
      ThriftRequest<WorkflowService.StartWorkflowExecution_args> request =
×
616
          buildThriftRequest(
×
617
              "StartWorkflowExecution",
618
              new WorkflowService.StartWorkflowExecution_args(startRequest));
619

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

655
  @Override
656
  public StartWorkflowExecutionAsyncResponse StartWorkflowExecutionAsync(
657
      StartWorkflowExecutionAsyncRequest startAsyncRequest) throws TException {
658
    return measureRemoteCall(
1✔
659
        ServiceMethod.START_WORKFLOW_EXECUTION_ASYNC,
660
        () -> startWorkflowExecutionAsync(startAsyncRequest));
1✔
661
  }
662

663
  private StartWorkflowExecutionAsyncResponse startWorkflowExecutionAsync(
664
      StartWorkflowExecutionAsyncRequest startAsyncRequest) throws TException {
665
    ThriftResponse<WorkflowService.StartWorkflowExecutionAsync_result> response = null;
1✔
666
    try {
667
      initializeStartWorkflowRequest(startAsyncRequest.getRequest());
1✔
668

669
      ThriftRequest<WorkflowService.StartWorkflowExecutionAsync_args> request =
1✔
670
          buildThriftRequest(
1✔
671
              "StartWorkflowExecutionAsync",
672
              new WorkflowService.StartWorkflowExecutionAsync_args(startAsyncRequest));
673

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

709
  private void initializeStartWorkflowRequest(StartWorkflowExecutionRequest startRequest) {
710
    startRequest.setRequestId(UUID.randomUUID().toString());
1✔
711
    // Write span context to header
712
    if (!startRequest.isSetHeader()) {
1✔
713
      startRequest.setHeader(new Header());
1✔
714
    }
715
    tracingPropagator.inject(startRequest.getHeader());
1✔
716
  }
1✔
717

718
  @Override
719
  public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistoryWithTimeout(
720
      GetWorkflowExecutionHistoryRequest request, Long timeoutInMillis) throws TException {
721
    Map<String, String> tags =
×
722
        ImmutableMap.of(
×
723
            MetricsTag.REQUEST_TYPE,
724
            request.isWaitForNewEvent() ? REQUEST_TYPE_LONG_POLL : REQUEST_TYPE_NORMAL);
×
725
    return measureRemoteCallWithTags(
×
726
        ServiceMethod.GET_WORKFLOW_EXECUTION_HISTORY,
727
        () -> getWorkflowExecutionHistory(request, timeoutInMillis),
×
728
        tags);
729
  }
730

731
  @Override
732
  public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistory(
733
      GetWorkflowExecutionHistoryRequest request) throws TException {
734
    Map<String, String> tags =
×
735
        ImmutableMap.of(
×
736
            MetricsTag.REQUEST_TYPE,
737
            request.isWaitForNewEvent() ? REQUEST_TYPE_LONG_POLL : REQUEST_TYPE_NORMAL);
×
738
    return measureRemoteCallWithTags(
×
739
        ServiceMethod.GET_WORKFLOW_EXECUTION_HISTORY,
740
        () -> getWorkflowExecutionHistory(request, null),
×
741
        tags);
742
  }
743

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

780
  private ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args>
781
      buildGetWorkflowExecutionHistoryThriftRequest(
782
          GetWorkflowExecutionHistoryRequest getRequest, Long timeoutInMillis) {
783

784
    if (getRequest.isWaitForNewEvent()) {
×
785
      timeoutInMillis =
×
786
          validateAndUpdateTimeout(timeoutInMillis, options.getRpcLongPollTimeoutMillis());
×
787
    } else {
788
      timeoutInMillis = validateAndUpdateTimeout(timeoutInMillis, options.getRpcTimeoutMillis());
×
789
    }
790

791
    return buildThriftRequest(
×
792
        "GetWorkflowExecutionHistory",
793
        new WorkflowService.GetWorkflowExecutionHistory_args(getRequest),
794
        timeoutInMillis);
795
  }
796

797
  @Override
798
  public PollForDecisionTaskResponse PollForDecisionTask(PollForDecisionTaskRequest request)
799
      throws TException {
800
    return measureRemoteCall(
×
801
        ServiceMethod.POLL_FOR_DECISION_TASK, () -> pollForDecisionTask(request));
×
802
  }
803

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

845
  @Override
846
  public RespondDecisionTaskCompletedResponse RespondDecisionTaskCompleted(
847
      RespondDecisionTaskCompletedRequest completedRequest) throws TException {
848
    return measureRemoteCall(
×
849
        ServiceMethod.RESPOND_DECISION_TASK_COMPLETED,
850
        () -> respondDecisionTaskCompleted(completedRequest));
×
851
  }
852

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

896
  @Override
897
  public void RespondDecisionTaskFailed(RespondDecisionTaskFailedRequest request)
898
      throws TException {
899
    measureRemoteProc(
×
900
        ServiceMethod.RESPOND_DECISION_TASK_FAILED, () -> respondDecisionTaskFailed(request));
×
901
  }
×
902

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

946
  @Override
947
  public PollForActivityTaskResponse PollForActivityTask(PollForActivityTaskRequest request)
948
      throws TException {
949
    return measureRemoteCall(
×
950
        ServiceMethod.POLL_FOR_ACTIVITY_TASK, () -> pollForActivityTask(request));
×
951
  }
952

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

994
  @Override
995
  public RecordActivityTaskHeartbeatResponse RecordActivityTaskHeartbeat(
996
      RecordActivityTaskHeartbeatRequest request) throws TException {
997
    return measureRemoteCall(
×
998
        ServiceMethod.RECORD_ACTIVITY_TASK_HEARTBEAT, () -> recordActivityTaskHeartbeat(request));
×
999
  }
1000

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

1044
  @Override
1045
  public RecordActivityTaskHeartbeatResponse RecordActivityTaskHeartbeatByID(
1046
      RecordActivityTaskHeartbeatByIDRequest heartbeatRequest)
1047
      throws BadRequestError, InternalServiceError, EntityNotExistsError, DomainNotActiveError,
1048
          WorkflowExecutionAlreadyCompletedError, LimitExceededError, ServiceBusyError, TException {
1049
    return measureRemoteCall(
×
1050
        ServiceMethod.RECORD_ACTIVITY_TASK_HEARTBEAT_BY_ID,
1051
        () -> recordActivityTaskHeartbeatByID(heartbeatRequest));
×
1052
  }
1053

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

1097
  @Override
1098
  public void RespondActivityTaskCompleted(RespondActivityTaskCompletedRequest request)
1099
      throws TException {
1100
    measureRemoteProc(
×
1101
        ServiceMethod.RESPOND_ACTIVITY_TASK_COMPLETED, () -> respondActivityTaskCompleted(request));
×
1102
  }
×
1103

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

1147
  @Override
1148
  public void RespondActivityTaskCompletedByID(RespondActivityTaskCompletedByIDRequest request)
1149
      throws TException {
1150
    measureRemoteProc(
×
1151
        ServiceMethod.RESPOND_ACTIVITY_TASK_COMPLETED_BY_ID,
1152
        () -> respondActivityTaskCompletedByID(request));
×
1153
  }
×
1154

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

1198
  @Override
1199
  public void RespondActivityTaskFailed(RespondActivityTaskFailedRequest request)
1200
      throws TException {
1201
    measureRemoteProc(
×
1202
        ServiceMethod.RESPOND_ACTIVITY_TASK_FAILED, () -> respondActivityTaskFailed(request));
×
1203
  }
×
1204

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

1248
  @Override
1249
  public void RespondActivityTaskFailedByID(RespondActivityTaskFailedByIDRequest request)
1250
      throws TException {
1251
    measureRemoteProc(
×
1252
        ServiceMethod.RESPOND_ACTIVITY_TASK_FAILED_BY_ID,
1253
        () -> respondActivityTaskFailedByID(request));
×
1254
  }
×
1255

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

1299
  @Override
1300
  public void RespondActivityTaskCanceled(RespondActivityTaskCanceledRequest request)
1301
      throws TException {
1302
    measureRemoteProc(
×
1303
        ServiceMethod.RESPOND_ACTIVITY_TASK_CANCELED, () -> respondActivityTaskCanceled(request));
×
1304
  }
×
1305

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

1349
  @Override
1350
  public void RespondActivityTaskCanceledByID(RespondActivityTaskCanceledByIDRequest request)
1351
      throws TException {
1352
    measureRemoteProc(
×
1353
        ServiceMethod.RESPOND_ACTIVITY_TASK_CANCELED_BY_ID,
1354
        () -> respondActivityTaskCanceledByID(request));
×
1355
  }
×
1356

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

1400
  @Override
1401
  public void RequestCancelWorkflowExecution(RequestCancelWorkflowExecutionRequest request)
1402
      throws TException {
1403
    measureRemoteProc(
×
1404
        ServiceMethod.REQUEST_CANCEL_WORKFLOW_EXECUTION,
1405
        () -> requestCancelWorkflowExecution(request));
×
1406
  }
×
1407

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

1455
  @Override
1456
  public void SignalWorkflowExecution(SignalWorkflowExecutionRequest request) throws TException {
1457
    measureRemoteProc(
×
1458
        ServiceMethod.SIGNAL_WORKFLOW_EXECUTION, () -> signalWorkflowExecution(request));
×
1459
  }
×
1460

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

1504
  @Override
1505
  public StartWorkflowExecutionResponse SignalWithStartWorkflowExecution(
1506
      SignalWithStartWorkflowExecutionRequest signalWithStartRequest) throws TException {
1507
    return measureRemoteCall(
×
1508
        ServiceMethod.SIGNAL_WITH_START_WORKFLOW_EXECUTION,
1509
        () -> signalWithStartWorkflowExecution(signalWithStartRequest));
×
1510
  }
1511

1512
  @Override
1513
  public SignalWithStartWorkflowExecutionAsyncResponse SignalWithStartWorkflowExecutionAsync(
1514
      SignalWithStartWorkflowExecutionAsyncRequest signalWithStartRequest) throws TException {
1515
    return measureRemoteCall(
1✔
1516
        ServiceMethod.SIGNAL_WITH_START_WORKFLOW_EXECUTION_ASYNC,
1517
        () -> signalWithStartWorkflowExecutionAsync(signalWithStartRequest));
1✔
1518
  }
1519

1520
  private SignalWithStartWorkflowExecutionAsyncResponse signalWithStartWorkflowExecutionAsync(
1521
      SignalWithStartWorkflowExecutionAsyncRequest signalWithStartRequest) throws TException {
1522
    ThriftResponse<WorkflowService.SignalWithStartWorkflowExecutionAsync_result> response = null;
1✔
1523
    try {
1524
      initializeSignalWithStartWorkflowRequest(signalWithStartRequest.getRequest());
1✔
1525

1526
      ThriftRequest<WorkflowService.SignalWithStartWorkflowExecutionAsync_args> request =
1✔
1527
          buildThriftRequest(
1✔
1528
              "SignalWithStartWorkflowExecutionAsync",
1529
              new WorkflowService.SignalWithStartWorkflowExecutionAsync_args(
1530
                  signalWithStartRequest));
1531

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

1568
  @Override
1569
  public ResetWorkflowExecutionResponse ResetWorkflowExecution(
1570
      ResetWorkflowExecutionRequest resetRequest)
1571
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1572
          DomainNotActiveError, LimitExceededError, ClientVersionNotSupportedError, TException {
1573
    return measureRemoteCall(
×
1574
        ServiceMethod.RESET_WORKFLOW_EXECUTION, () -> resetWorkflowExecution(resetRequest));
×
1575
  }
1576

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

1617
  private StartWorkflowExecutionResponse signalWithStartWorkflowExecution(
1618
      SignalWithStartWorkflowExecutionRequest signalWithStartRequest) throws TException {
1619
    ThriftResponse<WorkflowService.SignalWithStartWorkflowExecution_result> response = null;
×
1620
    try {
1621
      initializeSignalWithStartWorkflowRequest(signalWithStartRequest);
×
1622

1623
      ThriftRequest<WorkflowService.SignalWithStartWorkflowExecution_args> request =
×
1624
          buildThriftRequest(
×
1625
              "SignalWithStartWorkflowExecution",
1626
              new WorkflowService.SignalWithStartWorkflowExecution_args(signalWithStartRequest));
1627

1628
      response = doRemoteCall(request);
×
1629
      WorkflowService.SignalWithStartWorkflowExecution_result result =
×
1630
          response.getBody(WorkflowService.SignalWithStartWorkflowExecution_result.class);
×
1631
      if (response.getResponseCode() == ResponseCode.OK) {
×
1632
        return result.getSuccess();
×
1633
      }
1634
      if (result.isSetBadRequestError()) {
×
1635
        throw result.getBadRequestError();
×
1636
      }
1637
      if (result.isSetEntityNotExistError()) {
×
1638
        throw result.getEntityNotExistError();
×
1639
      }
1640
      if (result.isSetServiceBusyError()) {
×
1641
        throw result.getServiceBusyError();
×
1642
      }
1643
      if (result.isSetDomainNotActiveError()) {
×
1644
        throw result.getDomainNotActiveError();
×
1645
      }
1646
      if (result.isSetLimitExceededError()) {
×
1647
        throw result.getLimitExceededError();
×
1648
      }
1649
      if (result.isSetDomainNotActiveError()) {
×
1650
        throw result.getDomainNotActiveError();
×
1651
      }
1652
      if (result.isSetClientVersionNotSupportedError()) {
×
1653
        throw result.getClientVersionNotSupportedError();
×
1654
      }
1655
      throw new TException("SignalWithStartWorkflowExecution failed with unknown error:" + result);
×
1656
    } finally {
1657
      if (response != null) {
×
1658
        response.release();
×
1659
      }
1660
    }
1661
  }
1662

1663
  private void initializeSignalWithStartWorkflowRequest(
1664
      SignalWithStartWorkflowExecutionRequest request) {
1665
    request.setRequestId(UUID.randomUUID().toString());
1✔
1666
    // Write span context to header
1667
    if (!request.isSetHeader()) {
1✔
1668
      request.setHeader(new Header());
1✔
1669
    }
1670
    tracingPropagator.inject(request.getHeader());
1✔
1671
  }
1✔
1672

1673
  @Override
1674
  public void TerminateWorkflowExecution(TerminateWorkflowExecutionRequest request)
1675
      throws TException {
1676
    measureRemoteProc(
×
1677
        ServiceMethod.TERMINATE_WORKFLOW_EXECUTION, () -> terminateWorkflowExecution(request));
×
1678
  }
×
1679

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

1723
  @Override
1724
  public ListOpenWorkflowExecutionsResponse ListOpenWorkflowExecutions(
1725
      ListOpenWorkflowExecutionsRequest request) throws TException {
1726
    return measureRemoteCall(
×
1727
        ServiceMethod.LIST_OPEN_WORKFLOW_EXECUTIONS, () -> listOpenWorkflowExecutions(request));
×
1728
  }
1729

1730
  private ListOpenWorkflowExecutionsResponse listOpenWorkflowExecutions(
1731
      ListOpenWorkflowExecutionsRequest listRequest) throws TException {
1732
    ThriftResponse<WorkflowService.ListOpenWorkflowExecutions_result> response = null;
×
1733
    try {
1734
      ThriftRequest<WorkflowService.ListOpenWorkflowExecutions_args> request =
×
1735
          buildThriftRequest(
×
1736
              "ListOpenWorkflowExecutions",
1737
              new WorkflowService.ListOpenWorkflowExecutions_args(listRequest));
1738
      response = doRemoteCall(request);
×
1739
      WorkflowService.ListOpenWorkflowExecutions_result result =
×
1740
          response.getBody(WorkflowService.ListOpenWorkflowExecutions_result.class);
×
1741
      if (response.getResponseCode() == ResponseCode.OK) {
×
1742
        return result.getSuccess();
×
1743
      }
1744
      if (result.isSetBadRequestError()) {
×
1745
        throw result.getBadRequestError();
×
1746
      }
1747
      if (result.isSetEntityNotExistError()) {
×
1748
        throw result.getEntityNotExistError();
×
1749
      }
1750
      if (result.isSetServiceBusyError()) {
×
1751
        throw result.getServiceBusyError();
×
1752
      }
1753
      if (result.isSetLimitExceededError()) {
×
1754
        throw result.getLimitExceededError();
×
1755
      }
1756
      if (result.isSetClientVersionNotSupportedError()) {
×
1757
        throw result.getClientVersionNotSupportedError();
×
1758
      }
1759
      throw new TException("ListOpenWorkflowExecutions failed with unknown error:" + result);
×
1760
    } finally {
1761
      if (response != null) {
×
1762
        response.release();
×
1763
      }
1764
    }
1765
  }
1766

1767
  @Override
1768
  public ListClosedWorkflowExecutionsResponse ListClosedWorkflowExecutions(
1769
      ListClosedWorkflowExecutionsRequest request) throws TException {
1770
    return measureRemoteCall(
×
1771
        ServiceMethod.LIST_CLOSED_WORKFLOW_EXECUTIONS, () -> listClosedWorkflowExecutions(request));
×
1772
  }
1773

1774
  private ListClosedWorkflowExecutionsResponse listClosedWorkflowExecutions(
1775
      ListClosedWorkflowExecutionsRequest listRequest) throws TException {
1776
    ThriftResponse<WorkflowService.ListClosedWorkflowExecutions_result> response = null;
×
1777
    try {
1778
      ThriftRequest<WorkflowService.ListClosedWorkflowExecutions_args> request =
×
1779
          buildThriftRequest(
×
1780
              "ListClosedWorkflowExecutions",
1781
              new WorkflowService.ListClosedWorkflowExecutions_args(listRequest));
1782
      response = doRemoteCall(request);
×
1783
      WorkflowService.ListClosedWorkflowExecutions_result result =
×
1784
          response.getBody(WorkflowService.ListClosedWorkflowExecutions_result.class);
×
1785
      if (response.getResponseCode() == ResponseCode.OK) {
×
1786
        return result.getSuccess();
×
1787
      }
1788
      if (result.isSetBadRequestError()) {
×
1789
        throw result.getBadRequestError();
×
1790
      }
1791
      if (result.isSetEntityNotExistError()) {
×
1792
        throw result.getEntityNotExistError();
×
1793
      }
1794
      if (result.isSetServiceBusyError()) {
×
1795
        throw result.getServiceBusyError();
×
1796
      }
1797
      if (result.isSetClientVersionNotSupportedError()) {
×
1798
        throw result.getClientVersionNotSupportedError();
×
1799
      }
1800
      throw new TException("ListClosedWorkflowExecutions failed with unknown error:" + result);
×
1801
    } finally {
1802
      if (response != null) {
×
1803
        response.release();
×
1804
      }
1805
    }
1806
  }
1807

1808
  @Override
1809
  public ListWorkflowExecutionsResponse ListWorkflowExecutions(
1810
      ListWorkflowExecutionsRequest request)
1811
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1812
          ClientVersionNotSupportedError, TException {
1813
    return measureRemoteCall(
×
1814
        ServiceMethod.LIST_WORKFLOW_EXECUTIONS, () -> listWorkflowExecutions(request));
×
1815
  }
1816

1817
  private ListWorkflowExecutionsResponse listWorkflowExecutions(
1818
      ListWorkflowExecutionsRequest listRequest) throws TException {
1819
    ThriftResponse<WorkflowService.ListWorkflowExecutions_result> response = null;
×
1820
    try {
1821
      ThriftRequest<WorkflowService.ListWorkflowExecutions_args> request =
×
1822
          buildThriftRequest(
×
1823
              "ListWorkflowExecutions",
1824
              new WorkflowService.ListWorkflowExecutions_args(listRequest));
1825
      response = doRemoteCall(request);
×
1826
      WorkflowService.ListWorkflowExecutions_result result =
×
1827
          response.getBody(WorkflowService.ListWorkflowExecutions_result.class);
×
1828
      if (response.getResponseCode() == ResponseCode.OK) {
×
1829
        return result.getSuccess();
×
1830
      }
1831
      if (result.isSetBadRequestError()) {
×
1832
        throw result.getBadRequestError();
×
1833
      }
1834
      if (result.isSetEntityNotExistError()) {
×
1835
        throw result.getEntityNotExistError();
×
1836
      }
1837
      if (result.isSetServiceBusyError()) {
×
1838
        throw result.getServiceBusyError();
×
1839
      }
1840
      if (result.isSetClientVersionNotSupportedError()) {
×
1841
        throw result.getClientVersionNotSupportedError();
×
1842
      }
1843
      throw new TException("ListWorkflowExecutions failed with unknown error:" + result);
×
1844
    } finally {
1845
      if (response != null) {
×
1846
        response.release();
×
1847
      }
1848
    }
1849
  }
1850

1851
  @Override
1852
  public ListArchivedWorkflowExecutionsResponse ListArchivedWorkflowExecutions(
1853
      ListArchivedWorkflowExecutionsRequest listRequest)
1854
      throws BadRequestError, EntityNotExistsError, ServiceBusyError,
1855
          ClientVersionNotSupportedError, TException {
1856
    return measureRemoteCall(
×
1857
        ServiceMethod.LIST_ARCHIVED_WORKFLOW_EXECUTIONS,
1858
        () -> listArchivedWorkflowExecutions(listRequest));
×
1859
  }
1860

1861
  private ListArchivedWorkflowExecutionsResponse listArchivedWorkflowExecutions(
1862
      ListArchivedWorkflowExecutionsRequest listRequest) throws TException {
1863
    ThriftResponse<WorkflowService.ListArchivedWorkflowExecutions_result> response = null;
×
1864
    try {
1865
      ThriftRequest<WorkflowService.ListArchivedWorkflowExecutions_args> request =
×
1866
          buildThriftRequest(
×
1867
              "ListArchivedWorkflowExecutions",
1868
              new WorkflowService.ListArchivedWorkflowExecutions_args(listRequest),
1869
              options.getRpcListArchivedWorkflowTimeoutMillis());
×
1870
      response = doRemoteCall(request);
×
1871
      WorkflowService.ListArchivedWorkflowExecutions_result result =
×
1872
          response.getBody(WorkflowService.ListArchivedWorkflowExecutions_result.class);
×
1873
      if (response.getResponseCode() == ResponseCode.OK) {
×
1874
        return result.getSuccess();
×
1875
      }
1876
      if (result.isSetBadRequestError()) {
×
1877
        throw result.getBadRequestError();
×
1878
      }
1879
      if (result.isSetEntityNotExistError()) {
×
1880
        throw result.getEntityNotExistError();
×
1881
      }
1882
      if (result.isSetServiceBusyError()) {
×
1883
        throw result.getServiceBusyError();
×
1884
      }
1885
      if (result.isSetClientVersionNotSupportedError()) {
×
1886
        throw result.getClientVersionNotSupportedError();
×
1887
      }
1888
      throw new TException("ListArchivedWorkflowExecutions failed with unknown error:" + result);
×
1889
    } finally {
1890
      if (response != null) {
×
1891
        response.release();
×
1892
      }
1893
    }
1894
  }
1895

1896
  @Override
1897
  public ListWorkflowExecutionsResponse ScanWorkflowExecutions(
1898
      ListWorkflowExecutionsRequest request)
1899
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1900
          ClientVersionNotSupportedError, TException {
1901
    return measureRemoteCall(
×
1902
        ServiceMethod.SCAN_WORKFLOW_EXECUTIONS, () -> scanWorkflowExecutions(request));
×
1903
  }
1904

1905
  private ListWorkflowExecutionsResponse scanWorkflowExecutions(
1906
      ListWorkflowExecutionsRequest listRequest) throws TException {
1907
    ThriftResponse<WorkflowService.ScanWorkflowExecutions_result> response = null;
×
1908
    try {
1909
      ThriftRequest<WorkflowService.ScanWorkflowExecutions_args> request =
×
1910
          buildThriftRequest(
×
1911
              "ScanWorkflowExecutions",
1912
              new WorkflowService.ScanWorkflowExecutions_args(listRequest));
1913
      response = doRemoteCall(request);
×
1914
      WorkflowService.ScanWorkflowExecutions_result result =
×
1915
          response.getBody(WorkflowService.ScanWorkflowExecutions_result.class);
×
1916
      if (response.getResponseCode() == ResponseCode.OK) {
×
1917
        return result.getSuccess();
×
1918
      }
1919
      if (result.isSetBadRequestError()) {
×
1920
        throw result.getBadRequestError();
×
1921
      }
1922
      if (result.isSetEntityNotExistError()) {
×
1923
        throw result.getEntityNotExistError();
×
1924
      }
1925
      if (result.isSetServiceBusyError()) {
×
1926
        throw result.getServiceBusyError();
×
1927
      }
1928
      if (result.isSetClientVersionNotSupportedError()) {
×
1929
        throw result.getClientVersionNotSupportedError();
×
1930
      }
1931
      throw new TException("ScanWorkflowExecutions failed with unknown error:" + result);
×
1932
    } finally {
1933
      if (response != null) {
×
1934
        response.release();
×
1935
      }
1936
    }
1937
  }
1938

1939
  @Override
1940
  public CountWorkflowExecutionsResponse CountWorkflowExecutions(
1941
      CountWorkflowExecutionsRequest countRequest)
1942
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1943
          ClientVersionNotSupportedError, TException {
1944
    return measureRemoteCall(
×
1945
        ServiceMethod.COUNT_WORKFLOW_EXECUTIONS, () -> countWorkflowExecutions(countRequest));
×
1946
  }
1947

1948
  private CountWorkflowExecutionsResponse countWorkflowExecutions(
1949
      CountWorkflowExecutionsRequest countRequest) throws TException {
1950
    ThriftResponse<WorkflowService.CountWorkflowExecutions_result> response = null;
×
1951
    try {
1952
      ThriftRequest<WorkflowService.CountWorkflowExecutions_args> request =
×
1953
          buildThriftRequest(
×
1954
              "CountWorkflowExecutions",
1955
              new WorkflowService.CountWorkflowExecutions_args(countRequest));
1956
      response = doRemoteCall(request);
×
1957
      WorkflowService.CountWorkflowExecutions_result result =
×
1958
          response.getBody(WorkflowService.CountWorkflowExecutions_result.class);
×
1959
      if (response.getResponseCode() == ResponseCode.OK) {
×
1960
        return result.getSuccess();
×
1961
      }
1962
      if (result.isSetBadRequestError()) {
×
1963
        throw result.getBadRequestError();
×
1964
      }
1965
      if (result.isSetEntityNotExistError()) {
×
1966
        throw result.getEntityNotExistError();
×
1967
      }
1968
      if (result.isSetServiceBusyError()) {
×
1969
        throw result.getServiceBusyError();
×
1970
      }
1971
      if (result.isSetClientVersionNotSupportedError()) {
×
1972
        throw result.getClientVersionNotSupportedError();
×
1973
      }
1974
      throw new TException("CountWorkflowExecutions failed with unknown error:" + result);
×
1975
    } finally {
1976
      if (response != null) {
×
1977
        response.release();
×
1978
      }
1979
    }
1980
  }
1981

1982
  @Override
1983
  public GetSearchAttributesResponse GetSearchAttributes()
1984
      throws InternalServiceError, ServiceBusyError, ClientVersionNotSupportedError, TException {
1985
    return measureRemoteCall(ServiceMethod.GET_SEARCH_ATTRIBUTES, () -> getSearchAttributes());
×
1986
  }
1987

1988
  private GetSearchAttributesResponse getSearchAttributes() throws TException {
1989
    ThriftResponse<WorkflowService.GetSearchAttributes_result> response = null;
×
1990
    try {
1991
      ThriftRequest<WorkflowService.GetSearchAttributes_args> request =
×
1992
          buildThriftRequest("GetSearchAttributes", new WorkflowService.GetSearchAttributes_args());
×
1993
      response = doRemoteCall(request);
×
1994
      WorkflowService.GetSearchAttributes_result result =
×
1995
          response.getBody(WorkflowService.GetSearchAttributes_result.class);
×
1996
      if (response.getResponseCode() == ResponseCode.OK) {
×
1997
        return result.getSuccess();
×
1998
      }
1999
      if (result.isSetServiceBusyError()) {
×
2000
        throw result.getServiceBusyError();
×
2001
      }
2002
      if (result.isSetClientVersionNotSupportedError()) {
×
2003
        throw result.getClientVersionNotSupportedError();
×
2004
      }
2005
      throw new TException("GetSearchAttributes failed with unknown error:" + result);
×
2006
    } finally {
2007
      if (response != null) {
×
2008
        response.release();
×
2009
      }
2010
    }
2011
  }
2012

2013
  @Override
2014
  public void RespondQueryTaskCompleted(RespondQueryTaskCompletedRequest request)
2015
      throws TException {
2016
    measureRemoteProc(
×
2017
        ServiceMethod.RESPOND_QUERY_TASK_COMPLETED, () -> respondQueryTaskCompleted(request));
×
2018
  }
×
2019

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

2060
  @Override
2061
  public QueryWorkflowResponse QueryWorkflow(QueryWorkflowRequest request) throws TException {
2062
    return measureRemoteCall(ServiceMethod.QUERY_WORKFLOW, () -> queryWorkflow(request));
×
2063
  }
2064

2065
  private QueryWorkflowResponse queryWorkflow(QueryWorkflowRequest queryRequest) throws TException {
2066
    ThriftResponse<WorkflowService.QueryWorkflow_result> response = null;
×
2067
    try {
2068
      ThriftRequest<WorkflowService.QueryWorkflow_args> request =
×
2069
          buildThriftRequest(
×
2070
              "QueryWorkflow",
2071
              new WorkflowService.QueryWorkflow_args(queryRequest),
2072
              options.getRpcQueryTimeoutMillis());
×
2073
      response = doRemoteCall(request);
×
2074
      WorkflowService.QueryWorkflow_result result =
×
2075
          response.getBody(WorkflowService.QueryWorkflow_result.class);
×
2076
      if (response.getResponseCode() == ResponseCode.OK) {
×
2077
        return result.getSuccess();
×
2078
      }
2079
      if (result.isSetBadRequestError()) {
×
2080
        throw result.getBadRequestError();
×
2081
      }
2082
      if (result.isSetEntityNotExistError()) {
×
2083
        throw result.getEntityNotExistError();
×
2084
      }
2085
      if (result.isSetQueryFailedError()) {
×
2086
        throw result.getQueryFailedError();
×
2087
      }
2088
      if (result.isSetClientVersionNotSupportedError()) {
×
2089
        throw result.getClientVersionNotSupportedError();
×
2090
      }
2091
      throw new TException("QueryWorkflow failed with unknown error:" + result);
×
2092
    } finally {
2093
      if (response != null) {
×
2094
        response.release();
×
2095
      }
2096
    }
2097
  }
2098

2099
  @Override
2100
  public ResetStickyTaskListResponse ResetStickyTaskList(ResetStickyTaskListRequest resetRequest)
2101
      throws BadRequestError, InternalServiceError, EntityNotExistsError, LimitExceededError,
2102
          WorkflowExecutionAlreadyCompletedError, ServiceBusyError, DomainNotActiveError,
2103
          TException {
2104
    return measureRemoteCall(
×
2105
        ServiceMethod.RESET_STICKY_TASK_LIST, () -> resetStickyTaskList(resetRequest));
×
2106
  }
2107

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

2152
  @Override
2153
  public DescribeWorkflowExecutionResponse DescribeWorkflowExecution(
2154
      DescribeWorkflowExecutionRequest request) throws TException {
2155
    return measureRemoteCall(
×
2156
        ServiceMethod.DESCRIBE_WORKFLOW_EXECUTION, () -> describeWorkflowExecution(request));
×
2157
  }
2158

2159
  private DescribeWorkflowExecutionResponse describeWorkflowExecution(
2160
      DescribeWorkflowExecutionRequest describeRequest) throws TException {
2161
    ThriftResponse<WorkflowService.DescribeWorkflowExecution_result> response = null;
×
2162
    try {
2163
      ThriftRequest<WorkflowService.DescribeWorkflowExecution_args> request =
×
2164
          buildThriftRequest(
×
2165
              "DescribeWorkflowExecution",
2166
              new WorkflowService.DescribeWorkflowExecution_args(describeRequest));
2167
      response = doRemoteCall(request);
×
2168
      WorkflowService.DescribeWorkflowExecution_result result =
×
2169
          response.getBody(WorkflowService.DescribeWorkflowExecution_result.class);
×
2170
      if (response.getResponseCode() == ResponseCode.OK) {
×
2171
        return result.getSuccess();
×
2172
      }
2173
      if (result.isSetBadRequestError()) {
×
2174
        throw result.getBadRequestError();
×
2175
      }
2176
      if (result.isSetEntityNotExistError()) {
×
2177
        throw result.getEntityNotExistError();
×
2178
      }
2179
      if (result.isSetServiceBusyError()) {
×
2180
        throw result.getServiceBusyError();
×
2181
      }
2182
      if (result.isSetLimitExceededError()) {
×
2183
        throw result.getLimitExceededError();
×
2184
      }
2185
      if (result.isSetClientVersionNotSupportedError()) {
×
2186
        throw result.getClientVersionNotSupportedError();
×
2187
      }
2188
      throw new TException("DescribeWorkflowExecution failed with unknown error:" + result);
×
2189
    } finally {
2190
      if (response != null) {
×
2191
        response.release();
×
2192
      }
2193
    }
2194
  }
2195

2196
  @Override
2197
  public DescribeTaskListResponse DescribeTaskList(DescribeTaskListRequest request)
2198
      throws TException {
2199
    return measureRemoteCall(ServiceMethod.DESCRIBE_TASK_LIST, () -> describeTaskList(request));
×
2200
  }
2201

2202
  private DescribeTaskListResponse describeTaskList(DescribeTaskListRequest describeRequest)
2203
      throws TException {
2204
    ThriftResponse<WorkflowService.DescribeTaskList_result> response = null;
×
2205
    try {
2206
      ThriftRequest<WorkflowService.DescribeTaskList_args> request =
×
2207
          buildThriftRequest(
×
2208
              "DescribeTaskList", new WorkflowService.DescribeTaskList_args(describeRequest));
2209
      response = doRemoteCall(request);
×
2210
      WorkflowService.DescribeTaskList_result result =
×
2211
          response.getBody(WorkflowService.DescribeTaskList_result.class);
×
2212
      if (response.getResponseCode() == ResponseCode.OK) {
×
2213
        return result.getSuccess();
×
2214
      }
2215
      if (result.isSetBadRequestError()) {
×
2216
        throw result.getBadRequestError();
×
2217
      }
2218
      if (result.isSetEntityNotExistError()) {
×
2219
        throw result.getEntityNotExistError();
×
2220
      }
2221
      if (result.isSetServiceBusyError()) {
×
2222
        throw result.getServiceBusyError();
×
2223
      }
2224
      if (result.isSetLimitExceededError()) {
×
2225
        throw result.getLimitExceededError();
×
2226
      }
2227
      if (result.isSetClientVersionNotSupportedError()) {
×
2228
        throw result.getClientVersionNotSupportedError();
×
2229
      }
2230
      throw new TException("DescribeTaskList failed with unknown error:" + result);
×
2231
    } finally {
2232
      if (response != null) {
×
2233
        response.release();
×
2234
      }
2235
    }
2236
  }
2237

2238
  @Override
2239
  public ClusterInfo GetClusterInfo() throws InternalServiceError, ServiceBusyError, TException {
2240
    return measureRemoteCall(ServiceMethod.GET_CLUSTER_INFO, () -> getClusterInfo());
×
2241
  }
2242

2243
  private ClusterInfo getClusterInfo() throws TException {
2244
    ThriftResponse<WorkflowService.GetClusterInfo_result> response = null;
×
2245
    try {
2246
      ThriftRequest<WorkflowService.GetClusterInfo_args> request =
×
2247
          buildThriftRequest("GetClusterInfo", new WorkflowService.GetClusterInfo_args());
×
2248
      response = doRemoteCall(request);
×
2249
      WorkflowService.GetClusterInfo_result result =
×
2250
          response.getBody(WorkflowService.GetClusterInfo_result.class);
×
2251
      if (response.getResponseCode() == ResponseCode.OK) {
×
2252
        return result.getSuccess();
×
2253
      }
2254
      if (result.isSetServiceBusyError()) {
×
2255
        throw result.getServiceBusyError();
×
2256
      }
2257
      throw new TException("GetClusterInfo failed with unknown error:" + result);
×
2258
    } finally {
2259
      if (response != null) {
×
2260
        response.release();
×
2261
      }
2262
    }
2263
  }
2264

2265
  @Override
2266
  public ListTaskListPartitionsResponse ListTaskListPartitions(
2267
      ListTaskListPartitionsRequest request)
2268
      throws BadRequestError, EntityNotExistsError, LimitExceededError, ServiceBusyError,
2269
          TException {
2270
    return measureRemoteCall(
×
2271
        ServiceMethod.LIST_TASK_LIST_PARTITIONS, () -> listTaskListPartitions(request));
×
2272
  }
2273

2274
  @Override
2275
  public void RefreshWorkflowTasks(RefreshWorkflowTasksRequest refreshWorkflowTasks)
2276
      throws BadRequestError, DomainNotActiveError, ServiceBusyError, EntityNotExistsError,
2277
          TException {
2278
    ThriftResponse<WorkflowService.RefreshWorkflowTasks_result> response = null;
×
2279
    try {
2280
      ThriftRequest<WorkflowService.RefreshWorkflowTasks_args> request =
×
2281
          buildThriftRequest(
×
2282
              "RefreshWorkflowTasks",
2283
              new WorkflowService.RefreshWorkflowTasks_args(refreshWorkflowTasks));
2284
      response = doRemoteCall(request);
×
2285
      WorkflowService.RefreshWorkflowTasks_result result =
×
2286
          response.getBody(WorkflowService.RefreshWorkflowTasks_result.class);
×
2287
      if (result.isSetBadRequestError()) {
×
2288
        throw result.getBadRequestError();
×
2289
      }
2290
      if (result.isSetDomainNotActiveError()) {
×
2291
        throw result.getDomainNotActiveError();
×
2292
      }
2293
      if (result.isSetServiceBusyError()) {
×
2294
        throw result.getServiceBusyError();
×
2295
      }
2296
      if (result.isSetEntityNotExistError()) {
×
2297
        throw result.getEntityNotExistError();
×
2298
      }
2299
    } finally {
2300
      if (response != null) {
×
2301
        response.release();
×
2302
      }
2303
    }
2304
  }
×
2305

2306
  private ListTaskListPartitionsResponse listTaskListPartitions(
2307
      ListTaskListPartitionsRequest listRequest) throws TException {
2308
    ThriftResponse<WorkflowService.ListTaskListPartitions_result> response = null;
×
2309
    try {
2310
      ThriftRequest<WorkflowService.ListTaskListPartitions_args> request =
×
2311
          buildThriftRequest(
×
2312
              "ListTaskListPartitions",
2313
              new WorkflowService.ListTaskListPartitions_args(listRequest));
2314
      response = doRemoteCall(request);
×
2315
      WorkflowService.ListTaskListPartitions_result result =
×
2316
          response.getBody(WorkflowService.ListTaskListPartitions_result.class);
×
2317
      if (response.getResponseCode() == ResponseCode.OK) {
×
2318
        return result.getSuccess();
×
2319
      }
2320
      if (result.isSetBadRequestError()) {
×
2321
        throw result.getBadRequestError();
×
2322
      }
2323
      if (result.isSetEntityNotExistError()) {
×
2324
        throw result.getEntityNotExistError();
×
2325
      }
2326
      if (result.isSetServiceBusyError()) {
×
2327
        throw result.getServiceBusyError();
×
2328
      }
2329
      if (result.isSetLimitExceededError()) {
×
2330
        throw result.getLimitExceededError();
×
2331
      }
2332
      throw new TException("ListTaskListPartitions failed with unknown error:" + result);
×
2333
    } finally {
2334
      if (response != null) {
×
2335
        response.release();
×
2336
      }
2337
    }
2338
  }
2339

2340
  @Override
2341
  public void StartWorkflowExecution(
2342
      StartWorkflowExecutionRequest startRequest, AsyncMethodCallback resultHandler) {
2343
    startWorkflowExecution(startRequest, resultHandler, null);
×
2344
  }
×
2345

2346
  @Override
2347
  public void StartWorkflowExecutionWithTimeout(
2348
      StartWorkflowExecutionRequest startRequest,
2349
      AsyncMethodCallback resultHandler,
2350
      Long timeoutInMillis) {
2351
    startWorkflowExecution(startRequest, resultHandler, timeoutInMillis);
×
2352
  }
×
2353

2354
  private void startWorkflowExecution(
2355
      StartWorkflowExecutionRequest startRequest,
2356
      AsyncMethodCallback resultHandler,
2357
      Long timeoutInMillis) {
2358
    initializeStartWorkflowRequest(startRequest);
×
2359
    timeoutInMillis = validateAndUpdateTimeout(timeoutInMillis, options.getRpcTimeoutMillis());
×
2360
    ThriftRequest<WorkflowService.StartWorkflowExecution_args> request =
×
2361
        buildThriftRequest(
×
2362
            "StartWorkflowExecution",
2363
            new WorkflowService.StartWorkflowExecution_args(startRequest),
2364
            timeoutInMillis);
2365

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

2424
  @Override
2425
  public void StartWorkflowExecutionAsync(
2426
      StartWorkflowExecutionAsyncRequest startRequest, AsyncMethodCallback resultHandler)
2427
      throws TException {
2428
    startWorkflowExecutionAsync(startRequest, resultHandler, null);
×
2429
  }
×
2430

2431
  @Override
2432
  public void StartWorkflowExecutionAsyncWithTimeout(
2433
      StartWorkflowExecutionAsyncRequest startAsyncRequest,
2434
      AsyncMethodCallback resultHandler,
2435
      Long timeoutInMillis)
2436
      throws TException {
2437
    startWorkflowExecutionAsync(startAsyncRequest, resultHandler, timeoutInMillis);
1✔
2438
  }
1✔
2439

2440
  private void startWorkflowExecutionAsync(
2441
      StartWorkflowExecutionAsyncRequest startAsyncRequest,
2442
      AsyncMethodCallback resultHandler,
2443
      Long timeoutInMillis)
2444
      throws TException {
2445
    initializeStartWorkflowRequest(startAsyncRequest.getRequest());
1✔
2446
    timeoutInMillis = validateAndUpdateTimeout(timeoutInMillis, options.getRpcTimeoutMillis());
1✔
2447
    ThriftRequest<WorkflowService.StartWorkflowExecutionAsync_args> request =
1✔
2448
        buildThriftRequest(
1✔
2449
            "StartWorkflowExecutionAsync",
2450
            new WorkflowService.StartWorkflowExecutionAsync_args(startAsyncRequest),
2451
            timeoutInMillis);
2452

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

2512
  private Long validateAndUpdateTimeout(Long timeoutInMillis, Long defaultTimeoutInMillis) {
2513
    if (timeoutInMillis == null || timeoutInMillis <= 0 || timeoutInMillis == Long.MAX_VALUE) {
1✔
2514
      timeoutInMillis = defaultTimeoutInMillis;
1✔
2515
    } else {
2516
      timeoutInMillis = Math.min(timeoutInMillis, defaultTimeoutInMillis);
×
2517
    }
2518
    return timeoutInMillis;
1✔
2519
  }
2520

2521
  @SuppressWarnings({"unchecked", "FutureReturnValueIgnored"})
2522
  @Override
2523
  public void GetWorkflowExecutionHistoryWithTimeout(
2524
      GetWorkflowExecutionHistoryRequest getRequest,
2525
      AsyncMethodCallback resultHandler,
2526
      Long timeoutInMillis) {
2527

2528
    getWorkflowExecutionHistory(getRequest, resultHandler, timeoutInMillis);
×
2529
  }
×
2530

2531
  @SuppressWarnings({"unchecked", "FutureReturnValueIgnored"})
2532
  @Override
2533
  public void GetWorkflowExecutionHistory(
2534
      GetWorkflowExecutionHistoryRequest getRequest, AsyncMethodCallback resultHandler) {
2535

2536
    getWorkflowExecutionHistory(getRequest, resultHandler, null);
×
2537
  }
×
2538

2539
  private void getWorkflowExecutionHistory(
2540
      GetWorkflowExecutionHistoryRequest getRequest,
2541
      AsyncMethodCallback resultHandler,
2542
      Long timeoutInMillis) {
2543

2544
    ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args> request =
×
2545
        buildGetWorkflowExecutionHistoryThriftRequest(getRequest, timeoutInMillis);
×
2546

2547
    CompletableFuture<ThriftResponse<GetWorkflowExecutionHistory_result>> response =
×
2548
        doRemoteCallAsync(request);
×
2549
    response
×
2550
        .whenComplete(
×
2551
            (r, e) -> {
2552
              try {
2553
                if (e != null) {
×
2554
                  resultHandler.onError(CheckedExceptionWrapper.wrap(e));
×
2555
                  return;
×
2556
                }
2557
                WorkflowService.GetWorkflowExecutionHistory_result result =
×
2558
                    r.getBody(WorkflowService.GetWorkflowExecutionHistory_result.class);
×
2559

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

2601
  @Override
2602
  public void PollForDecisionTask(
2603
      PollForDecisionTaskRequest pollRequest, AsyncMethodCallback resultHandler) throws TException {
2604
    throw new UnsupportedOperationException("not implemented");
×
2605
  }
2606

2607
  @Override
2608
  public void RespondDecisionTaskCompleted(
2609
      RespondDecisionTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
2610
      throws TException {
2611
    throw new UnsupportedOperationException("not implemented");
×
2612
  }
2613

2614
  @Override
2615
  public void RespondDecisionTaskFailed(
2616
      RespondDecisionTaskFailedRequest failedRequest, AsyncMethodCallback resultHandler)
2617
      throws TException {
2618
    throw new UnsupportedOperationException("not implemented");
×
2619
  }
2620

2621
  @Override
2622
  public void PollForActivityTask(
2623
      PollForActivityTaskRequest pollRequest, AsyncMethodCallback resultHandler) throws TException {
2624
    throw new UnsupportedOperationException("not implemented");
×
2625
  }
2626

2627
  @Override
2628
  public void RecordActivityTaskHeartbeat(
2629
      RecordActivityTaskHeartbeatRequest heartbeatRequest, AsyncMethodCallback resultHandler)
2630
      throws TException {
2631
    throw new UnsupportedOperationException("not implemented");
×
2632
  }
2633

2634
  @Override
2635
  public void RecordActivityTaskHeartbeatByID(
2636
      RecordActivityTaskHeartbeatByIDRequest heartbeatRequest, AsyncMethodCallback resultHandler)
2637
      throws TException {
2638
    throw new UnsupportedOperationException("not implemented");
×
2639
  }
2640

2641
  @Override
2642
  public void RespondActivityTaskCompleted(
2643
      RespondActivityTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
2644
      throws TException {
2645
    throw new UnsupportedOperationException("not implemented");
×
2646
  }
2647

2648
  @Override
2649
  public void RespondActivityTaskCompletedByID(
2650
      RespondActivityTaskCompletedByIDRequest completeRequest, AsyncMethodCallback resultHandler)
2651
      throws TException {
2652
    throw new UnsupportedOperationException("not implemented");
×
2653
  }
2654

2655
  @Override
2656
  public void RespondActivityTaskFailed(
2657
      RespondActivityTaskFailedRequest failRequest, AsyncMethodCallback resultHandler)
2658
      throws TException {
2659
    throw new UnsupportedOperationException("not implemented");
×
2660
  }
2661

2662
  @Override
2663
  public void RespondActivityTaskFailedByID(
2664
      RespondActivityTaskFailedByIDRequest failRequest, AsyncMethodCallback resultHandler)
2665
      throws TException {
2666
    throw new UnsupportedOperationException("not implemented");
×
2667
  }
2668

2669
  @Override
2670
  public void RespondActivityTaskCanceled(
2671
      RespondActivityTaskCanceledRequest canceledRequest, AsyncMethodCallback resultHandler)
2672
      throws TException {
2673
    throw new UnsupportedOperationException("not implemented");
×
2674
  }
2675

2676
  @Override
2677
  public void RespondActivityTaskCanceledByID(
2678
      RespondActivityTaskCanceledByIDRequest canceledRequest, AsyncMethodCallback resultHandler)
2679
      throws TException {
2680
    throw new UnsupportedOperationException("not implemented");
×
2681
  }
2682

2683
  @Override
2684
  public void RequestCancelWorkflowExecution(
2685
      RequestCancelWorkflowExecutionRequest cancelRequest, AsyncMethodCallback resultHandler)
2686
      throws TException {
2687
    throw new UnsupportedOperationException("not implemented");
×
2688
  }
2689

2690
  @Override
2691
  public void SignalWorkflowExecution(
2692
      SignalWorkflowExecutionRequest signalRequest, AsyncMethodCallback resultHandler) {
2693
    signalWorkflowExecution(signalRequest, resultHandler, null);
×
2694
  }
×
2695

2696
  @Override
2697
  public void SignalWorkflowExecutionWithTimeout(
2698
      SignalWorkflowExecutionRequest signalRequest,
2699
      AsyncMethodCallback resultHandler,
2700
      Long timeoutInMillis) {
2701
    signalWorkflowExecution(signalRequest, resultHandler, timeoutInMillis);
×
2702
  }
×
2703

2704
  private void signalWorkflowExecution(
2705
      SignalWorkflowExecutionRequest signalRequest,
2706
      AsyncMethodCallback resultHandler,
2707
      Long timeoutInMillis) {
2708

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

2774
  @Override
2775
  public void SignalWithStartWorkflowExecution(
2776
      SignalWithStartWorkflowExecutionRequest signalWithStartRequest,
2777
      AsyncMethodCallback resultHandler)
2778
      throws TException {
2779
    throw new UnsupportedOperationException("not implemented");
×
2780
  }
2781

2782
  @Override
2783
  public void SignalWithStartWorkflowExecutionAsync(
2784
      SignalWithStartWorkflowExecutionAsyncRequest signalWithStartRequest,
2785
      AsyncMethodCallback resultHandler)
2786
      throws TException {
2787
    throw new IllegalArgumentException("unimplemented");
×
2788
  }
2789

2790
  @Override
2791
  public void ResetWorkflowExecution(
2792
      ResetWorkflowExecutionRequest resetRequest, AsyncMethodCallback resultHandler)
2793
      throws TException {
2794
    throw new UnsupportedOperationException("not implemented");
×
2795
  }
2796

2797
  @Override
2798
  public void TerminateWorkflowExecution(
2799
      TerminateWorkflowExecutionRequest terminateRequest, AsyncMethodCallback resultHandler)
2800
      throws TException {
2801
    throw new UnsupportedOperationException("not implemented");
×
2802
  }
2803

2804
  @Override
2805
  public void ListOpenWorkflowExecutions(
2806
      ListOpenWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2807
      throws TException {
2808
    throw new UnsupportedOperationException("not implemented");
×
2809
  }
2810

2811
  @Override
2812
  public void ListClosedWorkflowExecutions(
2813
      ListClosedWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2814
      throws TException {
2815
    throw new UnsupportedOperationException("not implemented");
×
2816
  }
2817

2818
  @Override
2819
  public void ListWorkflowExecutions(
2820
      ListWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2821
      throws TException {
2822
    throw new UnsupportedOperationException("not implemented");
×
2823
  }
2824

2825
  @Override
2826
  public void ListArchivedWorkflowExecutions(
2827
      ListArchivedWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2828
      throws TException {
2829
    throw new UnsupportedOperationException("not implemented");
×
2830
  }
2831

2832
  @Override
2833
  public void ScanWorkflowExecutions(
2834
      ListWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2835
      throws TException {
2836
    throw new UnsupportedOperationException("not implemented");
×
2837
  }
2838

2839
  @Override
2840
  public void CountWorkflowExecutions(
2841
      CountWorkflowExecutionsRequest countRequest, AsyncMethodCallback resultHandler)
2842
      throws TException {
2843
    throw new UnsupportedOperationException("not implemented");
×
2844
  }
2845

2846
  @Override
2847
  public void GetSearchAttributes(AsyncMethodCallback resultHandler) throws TException {
2848
    throw new UnsupportedOperationException("not implemented");
×
2849
  }
2850

2851
  @Override
2852
  public void RespondQueryTaskCompleted(
2853
      RespondQueryTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
2854
      throws TException {
2855
    throw new UnsupportedOperationException("not implemented");
×
2856
  }
2857

2858
  @Override
2859
  public void ResetStickyTaskList(
2860
      ResetStickyTaskListRequest resetRequest, AsyncMethodCallback resultHandler)
2861
      throws TException {
2862
    throw new UnsupportedOperationException("not implemented");
×
2863
  }
2864

2865
  @Override
2866
  public void QueryWorkflow(QueryWorkflowRequest queryRequest, AsyncMethodCallback resultHandler)
2867
      throws TException {
2868
    throw new UnsupportedOperationException("not implemented");
×
2869
  }
2870

2871
  @Override
2872
  public void DescribeWorkflowExecution(
2873
      DescribeWorkflowExecutionRequest describeRequest, AsyncMethodCallback resultHandler)
2874
      throws TException {
2875
    throw new UnsupportedOperationException("not implemented");
×
2876
  }
2877

2878
  @Override
2879
  public void DescribeTaskList(DescribeTaskListRequest request, AsyncMethodCallback resultHandler)
2880
      throws TException {
2881
    throw new UnsupportedOperationException("not implemented");
×
2882
  }
2883

2884
  @Override
2885
  public void GetClusterInfo(AsyncMethodCallback resultHandler) throws TException {}
×
2886

2887
  @Override
2888
  public void ListTaskListPartitions(
2889
      ListTaskListPartitionsRequest request, AsyncMethodCallback resultHandler) throws TException {}
×
2890

2891
  @Override
2892
  public void RefreshWorkflowTasks(
2893
      RefreshWorkflowTasksRequest request, AsyncMethodCallback resultHandler) throws TException {}
×
2894

2895
  @Override
2896
  public void RegisterDomain(
2897
      RegisterDomainRequest registerRequest, AsyncMethodCallback resultHandler) throws TException {
2898
    throw new UnsupportedOperationException("not implemented");
×
2899
  }
2900

2901
  @Override
2902
  public void DescribeDomain(
2903
      DescribeDomainRequest describeRequest, AsyncMethodCallback resultHandler) throws TException {
2904
    throw new UnsupportedOperationException("not implemented");
×
2905
  }
2906

2907
  @Override
2908
  public void ListDomains(ListDomainsRequest listRequest, AsyncMethodCallback resultHandler)
2909
      throws TException {
2910
    throw new UnsupportedOperationException("not implemented");
×
2911
  }
2912

2913
  @Override
2914
  public void UpdateDomain(UpdateDomainRequest updateRequest, AsyncMethodCallback resultHandler)
2915
      throws TException {
2916
    throw new UnsupportedOperationException("not implemented");
×
2917
  }
2918

2919
  @Override
2920
  public void DeprecateDomain(
2921
      DeprecateDomainRequest deprecateRequest, AsyncMethodCallback resultHandler)
2922
      throws TException {
2923
    throw new UnsupportedOperationException("not implemented");
×
2924
  }
2925

2926
  @Override
2927
  public void RestartWorkflowExecution(
2928
      RestartWorkflowExecutionRequest restartRequest, AsyncMethodCallback resultHandler)
2929
      throws TException {
2930
    throw new IllegalArgumentException("unimplemented");
×
2931
  }
2932

2933
  @Override
2934
  public void GetTaskListsByDomain(
2935
      GetTaskListsByDomainRequest request, AsyncMethodCallback resultHandler)
2936
      throws org.apache.thrift.TException {
2937
    throw new UnsupportedOperationException("not implemented");
×
2938
  }
2939
}
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