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

uber / cadence-java-client / 1847

pending completion
1847

Pull #821

buildkite

Shaddoll
dummy change
Pull Request #821: Add isolation group header to service client

10 of 10 new or added lines in 3 files covered. (100.0%)

11117 of 18414 relevant lines covered (60.37%)

0.6 hits per line

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

2.61
/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.m3.tally.Scope;
36
import com.uber.m3.tally.Stopwatch;
37
import com.uber.tchannel.api.ResponseCode;
38
import com.uber.tchannel.api.SubChannel;
39
import com.uber.tchannel.api.TChannel;
40
import com.uber.tchannel.api.TFuture;
41
import com.uber.tchannel.api.errors.TChannelError;
42
import com.uber.tchannel.errors.ErrorType;
43
import com.uber.tchannel.messages.ThriftRequest;
44
import com.uber.tchannel.messages.ThriftResponse;
45
import com.uber.tchannel.messages.generated.Meta;
46
import io.opentelemetry.api.GlobalOpenTelemetry;
47
import io.opentelemetry.context.Context;
48
import io.opentelemetry.context.propagation.TextMapPropagator;
49
import io.opentelemetry.context.propagation.TextMapSetter;
50
import java.net.InetAddress;
51
import java.net.InetSocketAddress;
52
import java.net.UnknownHostException;
53
import java.nio.charset.StandardCharsets;
54
import java.util.ArrayList;
55
import java.util.HashMap;
56
import java.util.Map;
57
import java.util.UUID;
58
import java.util.concurrent.CompletableFuture;
59
import java.util.concurrent.ExecutionException;
60
import org.apache.thrift.TException;
61
import org.apache.thrift.async.AsyncMethodCallback;
62
import org.apache.thrift.transport.TTransportException;
63
import org.slf4j.Logger;
64
import org.slf4j.LoggerFactory;
65

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

69
  private static final String INTERFACE_NAME = "WorkflowService";
70

71
  private final ClientOptions options;
72
  private final Map<String, String> thriftHeaders;
73
  private final TChannel tChannel;
74
  private SubChannel subChannel;
75

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

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

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

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

113
  /**
114
   * Creates Cadence client with specified sub channel and options.
115
   *
116
   * @param subChannel sub channel for communicating with cadence frontend service.
117
   * @param options configuration options like rpc timeouts.
118
   */
119
  public WorkflowServiceTChannel(SubChannel subChannel, ClientOptions options) {
×
120
    this.options = options;
×
121
    this.thriftHeaders = getThriftHeaders(options);
×
122
    this.tChannel = null;
×
123
    this.subChannel = subChannel;
×
124
  }
×
125

126
  private static Map<String, String> getThriftHeaders(ClientOptions options) {
127
    String envUserName = System.getProperty("user.name");
1✔
128
    String envHostname;
129
    try {
130
      envHostname = InetAddress.getLocalHost().getHostName();
1✔
131
    } catch (UnknownHostException e) {
×
132
      envHostname = "localhost";
×
133
    }
1✔
134

135
    ImmutableMap.Builder<String, String> builder =
136
        ImmutableMap.<String, String>builder()
1✔
137
            .put("user-name", envUserName)
1✔
138
            .put("host-name", envHostname)
1✔
139
            .put("cadence-client-library-version", Version.LIBRARY_VERSION)
1✔
140
            .put("cadence-client-feature-version", Version.FEATURE_VERSION)
1✔
141
            .put("cadence-client-name", "uber-java");
1✔
142

143
    if (options.getHeaders() != null) {
1✔
144
      for (Map.Entry<String, String> entry : options.getHeaders().entrySet()) {
1✔
145
        builder.put(entry.getKey(), entry.getValue());
×
146
      }
×
147
    }
148

149
    if (options.getFeatureFlags() != null) {
1✔
150
      GsonBuilder gsonBuilder = new GsonBuilder();
1✔
151
      Gson gson = gsonBuilder.create();
1✔
152
      String serialized = gson.toJson(options.getFeatureFlags());
1✔
153
      builder.put("cadence-client-feature-flags", serialized);
1✔
154
    }
155

156
    if (!Strings.isNullOrEmpty(options.getIsolationGroup())) {
1✔
157
      builder.put("cadence-client-isolation-group", options.getIsolationGroup());
×
158
    }
159

160
    return builder.build();
1✔
161
  }
162

163
  /** Returns the endpoint in the format service::method" */
164
  private static String getEndpoint(String service, String method) {
165
    return String.format("%s::%s", service, method);
×
166
  }
167

168
  private <T> ThriftRequest<T> buildThriftRequest(String apiName, T body) {
169
    return buildThriftRequest(apiName, body, null);
×
170
  }
171

172
  /**
173
   * Checks if we have a valid connection to the Cadence cluster, and potentially resets the peer
174
   * list
175
   */
176
  @Override
177
  public CompletableFuture<Boolean> isHealthy() {
178
    final ThriftRequest<Meta.health_args> req =
×
179
        new ThriftRequest.Builder<Meta.health_args>(options.getServiceName(), "Meta::health")
×
180
            .setBody(new Meta.health_args())
×
181
            .build();
×
182
    final CompletableFuture<Boolean> result = new CompletableFuture<>();
×
183
    try {
184

185
      final TFuture<ThriftResponse<Meta.health_result>> future = this.subChannel.send(req);
×
186
      future.addCallback(
×
187
          response -> {
188
            req.releaseQuietly();
×
189
            if (response.isError()) {
×
190
              try {
191
                this.resetSubchannelPeers();
×
192
              } catch (final Exception inner_e) {
×
193
              }
×
194
              result.completeExceptionally(new TException("Rpc error:" + response.getError()));
×
195
            } else {
196
              result.complete(response.getBody(Meta.health_result.class).getSuccess().isOk());
×
197
            }
198
            try {
199
              response.release();
×
200
            } catch (final Exception e) {
×
201
              // ignore
202
            }
×
203
          });
×
204
    } catch (final TChannelError e) {
×
205
      req.releaseQuietly();
×
206
      try {
207
        this.resetSubchannelPeers();
×
208
      } catch (final Exception inner_e) {
×
209
      }
×
210
      result.complete(Boolean.FALSE);
×
211
    }
×
212
    return result;
×
213
  }
214

215
  protected <T> ThriftRequest<T> buildThriftRequest(
216
      String apiName, T body, Long rpcTimeoutOverride) {
217
    String endpoint = getEndpoint(INTERFACE_NAME, apiName);
×
218
    ThriftRequest.Builder<T> builder =
×
219
        new ThriftRequest.Builder<>(options.getServiceName(), endpoint);
×
220
    // Create a mutable hashmap for headers, as tchannel.tracing.PrefixedHeadersCarrier assumes
221
    // that it can call put directly to add new stuffs (e.g. traces).
222
    final HashMap<String, String> headers = new HashMap<>(thriftHeaders);
×
223
    TextMapPropagator textMapPropagator =
224
        GlobalOpenTelemetry.getPropagators().getTextMapPropagator();
×
225

226
    String tracingHeadersPrefix = "$tracing$";
×
227
    TextMapSetter<Map<String, String>> setter =
×
228
        (carrier, key, value) -> {
229
          if (carrier != null) {
×
230
            carrier.put(tracingHeadersPrefix + key, value);
×
231
          }
232
        };
×
233

234
    textMapPropagator.inject(Context.current(), headers, setter);
×
235

236
    if (this.options.getAuthProvider() != null) {
×
237
      headers.put(
×
238
          "cadence-authorization",
239
          new String(options.getAuthProvider().getAuthToken(), StandardCharsets.UTF_8));
×
240
    }
241
    builder.setHeaders(headers);
×
242

243
    if (rpcTimeoutOverride != null) {
×
244
      builder.setTimeout(rpcTimeoutOverride);
×
245
    } else {
246
      builder.setTimeout(this.options.getRpcTimeoutMillis());
×
247
    }
248
    for (Map.Entry<String, String> header : this.options.getTransportHeaders().entrySet()) {
×
249
      builder.setTransportHeader(header.getKey(), header.getValue());
×
250
    }
×
251
    builder.setBody(body);
×
252
    return builder.build();
×
253
  }
254

255
  private <T> ThriftResponse<T> doRemoteCall(ThriftRequest<?> request) throws TException {
256
    ThriftResponse<T> response = null;
×
257
    try {
258
      TFuture<ThriftResponse<T>> future = subChannel.send(request);
×
259
      response = future.get();
×
260
    } catch (InterruptedException e) {
×
261
      Thread.currentThread().interrupt();
×
262
      throw new TException(e);
×
263
    } catch (ExecutionException e) {
×
264
      throw new TException(e);
×
265
    } catch (TChannelError e) {
×
266
      throw new TException("Rpc error", e);
×
267
    }
×
268
    this.throwOnRpcError(response);
×
269
    return response;
×
270
  }
271

272
  private <T> CompletableFuture<ThriftResponse<T>> doRemoteCallAsync(ThriftRequest<?> request) {
273
    final CompletableFuture<ThriftResponse<T>> result = new CompletableFuture<>();
×
274
    TFuture<ThriftResponse<T>> future = null;
×
275
    try {
276
      future = subChannel.send(request);
×
277
    } catch (TChannelError tChannelError) {
×
278
      result.completeExceptionally(new TException(tChannelError));
×
279
    }
×
280
    future.addCallback(
×
281
        response -> {
282
          if (response.isError()) {
×
283
            result.completeExceptionally(new TException("Rpc error:" + response.getError()));
×
284
          } else {
285
            result.complete(response);
×
286
          }
287
        });
×
288
    return result;
×
289
  }
290

291
  private void throwOnRpcError(ThriftResponse<?> response) throws TException {
292
    if (response.isError()) {
×
293
      if (response.getError().getErrorType() == ErrorType.Timeout) {
×
294
        throw new TTransportException(
×
295
            TTransportException.TIMED_OUT, response.getError().getMessage());
×
296
      } else {
297
        throw new TException("Rpc error:" + response.getError());
×
298
      }
299
    }
300
  }
×
301

302
  @Override
303
  public void close() {
304
    if (tChannel != null) {
1✔
305
      tChannel.shutdown();
1✔
306
    }
307
  }
1✔
308

309
  interface RemoteCall<T> {
310
    T apply() throws TException;
311
  }
312

313
  private <T> T measureRemoteCall(String scopeName, RemoteCall<T> call) throws TException {
314
    return measureRemoteCallWithTags(scopeName, call, null);
×
315
  }
316

317
  private <T> T measureRemoteCallWithTags(
318
      String scopeName, RemoteCall<T> call, Map<String, String> tags) throws TException {
319
    Scope scope = options.getMetricsScope().subScope(scopeName);
×
320
    if (tags != null) {
×
321
      scope = scope.tagged(tags);
×
322
    }
323
    scope.counter(MetricsType.CADENCE_REQUEST).inc(1);
×
324
    Stopwatch sw = scope.timer(MetricsType.CADENCE_LATENCY).start();
×
325
    try {
326
      T resp = call.apply();
×
327
      sw.stop();
×
328
      return resp;
×
329
    } catch (EntityNotExistsError
×
330
        | WorkflowExecutionAlreadyCompletedError
331
        | BadRequestError
332
        | DomainAlreadyExistsError
333
        | WorkflowExecutionAlreadyStartedError
334
        | QueryFailedError e) {
335
      sw.stop();
×
336
      scope.counter(MetricsType.CADENCE_INVALID_REQUEST).inc(1);
×
337
      throw e;
×
338
    } catch (TException e) {
×
339
      sw.stop();
×
340
      scope.counter(MetricsType.CADENCE_ERROR).inc(1);
×
341
      throw e;
×
342
    }
343
  }
344

