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

uber / cadence-java-client / 2326

15 May 2024 06:02PM CUT coverage: 61.521% (+0.08%) from 61.437%
2326

Pull #896

buildkite

shijiesheng
fix test
Pull Request #896: Fix memory leak caused by incorrect context deactivation

67 of 69 new or added lines in 6 files covered. (97.1%)

9 existing lines in 4 files now uncovered.

11975 of 19465 relevant lines covered (61.52%)

0.62 hits per line

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

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

18
package com.uber.cadence.serviceclient;
19

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1460
  @Override
1461
  public void SignalWorkflowExecution(SignalWorkflowExecutionRequest request) throws TException {
1462
    measureRemoteProc(
×
1463
        ServiceMethod.SIGNAL_WORKFLOW_EXECUTION, () -> signalWorkflowExecution(request));
×
1464
  }
×
1465

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

1509
  @Override
1510
  public StartWorkflowExecutionResponse SignalWithStartWorkflowExecution(
1511
      SignalWithStartWorkflowExecutionRequest signalWithStartRequest) throws TException {
1512
    return measureRemoteCall(
×
1513
        ServiceMethod.SIGNAL_WITH_START_WORKFLOW_EXECUTION,
1514
        () -> signalWithStartWorkflowExecution(signalWithStartRequest));
×
1515
  }
1516

1517
  @Override
1518
  public SignalWithStartWorkflowExecutionAsyncResponse SignalWithStartWorkflowExecutionAsync(
1519
      SignalWithStartWorkflowExecutionAsyncRequest signalWithStartRequest) throws TException {
1520
    return measureRemoteCall(
1✔
1521
        ServiceMethod.SIGNAL_WITH_START_WORKFLOW_EXECUTION_ASYNC,
1522
        () -> signalWithStartWorkflowExecutionAsync(signalWithStartRequest));
1✔
1523
  }
1524