345
  interface RemoteProc {
346
    void apply() throws TException;
347
  }
348

349
  private void measureRemoteProc(String scopeName, RemoteProc proc) throws TException {
350
    measureRemoteCall(
×
351
        scopeName,
352
        () -> {
353
          proc.apply();
×
354
          return null;
×
355
        });
356
  }
×
357

358
  @Override
359
  public void RegisterDomain(RegisterDomainRequest request) throws TException {
360
    measureRemoteProc(ServiceMethod.REGISTER_DOMAIN, () -> registerDomain(request));
×
361
  }
×
362

363
  private void registerDomain(RegisterDomainRequest registerRequest) throws TException {
364
    ThriftResponse<WorkflowService.RegisterDomain_result> response = null;
×
365
    try {
366
      ThriftRequest<WorkflowService.RegisterDomain_args> request =
×
367
          buildThriftRequest(
×
368
              "RegisterDomain", new WorkflowService.RegisterDomain_args(registerRequest));
369
      response = doRemoteCall(request);
×
370
      WorkflowService.RegisterDomain_result result =
×
371
          response.getBody(WorkflowService.RegisterDomain_result.class);
×
372
      if (response.getResponseCode() == ResponseCode.OK) {
×
373
        return;
×
374
      }
375
      if (result.isSetBadRequestError()) {
×
376
        throw result.getBadRequestError();
×
377
      }
378
      if (result.isSetDomainExistsError()) {
×
379
        throw result.getDomainExistsError();
×
380
      }
381
      if (result.isSetServiceBusyError()) {
×
382
        throw result.getServiceBusyError();
×
383
      }
384
      throw new TException("RegisterDomain failed with unknown error:" + result);
×
385
    } finally {
386
      if (response != null) {
×
387
        response.release();
×
388
      }
389
    }
390
  }
391

392
  @Override
393
  public DescribeDomainResponse DescribeDomain(DescribeDomainRequest describeRequest)
394
      throws TException {
395
    return measureRemoteCall(ServiceMethod.DESCRIBE_DOMAIN, () -> describeDomain(describeRequest));
×
396
  }
397

398
  private DescribeDomainResponse describeDomain(DescribeDomainRequest describeRequest)
399
      throws TException {
400
    ThriftResponse<WorkflowService.DescribeDomain_result> response = null;
×
401
    try {
402
      ThriftRequest<WorkflowService.DescribeDomain_args> request =
×
403
          buildThriftRequest(
×
404
              "DescribeDomain", new WorkflowService.DescribeDomain_args(describeRequest));
405
      response = doRemoteCall(request);
×
406
      WorkflowService.DescribeDomain_result result =
×
407
          response.getBody(WorkflowService.DescribeDomain_result.class);
×
408
      if (response.getResponseCode() == ResponseCode.OK) {
×
409
        return result.getSuccess();
×
410
      }
411
      if (result.isSetBadRequestError()) {
×
412
        throw result.getBadRequestError();
×
413
      }
414
      if (result.isSetEntityNotExistError()) {
×
415
        throw result.getEntityNotExistError();
×
416
      }
417
      if (result.isSetServiceBusyError()) {
×
418
        throw result.getServiceBusyError();
×
419
      }
420
      throw new TException("DescribeDomain failed with unknown error:" + result);
×
421
    } finally {
422
      if (response != null) {
×
423
        response.release();
×
424
      }
425
    }
426
  }
427

428
  @Override
429
  public ListDomainsResponse ListDomains(ListDomainsRequest listRequest)
430
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
431
          TException {
432
    return measureRemoteCall(ServiceMethod.LIST_DOMAINS, () -> listDomains(listRequest));
×
433
  }
434

435
  private ListDomainsResponse listDomains(ListDomainsRequest describeRequest) throws TException {
436
    ThriftResponse<WorkflowService.ListDomains_result> response = null;
×
437
    try {
438
      ThriftRequest<WorkflowService.ListDomains_args> request =
×
439
          buildThriftRequest("ListDomains", new WorkflowService.ListDomains_args(describeRequest));
×
440
      response = doRemoteCall(request);
×
441
      WorkflowService.ListDomains_result result =
×
442
          response.getBody(WorkflowService.ListDomains_result.class);
×
443
      if (response.getResponseCode() == ResponseCode.OK) {
×
444
        return result.getSuccess();
×
445
      }
446
      if (result.isSetBadRequestError()) {
×
447
        throw result.getBadRequestError();
×
448
      }
449
      if (result.isSetEntityNotExistError()) {
×
450
        throw result.getEntityNotExistError();
×
451
      }
452
      if (result.isSetServiceBusyError()) {
×
453
        throw result.getServiceBusyError();
×
454
      }
455
      throw new TException("ListDomains failed with unknown error:" + result);
×
456
    } finally {
457
      if (response != null) {
×
458
        response.release();
×
459
      }
460
    }
461
  }
462

463
  @Override
464
  public UpdateDomainResponse UpdateDomain(UpdateDomainRequest updateRequest) throws TException {
465
    return measureRemoteCall(ServiceMethod.UPDATE_DOMAIN, () -> updateDomain(updateRequest));
×
466
  }
467

468
  private UpdateDomainResponse updateDomain(UpdateDomainRequest updateRequest) throws TException {
469
    ThriftResponse<WorkflowService.UpdateDomain_result> response = null;
×
470
    try {
471
      ThriftRequest<WorkflowService.UpdateDomain_args> request =
×
472
          buildThriftRequest("UpdateDomain", new WorkflowService.UpdateDomain_args(updateRequest));
×
473
      response = doRemoteCall(request);
×
474
      WorkflowService.UpdateDomain_result result =
×
475
          response.getBody(WorkflowService.UpdateDomain_result.class);
×
476
      if (response.getResponseCode() == ResponseCode.OK) {
×
477
        return result.getSuccess();
×
478
      }
479
      if (result.isSetBadRequestError()) {
×
480
        throw result.getBadRequestError();
×
481
      }
482
      if (result.isSetEntityNotExistError()) {
×
483
        throw result.getEntityNotExistError();
×
484
      }
485
      if (result.isSetServiceBusyError()) {
×
486
        throw result.getServiceBusyError();
×
487
      }
488
      if (result.isSetDomainNotActiveError()) {
×
489
        throw result.getDomainNotActiveError();
×
490
      }
491
      throw new TException("UpdateDomain failed with unknown error:" + result);
×
492
    } finally {
493
      if (response != null) {
×
494
        response.release();
×
495
      }
496
    }
497
  }
498

499
  @Override
500
  public void DeprecateDomain(DeprecateDomainRequest deprecateRequest) throws TException {
501
    measureRemoteProc(ServiceMethod.DEPRECATE_DOMAIN, () -> deprecateDomain(deprecateRequest));
×
502
  }
×
503

504
  private void deprecateDomain(DeprecateDomainRequest deprecateRequest) throws TException {
505
    ThriftResponse<WorkflowService.DeprecateDomain_result> response = null;
×
506
    try {
507
      ThriftRequest<WorkflowService.DeprecateDomain_args> request =
×
508
          buildThriftRequest(
×
509
              "DeprecateDomain", new WorkflowService.DeprecateDomain_args(deprecateRequest));
510
      response = doRemoteCall(request);
×
511
      WorkflowService.DeprecateDomain_result result =
×
512
          response.getBody(WorkflowService.DeprecateDomain_result.class);
×
513
      if (response.getResponseCode() == ResponseCode.OK) {
×
514
        return;
×
515
      }
516
      if (result.isSetBadRequestError()) {
×
517
        throw result.getBadRequestError();
×
518
      }
519
      if (result.isSetEntityNotExistError()) {
×
520
        throw result.getEntityNotExistError();
×
521
      }
522
      if (result.isSetServiceBusyError()) {
×
523
        throw result.getServiceBusyError();
×
524
      }
525
      if (result.isSetDomainNotActiveError()) {
×
526
        throw result.getDomainNotActiveError();
×
527
      }
528
      throw new TException("DeprecateDomain failed with unknown error:" + result);
×
529
    } finally {
530
      if (response != null) {
×
531
        response.release();
×
532
      }
533
    }
534
  }
535

536
  @Override
537
  public GetTaskListsByDomainResponse GetTaskListsByDomain(
538
      GetTaskListsByDomainRequest getTaskListsByDomainRequest) throws TException {
539
    return measureRemoteCall(
×
540
        ServiceMethod.GET_TASK_LISTS_BY_DOMAIN,
541
        () -> getTaskListsByDomain(getTaskListsByDomainRequest));
×
542
  }
543

544
  private GetTaskListsByDomainResponse getTaskListsByDomain(
545
      GetTaskListsByDomainRequest getTaskListsByDomainRequest) throws TException {
546
    ThriftResponse<WorkflowService.GetTaskListsByDomain_result> response = null;
×
547
    try {
548
      ThriftRequest<WorkflowService.GetTaskListsByDomain_args> request =
×
549
          buildThriftRequest(
×
550
              "GetTaskListsByDomain",
551
              new WorkflowService.GetTaskListsByDomain_args(getTaskListsByDomainRequest));
552
      response = doRemoteCall(request);
×
553
      WorkflowService.GetTaskListsByDomain_result result =
×
554
          response.getBody(WorkflowService.GetTaskListsByDomain_result.class);
×
555
      if (response.getResponseCode() == ResponseCode.OK) {
×
556
        return result.getSuccess();
×
557
      }
558
      if (result.isSetBadRequestError()) {
×
559
        throw result.getBadRequestError();
×
560
      }
561
      if (result.isSetEntityNotExistError()) {
×
562
        throw result.getEntityNotExistError();
×
563
      }
564
      if (result.isSetLimitExceededError()) {
×
565
        throw result.getLimitExceededError();
×
566
      }
567
      if (result.isSetServiceBusyError()) {
×
568
        throw result.getServiceBusyError();
×
569
      }
570
      if (result.isSetClientVersionNotSupportedError()) {
×
571
        throw result.getClientVersionNotSupportedError();
×
572
      }
573
      throw new TException("GetTaskListsByDomain failed with unknown error:" + result);
×
574
    } finally {
575
      if (response != null) {
×
576
        response.release();
×
577
      }
578
    }
579
  }
580

581
  @Override
582
  public StartWorkflowExecutionResponse StartWorkflowExecution(
583
      StartWorkflowExecutionRequest request) throws TException {
584
    return measureRemoteCall(
×
585
        ServiceMethod.START_WORKFLOW_EXECUTION, () -> startWorkflowExecution(request));
×
586
  }
587

588
  private StartWorkflowExecutionResponse startWorkflowExecution(
589
      StartWorkflowExecutionRequest startRequest) throws TException {
590
    startRequest.setRequestId(UUID.randomUUID().toString());
×
591
    ThriftResponse<WorkflowService.StartWorkflowExecution_result> response = null;
×
592
    try {
593
      ThriftRequest<WorkflowService.StartWorkflowExecution_args> request =
×
594
          buildThriftRequest(
×
595
              "StartWorkflowExecution",
596
              new WorkflowService.StartWorkflowExecution_args(startRequest));
597
      response = doRemoteCall(request);
×
598
      WorkflowService.StartWorkflowExecution_result result =
×
599
          response.getBody(WorkflowService.StartWorkflowExecution_result.class);
×
600
      if (response.getResponseCode() == ResponseCode.OK) {
×
601
        return result.getSuccess();
×
602
      }
603
      if (result.isSetBadRequestError()) {
×
604
        throw result.getBadRequestError();
×
605
      }
606
      if (result.isSetSessionAlreadyExistError()) {
×
607
        throw result.getSessionAlreadyExistError();
×
608
      }
609
      if (result.isSetServiceBusyError()) {
×
610
        throw result.getServiceBusyError();
×
611
      }
612
      if (result.isSetDomainNotActiveError()) {
×
613
        throw result.getDomainNotActiveError();
×
614
      }
615
      if (result.isSetLimitExceededError()) {
×
616
        throw result.getLimitExceededError();
×
617
      }
618
      if (result.isSetEntityNotExistError()) {
×
619
        throw result.getEntityNotExistError();
×
620
      }
621
      throw new TException("StartWorkflowExecution failed with unknown error:" + result);
×
622
    } finally {
623
      if (response != null) {
×
624
        response.release();
×
625
      }
626
    }
627
  }
628

629
  @Override
630
  public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistoryWithTimeout(
631
      GetWorkflowExecutionHistoryRequest request, Long timeoutInMillis) throws TException {
632
    Map<String, String> tags =
×
633
        ImmutableMap.of(
×
634
            MetricsTag.REQUEST_TYPE,
635
            request.isWaitForNewEvent() ? REQUEST_TYPE_LONG_POLL : REQUEST_TYPE_NORMAL);
×
636
    return measureRemoteCallWithTags(
×
637
        ServiceMethod.GET_WORKFLOW_EXECUTION_HISTORY,
638
        () -> getWorkflowExecutionHistory(request, timeoutInMillis),
×
639
        tags);
640
  }
641

642
  @Override
643
  public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistory(
644
      GetWorkflowExecutionHistoryRequest request) throws TException {
645
    Map<String, String> tags =
×
646
        ImmutableMap.of(
×
647
            MetricsTag.REQUEST_TYPE,
648
            request.isWaitForNewEvent() ? REQUEST_TYPE_LONG_POLL : REQUEST_TYPE_NORMAL);
×
649
    return measureRemoteCallWithTags(
×
650
        ServiceMethod.GET_WORKFLOW_EXECUTION_HISTORY,
651
        () -> getWorkflowExecutionHistory(request, null),
×
652
        tags);
653
  }
654

655
  private GetWorkflowExecutionHistoryResponse getWorkflowExecutionHistory(
656
      GetWorkflowExecutionHistoryRequest getRequest, Long timeoutInMillis) throws TException {
657
    ThriftResponse<WorkflowService.GetWorkflowExecutionHistory_result> response = null;
×
658
    try {
659
      ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args> request =
×
660
          buildGetWorkflowExecutionHistoryThriftRequest(getRequest, timeoutInMillis);
×
661
      response = doRemoteCall(request);
×
662
      WorkflowService.GetWorkflowExecutionHistory_result result =
×
663
          response.getBody(WorkflowService.GetWorkflowExecutionHistory_result.class);
×
664
      if (response.getResponseCode() == ResponseCode.OK) {
×
665
        GetWorkflowExecutionHistoryResponse res = result.getSuccess();
×
666
        if (res.getRawHistory() != null) {
×
667
          History history =
×
668
              InternalUtils.DeserializeFromBlobDataToHistory(
×
669
                  res.getRawHistory(), getRequest.getHistoryEventFilterType());
×
670
          res.setHistory(history);
×
671
        }
672
        return res;
×
673
      }
674
      if (result.isSetBadRequestError()) {
×
675
        throw result.getBadRequestError();
×
676
      }
677
      if (result.isSetEntityNotExistError()) {
×
678
        throw result.getEntityNotExistError();
×
679
      }
680
      if (result.isSetServiceBusyError()) {
×
681
        throw result.getServiceBusyError();
×
682
      }
683
      throw new TException("GetWorkflowExecutionHistory failed with unknown error:" + result);
×
684
    } finally {
685
      if (response != null) {
×
686
        response.release();
×
687
      }
688
    }
689
  }
690

691
  private ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args>
692
      buildGetWorkflowExecutionHistoryThriftRequest(
693
          GetWorkflowExecutionHistoryRequest getRequest, Long timeoutInMillis) {
694

695
    if (getRequest.isWaitForNewEvent()) {
×
696
      timeoutInMillis =
×
697
          validateAndUpdateTimeout(timeoutInMillis, options.getRpcLongPollTimeoutMillis());
×
698
    } else {
699
      timeoutInMillis = validateAndUpdateTimeout(timeoutInMillis, options.getRpcTimeoutMillis());
×
700
    }
701

702
    return buildThriftRequest(
×
703
        "GetWorkflowExecutionHistory",
704
        new WorkflowService.GetWorkflowExecutionHistory_args(getRequest),
705
        timeoutInMillis);
706
  }
707

708
  @Override
709
  public PollForDecisionTaskResponse PollForDecisionTask(PollForDecisionTaskRequest request)
710
      throws TException {
711
    return measureRemoteCall(
×
712
        ServiceMethod.POLL_FOR_DECISION_TASK, () -> pollForDecisionTask(request));
×
713
  }
714

715
  private PollForDecisionTaskResponse pollForDecisionTask(PollForDecisionTaskRequest pollRequest)
716
      throws TException {
717
    ThriftResponse<WorkflowService.PollForDecisionTask_result> response = null;
×
718
    try {
719
      ThriftRequest<WorkflowService.PollForDecisionTask_args> request =
×
720
          buildThriftRequest(
×
721
              "PollForDecisionTask",
722
              new WorkflowService.PollForDecisionTask_args(pollRequest),
723
              options.getRpcLongPollTimeoutMillis());
×
724
      response = doRemoteCall(request);
×
725
      WorkflowService.PollForDecisionTask_result result =
×
726
          response.getBody(WorkflowService.PollForDecisionTask_result.class);
×
727
      if (response.getResponseCode() == ResponseCode.OK) {
×
728
        return result.getSuccess();
×
729
      }
730
      if (result.isSetBadRequestError()) {
×
731
        throw result.getBadRequestError();
×
732
      }
733
      if (result.isSetServiceBusyError()) {
×
734
        throw result.getServiceBusyError();
×
735
      }
736
      if (result.isSetDomainNotActiveError()) {
×
737
        throw result.getDomainNotActiveError();
×
738
      }
739
      if (result.isSetLimitExceededError()) {
×
740
        throw result.getLimitExceededError();
×
741
      }
742
      if (result.isSetEntityNotExistError()) {
×
743
        throw result.getEntityNotExistError();
×
744
      }
745
      if (result.isSetClientVersionNotSupportedError()) {
×
746
        throw result.getClientVersionNotSupportedError();
×
747
      }
748
      throw new TException("PollForDecisionTask failed with unknown error:" + result);
×
749
    } finally {
750
      if (response != null) {
×
751
        response.release();
×
752
      }
753
    }
754
  }
755

756
  @Override
757
  public RespondDecisionTaskCompletedResponse RespondDecisionTaskCompleted(
758
      RespondDecisionTaskCompletedRequest completedRequest) throws TException {
759
    return measureRemoteCall(
×
760
        ServiceMethod.RESPOND_DECISION_TASK_COMPLETED,
761
        () -> respondDecisionTaskCompleted(completedRequest));
×
762
  }
763

764
  private RespondDecisionTaskCompletedResponse respondDecisionTaskCompleted(
765
      RespondDecisionTaskCompletedRequest completedRequest) throws TException {
766
    ThriftResponse<WorkflowService.RespondDecisionTaskCompleted_result> response = null;
×
767
    try {
768
      ThriftRequest<WorkflowService.RespondDecisionTaskCompleted_args> request =
×
769
          buildThriftRequest(
×
770
              "RespondDecisionTaskCompleted",
771
              new WorkflowService.RespondDecisionTaskCompleted_args(completedRequest));
772
      response = doRemoteCall(request);
×
773
      WorkflowService.RespondDecisionTaskCompleted_result result =
×
774
          response.getBody(WorkflowService.RespondDecisionTaskCompleted_result.class);
×
775
      if (response.getResponseCode() == ResponseCode.OK) {
×
776
        return result.getSuccess();
×
777
      }
778
      if (result.isSetBadRequestError()) {
×
779
        throw result.getBadRequestError();
×
780
      }
781
      if (result.isSetServiceBusyError()) {
×
782
        throw result.getServiceBusyError();
×
783
      }
784
      if (result.isSetDomainNotActiveError()) {
×
785
        throw result.getDomainNotActiveError();
×
786
      }
787
      if (result.isSetLimitExceededError()) {
×
788
        throw result.getLimitExceededError();
×
789
      }
790
      if (result.isSetEntityNotExistError()) {
×
791
        throw result.getEntityNotExistError();
×
792
      }
793
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
794
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
795
      }
796
      if (result.isSetClientVersionNotSupportedError()) {
×
797
        throw result.getClientVersionNotSupportedError();
×
798
      }
799
      throw new TException("RespondDecisionTaskCompleted failed with unknown error:" + result);
×
800
    } finally {
801
      if (response != null) {
×
802
        response.release();
×
803
      }
804
    }
805
  }
806

807
  @Override
808
  public void RespondDecisionTaskFailed(RespondDecisionTaskFailedRequest request)
809
      throws TException {
810
    measureRemoteProc(
×
811
        ServiceMethod.RESPOND_DECISION_TASK_FAILED, () -> respondDecisionTaskFailed(request));
×
812
  }
×
813

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

857
  @Override
858
  public PollForActivityTaskResponse PollForActivityTask(PollForActivityTaskRequest request)
859
      throws TException {
860
    return measureRemoteCall(
×
861
        ServiceMethod.POLL_FOR_ACTIVITY_TASK, () -> pollForActivityTask(request));
×
862
  }
863

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

905
  @Override
906
  public RecordActivityTaskHeartbeatResponse RecordActivityTaskHeartbeat(
907
      RecordActivityTaskHeartbeatRequest request) throws TException {
908
    return measureRemoteCall(
×
909
        ServiceMethod.RECORD_ACTIVITY_TASK_HEARTBEAT, () -> recordActivityTaskHeartbeat(request));
×
910
  }
911

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

955
  @Override
956
  public RecordActivityTaskHeartbeatResponse RecordActivityTaskHeartbeatByID(
957
      RecordActivityTaskHeartbeatByIDRequest heartbeatRequest)
958
      throws BadRequestError, InternalServiceError, EntityNotExistsError, DomainNotActiveError,
959
          WorkflowExecutionAlreadyCompletedError, LimitExceededError, ServiceBusyError, TException {
960
    return measureRemoteCall(
×
961
        ServiceMethod.RECORD_ACTIVITY_TASK_HEARTBEAT_BY_ID,
962
        () -> recordActivityTaskHeartbeatByID(heartbeatRequest));
×
963
  }
964

965
  private RecordActivityTaskHeartbeatResponse recordActivityTaskHeartbeatByID(
966
      RecordActivityTaskHeartbeatByIDRequest heartbeatRequest) throws TException {
967
    ThriftResponse<WorkflowService.RecordActivityTaskHeartbeatByID_result> response = null;
×
968
    try {
969
      ThriftRequest<WorkflowService.RecordActivityTaskHeartbeatByID_args> request =
×
970
          buildThriftRequest(
×
971
              "RecordActivityTaskHeartbeatByID",
972
              new WorkflowService.RecordActivityTaskHeartbeatByID_args(heartbeatRequest));
973
      response = doRemoteCall(request);
×
974
      WorkflowService.RecordActivityTaskHeartbeatByID_result result =
×
975
          response.getBody(WorkflowService.RecordActivityTaskHeartbeatByID_result.class);
×
976
      if (response.getResponseCode() == ResponseCode.OK) {
×
977
        return result.getSuccess();
×
978
      }
979
      if (result.isSetBadRequestError()) {
×
980
        throw result.getBadRequestError();
×
981
      }
982
      if (result.isSetEntityNotExistError()) {
×
983
        throw result.getEntityNotExistError();
×
984
      }
985
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
986
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
987
      }
988
      if (result.isSetServiceBusyError()) {
×
989
        throw result.getServiceBusyError();
×
990
      }
991
      if (result.isSetDomainNotActiveError()) {
×
992
        throw result.getDomainNotActiveError();
×
993
      }
994
      if (result.isSetLimitExceededError()) {
×
995
        throw result.getLimitExceededError();
×
996
      }
997
      if (result.isSetClientVersionNotSupportedError()) {
×
998
        throw result.getClientVersionNotSupportedError();
×
999
      }
1000
      throw new TException("RecordActivityTaskHeartbeatByID failed with unknown error:" + result);
×
1001
    } finally {
1002
      if (response != null) {
×
1003
        response.release();
×
1004
      }
1005
    }