1525
  private SignalWithStartWorkflowExecutionAsyncResponse signalWithStartWorkflowExecutionAsync(
1526
      SignalWithStartWorkflowExecutionAsyncRequest signalWithStartRequest) throws TException {
1527
    ThriftResponse<WorkflowService.SignalWithStartWorkflowExecutionAsync_result> response = null;
1✔
1528
    try {
1529
      initializeSignalWithStartWorkflowRequest(signalWithStartRequest.getRequest());
1✔
1530

1531
      ThriftRequest<WorkflowService.SignalWithStartWorkflowExecutionAsync_args> request =
1✔
1532
          buildThriftRequest(
1✔
1533
              "SignalWithStartWorkflowExecutionAsync",
1534
              new WorkflowService.SignalWithStartWorkflowExecutionAsync_args(
1535
                  signalWithStartRequest));
1536

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

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

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

1622
  private StartWorkflowExecutionResponse signalWithStartWorkflowExecution(
1623
      SignalWithStartWorkflowExecutionRequest signalWithStartRequest) throws TException {
1624
    ThriftResponse<WorkflowService.SignalWithStartWorkflowExecution_result> response = null;
×
1625
    try {
1626
      initializeSignalWithStartWorkflowRequest(signalWithStartRequest);
×
1627

1628
      ThriftRequest<WorkflowService.SignalWithStartWorkflowExecution_args> request =
×
1629
          buildThriftRequest(
×
1630
              "SignalWithStartWorkflowExecution",
1631
              new WorkflowService.SignalWithStartWorkflowExecution_args(signalWithStartRequest));
1632

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

1668
  private void initializeSignalWithStartWorkflowRequest(
1669
      SignalWithStartWorkflowExecutionRequest request) {
1670
    request.setRequestId(UUID.randomUUID().toString());
1✔
1671
    // Write span context to header
1672
    if (!request.isSetHeader()) {
1✔
1673
      request.setHeader(new Header());
1✔
1674
    }
1675
    tracingPropagator.inject(request.getHeader());
1✔
1676
  }
1✔
1677

1678
  @Override
1679
  public void TerminateWorkflowExecution(TerminateWorkflowExecutionRequest request)
1680
      throws TException {
1681
    measureRemoteProc(
×
1682
        ServiceMethod.TERMINATE_WORKFLOW_EXECUTION, () -> terminateWorkflowExecution(request));
×
1683
  }
×
1684

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

1728
  @Override
1729
  public ListOpenWorkflowExecutionsResponse ListOpenWorkflowExecutions(
1730
      ListOpenWorkflowExecutionsRequest request) throws TException {
1731
    return measureRemoteCall(
×
1732
        ServiceMethod.LIST_OPEN_WORKFLOW_EXECUTIONS, () -> listOpenWorkflowExecutions(request));
×
1733
  }
1734

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

1772
  @Override
1773
  public ListClosedWorkflowExecutionsResponse ListClosedWorkflowExecutions(
1774
      ListClosedWorkflowExecutionsRequest request) throws TException {
1775
    return measureRemoteCall(
×
1776
        ServiceMethod.LIST_CLOSED_WORKFLOW_EXECUTIONS, () -> listClosedWorkflowExecutions(request));
×
1777
  }
1778

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

1813
  @Override
1814
  public ListWorkflowExecutionsResponse ListWorkflowExecutions(
1815
      ListWorkflowExecutionsRequest request)
1816
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1817
          ClientVersionNotSupportedError, TException {
1818
    return measureRemoteCall(
×
1819
        ServiceMethod.LIST_WORKFLOW_EXECUTIONS, () -> listWorkflowExecutions(request));
×
1820
  }
1821

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

1856
  @Override
1857
  public ListArchivedWorkflowExecutionsResponse ListArchivedWorkflowExecutions(
1858
      ListArchivedWorkflowExecutionsRequest listRequest)
1859
      throws BadRequestError, EntityNotExistsError, ServiceBusyError,
1860
          ClientVersionNotSupportedError, TException {
1861
    return measureRemoteCall(
×
1862
        ServiceMethod.LIST_ARCHIVED_WORKFLOW_EXECUTIONS,
1863
        () -> listArchivedWorkflowExecutions(listRequest));
×
1864
  }
1865

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

1901
  @Override
1902
  public ListWorkflowExecutionsResponse ScanWorkflowExecutions(
1903
      ListWorkflowExecutionsRequest request)
1904
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1905
          ClientVersionNotSupportedError, TException {
1906
    return measureRemoteCall(
×
1907
        ServiceMethod.SCAN_WORKFLOW_EXECUTIONS, () -> scanWorkflowExecutions(request));
×
1908
  }
1909

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

1944
  @Override
1945
  public CountWorkflowExecutionsResponse CountWorkflowExecutions(
1946
      CountWorkflowExecutionsRequest countRequest)
1947
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1948
          ClientVersionNotSupportedError, TException {
1949
    return measureRemoteCall(
×
1950
        ServiceMethod.COUNT_WORKFLOW_EXECUTIONS, () -> countWorkflowExecutions(countRequest));
×
1951
  }
1952

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

1987
  @Override
1988
  public GetSearchAttributesResponse GetSearchAttributes()
1989
      throws InternalServiceError, ServiceBusyError, ClientVersionNotSupportedError, TException {
1990
    return measureRemoteCall(ServiceMethod.GET_SEARCH_ATTRIBUTES, () -> getSearchAttributes());
×
1991
  }
1992

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

2018
  @Override
2019
  public void RespondQueryTaskCompleted(RespondQueryTaskCompletedRequest request)
2020
      throws TException {
2021
    measureRemoteProc(
×
2022
        ServiceMethod.RESPOND_QUERY_TASK_COMPLETED, () -> respondQueryTaskCompleted(request));
×
2023
  }
×
2024

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

2065
  @Override
2066
  public QueryWorkflowResponse QueryWorkflow(QueryWorkflowRequest request) throws TException {
2067
    return measureRemoteCall(ServiceMethod.QUERY_WORKFLOW, () -> queryWorkflow(request));
×
2068
  }
2069

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

2104
  @Override
2105
  public ResetStickyTaskListResponse ResetStickyTaskList(ResetStickyTaskListRequest resetRequest)
2106
      throws BadRequestError, InternalServiceError, EntityNotExistsError, LimitExceededError,
2107
          WorkflowExecutionAlreadyCompletedError, ServiceBusyError, DomainNotActiveError,
2108
          TException {
2109
    return measureRemoteCall(
×
2110
        ServiceMethod.RESET_STICKY_TASK_LIST, () -> resetStickyTaskList(resetRequest));
×
2111
  }
2112

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

2157
  @Override
2158
  public DescribeWorkflowExecutionResponse DescribeWorkflowExecution(
2159
      DescribeWorkflowExecutionRequest request) throws TException {
2160
    return measureRemoteCall(
×
2161
        ServiceMethod.DESCRIBE_WORKFLOW_EXECUTION, () -> describeWorkflowExecution(request));
×
2162
  }
2163

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

2201
  @Override
2202
  public DescribeTaskListResponse DescribeTaskList(DescribeTaskListRequest request)
2203
      throws TException {
2204
    return measureRemoteCall(ServiceMethod.DESCRIBE_TASK_LIST, () -> describeTaskList(request));
×
2205
  }
2206

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

2243
  @Override
2244
  public ClusterInfo GetClusterInfo() throws InternalServiceError, ServiceBusyError, TException {
2245
    return measureRemoteCall(ServiceMethod.GET_CLUSTER_INFO, () -> getClusterInfo());
×
2246
  }
2247

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

2270
  @Override
2271
  public ListTaskListPartitionsResponse ListTaskListPartitions(
2272
      ListTaskListPartitionsRequest request)
2273
      throws BadRequestError, EntityNotExistsError, LimitExceededError, ServiceBusyError,
2274
          TException {
2275
    return measureRemoteCall(
×
2276
        ServiceMethod.LIST_TASK_LIST_PARTITIONS, () -> listTaskListPartitions(request));
×
2277
  }
2278

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

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

2345
  @Override
2346
  public void StartWorkflowExecution(
2347
      StartWorkflowExecutionRequest startRequest, AsyncMethodCallback resultHandler) {
2348
    startWorkflowExecution(startRequest, resultHandler, null);
×
2349
  }
×
2350

2351
  @Override
2352
  public void StartWorkflowExecutionWithTimeout(
2353
      StartWorkflowExecutionRequest startRequest,
2354
      AsyncMethodCallback resultHandler,
2355
      Long timeoutInMillis) {
2356
    startWorkflowExecution(startRequest, resultHandler, timeoutInMillis);
×
2357
  }
×
2358

2359
  private void startWorkflowExecution(
2360
      StartWorkflowExecutionRequest startRequest,
2361
      AsyncMethodCallback resultHandler,
2362
      Long timeoutInMillis) {
2363
    initializeStartWorkflowRequest(startRequest);
×
2364
    timeoutInMillis = validateAndUpdateTimeout(timeoutInMillis, options.getRpcTimeoutMillis());
×
2365
    ThriftRequest<WorkflowService.StartWorkflowExecution_args> request =
×
2366
        buildThriftRequest(
×
2367
            "StartWorkflowExecution",
2368
            new WorkflowService.StartWorkflowExecution_args(startRequest),
2369
            timeoutInMillis);
2370

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

2429
  @Override
2430
  public void StartWorkflowExecutionAsync(
2431
      StartWorkflowExecutionAsyncRequest startRequest, AsyncMethodCallback resultHandler)
2432
      throws TException {
2433
    startWorkflowExecutionAsync(startRequest, resultHandler, null);
×
2434
  }
×
2435

2436
  @Override
2437
  public void StartWorkflowExecutionAsyncWithTimeout(
2438
      StartWorkflowExecutionAsyncRequest startAsyncRequest,
2439
      AsyncMethodCallback resultHandler,
2440
      Long timeoutInMillis)
2441
      throws TException {
2442
    startWorkflowExecutionAsync(startAsyncRequest, resultHandler, timeoutInMillis);
1✔
2443
  }
1✔
2444

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

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

2517
  private Long validateAndUpdateTimeout(Long timeoutInMillis, Long defaultTimeoutInMillis) {
2518
    if (timeoutInMillis == null || timeoutInMillis <= 0 || timeoutInMillis == Long.MAX_VALUE) {
1✔
2519
      timeoutInMillis = defaultTimeoutInMillis;
1✔
2520
    } else {
2521
      timeoutInMillis = Math.min(timeoutInMillis, defaultTimeoutInMillis);
×
2522
    }
2523
    return timeoutInMillis;
1✔
2524
  }
2525

2526
  @SuppressWarnings({"unchecked", "FutureReturnValueIgnored"})
2527
  @Override
2528
  public void GetWorkflowExecutionHistoryWithTimeout(
2529
      GetWorkflowExecutionHistoryRequest getRequest,
2530
      AsyncMethodCallback resultHandler,
2531
      Long timeoutInMillis) {
2532

2533
    getWorkflowExecutionHistory(getRequest, resultHandler, timeoutInMillis);
×
2534
  }
×
2535

2536
  @SuppressWarnings({"unchecked", "FutureReturnValueIgnored"})
2537
  @Override
2538
  public void GetWorkflowExecutionHistory(
2539
      GetWorkflowExecutionHistoryRequest getRequest, AsyncMethodCallback resultHandler) {
2540

2541
    getWorkflowExecutionHistory(getRequest, resultHandler, null);
×
2542
  }
×
2543

2544
  private void getWorkflowExecutionHistory(
2545
      GetWorkflowExecutionHistoryRequest getRequest,
2546
      AsyncMethodCallback resultHandler,
2547
      Long timeoutInMillis) {
2548

2549
    ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args> request =
×
2550
        buildGetWorkflowExecutionHistoryThriftRequest(getRequest, timeoutInMillis);
×
2551

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

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

2606
  @Override
2607
  public void PollForDecisionTask(
2608
      PollForDecisionTaskRequest pollRequest, AsyncMethodCallback resultHandler) throws TException {
2609
    throw new UnsupportedOperationException("not implemented");
×
2610
  }
2611

2612
  @Override
2613
  public void RespondDecisionTaskCompleted(
2614
      RespondDecisionTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
2615
      throws TException {
2616
    throw new UnsupportedOperationException("not implemented");
×
2617
  }
2618

2619
  @Override
2620
  public void RespondDecisionTaskFailed(
2621
      RespondDecisionTaskFailedRequest failedRequest, AsyncMethodCallback resultHandler)
2622
      throws TException {
2623
    throw new UnsupportedOperationException("not implemented");
×
2624
  }
2625

2626
  @Override
2627
  public void PollForActivityTask(
2628
      PollForActivityTaskRequest pollRequest, AsyncMethodCallback resultHandler) throws TException {
2629
    throw new UnsupportedOperationException("not implemented");
×
2630
  }
2631

2632
  @Override
2633
  public void RecordActivityTaskHeartbeat(
2634
      RecordActivityTaskHeartbeatRequest heartbeatRequest, AsyncMethodCallback resultHandler)
2635
      throws TException {
2636
    throw new UnsupportedOperationException("not implemented");
×
2637
  }
2638

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

2646
  @Override
2647
  public void RespondActivityTaskCompleted(
2648
      RespondActivityTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
2649
      throws TException {
2650
    throw new UnsupportedOperationException("not implemented");
×
2651
  }
2652

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

2660
  @Override
2661
  public void RespondActivityTaskFailed(
2662
      RespondActivityTaskFailedRequest failRequest, AsyncMethodCallback resultHandler)
2663
      throws TException {
2664
    throw new UnsupportedOperationException("not implemented");
×
2665
  }
2666

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

2674
  @Override
2675
  public void RespondActivityTaskCanceled(
2676
      RespondActivityTaskCanceledRequest canceledRequest, AsyncMethodCallback resultHandler)
2677
      throws TException {
2678
    throw new UnsupportedOperationException("not implemented");
×
2679
  }
2680

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

2688
  @Override
2689
  public void RequestCancelWorkflowExecution(
2690
      RequestCancelWorkflowExecutionRequest cancelRequest, AsyncMethodCallback resultHandler)
2691
      throws TException {
2692
    throw new UnsupportedOperationException("not implemented");
×
2693
  }
2694

2695
  @Override
2696
  public void SignalWorkflowExecution(
2697
      SignalWorkflowExecutionRequest signalRequest, AsyncMethodCallback resultHandler) {
2698
    signalWorkflowExecution(signalRequest, resultHandler, null);
×
2699
  }
×
2700

2701
  @Override
2702
  public void SignalWorkflowExecutionWithTimeout(
2703
      SignalWorkflowExecutionRequest signalRequest,
2704
      AsyncMethodCallback resultHandler,
2705
      Long timeoutInMillis) {
2706
    signalWorkflowExecution(signalRequest, resultHandler, timeoutInMillis);
×
2707
  }
×
2708

2709
  private void signalWorkflowExecution(
2710
      SignalWorkflowExecutionRequest signalRequest,
2711
      AsyncMethodCallback resultHandler,
2712
      Long timeoutInMillis) {
2713

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

2779
  @Override
2780
  public void SignalWithStartWorkflowExecution(
2781
      SignalWithStartWorkflowExecutionRequest signalWithStartRequest,
2782
      AsyncMethodCallback resultHandler)
2783
      throws TException {
2784
    throw new UnsupportedOperationException("not implemented");
×
2785
  }
2786

2787
  @Override
2788
  public void SignalWithStartWorkflowExecutionAsync(
2789
      SignalWithStartWorkflowExecutionAsyncRequest signalWithStartRequest,
2790
      AsyncMethodCallback resultHandler)
2791
      throws TException {
2792
    throw new IllegalArgumentException("unimplemented");
×
2793
  }
2794

2795
  @Override
2796
  public void ResetWorkflowExecution(
2797
      ResetWorkflowExecutionRequest resetRequest, AsyncMethodCallback resultHandler)
2798
      throws TException {
2799
    throw new UnsupportedOperationException("not implemented");
×
2800
  }
2801

2802
  @Override
2803
  public void TerminateWorkflowExecution(
2804
      TerminateWorkflowExecutionRequest terminateRequest, AsyncMethodCallback resultHandler)
2805
      throws TException {
2806
    throw new UnsupportedOperationException("not implemented");
×
2807
  }
2808

2809
  @Override
2810
  public void ListOpenWorkflowExecutions(
2811
      ListOpenWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2812
      throws TException {
2813
    throw new UnsupportedOperationException("not implemented");
×
2814
  }
2815

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

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

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

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

2844
  @Override
2845
  public void CountWorkflowExecutions(
2846
      CountWorkflowExecutionsRequest countRequest, AsyncMethodCallback resultHandler)
2847
      throws TException {
2848
    throw new UnsupportedOperationException("not implemented");
×
2849
  }
2850

2851
  @Override
2852
  public void GetSearchAttributes(AsyncMethodCallback resultHandler) throws TException {
2853
    throw new UnsupportedOperationException("not implemented");
×
2854
  }
2855

2856
  @Override
2857
  public void RespondQueryTaskCompleted(
2858
      RespondQueryTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
2859
      throws TException {
2860
    throw new UnsupportedOperationException("not implemented");
×
2861
  }
2862

2863
  @Override
2864
  public void ResetStickyTaskList(
2865
      ResetStickyTaskListRequest resetRequest, AsyncMethodCallback resultHandler)
2866
      throws TException {
2867
    throw new UnsupportedOperationException("not implemented");
×
2868
  }
2869

2870
  @Override
2871
  public void QueryWorkflow(QueryWorkflowRequest queryRequest, AsyncMethodCallback resultHandler)
2872
      throws TException {
2873
    throw new UnsupportedOperationException("not implemented");
×
2874
  }
2875

2876
  @Override
2877
  public void DescribeWorkflowExecution(
2878
      DescribeWorkflowExecutionRequest describeRequest, AsyncMethodCallback resultHandler)
2879
      throws TException {
2880
    throw new UnsupportedOperationException("not implemented");
×
2881
  }
2882

2883
  @Override
2884
  public void DescribeTaskList(DescribeTaskListRequest request, AsyncMethodCallback resultHandler)
2885
      throws TException {
2886
    throw new UnsupportedOperationException("not implemented");
×
2887
  }
2888

2889
  @Override
2890
  public void GetClusterInfo(AsyncMethodCallback resultHandler) throws TException {}
×
2891

2892
  @Override
2893
  public void ListTaskListPartitions(
2894
      ListTaskListPartitionsRequest request, AsyncMethodCallback resultHandler) throws TException {}
×
2895

2896
  @Override
2897
  public void RefreshWorkflowTasks(
2898
      RefreshWorkflowTasksRequest request, AsyncMethodCallback resultHandler) throws TException {}
×
2899

2900
  @Override
2901
  public void RegisterDomain(
2902
      RegisterDomainRequest registerRequest, AsyncMethodCallback resultHandler) throws TException {
2903
    throw new UnsupportedOperationException("not implemented");
×
2904
  }
2905

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

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

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

2924
  @Override
2925
  public void DeprecateDomain(
2926
      DeprecateDomainRequest deprecateRequest, AsyncMethodCallback resultHandler)
2927
      throws TException {
2928
    throw new UnsupportedOperationException("not implemented");
×
2929
  }
2930

2931
  @Override
2932
  public void RestartWorkflowExecution(
2933
      RestartWorkflowExecutionRequest restartRequest, AsyncMethodCallback resultHandler)
2934
      throws TException {
2935
    throw new IllegalArgumentException("unimplemented");
×
2936
  }
2937

2938
  @Override
2939
  public void GetTaskListsByDomain(
2940
      GetTaskListsByDomainRequest request, AsyncMethodCallback resultHandler)
2941
      throws org.apache.thrift.TException {
2942
    throw new UnsupportedOperationException("not implemented");
×
2943
  }
2944
}
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