1006
  }
1007

1008
  @Override
1009
  public void RespondActivityTaskCompleted(RespondActivityTaskCompletedRequest request)
1010
      throws TException {
1011
    measureRemoteProc(
×
1012
        ServiceMethod.RESPOND_ACTIVITY_TASK_COMPLETED, () -> respondActivityTaskCompleted(request));
×
1013
  }
×
1014

1015
  private void respondActivityTaskCompleted(RespondActivityTaskCompletedRequest completeRequest)
1016
      throws TException {
1017
    ThriftResponse<WorkflowService.RespondActivityTaskCompleted_result> response = null;
×
1018
    try {
1019
      ThriftRequest<WorkflowService.RespondActivityTaskCompleted_args> request =
×
1020
          buildThriftRequest(
×
1021
              "RespondActivityTaskCompleted",
1022
              new WorkflowService.RespondActivityTaskCompleted_args(completeRequest));
1023
      response = doRemoteCall(request);
×
1024
      WorkflowService.RespondActivityTaskCompleted_result result =
×
1025
          response.getBody(WorkflowService.RespondActivityTaskCompleted_result.class);
×
1026
      if (response.getResponseCode() == ResponseCode.OK) {
×
1027
        return;
×
1028
      }
1029
      if (result.isSetBadRequestError()) {
×
1030
        throw result.getBadRequestError();
×
1031
      }
1032
      if (result.isSetEntityNotExistError()) {
×
1033
        throw result.getEntityNotExistError();
×
1034
      }
1035
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
1036
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1037
      }
1038
      if (result.isSetServiceBusyError()) {
×
1039
        throw result.getServiceBusyError();
×
1040
      }
1041
      if (result.isSetDomainNotActiveError()) {
×
1042
        throw result.getDomainNotActiveError();
×
1043
      }
1044
      if (result.isSetLimitExceededError()) {
×
1045
        throw result.getLimitExceededError();
×
1046
      }
1047
      if (result.isSetClientVersionNotSupportedError()) {
×
1048
        throw result.getClientVersionNotSupportedError();
×
1049
      }
1050
      throw new TException("RespondActivityTaskCompleted failed with unknown error:" + result);
×
1051
    } finally {
1052
      if (response != null) {
×
1053
        response.release();
×
1054
      }
1055
    }
1056
  }
1057

1058
  @Override
1059
  public void RespondActivityTaskCompletedByID(RespondActivityTaskCompletedByIDRequest request)
1060
      throws TException {
1061
    measureRemoteProc(
×
1062
        ServiceMethod.RESPOND_ACTIVITY_TASK_COMPLETED_BY_ID,
1063
        () -> respondActivityTaskCompletedByID(request));
×
1064
  }
×
1065

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

1109
  @Override
1110
  public void RespondActivityTaskFailed(RespondActivityTaskFailedRequest request)
1111
      throws TException {
1112
    measureRemoteProc(
×
1113
        ServiceMethod.RESPOND_ACTIVITY_TASK_FAILED, () -> respondActivityTaskFailed(request));
×
1114
  }
×
1115

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

1159
  @Override
1160
  public void RespondActivityTaskFailedByID(RespondActivityTaskFailedByIDRequest request)
1161
      throws TException {
1162
    measureRemoteProc(
×
1163
        ServiceMethod.RESPOND_ACTIVITY_TASK_FAILED_BY_ID,
1164
        () -> respondActivityTaskFailedByID(request));
×
1165
  }
×
1166

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

1210
  @Override
1211
  public void RespondActivityTaskCanceled(RespondActivityTaskCanceledRequest request)
1212
      throws TException {
1213
    measureRemoteProc(
×
1214
        ServiceMethod.RESPOND_ACTIVITY_TASK_CANCELED, () -> respondActivityTaskCanceled(request));
×
1215
  }
×
1216

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

1260
  @Override
1261
  public void RespondActivityTaskCanceledByID(RespondActivityTaskCanceledByIDRequest request)
1262
      throws TException {
1263
    measureRemoteProc(
×
1264
        ServiceMethod.RESPOND_ACTIVITY_TASK_CANCELED_BY_ID,
1265
        () -> respondActivityTaskCanceledByID(request));
×
1266
  }
×
1267

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

1311
  @Override
1312
  public void RequestCancelWorkflowExecution(RequestCancelWorkflowExecutionRequest request)
1313
      throws TException {
1314
    measureRemoteProc(
×
1315
        ServiceMethod.REQUEST_CANCEL_WORKFLOW_EXECUTION,
1316
        () -> requestCancelWorkflowExecution(request));
×
1317
  }
×
1318

1319
  private void requestCancelWorkflowExecution(RequestCancelWorkflowExecutionRequest cancelRequest)
1320
      throws TException {
1321
    cancelRequest.setRequestId(UUID.randomUUID().toString());
×
1322
    ThriftResponse<WorkflowService.RequestCancelWorkflowExecution_result> response = null;
×
1323
    try {
1324
      ThriftRequest<WorkflowService.RequestCancelWorkflowExecution_args> request =
×
1325
          buildThriftRequest(
×
1326
              "RequestCancelWorkflowExecution",
1327
              new WorkflowService.RequestCancelWorkflowExecution_args(cancelRequest));
1328
      response = doRemoteCall(request);
×
1329
      WorkflowService.RequestCancelWorkflowExecution_result result =
×
1330
          response.getBody(WorkflowService.RequestCancelWorkflowExecution_result.class);
×
1331
      if (response.getResponseCode() == ResponseCode.OK) {
×
1332
        return;
×
1333
      }
1334
      if (result.isSetBadRequestError()) {
×
1335
        throw result.getBadRequestError();
×
1336
      }
1337
      if (result.isSetEntityNotExistError()) {
×
1338
        throw result.getEntityNotExistError();
×
1339
      }
1340
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
1341
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1342
      }
1343
      if (result.isSetCancellationAlreadyRequestedError()) {
×
1344
        throw result.getCancellationAlreadyRequestedError();
×
1345
      }
1346
      if (result.isSetServiceBusyError()) {
×
1347
        throw result.getServiceBusyError();
×
1348
      }
1349
      if (result.isSetDomainNotActiveError()) {
×
1350
        throw result.getDomainNotActiveError();
×
1351
      }
1352
      if (result.isSetLimitExceededError()) {
×
1353
        throw result.getLimitExceededError();
×
1354
      }
1355
      if (result.isSetClientVersionNotSupportedError()) {
×
1356
        throw result.getClientVersionNotSupportedError();
×
1357
      }
1358
      throw new TException("RequestCancelWorkflowExecution failed with unknown error:" + result);
×
1359
    } finally {
1360
      if (response != null) {
×
1361
        response.release();
×
1362
      }
1363
    }
1364
  }
1365

1366
  @Override
1367
  public void SignalWorkflowExecution(SignalWorkflowExecutionRequest request) throws TException {
1368
    measureRemoteProc(
×
1369
        ServiceMethod.SIGNAL_WORKFLOW_EXECUTION, () -> signalWorkflowExecution(request));
×
1370
  }
×
1371

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

1415
  @Override
1416
  public StartWorkflowExecutionResponse SignalWithStartWorkflowExecution(
1417
      SignalWithStartWorkflowExecutionRequest signalWithStartRequest) throws TException {
1418
    return measureRemoteCall(
×
1419
        ServiceMethod.SIGNAL_WITH_START_WORKFLOW_EXECUTION,
1420
        () -> signalWithStartWorkflowExecution(signalWithStartRequest));
×
1421
  }
1422

1423
  @Override
1424
  public ResetWorkflowExecutionResponse ResetWorkflowExecution(
1425
      ResetWorkflowExecutionRequest resetRequest)
1426
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1427
          DomainNotActiveError, LimitExceededError, ClientVersionNotSupportedError, TException {
1428
    return measureRemoteCall(
×
1429
        ServiceMethod.RESET_WORKFLOW_EXECUTION, () -> resetWorkflowExecution(resetRequest));
×
1430
  }
1431

1432
  private ResetWorkflowExecutionResponse resetWorkflowExecution(
1433
      ResetWorkflowExecutionRequest resetRequest) throws TException {
1434
    ThriftResponse<WorkflowService.ResetWorkflowExecution_result> response = null;
×
1435
    try {
1436
      ThriftRequest<WorkflowService.ResetWorkflowExecution_args> request =
×
1437
          buildThriftRequest(
×
1438
              "ResetWorkflowExecution",
1439
              new WorkflowService.ResetWorkflowExecution_args(resetRequest));
1440
      response = doRemoteCall(request);
×
1441
      WorkflowService.ResetWorkflowExecution_result result =
×
1442
          response.getBody(WorkflowService.ResetWorkflowExecution_result.class);
×
1443
      if (response.getResponseCode() == ResponseCode.OK) {
×
1444
        return result.getSuccess();
×
1445
      }
1446
      if (result.isSetBadRequestError()) {
×
1447
        throw result.getBadRequestError();
×
1448
      }
1449
      if (result.isSetEntityNotExistError()) {
×
1450
        throw result.getEntityNotExistError();
×
1451
      }
1452
      if (result.isSetServiceBusyError()) {
×
1453
        throw result.getServiceBusyError();
×
1454
      }
1455
      if (result.isSetDomainNotActiveError()) {
×
1456
        throw result.getDomainNotActiveError();
×
1457
      }
1458
      if (result.isSetLimitExceededError()) {
×
1459
        throw result.getLimitExceededError();
×
1460
      }
1461
      if (result.isSetClientVersionNotSupportedError()) {
×
1462
        throw result.getClientVersionNotSupportedError();
×
1463
      }
1464
      throw new TException("ResetWorkflowExecution failed with unknown error:" + result);
×
1465
    } finally {
1466
      if (response != null) {
×
1467
        response.release();
×
1468
      }
1469
    }
1470
  }
1471

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

1516
  @Override
1517
  public void TerminateWorkflowExecution(TerminateWorkflowExecutionRequest request)
1518
      throws TException {
1519
    measureRemoteProc(
×
1520
        ServiceMethod.TERMINATE_WORKFLOW_EXECUTION, () -> terminateWorkflowExecution(request));
×
1521
  }
×
1522

1523
  private void terminateWorkflowExecution(TerminateWorkflowExecutionRequest terminateRequest)
1524
      throws TException {
1525
    ThriftResponse<WorkflowService.TerminateWorkflowExecution_result> response = null;
×
1526
    try {
1527
      ThriftRequest<WorkflowService.TerminateWorkflowExecution_args> request =
×
1528
          buildThriftRequest(
×
1529
              "TerminateWorkflowExecution",
1530
              new WorkflowService.TerminateWorkflowExecution_args(terminateRequest));
1531
      response = doRemoteCall(request);
×
1532
      WorkflowService.TerminateWorkflowExecution_result result =
×
1533
          response.getBody(WorkflowService.TerminateWorkflowExecution_result.class);
×
1534
      if (response.getResponseCode() == ResponseCode.OK) {
×
1535
        return;
×
1536
      }
1537
      if (result.isSetBadRequestError()) {
×
1538
        throw result.getBadRequestError();
×
1539
      }
1540
      if (result.isSetEntityNotExistError()) {
×
1541
        throw result.getEntityNotExistError();
×
1542
      }
1543
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
1544
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1545
      }
1546
      if (result.isSetServiceBusyError()) {
×
1547
        throw result.getServiceBusyError();
×
1548
      }
1549
      if (result.isSetDomainNotActiveError()) {
×
1550
        throw result.getDomainNotActiveError();
×
1551
      }
1552
      if (result.isSetLimitExceededError()) {
×
1553
        throw result.getLimitExceededError();
×
1554
      }
1555
      if (result.isSetClientVersionNotSupportedError()) {
×
1556
        throw result.getClientVersionNotSupportedError();
×
1557
      }
1558
      throw new TException("TerminateWorkflowExecution failed with unknown error:" + result);
×
1559
    } finally {
1560
      if (response != null) {
×
1561
        response.release();
×
1562
      }
1563
    }
1564
  }
1565

1566
  @Override
1567
  public ListOpenWorkflowExecutionsResponse ListOpenWorkflowExecutions(
1568
      ListOpenWorkflowExecutionsRequest request) throws TException {
1569
    return measureRemoteCall(
×
1570
        ServiceMethod.LIST_OPEN_WORKFLOW_EXECUTIONS, () -> listOpenWorkflowExecutions(request));
×
1571
  }
1572

1573
  private ListOpenWorkflowExecutionsResponse listOpenWorkflowExecutions(
1574
      ListOpenWorkflowExecutionsRequest listRequest) throws TException {
1575
    ThriftResponse<WorkflowService.ListOpenWorkflowExecutions_result> response = null;
×
1576
    try {
1577
      ThriftRequest<WorkflowService.ListOpenWorkflowExecutions_args> request =
×
1578
          buildThriftRequest(
×
1579
              "ListOpenWorkflowExecutions",
1580
              new WorkflowService.ListOpenWorkflowExecutions_args(listRequest));
1581
      response = doRemoteCall(request);
×
1582
      WorkflowService.ListOpenWorkflowExecutions_result result =
×
1583
          response.getBody(WorkflowService.ListOpenWorkflowExecutions_result.class);
×
1584
      if (response.getResponseCode() == ResponseCode.OK) {
×
1585
        return result.getSuccess();
×
1586
      }
1587
      if (result.isSetBadRequestError()) {
×
1588
        throw result.getBadRequestError();
×
1589
      }
1590
      if (result.isSetEntityNotExistError()) {
×
1591
        throw result.getEntityNotExistError();
×
1592
      }
1593
      if (result.isSetServiceBusyError()) {
×
1594
        throw result.getServiceBusyError();
×
1595
      }
1596
      if (result.isSetLimitExceededError()) {
×
1597
        throw result.getLimitExceededError();
×
1598
      }
1599
      if (result.isSetClientVersionNotSupportedError()) {
×
1600
        throw result.getClientVersionNotSupportedError();
×
1601
      }
1602
      throw new TException("ListOpenWorkflowExecutions failed with unknown error:" + result);
×
1603
    } finally {
1604
      if (response != null) {
×
1605
        response.release();
×
1606
      }
1607
    }
1608
  }
1609

1610
  @Override
1611
  public ListClosedWorkflowExecutionsResponse ListClosedWorkflowExecutions(
1612
      ListClosedWorkflowExecutionsRequest request) throws TException {
1613
    return measureRemoteCall(
×
1614
        ServiceMethod.LIST_CLOSED_WORKFLOW_EXECUTIONS, () -> listClosedWorkflowExecutions(request));
×
1615
  }
1616

1617
  private ListClosedWorkflowExecutionsResponse listClosedWorkflowExecutions(
1618
      ListClosedWorkflowExecutionsRequest listRequest) throws TException {
1619
    ThriftResponse<WorkflowService.ListClosedWorkflowExecutions_result> response = null;
×
1620
    try {
1621
      ThriftRequest<WorkflowService.ListClosedWorkflowExecutions_args> request =
×
1622
          buildThriftRequest(
×
1623
              "ListClosedWorkflowExecutions",
1624
              new WorkflowService.ListClosedWorkflowExecutions_args(listRequest));
1625
      response = doRemoteCall(request);
×
1626
      WorkflowService.ListClosedWorkflowExecutions_result result =
×
1627
          response.getBody(WorkflowService.ListClosedWorkflowExecutions_result.class);
×
1628
      if (response.getResponseCode() == ResponseCode.OK) {
×
1629
        return result.getSuccess();
×
1630
      }
1631
      if (result.isSetBadRequestError()) {
×
1632
        throw result.getBadRequestError();
×
1633
      }
1634
      if (result.isSetEntityNotExistError()) {
×
1635
        throw result.getEntityNotExistError();
×
1636
      }
1637
      if (result.isSetServiceBusyError()) {
×
1638
        throw result.getServiceBusyError();
×
1639
      }
1640
      if (result.isSetClientVersionNotSupportedError()) {
×
1641
        throw result.getClientVersionNotSupportedError();
×
1642
      }
1643
      throw new TException("ListClosedWorkflowExecutions failed with unknown error:" + result);
×
1644
    } finally {
1645
      if (response != null) {
×
1646
        response.release();
×
1647
      }
1648
    }
1649
  }
1650

1651
  @Override
1652
  public ListWorkflowExecutionsResponse ListWorkflowExecutions(
1653
      ListWorkflowExecutionsRequest request)
1654
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1655
          ClientVersionNotSupportedError, TException {
1656
    return measureRemoteCall(
×
1657
        ServiceMethod.LIST_WORKFLOW_EXECUTIONS, () -> listWorkflowExecutions(request));
×
1658
  }
1659

1660
  private ListWorkflowExecutionsResponse listWorkflowExecutions(
1661
      ListWorkflowExecutionsRequest listRequest) throws TException {
1662
    ThriftResponse<WorkflowService.ListWorkflowExecutions_result> response = null;
×
1663
    try {
1664
      ThriftRequest<WorkflowService.ListWorkflowExecutions_args> request =
×
1665
          buildThriftRequest(
×
1666
              "ListWorkflowExecutions",
1667
              new WorkflowService.ListWorkflowExecutions_args(listRequest));
1668
      response = doRemoteCall(request);
×
1669
      WorkflowService.ListWorkflowExecutions_result result =
×
1670
          response.getBody(WorkflowService.ListWorkflowExecutions_result.class);
×
1671
      if (response.getResponseCode() == ResponseCode.OK) {
×
1672
        return result.getSuccess();
×
1673
      }
1674
      if (result.isSetBadRequestError()) {
×
1675
        throw result.getBadRequestError();
×
1676
      }
1677
      if (result.isSetEntityNotExistError()) {
×
1678
        throw result.getEntityNotExistError();
×
1679
      }
1680
      if (result.isSetServiceBusyError()) {
×
1681
        throw result.getServiceBusyError();
×
1682
      }
1683
      if (result.isSetClientVersionNotSupportedError()) {
×
1684
        throw result.getClientVersionNotSupportedError();
×
1685
      }
1686
      throw new TException("ListWorkflowExecutions failed with unknown error:" + result);
×
1687
    } finally {
1688
      if (response != null) {
×
1689
        response.release();
×
1690
      }
1691
    }
1692
  }
1693

1694
  @Override
1695
  public ListArchivedWorkflowExecutionsResponse ListArchivedWorkflowExecutions(
1696
      ListArchivedWorkflowExecutionsRequest listRequest)
1697
      throws BadRequestError, EntityNotExistsError, ServiceBusyError,
1698
          ClientVersionNotSupportedError, TException {
1699
    return measureRemoteCall(
×
1700
        ServiceMethod.LIST_ARCHIVED_WORKFLOW_EXECUTIONS,
1701
        () -> listArchivedWorkflowExecutions(listRequest));
×
1702
  }
1703

1704
  private ListArchivedWorkflowExecutionsResponse listArchivedWorkflowExecutions(
1705
      ListArchivedWorkflowExecutionsRequest listRequest) throws TException {
1706
    ThriftResponse<WorkflowService.ListArchivedWorkflowExecutions_result> response = null;
×
1707
    try {
1708
      ThriftRequest<WorkflowService.ListArchivedWorkflowExecutions_args> request =
×
1709
          buildThriftRequest(
×
1710
              "ListArchivedWorkflowExecutions",
1711
              new WorkflowService.ListArchivedWorkflowExecutions_args(listRequest),
1712
              options.getRpcListArchivedWorkflowTimeoutMillis());
×
1713
      response = doRemoteCall(request);
×
1714
      WorkflowService.ListArchivedWorkflowExecutions_result result =
×
1715
          response.getBody(WorkflowService.ListArchivedWorkflowExecutions_result.class);
×
1716
      if (response.getResponseCode() == ResponseCode.OK) {
×
1717
        return result.getSuccess();
×
1718
      }
1719
      if (result.isSetBadRequestError()) {
×
1720
        throw result.getBadRequestError();
×
1721
      }
1722
      if (result.isSetEntityNotExistError()) {
×
1723
        throw result.getEntityNotExistError();
×
1724
      }
1725
      if (result.isSetServiceBusyError()) {
×
1726
        throw result.getServiceBusyError();
×
1727
      }
1728
      if (result.isSetClientVersionNotSupportedError()) {
×
1729
        throw result.getClientVersionNotSupportedError();
×
1730
      }
1731
      throw new TException("ListArchivedWorkflowExecutions failed with unknown error:" + result);
×
1732
    } finally {
1733
      if (response != null) {
×
1734
        response.release();
×
1735
      }
1736
    }
1737
  }
1738

1739
  @Override
1740
  public ListWorkflowExecutionsResponse ScanWorkflowExecutions(
1741
      ListWorkflowExecutionsRequest request)
1742
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1743
          ClientVersionNotSupportedError, TException {
1744
    return measureRemoteCall(
×
1745
        ServiceMethod.SCAN_WORKFLOW_EXECUTIONS, () -> scanWorkflowExecutions(request));
×
1746
  }
1747

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

1782
  @Override
1783
  public CountWorkflowExecutionsResponse CountWorkflowExecutions(
1784
      CountWorkflowExecutionsRequest countRequest)
1785
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1786
          ClientVersionNotSupportedError, TException {
1787
    return measureRemoteCall(
×
1788
        ServiceMethod.COUNT_WORKFLOW_EXECUTIONS, () -> countWorkflowExecutions(countRequest));
×
1789
  }
1790

1791
  private CountWorkflowExecutionsResponse countWorkflowExecutions(
1792
      CountWorkflowExecutionsRequest countRequest) throws TException {
1793
    ThriftResponse<WorkflowService.CountWorkflowExecutions_result> response = null;
×
1794
    try {
1795
      ThriftRequest<WorkflowService.CountWorkflowExecutions_args> request =
×
1796
          buildThriftRequest(
×
1797
              "CountWorkflowExecutions",
1798
              new WorkflowService.CountWorkflowExecutions_args(countRequest));
1799
      response = doRemoteCall(request);
×
1800
      WorkflowService.CountWorkflowExecutions_result result =
×
1801
          response.getBody(WorkflowService.CountWorkflowExecutions_result.class);
×
1802
      if (response.getResponseCode() == ResponseCode.OK) {
×
1803
        return result.getSuccess();
×
1804
      }
1805
      if (result.isSetBadRequestError()) {
×
1806
        throw result.getBadRequestError();
×
1807
      }
1808
      if (result.isSetEntityNotExistError()) {
×
1809
        throw result.getEntityNotExistError();
×
1810
      }
1811
      if (result.isSetServiceBusyError()) {
×
1812
        throw result.getServiceBusyError();
×
1813
      }
1814
      if (result.isSetClientVersionNotSupportedError()) {
×
1815
        throw result.getClientVersionNotSupportedError();
×
1816
      }
1817
      throw new TException("CountWorkflowExecutions failed with unknown error:" + result);
×
1818
    } finally {
1819
      if (response != null) {
×
1820
        response.release();
×
1821
      }
1822
    }
1823
  }
1824

1825
  @Override
1826
  public GetSearchAttributesResponse GetSearchAttributes()
1827
      throws InternalServiceError, ServiceBusyError, ClientVersionNotSupportedError, TException {
1828
    return measureRemoteCall(ServiceMethod.GET_SEARCH_ATTRIBUTES, () -> getSearchAttributes());
×
1829
  }
1830

1831
  private GetSearchAttributesResponse getSearchAttributes() throws TException {
1832
    ThriftResponse<WorkflowService.GetSearchAttributes_result> response = null;
×
1833
    try {
1834
      ThriftRequest<WorkflowService.GetSearchAttributes_args> request =
×
1835
          buildThriftRequest("GetSearchAttributes", new WorkflowService.GetSearchAttributes_args());
×
1836
      response = doRemoteCall(request);
×
1837
      WorkflowService.GetSearchAttributes_result result =
×
1838
          response.getBody(WorkflowService.GetSearchAttributes_result.class);
×
1839
      if (response.getResponseCode() == ResponseCode.OK) {
×
1840
        return result.getSuccess();
×
1841
      }
1842
      if (result.isSetServiceBusyError()) {
×
1843
        throw result.getServiceBusyError();
×
1844
      }
1845
      if (result.isSetClientVersionNotSupportedError()) {
×
1846
        throw result.getClientVersionNotSupportedError();
×
1847
      }
1848
      throw new TException("GetSearchAttributes failed with unknown error:" + result);
×
1849
    } finally {
1850
      if (response != null) {
×
1851
        response.release();
×
1852
      }
1853
    }
1854
  }
1855

1856
  @Override
1857
  public void RespondQueryTaskCompleted(RespondQueryTaskCompletedRequest request)
1858
      throws TException {
1859
    measureRemoteProc(
×
1860
        ServiceMethod.RESPOND_QUERY_TASK_COMPLETED, () -> respondQueryTaskCompleted(request));
×
1861
  }
×
1862

1863
  private void respondQueryTaskCompleted(RespondQueryTaskCompletedRequest completeRequest)
1864
      throws TException {
1865
    ThriftResponse<WorkflowService.RespondQueryTaskCompleted_result> response = null;
×
1866
    try {
1867
      ThriftRequest<WorkflowService.RespondQueryTaskCompleted_args> request =
×
1868
          buildThriftRequest(
×
1869
              "RespondQueryTaskCompleted",
1870
              new WorkflowService.RespondQueryTaskCompleted_args(completeRequest));
1871
      response = doRemoteCall(request);
×
1872
      WorkflowService.RespondQueryTaskCompleted_result result =
×
1873
          response.getBody(WorkflowService.RespondQueryTaskCompleted_result.class);
×
1874
      if (response.getResponseCode() == ResponseCode.OK) {
×
1875
        return;
×
1876
      }
1877
      if (result.isSetBadRequestError()) {
×
1878
        throw result.getBadRequestError();
×
1879
      }
1880
      if (result.isSetEntityNotExistError()) {
×
1881
        throw result.getEntityNotExistError();
×
1882
      }
1883
      if (result.isSetServiceBusyError()) {
×
1884
        throw result.getServiceBusyError();
×
1885
      }
1886
      if (result.isSetDomainNotActiveError()) {
×
1887
        throw result.getDomainNotActiveError();
×
1888
      }
1889
      if (result.isSetLimitExceededError()) {
×
1890
        throw result.getLimitExceededError();
×
1891
      }
1892
      if (result.isSetClientVersionNotSupportedError()) {
×
1893
        throw result.getClientVersionNotSupportedError();
×
1894
      }
1895
      throw new TException("RespondQueryTaskCompleted failed with unknown error:" + result);
×
1896
    } finally {
1897
      if (response != null) {
×
1898
        response.release();
×
1899
      }
1900
    }
1901
  }
1902

1903
  @Override
1904
  public QueryWorkflowResponse QueryWorkflow(QueryWorkflowRequest request) throws TException {
1905
    return measureRemoteCall(ServiceMethod.QUERY_WORKFLOW, () -> queryWorkflow(request));
×
1906
  }
1907

1908
  private QueryWorkflowResponse queryWorkflow(QueryWorkflowRequest queryRequest) throws TException {
1909
    ThriftResponse<WorkflowService.QueryWorkflow_result> response = null;
×
1910
    try {
1911
      ThriftRequest<WorkflowService.QueryWorkflow_args> request =
×
1912
          buildThriftRequest(
×
1913
              "QueryWorkflow",
1914
              new WorkflowService.QueryWorkflow_args(queryRequest),
1915
              options.getRpcQueryTimeoutMillis());
×
1916
      response = doRemoteCall(request);
×
1917
      WorkflowService.QueryWorkflow_result result =
×
1918
          response.getBody(WorkflowService.QueryWorkflow_result.class);
×
1919
      if (response.getResponseCode() == ResponseCode.OK) {
×
1920
        return result.getSuccess();
×
1921
      }
1922
      if (result.isSetBadRequestError()) {
×
1923
        throw result.getBadRequestError();
×
1924
      }
1925
      if (result.isSetEntityNotExistError()) {
×
1926
        throw result.getEntityNotExistError();
×
1927
      }
1928
      if (result.isSetQueryFailedError()) {
×
1929
        throw result.getQueryFailedError();
×
1930
      }
1931
      if (result.isSetClientVersionNotSupportedError()) {
×
1932
        throw result.getClientVersionNotSupportedError();
×
1933
      }
1934
      throw new TException("QueryWorkflow failed with unknown error:" + result);
×
1935
    } finally {
1936
      if (response != null) {
×
1937
        response.release();
×
1938
      }
1939
    }
1940
  }
1941

1942
  @Override
1943
  public ResetStickyTaskListResponse ResetStickyTaskList(ResetStickyTaskListRequest resetRequest)
1944
      throws BadRequestError, InternalServiceError, EntityNotExistsError, LimitExceededError,
1945
          WorkflowExecutionAlreadyCompletedError, ServiceBusyError, DomainNotActiveError,
1946
          TException {
1947
    return measureRemoteCall(
×
1948
        ServiceMethod.RESET_STICKY_TASK_LIST, () -> resetStickyTaskList(resetRequest));
×
1949
  }
1950

1951
  private ResetStickyTaskListResponse resetStickyTaskList(ResetStickyTaskListRequest queryRequest)
1952
      throws TException {
1953
    ThriftResponse<WorkflowService.ResetStickyTaskList_result> response = null;
×
1954
    try {
1955
      ThriftRequest<WorkflowService.ResetStickyTaskList_args> request =
×
1956
          buildThriftRequest(
×
1957
              "ResetStickyTaskList",
1958
              new WorkflowService.ResetStickyTaskList_args(queryRequest),
1959
              options.getRpcQueryTimeoutMillis());
×
1960
      response = doRemoteCall(request);
×
1961
      WorkflowService.ResetStickyTaskList_result result =
×
1962
          response.getBody(WorkflowService.ResetStickyTaskList_result.class);
×
1963
      if (response.getResponseCode() == ResponseCode.OK) {
×
1964
        return result.getSuccess();
×
1965
      }
1966
      if (result.isSetBadRequestError()) {
×
1967
        throw result.getBadRequestError();
×
1968
      }
1969
      if (result.isSetEntityNotExistError()) {
×
1970
        throw result.getEntityNotExistError();
×
1971
      }
1972
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
1973
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1974
      }
1975
      if (result.isSetServiceBusyError()) {
×
1976
        throw result.getServiceBusyError();
×
1977
      }
1978
      if (result.isSetDomainNotActiveError()) {
×
1979
        throw result.getDomainNotActiveError();
×
1980
      }
1981
      if (result.isSetLimitExceededError()) {
×
1982
        throw result.getLimitExceededError();
×
1983
      }
1984
      if (result.isSetClientVersionNotSupportedError()) {
×
1985
        throw result.getClientVersionNotSupportedError();
×
1986
      }
1987
      throw new TException("ResetStickyTaskList failed with unknown error:" + result);
×
1988
    } finally {
1989
      if (response != null) {
×
1990
        response.release();
×
1991
      }
1992
    }
1993
  }
1994

1995
  @Override
1996
  public DescribeWorkflowExecutionResponse DescribeWorkflowExecution(
1997
      DescribeWorkflowExecutionRequest request) throws TException {
1998
    return measureRemoteCall(
×
1999
        ServiceMethod.DESCRIBE_WORKFLOW_EXECUTION, () -> describeWorkflowExecution(request));
×
2000
  }
2001

2002
  private DescribeWorkflowExecutionResponse describeWorkflowExecution(
2003
      DescribeWorkflowExecutionRequest describeRequest) throws TException {
2004
    ThriftResponse<WorkflowService.DescribeWorkflowExecution_result> response = null;
×
2005
    try {
2006
      ThriftRequest<WorkflowService.DescribeWorkflowExecution_args> request =
×
2007
          buildThriftRequest(
×
2008
              "DescribeWorkflowExecution",
2009
              new WorkflowService.DescribeWorkflowExecution_args(describeRequest));
2010
      response = doRemoteCall(request);
×
2011
      WorkflowService.DescribeWorkflowExecution_result result =
×
2012
          response.getBody(WorkflowService.DescribeWorkflowExecution_result.class);
×
2013
      if (response.getResponseCode() == ResponseCode.OK) {
×
2014
        return result.getSuccess();
×
2015
      }
2016
      if (result.isSetBadRequestError()) {
×
2017
        throw result.getBadRequestError();
×
2018
      }
2019
      if (result.isSetEntityNotExistError()) {
×
2020
        throw result.getEntityNotExistError();
×
2021
      }
2022
      if (result.isSetServiceBusyError()) {
×
2023
        throw result.getServiceBusyError();
×
2024
      }
2025
      if (result.isSetLimitExceededError()) {
×
2026
        throw result.getLimitExceededError();
×
2027
      }
2028
      if (result.isSetClientVersionNotSupportedError()) {
×
2029
        throw result.getClientVersionNotSupportedError();
×
2030
      }
2031
      throw new TException("DescribeWorkflowExecution failed with unknown error:" + result);
×
2032
    } finally {
2033
      if (response != null) {
×
2034
        response.release();
×
2035
      }
2036
    }
2037
  }
2038

2039
  @Override
2040
  public DescribeTaskListResponse DescribeTaskList(DescribeTaskListRequest request)
2041
      throws TException {
2042
    return measureRemoteCall(ServiceMethod.DESCRIBE_TASK_LIST, () -> describeTaskList(request));
×
2043
  }
2044

2045
  private DescribeTaskListResponse describeTaskList(DescribeTaskListRequest describeRequest)
2046
      throws TException {
2047
    ThriftResponse<WorkflowService.DescribeTaskList_result> response = null;
×
2048
    try {
2049
      ThriftRequest<WorkflowService.DescribeTaskList_args> request =
×
2050
          buildThriftRequest(
×
2051
              "DescribeTaskList", new WorkflowService.DescribeTaskList_args(describeRequest));
2052
      response = doRemoteCall(request);
×
2053
      WorkflowService.DescribeTaskList_result result =
×
2054
          response.getBody(WorkflowService.DescribeTaskList_result.class);
×
2055
      if (response.getResponseCode() == ResponseCode.OK) {
×
2056
        return result.getSuccess();
×
2057
      }
2058
      if (result.isSetBadRequestError()) {
×
2059
        throw result.getBadRequestError();
×
2060
      }
2061
      if (result.isSetEntityNotExistError()) {
×
2062
        throw result.getEntityNotExistError();
×
2063
      }
2064
      if (result.isSetServiceBusyError()) {
×
2065
        throw result.getServiceBusyError();
×
2066
      }
2067
      if (result.isSetLimitExceededError()) {
×
2068
        throw result.getLimitExceededError();
×
2069
      }
2070
      if (result.isSetClientVersionNotSupportedError()) {
×
2071
        throw result.getClientVersionNotSupportedError();
×
2072
      }
2073
      throw new TException("DescribeTaskList failed with unknown error:" + result);
×
2074
    } finally {
2075
      if (response != null) {
×
2076
        response.release();
×
2077
      }
2078
    }
2079
  }
2080

2081
  @Override
2082
  public ClusterInfo GetClusterInfo() throws InternalServiceError, ServiceBusyError, TException {
2083
    return measureRemoteCall(ServiceMethod.GET_CLUSTER_INFO, () -> getClusterInfo());
×
2084
  }
2085

2086
  private ClusterInfo getClusterInfo() throws TException {
2087
    ThriftResponse<WorkflowService.GetClusterInfo_result> response = null;
×
2088
    try {
2089
      ThriftRequest<WorkflowService.GetClusterInfo_args> request =
×
2090
          buildThriftRequest("GetClusterInfo", new WorkflowService.GetClusterInfo_args());
×
2091
      response = doRemoteCall(request);
×
2092
      WorkflowService.GetClusterInfo_result result =
×
2093
          response.getBody(WorkflowService.GetClusterInfo_result.class);
×
2094
      if (response.getResponseCode() == ResponseCode.OK) {
×
2095
        return result.getSuccess();
×
2096
      }
2097
      if (result.isSetServiceBusyError()) {
×
2098
        throw result.getServiceBusyError();
×
2099
      }
2100
      throw new TException("GetClusterInfo failed with unknown error:" + result);
×
2101
    } finally {
2102
      if (response != null) {
×
2103
        response.release();
×
2104
      }
2105
    }
2106
  }
2107

2108
  @Override
2109
  public ListTaskListPartitionsResponse ListTaskListPartitions(
2110
      ListTaskListPartitionsRequest request)
2111
      throws BadRequestError, EntityNotExistsError, LimitExceededError, ServiceBusyError,
2112
          TException {
2113
    return measureRemoteCall(
×
2114
        ServiceMethod.LIST_TASK_LIST_PARTITIONS, () -> listTaskListPartitions(request));
×
2115
  }
2116

2117
  @Override
2118
  public void RefreshWorkflowTasks(RefreshWorkflowTasksRequest refreshWorkflowTasks)
2119
      throws BadRequestError, DomainNotActiveError, ServiceBusyError, EntityNotExistsError,
2120
          TException {
2121
    ThriftResponse<WorkflowService.RefreshWorkflowTasks_result> response = null;
×
2122
    try {
2123
      ThriftRequest<WorkflowService.RefreshWorkflowTasks_args> request =
×
2124
          buildThriftRequest(
×
2125
              "RefreshWorkflowTasks",
2126
              new WorkflowService.RefreshWorkflowTasks_args(refreshWorkflowTasks));
2127
      response = doRemoteCall(request);
×
2128
      WorkflowService.RefreshWorkflowTasks_result result =
×
2129
          response.getBody(WorkflowService.RefreshWorkflowTasks_result.class);
×
2130
      if (result.isSetBadRequestError()) {
×
2131
        throw result.getBadRequestError();
×
2132
      }
2133
      if (result.isSetDomainNotActiveError()) {
×
2134
        throw result.getDomainNotActiveError();
×
2135
      }
2136
      if (result.isSetServiceBusyError()) {
×
2137
        throw result.getServiceBusyError();
×
2138
      }
2139
      if (result.isSetEntityNotExistError()) {
×
2140
        throw result.getEntityNotExistError();
×
2141
      }
2142
    } finally {
2143
      if (response != null) {
×
2144
        response.release();
×
2145
      }
2146
    }
2147
  }
×
2148

2149
  private ListTaskListPartitionsResponse listTaskListPartitions(
2150
      ListTaskListPartitionsRequest listRequest) throws TException {
2151
    ThriftResponse<WorkflowService.ListTaskListPartitions_result> response = null;
×
2152
    try {
2153
      ThriftRequest<WorkflowService.ListTaskListPartitions_args> request =
×
2154
          buildThriftRequest(
×
2155
              "ListTaskListPartitions",
2156
              new WorkflowService.ListTaskListPartitions_args(listRequest));
2157
      response = doRemoteCall(request);
×
2158
      WorkflowService.ListTaskListPartitions_result result =
×
2159
          response.getBody(WorkflowService.ListTaskListPartitions_result.class);
×
2160
      if (response.getResponseCode() == ResponseCode.OK) {
×
2161
        return result.getSuccess();
×
2162
      }
2163
      if (result.isSetBadRequestError()) {
×
2164
        throw result.getBadRequestError();
×
2165
      }
2166
      if (result.isSetEntityNotExistError()) {
×
2167
        throw result.getEntityNotExistError();
×
2168
      }
2169
      if (result.isSetServiceBusyError()) {
×
2170
        throw result.getServiceBusyError();
×
2171
      }
2172
      if (result.isSetLimitExceededError()) {
×
2173
        throw result.getLimitExceededError();
×
2174
      }
2175
      throw new TException("ListTaskListPartitions failed with unknown error:" + result);
×
2176
    } finally {
2177
      if (response != null) {
×
2178
        response.release();
×
2179
      }
2180
    }
2181
  }
2182

2183
  @Override
2184
  public void StartWorkflowExecution(
2185
      StartWorkflowExecutionRequest startRequest, AsyncMethodCallback resultHandler) {
2186
    startWorkflowExecution(startRequest, resultHandler, null);
×
2187
  }
×
2188

2189
  @Override
2190
  public void StartWorkflowExecutionWithTimeout(
2191
      StartWorkflowExecutionRequest startRequest,
2192
      AsyncMethodCallback resultHandler,
2193
      Long timeoutInMillis) {
2194
    startWorkflowExecution(startRequest, resultHandler, timeoutInMillis);
×
2195
  }
×
2196

2197
  private void startWorkflowExecution(
2198
      StartWorkflowExecutionRequest startRequest,
2199
      AsyncMethodCallback resultHandler,
2200
      Long timeoutInMillis) {
2201

2202
    startRequest.setRequestId(UUID.randomUUID().toString());
×
2203
    timeoutInMillis = validateAndUpdateTimeout(timeoutInMillis, options.getRpcTimeoutMillis());
×
2204
    ThriftRequest<WorkflowService.StartWorkflowExecution_args> request =
×
2205
        buildThriftRequest(
×
2206
            "StartWorkflowExecution",
2207
            new WorkflowService.StartWorkflowExecution_args(startRequest),
2208
            timeoutInMillis);
2209

2210
    CompletableFuture<ThriftResponse<WorkflowService.StartWorkflowExecution_result>> response =
×
2211
        doRemoteCallAsync(request);
×
2212
    response
×
2213
        .whenComplete(
×
2214
            (r, e) -> {
2215
              try {
2216
                if (e != null) {
×
2217
                  resultHandler.onError(CheckedExceptionWrapper.wrap(e));
×
2218
                  return;
×
2219
                }
2220
                WorkflowService.StartWorkflowExecution_result result =
×
2221
                    r.getBody(WorkflowService.StartWorkflowExecution_result.class);
×
2222
                if (r.getResponseCode() == ResponseCode.OK) {
×
2223
                  resultHandler.onComplete(result.getSuccess());
×
2224
                  return;
×
2225
                }
2226
                if (result.isSetBadRequestError()) {
×
2227
                  resultHandler.onError(result.getBadRequestError());
×
2228
                  return;
×
2229
                }
2230
                if (result.isSetSessionAlreadyExistError()) {
×
2231
                  resultHandler.onError(result.getSessionAlreadyExistError());
×
2232
                  return;
×
2233
                }
2234
                if (result.isSetServiceBusyError()) {
×
2235
                  resultHandler.onError(result.getServiceBusyError());
×
2236
                  return;
×
2237
                }
2238
                if (result.isSetDomainNotActiveError()) {
×
2239
                  resultHandler.onError(result.getDomainNotActiveError());
×
2240
                  return;
×
2241
                }
2242
                if (result.isSetLimitExceededError()) {
×
2243
                  resultHandler.onError(result.getLimitExceededError());
×
2244
                  return;
×
2245
                }
2246
                if (result.isSetEntityNotExistError()) {
×
2247
                  resultHandler.onError(result.getEntityNotExistError());
×
2248
                  return;
×
2249
                }
2250
                resultHandler.onError(
×
2251
                    new TException("StartWorkflowExecution failed with unknown error:" + result));
2252
              } finally {
2253
                if (r != null) {
×
2254
                  r.release();
×
2255
                }
2256
              }
2257
            })
×
2258
        .exceptionally(
×
2259
            (e) -> {
2260
              log.error("Unexpected error in StartWorkflowExecution", e);
×
2261
              return null;
×
2262
            });
2263
  }
×
2264

2265
  private Long validateAndUpdateTimeout(Long timeoutInMillis, Long defaultTimeoutInMillis) {
2266
    if (timeoutInMillis == null || timeoutInMillis <= 0 || timeoutInMillis == Long.MAX_VALUE) {
×
2267
      timeoutInMillis = defaultTimeoutInMillis;
×
2268
    } else {
2269
      timeoutInMillis = Math.min(timeoutInMillis, defaultTimeoutInMillis);
×
2270
    }
2271
    return timeoutInMillis;
×
2272
  }
2273

2274
  @SuppressWarnings({"unchecked", "FutureReturnValueIgnored"})
2275
  @Override
2276
  public void GetWorkflowExecutionHistoryWithTimeout(
2277
      GetWorkflowExecutionHistoryRequest getRequest,
2278
      AsyncMethodCallback resultHandler,
2279
      Long timeoutInMillis) {
2280

2281
    getWorkflowExecutionHistory(getRequest, resultHandler, timeoutInMillis);
×
2282
  }
×
2283

2284
  @SuppressWarnings({"unchecked", "FutureReturnValueIgnored"})
2285
  @Override
2286
  public void GetWorkflowExecutionHistory(
2287
      GetWorkflowExecutionHistoryRequest getRequest, AsyncMethodCallback resultHandler) {
2288

2289
    getWorkflowExecutionHistory(getRequest, resultHandler, null);
×
2290
  }
×
2291

2292
  private void getWorkflowExecutionHistory(
2293
      GetWorkflowExecutionHistoryRequest getRequest,
2294
      AsyncMethodCallback resultHandler,
2295
      Long timeoutInMillis) {
2296

2297
    ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args> request =
×
2298
        buildGetWorkflowExecutionHistoryThriftRequest(getRequest, timeoutInMillis);
×
2299

2300
    CompletableFuture<ThriftResponse<GetWorkflowExecutionHistory_result>> response =
×
2301
        doRemoteCallAsync(request);
×
2302
    response
×
2303
        .whenComplete(
×
2304
            (r, e) -> {
2305
              try {
2306
                if (e != null) {
×
2307
                  resultHandler.onError(CheckedExceptionWrapper.wrap(e));
×
2308
                  return;
×
2309
                }
2310
                WorkflowService.GetWorkflowExecutionHistory_result result =
×
2311
                    r.getBody(WorkflowService.GetWorkflowExecutionHistory_result.class);
×
2312

2313
                if (r.getResponseCode() == ResponseCode.OK) {
×
2314
                  GetWorkflowExecutionHistoryResponse res = result.getSuccess();
×
2315
                  if (res.getRawHistory() != null) {
×
2316
                    History history =
×
2317
                        InternalUtils.DeserializeFromBlobDataToHistory(
×
2318
                            res.getRawHistory(), getRequest.getHistoryEventFilterType());
×
2319
                    res.setHistory(history);
×
2320
                  }
2321
                  resultHandler.onComplete(res);
×
2322
                  return;
×
2323
                }
2324
                if (result.isSetBadRequestError()) {
×
2325
                  resultHandler.onError(result.getBadRequestError());
×
2326
                  return;
×
2327
                }
2328
                if (result.isSetEntityNotExistError()) {
×
2329
                  resultHandler.onError(result.getEntityNotExistError());
×
2330
                  return;
×
2331
                }
2332
                if (result.isSetServiceBusyError()) {
×
2333
                  resultHandler.onError(result.getServiceBusyError());
×
2334
                  return;
×
2335
                }
2336
                resultHandler.onError(
×
2337
                    new TException(
2338
                        "GetWorkflowExecutionHistory failed with unknown " + "error:" + result));
2339
              } catch (TException tException) {
×
2340
                resultHandler.onError(tException);
×
2341
              } finally {
2342
                if (r != null) {
×
2343
                  r.release();
×
2344
                }
2345
              }
2346
            })
×
2347
        .exceptionally(
×
2348
            (e) -> {
2349
              log.error("Unexpected error in GetWorkflowExecutionHistory", e);
×
2350
              return null;
×
2351
            });
2352
  }
×
2353

2354
  @Override
2355
  public void PollForDecisionTask(
2356
      PollForDecisionTaskRequest pollRequest, AsyncMethodCallback resultHandler) throws TException {
2357
    throw new UnsupportedOperationException("not implemented");
×
2358
  }
2359

2360
  @Override
2361
  public void RespondDecisionTaskCompleted(
2362
      RespondDecisionTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
2363
      throws TException {
2364
    throw new UnsupportedOperationException("not implemented");
×
2365
  }
2366

2367
  @Override
2368
  public void RespondDecisionTaskFailed(
2369
      RespondDecisionTaskFailedRequest failedRequest, AsyncMethodCallback resultHandler)
2370
      throws TException {
2371
    throw new UnsupportedOperationException("not implemented");
×
2372
  }
2373

2374
  @Override
2375
  public void PollForActivityTask(
2376
      PollForActivityTaskRequest pollRequest, AsyncMethodCallback resultHandler) throws TException {
2377
    throw new UnsupportedOperationException("not implemented");
×
2378
  }
2379

2380
  @Override
2381
  public void RecordActivityTaskHeartbeat(
2382
      RecordActivityTaskHeartbeatRequest heartbeatRequest, AsyncMethodCallback resultHandler)
2383
      throws TException {
2384
    throw new UnsupportedOperationException("not implemented");
×
2385
  }
2386

2387
  @Override
2388
  public void RecordActivityTaskHeartbeatByID(
2389
      RecordActivityTaskHeartbeatByIDRequest heartbeatRequest, AsyncMethodCallback resultHandler)
2390
      throws TException {
2391
    throw new UnsupportedOperationException("not implemented");
×
2392
  }
2393

2394
  @Override
2395
  public void RespondActivityTaskCompleted(
2396
      RespondActivityTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
2397
      throws TException {
2398
    throw new UnsupportedOperationException("not implemented");
×
2399
  }
2400

2401
  @Override
2402
  public void RespondActivityTaskCompletedByID(
2403
      RespondActivityTaskCompletedByIDRequest completeRequest, AsyncMethodCallback resultHandler)
2404
      throws TException {
2405
    throw new UnsupportedOperationException("not implemented");
×
2406
  }
2407

2408
  @Override
2409
  public void RespondActivityTaskFailed(
2410
      RespondActivityTaskFailedRequest failRequest, AsyncMethodCallback resultHandler)
2411
      throws TException {
2412
    throw new UnsupportedOperationException("not implemented");
×
2413
  }
2414

2415
  @Override
2416
  public void RespondActivityTaskFailedByID(
2417
      RespondActivityTaskFailedByIDRequest failRequest, AsyncMethodCallback resultHandler)
2418
      throws TException {
2419
    throw new UnsupportedOperationException("not implemented");
×
2420
  }
2421

2422
  @Override
2423
  public void RespondActivityTaskCanceled(
2424
      RespondActivityTaskCanceledRequest canceledRequest, AsyncMethodCallback resultHandler)
2425
      throws TException {
2426
    throw new UnsupportedOperationException("not implemented");
×
2427
  }
2428

2429
  @Override
2430
  public void RespondActivityTaskCanceledByID(
2431
      RespondActivityTaskCanceledByIDRequest canceledRequest, AsyncMethodCallback resultHandler)
2432
      throws TException {
2433
    throw new UnsupportedOperationException("not implemented");
×
2434
  }
2435

2436
  @Override
2437
  public void RequestCancelWorkflowExecution(
2438
      RequestCancelWorkflowExecutionRequest cancelRequest, AsyncMethodCallback resultHandler)
2439
      throws TException {
2440
    throw new UnsupportedOperationException("not implemented");
×
2441
  }
2442

2443
  @Override
2444
  public void SignalWorkflowExecution(
2445
      SignalWorkflowExecutionRequest signalRequest, AsyncMethodCallback resultHandler) {
2446
    signalWorkflowExecution(signalRequest, resultHandler, null);
×
2447
  }
×
2448

2449
  @Override
2450
  public void SignalWorkflowExecutionWithTimeout(
2451
      SignalWorkflowExecutionRequest signalRequest,
2452
      AsyncMethodCallback resultHandler,
2453
      Long timeoutInMillis) {
2454
    signalWorkflowExecution(signalRequest, resultHandler, timeoutInMillis);
×
2455
  }
×
2456

2457
  private void signalWorkflowExecution(
2458
      SignalWorkflowExecutionRequest signalRequest,
2459
      AsyncMethodCallback resultHandler,
2460
      Long timeoutInMillis) {
2461

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

2527
  @Override
2528
  public void SignalWithStartWorkflowExecution(
2529
      SignalWithStartWorkflowExecutionRequest signalWithStartRequest,
2530
      AsyncMethodCallback resultHandler)
2531
      throws TException {
2532
    throw new UnsupportedOperationException("not implemented");
×
2533
  }
2534

2535
  @Override
2536
  public void ResetWorkflowExecution(
2537
      ResetWorkflowExecutionRequest resetRequest, AsyncMethodCallback resultHandler)
2538
      throws TException {
2539
    throw new UnsupportedOperationException("not implemented");
×
2540
  }
2541

2542
  @Override
2543
  public void TerminateWorkflowExecution(
2544
      TerminateWorkflowExecutionRequest terminateRequest, AsyncMethodCallback resultHandler)
2545
      throws TException {
2546
    throw new UnsupportedOperationException("not implemented");
×
2547
  }
2548

2549
  @Override
2550
  public void ListOpenWorkflowExecutions(
2551
      ListOpenWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2552
      throws TException {
2553
    throw new UnsupportedOperationException("not implemented");
×
2554
  }
2555

2556
  @Override
2557
  public void ListClosedWorkflowExecutions(
2558
      ListClosedWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2559
      throws TException {
2560
    throw new UnsupportedOperationException("not implemented");
×
2561
  }
2562

2563
  @Override
2564
  public void ListWorkflowExecutions(
2565
      ListWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2566
      throws TException {
2567
    throw new UnsupportedOperationException("not implemented");
×
2568
  }
2569

2570
  @Override
2571
  public void ListArchivedWorkflowExecutions(
2572
      ListArchivedWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2573
      throws TException {
2574
    throw new UnsupportedOperationException("not implemented");
×
2575
  }
2576

2577
  @Override
2578
  public void ScanWorkflowExecutions(
2579
      ListWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2580
      throws TException {
2581
    throw new UnsupportedOperationException("not implemented");
×
2582
  }
2583

2584
  @Override
2585
  public void CountWorkflowExecutions(
2586
      CountWorkflowExecutionsRequest countRequest, AsyncMethodCallback resultHandler)
2587
      throws TException {
2588
    throw new UnsupportedOperationException("not implemented");
×
2589
  }
2590

2591
  @Override
2592
  public void GetSearchAttributes(AsyncMethodCallback resultHandler) throws TException {
2593
    throw new UnsupportedOperationException("not implemented");
×
2594
  }
2595

2596
  @Override
2597
  public void RespondQueryTaskCompleted(
2598
      RespondQueryTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
2599
      throws TException {
2600
    throw new UnsupportedOperationException("not implemented");
×
2601
  }
2602

2603
  @Override
2604
  public void ResetStickyTaskList(
2605
      ResetStickyTaskListRequest resetRequest, AsyncMethodCallback resultHandler)
2606
      throws TException {
2607
    throw new UnsupportedOperationException("not implemented");
×
2608
  }
2609

2610
  @Override
2611
  public void QueryWorkflow(QueryWorkflowRequest queryRequest, AsyncMethodCallback resultHandler)
2612
      throws TException {
2613
    throw new UnsupportedOperationException("not implemented");
×
2614
  }
2615

2616
  @Override
2617
  public void DescribeWorkflowExecution(
2618
      DescribeWorkflowExecutionRequest describeRequest, AsyncMethodCallback resultHandler)
2619
      throws TException {
2620
    throw new UnsupportedOperationException("not implemented");
×
2621
  }
2622

2623
  @Override
2624
  public void DescribeTaskList(DescribeTaskListRequest request, AsyncMethodCallback resultHandler)
2625
      throws TException {
2626
    throw new UnsupportedOperationException("not implemented");
×
2627
  }
2628

2629
  @Override
2630
  public void GetClusterInfo(AsyncMethodCallback resultHandler) throws TException {}
×
2631

2632
  @Override
2633
  public void ListTaskListPartitions(
2634
      ListTaskListPartitionsRequest request, AsyncMethodCallback resultHandler) throws TException {}
×
2635

2636
  @Override
2637
  public void RefreshWorkflowTasks(
2638
      RefreshWorkflowTasksRequest request, AsyncMethodCallback resultHandler) throws TException {}
×
2639

2640
  @Override
2641
  public void RegisterDomain(
2642
      RegisterDomainRequest registerRequest, AsyncMethodCallback resultHandler) throws TException {
2643
    throw new UnsupportedOperationException("not implemented");
×
2644
  }
2645

2646
  @Override
2647
  public void DescribeDomain(
2648
      DescribeDomainRequest describeRequest, AsyncMethodCallback resultHandler) throws TException {
2649
    throw new UnsupportedOperationException("not implemented");
×
2650
  }
2651

2652
  @Override
2653
  public void ListDomains(ListDomainsRequest listRequest, AsyncMethodCallback resultHandler)
2654
      throws TException {
2655
    throw new UnsupportedOperationException("not implemented");
×
2656
  }
2657

2658
  @Override
2659
  public void UpdateDomain(UpdateDomainRequest updateRequest, AsyncMethodCallback resultHandler)
2660
      throws TException {
2661
    throw new UnsupportedOperationException("not implemented");
×
2662
  }
2663

2664
  @Override
2665
  public void DeprecateDomain(
2666
      DeprecateDomainRequest deprecateRequest, AsyncMethodCallback resultHandler)
2667
      throws TException {
2668
    throw new UnsupportedOperationException("not implemented");
×
2669
  }
2670

2671
  @Override
2672
  public void GetTaskListsByDomain(
2673
      GetTaskListsByDomainRequest request, AsyncMethodCallback resultHandler)
2674
      throws org.apache.thrift.TException {
2675
    throw new UnsupportedOperationException("not implemented");
×
2676
  }
2677
}
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