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

uber / cadence-java-client / 16

16 Apr 2024 01:28AM UTC coverage: 60.239% (-0.1%) from 60.343%
16

push

buildkite

mstifflin
Remove unnecessary sidecar command, try executing with lower resources

11446 of 19001 relevant lines covered (60.24%)

0.6 hits per line

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

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

18
package com.uber.cadence.serviceclient;
19

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

231
    String tracingHeadersPrefix = "$tracing$";
1✔
232
    TextMapSetter<Map<String, String>> setter =
1✔
233
        (carrier, key, value) -> {
234
          if (carrier != null) {
×
235
            carrier.put(tracingHeadersPrefix + key, value);
×
236
          }
237
        };
×
238

239
    textMapPropagator.inject(Context.current(), headers, setter);
1✔
240

241
    if (this.options.getAuthProvider() != null) {
1✔
242
      headers.put(
×
243
          "cadence-authorization",
244
          new String(options.getAuthProvider().getAuthToken(), StandardCharsets.UTF_8));
×
245
    }
246
    builder.setHeaders(headers);
1✔
247

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

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

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

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

307
  @Override
308
  public void close() {
309
    if (tChannel != null) {
1✔
310
      tChannel.shutdown();
1✔
311
    }
312
  }
1✔
313

314
  interface RemoteCall<T> {
315
    T apply() throws TException;
316
  }
317

318
  private <T> T measureRemoteCall(String scopeName, RemoteCall<T> call) throws TException {
319
    return measureRemoteCallWithTags(scopeName, call, null);
×
320
  }
321

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

353
  interface RemoteProc {
354
    void apply() throws TException;
355
  }
356

357
  private void measureRemoteProc(String scopeName, RemoteProc proc) throws TException {
358
    measureRemoteCall(
×
359
        scopeName,
360
        () -> {
361
          proc.apply();
×
362
          return null;
×
363
        });
364
  }
×
365

366
  @Override
367
  public void RegisterDomain(RegisterDomainRequest request) throws TException {
368
    measureRemoteProc(ServiceMethod.REGISTER_DOMAIN, () -> registerDomain(request));
×
369
  }
×
370

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

400
  @Override
401
  public DescribeDomainResponse DescribeDomain(DescribeDomainRequest describeRequest)
402
      throws TException {
403
    return measureRemoteCall(ServiceMethod.DESCRIBE_DOMAIN, () -> describeDomain(describeRequest));
×
404
  }
405

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

436
  @Override
437
  public ListDomainsResponse ListDomains(ListDomainsRequest listRequest)
438
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
439
          TException {
440
    return measureRemoteCall(ServiceMethod.LIST_DOMAINS, () -> listDomains(listRequest));
×
441
  }
442

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

471
  @Override
472
  public UpdateDomainResponse UpdateDomain(UpdateDomainRequest updateRequest) throws TException {
473
    return measureRemoteCall(ServiceMethod.UPDATE_DOMAIN, () -> updateDomain(updateRequest));
×
474
  }
475

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

507
  @Override
508
  public void DeprecateDomain(DeprecateDomainRequest deprecateRequest) throws TException {
509
    measureRemoteProc(ServiceMethod.DEPRECATE_DOMAIN, () -> deprecateDomain(deprecateRequest));
×
510
  }
×
511

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

544
  @Override
545
  public GetTaskListsByDomainResponse GetTaskListsByDomain(
546
      GetTaskListsByDomainRequest getTaskListsByDomainRequest) throws TException {
547
    return measureRemoteCall(
×
548
        ServiceMethod.GET_TASK_LISTS_BY_DOMAIN,
549
        () -> getTaskListsByDomain(getTaskListsByDomainRequest));
×
550
  }
551

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

589
  @Override
590
  public StartWorkflowExecutionResponse StartWorkflowExecution(
591
      StartWorkflowExecutionRequest request) throws TException {
592
    return measureRemoteCall(
×
593
        ServiceMethod.START_WORKFLOW_EXECUTION, () -> startWorkflowExecution(request));
×
594
  }
595

596
  private StartWorkflowExecutionResponse startWorkflowExecution(
597
      StartWorkflowExecutionRequest startRequest) throws TException {
598
    startRequest.setRequestId(UUID.randomUUID().toString());
×
599
    ThriftResponse<WorkflowService.StartWorkflowExecution_result> response = null;
×
600
    try {
601
      // Write span context to header
602
      if (!startRequest.isSetHeader()) {
×
603
        startRequest.setHeader(new Header());
×
604
      }
605
      tracingPropagator.inject(startRequest.getHeader());
×
606

607
      ThriftRequest<WorkflowService.StartWorkflowExecution_args> request =
×
608
          buildThriftRequest(
×
609
              "StartWorkflowExecution",
610
              new WorkflowService.StartWorkflowExecution_args(startRequest));
611

612
      response = doRemoteCall(request);
×
613
      WorkflowService.StartWorkflowExecution_result result =
×
614
          response.getBody(WorkflowService.StartWorkflowExecution_result.class);
×
615
      if (response.getResponseCode() == ResponseCode.OK) {
×
616
        return result.getSuccess();
×
617
      }
618
      if (result.isSetBadRequestError()) {
×
619
        throw result.getBadRequestError();
×
620
      }
621
      if (result.isSetSessionAlreadyExistError()) {
×
622
        throw result.getSessionAlreadyExistError();
×
623
      }
624
      if (result.isSetServiceBusyError()) {
×
625
        throw result.getServiceBusyError();
×
626
      }
627
      if (result.isSetDomainNotActiveError()) {
×
628
        throw result.getDomainNotActiveError();
×
629
      }
630
      if (result.isSetLimitExceededError()) {
×
631
        throw result.getLimitExceededError();
×
632
      }
633
      if (result.isSetEntityNotExistError()) {
×
634
        throw result.getEntityNotExistError();
×
635
      }
636
      throw new TException("StartWorkflowExecution failed with unknown error:" + result);
×
637
    } finally {
638
      if (response != null) {
×
639
        response.release();
×
640
      }
641
    }
642
  }
643

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

657
  @Override
658
  public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistory(
659
      GetWorkflowExecutionHistoryRequest request) throws TException {
660
    Map<String, String> tags =
×
661
        ImmutableMap.of(
×
662
            MetricsTag.REQUEST_TYPE,
663
            request.isWaitForNewEvent() ? REQUEST_TYPE_LONG_POLL : REQUEST_TYPE_NORMAL);
×
664
    return measureRemoteCallWithTags(
×
665
        ServiceMethod.GET_WORKFLOW_EXECUTION_HISTORY,
666
        () -> getWorkflowExecutionHistory(request, null),
×
667
        tags);
668
  }
669

670
  private GetWorkflowExecutionHistoryResponse getWorkflowExecutionHistory(
671
      GetWorkflowExecutionHistoryRequest getRequest, Long timeoutInMillis) throws TException {
672
    ThriftResponse<WorkflowService.GetWorkflowExecutionHistory_result> response = null;
×
673
    try {
674
      ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args> request =
×
675
          buildGetWorkflowExecutionHistoryThriftRequest(getRequest, timeoutInMillis);
×
676
      response = doRemoteCall(request);
×
677
      WorkflowService.GetWorkflowExecutionHistory_result result =
×
678
          response.getBody(WorkflowService.GetWorkflowExecutionHistory_result.class);
×
679
      if (response.getResponseCode() == ResponseCode.OK) {
×
680
        GetWorkflowExecutionHistoryResponse res = result.getSuccess();
×
681
        if (res.getRawHistory() != null) {
×
682
          History history =
×
683
              InternalUtils.DeserializeFromBlobDataToHistory(
×
684
                  res.getRawHistory(), getRequest.getHistoryEventFilterType());
×
685
          res.setHistory(history);
×
686
        }
687
        return res;
×
688
      }
689
      if (result.isSetBadRequestError()) {
×
690
        throw result.getBadRequestError();
×
691
      }
692
      if (result.isSetEntityNotExistError()) {
×
693
        throw result.getEntityNotExistError();
×
694
      }
695
      if (result.isSetServiceBusyError()) {
×
696
        throw result.getServiceBusyError();
×
697
      }
698
      throw new TException("GetWorkflowExecutionHistory failed with unknown error:" + result);
×
699
    } finally {
700
      if (response != null) {
×
701
        response.release();
×
702
      }
703
    }
704
  }
705

706
  private ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args>
707
      buildGetWorkflowExecutionHistoryThriftRequest(
708
          GetWorkflowExecutionHistoryRequest getRequest, Long timeoutInMillis) {
709

710
    if (getRequest.isWaitForNewEvent()) {
×
711
      timeoutInMillis =
×
712
          validateAndUpdateTimeout(timeoutInMillis, options.getRpcLongPollTimeoutMillis());
×
713
    } else {
714
      timeoutInMillis = validateAndUpdateTimeout(timeoutInMillis, options.getRpcTimeoutMillis());
×
715
    }
716

717
    return buildThriftRequest(
×
718
        "GetWorkflowExecutionHistory",
719
        new WorkflowService.GetWorkflowExecutionHistory_args(getRequest),
720
        timeoutInMillis);
721
  }
722

723
  @Override
724
  public PollForDecisionTaskResponse PollForDecisionTask(PollForDecisionTaskRequest request)
725
      throws TException {
726
    return measureRemoteCall(
×
727
        ServiceMethod.POLL_FOR_DECISION_TASK, () -> pollForDecisionTask(request));
×
728
  }
729

730
  private PollForDecisionTaskResponse pollForDecisionTask(PollForDecisionTaskRequest pollRequest)
731
      throws TException {
732
    ThriftResponse<WorkflowService.PollForDecisionTask_result> response = null;
1✔
733
    try {
734
      ThriftRequest<WorkflowService.PollForDecisionTask_args> request =
1✔
735
          buildThriftRequest(
1✔
736
              "PollForDecisionTask",
737
              new WorkflowService.PollForDecisionTask_args(pollRequest),
738
              options.getRpcLongPollTimeoutMillis());
1✔
739
      response = doRemoteCall(request);
×
740
      WorkflowService.PollForDecisionTask_result result =
×
741
          response.getBody(WorkflowService.PollForDecisionTask_result.class);
×
742
      if (response.getResponseCode() == ResponseCode.OK) {
×
743
        return result.getSuccess();
×
744
      }
745
      if (result.isSetBadRequestError()) {
×
746
        throw result.getBadRequestError();
×
747
      }
748
      if (result.isSetServiceBusyError()) {
×
749
        throw result.getServiceBusyError();
×
750
      }
751
      if (result.isSetDomainNotActiveError()) {
×
752
        throw result.getDomainNotActiveError();
×
753
      }
754
      if (result.isSetLimitExceededError()) {
×
755
        throw result.getLimitExceededError();
×
756
      }
757
      if (result.isSetEntityNotExistError()) {
×
758
        throw result.getEntityNotExistError();
×
759
      }
760
      if (result.isSetClientVersionNotSupportedError()) {
×
761
        throw result.getClientVersionNotSupportedError();
×
762
      }
763
      throw new TException("PollForDecisionTask failed with unknown error:" + result);
×
764
    } finally {
765
      if (response != null) {
1✔
766
        response.release();
×
767
      }
768
    }
769
  }
770

771
  @Override
772
  public RespondDecisionTaskCompletedResponse RespondDecisionTaskCompleted(
773
      RespondDecisionTaskCompletedRequest completedRequest) throws TException {
774
    return measureRemoteCall(
×
775
        ServiceMethod.RESPOND_DECISION_TASK_COMPLETED,
776
        () -> respondDecisionTaskCompleted(completedRequest));
×
777
  }
778

779
  private RespondDecisionTaskCompletedResponse respondDecisionTaskCompleted(
780
      RespondDecisionTaskCompletedRequest completedRequest) throws TException {
781
    ThriftResponse<WorkflowService.RespondDecisionTaskCompleted_result> response = null;
×
782
    try {
783
      ThriftRequest<WorkflowService.RespondDecisionTaskCompleted_args> request =
×
784
          buildThriftRequest(
×
785
              "RespondDecisionTaskCompleted",
786
              new WorkflowService.RespondDecisionTaskCompleted_args(completedRequest));
787
      response = doRemoteCall(request);
×
788
      WorkflowService.RespondDecisionTaskCompleted_result result =
×
789
          response.getBody(WorkflowService.RespondDecisionTaskCompleted_result.class);
×
790
      if (response.getResponseCode() == ResponseCode.OK) {
×
791
        return result.getSuccess();
×
792
      }
793
      if (result.isSetBadRequestError()) {
×
794
        throw result.getBadRequestError();
×
795
      }
796
      if (result.isSetServiceBusyError()) {
×
797
        throw result.getServiceBusyError();
×
798
      }
799
      if (result.isSetDomainNotActiveError()) {
×
800
        throw result.getDomainNotActiveError();
×
801
      }
802
      if (result.isSetLimitExceededError()) {
×
803
        throw result.getLimitExceededError();
×
804
      }
805
      if (result.isSetEntityNotExistError()) {
×
806
        throw result.getEntityNotExistError();
×
807
      }
808
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
809
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
810
      }
811
      if (result.isSetClientVersionNotSupportedError()) {
×
812
        throw result.getClientVersionNotSupportedError();
×
813
      }
814
      throw new TException("RespondDecisionTaskCompleted failed with unknown error:" + result);
×
815
    } finally {
816
      if (response != null) {
×
817
        response.release();
×
818
      }
819
    }
820
  }
821

822
  @Override
823
  public void RespondDecisionTaskFailed(RespondDecisionTaskFailedRequest request)
824
      throws TException {
825
    measureRemoteProc(
×
826
        ServiceMethod.RESPOND_DECISION_TASK_FAILED, () -> respondDecisionTaskFailed(request));
×
827
  }
×
828

829
  private void respondDecisionTaskFailed(RespondDecisionTaskFailedRequest failedRequest)
830
      throws TException {
831
    ThriftResponse<WorkflowService.RespondDecisionTaskFailed_result> response = null;
×
832
    try {
833
      ThriftRequest<WorkflowService.RespondDecisionTaskFailed_args> request =
×
834
          buildThriftRequest(
×
835
              "RespondDecisionTaskFailed",
836
              new WorkflowService.RespondDecisionTaskFailed_args(failedRequest));
837
      response = doRemoteCall(request);
×
838
      WorkflowService.RespondDecisionTaskFailed_result result =
×
839
          response.getBody(WorkflowService.RespondDecisionTaskFailed_result.class);
×
840
      if (response.getResponseCode() == ResponseCode.OK) {
×
841
        return;
×
842
      }
843
      if (result.isSetBadRequestError()) {
×
844
        throw result.getBadRequestError();
×
845
      }
846
      if (result.isSetEntityNotExistError()) {
×
847
        throw result.getEntityNotExistError();
×
848
      }
849
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
850
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
851
      }
852
      if (result.isSetServiceBusyError()) {
×
853
        throw result.getServiceBusyError();
×
854
      }
855
      if (result.isSetDomainNotActiveError()) {
×
856
        throw result.getDomainNotActiveError();
×
857
      }
858
      if (result.isSetLimitExceededError()) {
×
859
        throw result.getLimitExceededError();
×
860
      }
861
      if (result.isSetClientVersionNotSupportedError()) {
×
862
        throw result.getClientVersionNotSupportedError();
×
863
      }
864
      throw new TException("RespondDecisionTaskFailed failed with unknown error:" + result);
×
865
    } finally {
866
      if (response != null) {
×
867
        response.release();
×
868
      }
869
    }
870
  }
871

872
  @Override
873
  public PollForActivityTaskResponse PollForActivityTask(PollForActivityTaskRequest request)
874
      throws TException {
875
    return measureRemoteCall(
×
876
        ServiceMethod.POLL_FOR_ACTIVITY_TASK, () -> pollForActivityTask(request));
×
877
  }
878

879
  private PollForActivityTaskResponse pollForActivityTask(PollForActivityTaskRequest pollRequest)
880
      throws TException {
881
    ThriftResponse<WorkflowService.PollForActivityTask_result> response = null;
1✔
882
    try {
883
      ThriftRequest<WorkflowService.PollForActivityTask_args> request =
1✔
884
          buildThriftRequest(
1✔
885
              "PollForActivityTask",
886
              new WorkflowService.PollForActivityTask_args(pollRequest),
887
              options.getRpcLongPollTimeoutMillis());
1✔
888
      response = doRemoteCall(request);
×
889
      WorkflowService.PollForActivityTask_result result =
×
890
          response.getBody(WorkflowService.PollForActivityTask_result.class);
×
891
      if (response.getResponseCode() == ResponseCode.OK) {
×
892
        return result.getSuccess();
×
893
      }
894
      if (result.isSetBadRequestError()) {
×
895
        throw result.getBadRequestError();
×
896
      }
897
      if (result.isSetServiceBusyError()) {
×
898
        throw result.getServiceBusyError();
×
899
      }
900
      if (result.isSetEntityNotExistError()) {
×
901
        throw result.getEntityNotExistError();
×
902
      }
903
      if (result.isSetDomainNotActiveError()) {
×
904
        throw result.getDomainNotActiveError();
×
905
      }
906
      if (result.isSetLimitExceededError()) {
×
907
        throw result.getLimitExceededError();
×
908
      }
909
      if (result.isSetClientVersionNotSupportedError()) {
×
910
        throw result.getClientVersionNotSupportedError();
×
911
      }
912
      throw new TException("PollForActivityTask failed with unknown error:" + result);
×
913
    } finally {
914
      if (response != null) {
1✔
915
        response.release();
×
916
      }
917
    }
918
  }
919

920
  @Override
921
  public RecordActivityTaskHeartbeatResponse RecordActivityTaskHeartbeat(
922
      RecordActivityTaskHeartbeatRequest request) throws TException {
923
    return measureRemoteCall(
×
924
        ServiceMethod.RECORD_ACTIVITY_TASK_HEARTBEAT, () -> recordActivityTaskHeartbeat(request));
×
925
  }
926

927
  private RecordActivityTaskHeartbeatResponse recordActivityTaskHeartbeat(
928
      RecordActivityTaskHeartbeatRequest heartbeatRequest) throws TException {
929
    ThriftResponse<WorkflowService.RecordActivityTaskHeartbeat_result> response = null;
×
930
    try {
931
      ThriftRequest<WorkflowService.RecordActivityTaskHeartbeat_args> request =
×
932
          buildThriftRequest(
×
933
              "RecordActivityTaskHeartbeat",
934
              new WorkflowService.RecordActivityTaskHeartbeat_args(heartbeatRequest));
935
      response = doRemoteCall(request);
×
936
      WorkflowService.RecordActivityTaskHeartbeat_result result =
×
937
          response.getBody(WorkflowService.RecordActivityTaskHeartbeat_result.class);
×
938
      if (response.getResponseCode() == ResponseCode.OK) {
×
939
        return result.getSuccess();
×
940
      }
941
      if (result.isSetBadRequestError()) {
×
942
        throw result.getBadRequestError();
×
943
      }
944
      if (result.isSetEntityNotExistError()) {
×
945
        throw result.getEntityNotExistError();
×
946
      }
947
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
948
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
949
      }
950
      if (result.isSetServiceBusyError()) {
×
951
        throw result.getServiceBusyError();
×
952
      }
953
      if (result.isSetDomainNotActiveError()) {
×
954
        throw result.getDomainNotActiveError();
×
955
      }
956
      if (result.isSetLimitExceededError()) {
×
957
        throw result.getLimitExceededError();
×
958
      }
959
      if (result.isSetClientVersionNotSupportedError()) {
×
960
        throw result.getClientVersionNotSupportedError();
×
961
      }
962
      throw new TException("RecordActivityTaskHeartbeat failed with unknown error:" + result);
×
963
    } finally {
964
      if (response != null) {
×
965
        response.release();
×
966
      }
967
    }
968
  }
969

970
  @Override
971
  public RecordActivityTaskHeartbeatResponse RecordActivityTaskHeartbeatByID(
972
      RecordActivityTaskHeartbeatByIDRequest heartbeatRequest)
973
      throws BadRequestError, InternalServiceError, EntityNotExistsError, DomainNotActiveError,
974
          WorkflowExecutionAlreadyCompletedError, LimitExceededError, ServiceBusyError, TException {
975
    return measureRemoteCall(
×
976
        ServiceMethod.RECORD_ACTIVITY_TASK_HEARTBEAT_BY_ID,
977
        () -> recordActivityTaskHeartbeatByID(heartbeatRequest));
×
978
  }
979

980
  private RecordActivityTaskHeartbeatResponse recordActivityTaskHeartbeatByID(
981
      RecordActivityTaskHeartbeatByIDRequest heartbeatRequest) throws TException {
982
    ThriftResponse<WorkflowService.RecordActivityTaskHeartbeatByID_result> response = null;
×
983
    try {
984
      ThriftRequest<WorkflowService.RecordActivityTaskHeartbeatByID_args> request =
×
985
          buildThriftRequest(
×
986
              "RecordActivityTaskHeartbeatByID",
987
              new WorkflowService.RecordActivityTaskHeartbeatByID_args(heartbeatRequest));
988
      response = doRemoteCall(request);
×
989
      WorkflowService.RecordActivityTaskHeartbeatByID_result result =
×
990
          response.getBody(WorkflowService.RecordActivityTaskHeartbeatByID_result.class);
×
991
      if (response.getResponseCode() == ResponseCode.OK) {
×
992
        return result.getSuccess();
×
993
      }
994
      if (result.isSetBadRequestError()) {
×
995
        throw result.getBadRequestError();
×
996
      }
997
      if (result.isSetEntityNotExistError()) {
×
998
        throw result.getEntityNotExistError();
×
999
      }
1000
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
1001
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1002
      }
1003
      if (result.isSetServiceBusyError()) {
×
1004
        throw result.getServiceBusyError();
×
1005
      }
1006
      if (result.isSetDomainNotActiveError()) {
×
1007
        throw result.getDomainNotActiveError();
×
1008
      }
1009
      if (result.isSetLimitExceededError()) {
×
1010
        throw result.getLimitExceededError();
×
1011
      }
1012
      if (result.isSetClientVersionNotSupportedError()) {
×
1013
        throw result.getClientVersionNotSupportedError();
×
1014
      }
1015
      throw new TException("RecordActivityTaskHeartbeatByID failed with unknown error:" + result);
×
1016
    } finally {
1017
      if (response != null) {
×
1018
        response.release();
×
1019
      }
1020
    }
1021
  }
1022

1023
  @Override
1024
  public void RespondActivityTaskCompleted(RespondActivityTaskCompletedRequest request)
1025
      throws TException {
1026
    measureRemoteProc(
×
1027
        ServiceMethod.RESPOND_ACTIVITY_TASK_COMPLETED, () -> respondActivityTaskCompleted(request));
×
1028
  }
×
1029

1030
  private void respondActivityTaskCompleted(RespondActivityTaskCompletedRequest completeRequest)
1031
      throws TException {
1032
    ThriftResponse<WorkflowService.RespondActivityTaskCompleted_result> response = null;
×
1033
    try {
1034
      ThriftRequest<WorkflowService.RespondActivityTaskCompleted_args> request =
×
1035
          buildThriftRequest(
×
1036
              "RespondActivityTaskCompleted",
1037
              new WorkflowService.RespondActivityTaskCompleted_args(completeRequest));
1038
      response = doRemoteCall(request);
×
1039
      WorkflowService.RespondActivityTaskCompleted_result result =
×
1040
          response.getBody(WorkflowService.RespondActivityTaskCompleted_result.class);
×
1041
      if (response.getResponseCode() == ResponseCode.OK) {
×
1042
        return;
×
1043
      }
1044
      if (result.isSetBadRequestError()) {
×
1045
        throw result.getBadRequestError();
×
1046
      }
1047
      if (result.isSetEntityNotExistError()) {
×
1048
        throw result.getEntityNotExistError();
×
1049
      }
1050
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
1051
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1052
      }
1053
      if (result.isSetServiceBusyError()) {
×
1054
        throw result.getServiceBusyError();
×
1055
      }
1056
      if (result.isSetDomainNotActiveError()) {
×
1057
        throw result.getDomainNotActiveError();
×
1058
      }
1059
      if (result.isSetLimitExceededError()) {
×
1060
        throw result.getLimitExceededError();
×
1061
      }
1062
      if (result.isSetClientVersionNotSupportedError()) {
×
1063
        throw result.getClientVersionNotSupportedError();
×
1064
      }
1065
      throw new TException("RespondActivityTaskCompleted failed with unknown error:" + result);
×
1066
    } finally {
1067
      if (response != null) {
×
1068
        response.release();
×
1069
      }
1070
    }
1071
  }
1072

1073
  @Override
1074
  public void RespondActivityTaskCompletedByID(RespondActivityTaskCompletedByIDRequest request)
1075
      throws TException {
1076
    measureRemoteProc(
×
1077
        ServiceMethod.RESPOND_ACTIVITY_TASK_COMPLETED_BY_ID,
1078
        () -> respondActivityTaskCompletedByID(request));
×
1079
  }
×
1080

1081
  private void respondActivityTaskCompletedByID(
1082
      RespondActivityTaskCompletedByIDRequest completeRequest) throws TException {
1083
    ThriftResponse<WorkflowService.RespondActivityTaskCompletedByID_result> response = null;
×
1084
    try {
1085
      ThriftRequest<WorkflowService.RespondActivityTaskCompletedByID_args> request =
×
1086
          buildThriftRequest(
×
1087
              "RespondActivityTaskCompletedByID",
1088
              new WorkflowService.RespondActivityTaskCompletedByID_args(completeRequest));
1089
      response = doRemoteCall(request);
×
1090
      WorkflowService.RespondActivityTaskCompletedByID_result result =
×
1091
          response.getBody(WorkflowService.RespondActivityTaskCompletedByID_result.class);
×
1092
      if (response.getResponseCode() == ResponseCode.OK) {
×
1093
        return;
×
1094
      }
1095
      if (result.isSetBadRequestError()) {
×
1096
        throw result.getBadRequestError();
×
1097
      }
1098
      if (result.isSetEntityNotExistError()) {
×
1099
        throw result.getEntityNotExistError();
×
1100
      }
1101
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
1102
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1103
      }
1104
      if (result.isSetServiceBusyError()) {
×
1105
        throw result.getServiceBusyError();
×
1106
      }
1107
      if (result.isSetDomainNotActiveError()) {
×
1108
        throw result.getDomainNotActiveError();
×
1109
      }
1110
      if (result.isSetLimitExceededError()) {
×
1111
        throw result.getLimitExceededError();
×
1112
      }
1113
      if (result.isSetClientVersionNotSupportedError()) {
×
1114
        throw result.getClientVersionNotSupportedError();
×
1115
      }
1116
      throw new TException("RespondActivityTaskCompletedByID failed with unknown error:" + result);
×
1117
    } finally {
1118
      if (response != null) {
×
1119
        response.release();
×
1120
      }
1121
    }
1122
  }
1123

1124
  @Override
1125
  public void RespondActivityTaskFailed(RespondActivityTaskFailedRequest request)
1126
      throws TException {
1127
    measureRemoteProc(
×
1128
        ServiceMethod.RESPOND_ACTIVITY_TASK_FAILED, () -> respondActivityTaskFailed(request));
×
1129
  }
×
1130

1131
  private void respondActivityTaskFailed(RespondActivityTaskFailedRequest failRequest)
1132
      throws TException {
1133
    ThriftResponse<WorkflowService.RespondActivityTaskFailed_result> response = null;
×
1134
    try {
1135
      ThriftRequest<WorkflowService.RespondActivityTaskFailed_args> request =
×
1136
          buildThriftRequest(
×
1137
              "RespondActivityTaskFailed",
1138
              new WorkflowService.RespondActivityTaskFailed_args(failRequest));
1139
      response = doRemoteCall(request);
×
1140
      WorkflowService.RespondActivityTaskFailed_result result =
×
1141
          response.getBody(WorkflowService.RespondActivityTaskFailed_result.class);
×
1142
      if (response.getResponseCode() == ResponseCode.OK) {
×
1143
        return;
×
1144
      }
1145
      if (result.isSetBadRequestError()) {
×
1146
        throw result.getBadRequestError();
×
1147
      }
1148
      if (result.isSetEntityNotExistError()) {
×
1149
        throw result.getEntityNotExistError();
×
1150
      }
1151
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
1152
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1153
      }
1154
      if (result.isSetServiceBusyError()) {
×
1155
        throw result.getServiceBusyError();
×
1156
      }
1157
      if (result.isSetDomainNotActiveError()) {
×
1158
        throw result.getDomainNotActiveError();
×
1159
      }
1160
      if (result.isSetLimitExceededError()) {
×
1161
        throw result.getLimitExceededError();
×
1162
      }
1163
      if (result.isSetClientVersionNotSupportedError()) {
×
1164
        throw result.getClientVersionNotSupportedError();
×
1165
      }
1166
      throw new TException("RespondActivityTaskFailed failed with unknown error:" + result);
×
1167
    } finally {
1168
      if (response != null) {
×
1169
        response.release();
×
1170
      }
1171
    }
1172
  }
1173

1174
  @Override
1175
  public void RespondActivityTaskFailedByID(RespondActivityTaskFailedByIDRequest request)
1176
      throws TException {
1177
    measureRemoteProc(
×
1178
        ServiceMethod.RESPOND_ACTIVITY_TASK_FAILED_BY_ID,
1179
        () -> respondActivityTaskFailedByID(request));
×
1180
  }
×
1181

1182
  private void respondActivityTaskFailedByID(RespondActivityTaskFailedByIDRequest failRequest)
1183
      throws TException {
1184
    ThriftResponse<WorkflowService.RespondActivityTaskFailedByID_result> response = null;
×
1185
    try {
1186
      ThriftRequest<WorkflowService.RespondActivityTaskFailedByID_args> request =
×
1187
          buildThriftRequest(
×
1188
              "RespondActivityTaskFailedByID",
1189
              new WorkflowService.RespondActivityTaskFailedByID_args(failRequest));
1190
      response = doRemoteCall(request);
×
1191
      WorkflowService.RespondActivityTaskFailedByID_result result =
×
1192
          response.getBody(WorkflowService.RespondActivityTaskFailedByID_result.class);
×
1193
      if (response.getResponseCode() == ResponseCode.OK) {
×
1194
        return;
×
1195
      }
1196
      if (result.isSetBadRequestError()) {
×
1197
        throw result.getBadRequestError();
×
1198
      }
1199
      if (result.isSetEntityNotExistError()) {
×
1200
        throw result.getEntityNotExistError();
×
1201
      }
1202
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
1203
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1204
      }
1205
      if (result.isSetServiceBusyError()) {
×
1206
        throw result.getServiceBusyError();
×
1207
      }
1208
      if (result.isSetDomainNotActiveError()) {
×
1209
        throw result.getDomainNotActiveError();
×
1210
      }
1211
      if (result.isSetLimitExceededError()) {
×
1212
        throw result.getLimitExceededError();
×
1213
      }
1214
      if (result.isSetClientVersionNotSupportedError()) {
×
1215
        throw result.getClientVersionNotSupportedError();
×
1216
      }
1217
      throw new TException("RespondActivityTaskFailedByID failedByID with unknown error:" + result);
×
1218
    } finally {
1219
      if (response != null) {
×
1220
        response.release();
×
1221
      }
1222
    }
1223
  }
1224

1225
  @Override
1226
  public void RespondActivityTaskCanceled(RespondActivityTaskCanceledRequest request)
1227
      throws TException {
1228
    measureRemoteProc(
×
1229
        ServiceMethod.RESPOND_ACTIVITY_TASK_CANCELED, () -> respondActivityTaskCanceled(request));
×
1230
  }
×
1231

1232
  private void respondActivityTaskCanceled(RespondActivityTaskCanceledRequest canceledRequest)
1233
      throws TException {
1234
    ThriftResponse<WorkflowService.RespondActivityTaskCanceled_result> response = null;
×
1235
    try {
1236
      ThriftRequest<WorkflowService.RespondActivityTaskCanceled_args> request =
×
1237
          buildThriftRequest(
×
1238
              "RespondActivityTaskCanceled",
1239
              new WorkflowService.RespondActivityTaskCanceled_args(canceledRequest));
1240
      response = doRemoteCall(request);
×
1241
      WorkflowService.RespondActivityTaskCanceled_result result =
×
1242
          response.getBody(WorkflowService.RespondActivityTaskCanceled_result.class);
×
1243
      if (response.getResponseCode() == ResponseCode.OK) {
×
1244
        return;
×
1245
      }
1246
      if (result.isSetBadRequestError()) {
×
1247
        throw result.getBadRequestError();
×
1248
      }
1249
      if (result.isSetEntityNotExistError()) {
×
1250
        throw result.getEntityNotExistError();
×
1251
      }
1252
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
1253
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1254
      }
1255
      if (result.isSetServiceBusyError()) {
×
1256
        throw result.getServiceBusyError();
×
1257
      }
1258
      if (result.isSetDomainNotActiveError()) {
×
1259
        throw result.getDomainNotActiveError();
×
1260
      }
1261
      if (result.isSetLimitExceededError()) {
×
1262
        throw result.getLimitExceededError();
×
1263
      }
1264
      if (result.isSetClientVersionNotSupportedError()) {
×
1265
        throw result.getClientVersionNotSupportedError();
×
1266
      }
1267
      throw new TException("RespondActivityTaskCanceled failed with unknown error:" + result);
×
1268
    } finally {
1269
      if (response != null) {
×
1270
        response.release();
×
1271
      }
1272
    }
1273
  }
1274

1275
  @Override
1276
  public void RespondActivityTaskCanceledByID(RespondActivityTaskCanceledByIDRequest request)
1277
      throws TException {
1278
    measureRemoteProc(
×
1279
        ServiceMethod.RESPOND_ACTIVITY_TASK_CANCELED_BY_ID,
1280
        () -> respondActivityTaskCanceledByID(request));
×
1281
  }
×
1282

1283
  private void respondActivityTaskCanceledByID(
1284
      RespondActivityTaskCanceledByIDRequest canceledByIDRequest) throws TException {
1285
    ThriftResponse<WorkflowService.RespondActivityTaskCanceledByID_result> response = null;
×
1286
    try {
1287
      ThriftRequest<WorkflowService.RespondActivityTaskCanceledByID_args> request =
×
1288
          buildThriftRequest(
×
1289
              "RespondActivityTaskCanceledByID",
1290
              new WorkflowService.RespondActivityTaskCanceledByID_args(canceledByIDRequest));
1291
      response = doRemoteCall(request);
×
1292
      WorkflowService.RespondActivityTaskCanceledByID_result result =
×
1293
          response.getBody(WorkflowService.RespondActivityTaskCanceledByID_result.class);
×
1294
      if (response.getResponseCode() == ResponseCode.OK) {
×
1295
        return;
×
1296
      }
1297
      if (result.isSetBadRequestError()) {
×
1298
        throw result.getBadRequestError();
×
1299
      }
1300
      if (result.isSetEntityNotExistError()) {
×
1301
        throw result.getEntityNotExistError();
×
1302
      }
1303
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
1304
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1305
      }
1306
      if (result.isSetServiceBusyError()) {
×
1307
        throw result.getServiceBusyError();
×
1308
      }
1309
      if (result.isSetDomainNotActiveError()) {
×
1310
        throw result.getDomainNotActiveError();
×
1311
      }
1312
      if (result.isSetLimitExceededError()) {
×
1313
        throw result.getLimitExceededError();
×
1314
      }
1315
      if (result.isSetClientVersionNotSupportedError()) {
×
1316
        throw result.getClientVersionNotSupportedError();
×
1317
      }
1318
      throw new TException("RespondActivityTaskCanceledByID failed with unknown error:" + result);
×
1319
    } finally {
1320
      if (response != null) {
×
1321
        response.release();
×
1322
      }
1323
    }
1324
  }
1325

1326
  @Override
1327
  public void RequestCancelWorkflowExecution(RequestCancelWorkflowExecutionRequest request)
1328
      throws TException {
1329
    measureRemoteProc(
×
1330
        ServiceMethod.REQUEST_CANCEL_WORKFLOW_EXECUTION,
1331
        () -> requestCancelWorkflowExecution(request));
×
1332
  }
×
1333

1334
  private void requestCancelWorkflowExecution(RequestCancelWorkflowExecutionRequest cancelRequest)
1335
      throws TException {
1336
    cancelRequest.setRequestId(UUID.randomUUID().toString());
×
1337
    ThriftResponse<WorkflowService.RequestCancelWorkflowExecution_result> response = null;
×
1338
    try {
1339
      ThriftRequest<WorkflowService.RequestCancelWorkflowExecution_args> request =
×
1340
          buildThriftRequest(
×
1341
              "RequestCancelWorkflowExecution",
1342
              new WorkflowService.RequestCancelWorkflowExecution_args(cancelRequest));
1343
      response = doRemoteCall(request);
×
1344
      WorkflowService.RequestCancelWorkflowExecution_result result =
×
1345
          response.getBody(WorkflowService.RequestCancelWorkflowExecution_result.class);
×
1346
      if (response.getResponseCode() == ResponseCode.OK) {
×
1347
        return;
×
1348
      }
1349
      if (result.isSetBadRequestError()) {
×
1350
        throw result.getBadRequestError();
×
1351
      }
1352
      if (result.isSetEntityNotExistError()) {
×
1353
        throw result.getEntityNotExistError();
×
1354
      }
1355
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
1356
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1357
      }
1358
      if (result.isSetCancellationAlreadyRequestedError()) {
×
1359
        throw result.getCancellationAlreadyRequestedError();
×
1360
      }
1361
      if (result.isSetServiceBusyError()) {
×
1362
        throw result.getServiceBusyError();
×
1363
      }
1364
      if (result.isSetDomainNotActiveError()) {
×
1365
        throw result.getDomainNotActiveError();
×
1366
      }
1367
      if (result.isSetLimitExceededError()) {
×
1368
        throw result.getLimitExceededError();
×
1369
      }
1370
      if (result.isSetClientVersionNotSupportedError()) {
×
1371
        throw result.getClientVersionNotSupportedError();
×
1372
      }
1373
      throw new TException("RequestCancelWorkflowExecution failed with unknown error:" + result);
×
1374
    } finally {
1375
      if (response != null) {
×
1376
        response.release();
×
1377
      }
1378
    }
1379
  }
1380

1381
  @Override
1382
  public void SignalWorkflowExecution(SignalWorkflowExecutionRequest request) throws TException {
1383
    measureRemoteProc(
×
1384
        ServiceMethod.SIGNAL_WORKFLOW_EXECUTION, () -> signalWorkflowExecution(request));
×
1385
  }
×
1386

1387
  private void signalWorkflowExecution(SignalWorkflowExecutionRequest signalRequest)
1388
      throws TException {
1389
    ThriftResponse<WorkflowService.SignalWorkflowExecution_result> response = null;
×
1390
    try {
1391
      ThriftRequest<WorkflowService.SignalWorkflowExecution_args> request =
×
1392
          buildThriftRequest(
×
1393
              "SignalWorkflowExecution",
1394
              new WorkflowService.SignalWorkflowExecution_args(signalRequest));
1395
      response = doRemoteCall(request);
×
1396
      WorkflowService.SignalWorkflowExecution_result result =
×
1397
          response.getBody(WorkflowService.SignalWorkflowExecution_result.class);
×
1398
      if (response.getResponseCode() == ResponseCode.OK) {
×
1399
        return;
×
1400
      }
1401
      if (result.isSetBadRequestError()) {
×
1402
        throw result.getBadRequestError();
×
1403
      }
1404
      if (result.isSetEntityNotExistError()) {
×
1405
        throw result.getEntityNotExistError();
×
1406
      }
1407
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
1408
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1409
      }
1410
      if (result.isSetServiceBusyError()) {
×
1411
        throw result.getServiceBusyError();
×
1412
      }
1413
      if (result.isSetDomainNotActiveError()) {
×
1414
        throw result.getDomainNotActiveError();
×
1415
      }
1416
      if (result.isSetLimitExceededError()) {
×
1417
        throw result.getLimitExceededError();
×
1418
      }
1419
      if (result.isSetClientVersionNotSupportedError()) {
×
1420
        throw result.getClientVersionNotSupportedError();
×
1421
      }
1422
      throw new TException("SignalWorkflowExecution failed with unknown error:" + result);
×
1423
    } finally {
1424
      if (response != null) {
×
1425
        response.release();
×
1426
      }
1427
    }
1428
  }
1429

1430
  @Override
1431
  public StartWorkflowExecutionResponse SignalWithStartWorkflowExecution(
1432
      SignalWithStartWorkflowExecutionRequest signalWithStartRequest) throws TException {
1433
    return measureRemoteCall(
×
1434
        ServiceMethod.SIGNAL_WITH_START_WORKFLOW_EXECUTION,
1435
        () -> signalWithStartWorkflowExecution(signalWithStartRequest));
×
1436
  }
1437

1438
  @Override
1439
  public ResetWorkflowExecutionResponse ResetWorkflowExecution(
1440
      ResetWorkflowExecutionRequest resetRequest)
1441
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1442
          DomainNotActiveError, LimitExceededError, ClientVersionNotSupportedError, TException {
1443
    return measureRemoteCall(
×
1444
        ServiceMethod.RESET_WORKFLOW_EXECUTION, () -> resetWorkflowExecution(resetRequest));
×
1445
  }
1446

1447
  private ResetWorkflowExecutionResponse resetWorkflowExecution(
1448
      ResetWorkflowExecutionRequest resetRequest) throws TException {
1449
    ThriftResponse<WorkflowService.ResetWorkflowExecution_result> response = null;
×
1450
    try {
1451
      ThriftRequest<WorkflowService.ResetWorkflowExecution_args> request =
×
1452
          buildThriftRequest(
×
1453
              "ResetWorkflowExecution",
1454
              new WorkflowService.ResetWorkflowExecution_args(resetRequest));
1455
      response = doRemoteCall(request);
×
1456
      WorkflowService.ResetWorkflowExecution_result result =
×
1457
          response.getBody(WorkflowService.ResetWorkflowExecution_result.class);
×
1458
      if (response.getResponseCode() == ResponseCode.OK) {
×
1459
        return result.getSuccess();
×
1460
      }
1461
      if (result.isSetBadRequestError()) {
×
1462
        throw result.getBadRequestError();
×
1463
      }
1464
      if (result.isSetEntityNotExistError()) {
×
1465
        throw result.getEntityNotExistError();
×
1466
      }
1467
      if (result.isSetServiceBusyError()) {
×
1468
        throw result.getServiceBusyError();
×
1469
      }
1470
      if (result.isSetDomainNotActiveError()) {
×
1471
        throw result.getDomainNotActiveError();
×
1472
      }
1473
      if (result.isSetLimitExceededError()) {
×
1474
        throw result.getLimitExceededError();
×
1475
      }
1476
      if (result.isSetClientVersionNotSupportedError()) {
×
1477
        throw result.getClientVersionNotSupportedError();
×
1478
      }
1479
      throw new TException("ResetWorkflowExecution failed with unknown error:" + result);
×
1480
    } finally {
1481
      if (response != null) {
×
1482
        response.release();
×
1483
      }
1484
    }
1485
  }
1486

1487
  private StartWorkflowExecutionResponse signalWithStartWorkflowExecution(
1488
      SignalWithStartWorkflowExecutionRequest signalWithStartRequest) throws TException {
1489
    signalWithStartRequest.setRequestId(UUID.randomUUID().toString());
×
1490
    ThriftResponse<WorkflowService.SignalWithStartWorkflowExecution_result> response = null;
×
1491
    try {
1492
      // Write span context to header
1493
      if (!signalWithStartRequest.isSetHeader()) {
×
1494
        signalWithStartRequest.setHeader(new Header());
×
1495
      }
1496
      tracingPropagator.inject(signalWithStartRequest.getHeader());
×
1497

1498
      ThriftRequest<WorkflowService.SignalWithStartWorkflowExecution_args> request =
×
1499
          buildThriftRequest(
×
1500
              "SignalWithStartWorkflowExecution",
1501
              new WorkflowService.SignalWithStartWorkflowExecution_args(signalWithStartRequest));
1502

1503
      response = doRemoteCall(request);
×
1504
      WorkflowService.SignalWithStartWorkflowExecution_result result =
×
1505
          response.getBody(WorkflowService.SignalWithStartWorkflowExecution_result.class);
×
1506
      if (response.getResponseCode() == ResponseCode.OK) {
×
1507
        return result.getSuccess();
×
1508
      }
1509
      if (result.isSetBadRequestError()) {
×
1510
        throw result.getBadRequestError();
×
1511
      }
1512
      if (result.isSetEntityNotExistError()) {
×
1513
        throw result.getEntityNotExistError();
×
1514
      }
1515
      if (result.isSetServiceBusyError()) {
×
1516
        throw result.getServiceBusyError();
×
1517
      }
1518
      if (result.isSetDomainNotActiveError()) {
×
1519
        throw result.getDomainNotActiveError();
×
1520
      }
1521
      if (result.isSetLimitExceededError()) {
×
1522
        throw result.getLimitExceededError();
×
1523
      }
1524
      if (result.isSetDomainNotActiveError()) {
×
1525
        throw result.getDomainNotActiveError();
×
1526
      }
1527
      if (result.isSetClientVersionNotSupportedError()) {
×
1528
        throw result.getClientVersionNotSupportedError();
×
1529
      }
1530
      throw new TException("SignalWithStartWorkflowExecution failed with unknown error:" + result);
×
1531
    } finally {
1532
      if (response != null) {
×
1533
        response.release();
×
1534
      }
1535
    }
1536
  }
1537

1538
  @Override
1539
  public void TerminateWorkflowExecution(TerminateWorkflowExecutionRequest request)
1540
      throws TException {
1541
    measureRemoteProc(
×
1542
        ServiceMethod.TERMINATE_WORKFLOW_EXECUTION, () -> terminateWorkflowExecution(request));
×
1543
  }
×
1544

1545
  private void terminateWorkflowExecution(TerminateWorkflowExecutionRequest terminateRequest)
1546
      throws TException {
1547
    ThriftResponse<WorkflowService.TerminateWorkflowExecution_result> response = null;
×
1548
    try {
1549
      ThriftRequest<WorkflowService.TerminateWorkflowExecution_args> request =
×
1550
          buildThriftRequest(
×
1551
              "TerminateWorkflowExecution",
1552
              new WorkflowService.TerminateWorkflowExecution_args(terminateRequest));
1553
      response = doRemoteCall(request);
×
1554
      WorkflowService.TerminateWorkflowExecution_result result =
×
1555
          response.getBody(WorkflowService.TerminateWorkflowExecution_result.class);
×
1556
      if (response.getResponseCode() == ResponseCode.OK) {
×
1557
        return;
×
1558
      }
1559
      if (result.isSetBadRequestError()) {
×
1560
        throw result.getBadRequestError();
×
1561
      }
1562
      if (result.isSetEntityNotExistError()) {
×
1563
        throw result.getEntityNotExistError();
×
1564
      }
1565
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
1566
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1567
      }
1568
      if (result.isSetServiceBusyError()) {
×
1569
        throw result.getServiceBusyError();
×
1570
      }
1571
      if (result.isSetDomainNotActiveError()) {
×
1572
        throw result.getDomainNotActiveError();
×
1573
      }
1574
      if (result.isSetLimitExceededError()) {
×
1575
        throw result.getLimitExceededError();
×
1576
      }
1577
      if (result.isSetClientVersionNotSupportedError()) {
×
1578
        throw result.getClientVersionNotSupportedError();
×
1579
      }
1580
      throw new TException("TerminateWorkflowExecution failed with unknown error:" + result);
×
1581
    } finally {
1582
      if (response != null) {
×
1583
        response.release();
×
1584
      }
1585
    }
1586
  }
1587

1588
  @Override
1589
  public ListOpenWorkflowExecutionsResponse ListOpenWorkflowExecutions(
1590
      ListOpenWorkflowExecutionsRequest request) throws TException {
1591
    return measureRemoteCall(
×
1592
        ServiceMethod.LIST_OPEN_WORKFLOW_EXECUTIONS, () -> listOpenWorkflowExecutions(request));
×
1593
  }
1594

1595
  private ListOpenWorkflowExecutionsResponse listOpenWorkflowExecutions(
1596
      ListOpenWorkflowExecutionsRequest listRequest) throws TException {
1597
    ThriftResponse<WorkflowService.ListOpenWorkflowExecutions_result> response = null;
×
1598
    try {
1599
      ThriftRequest<WorkflowService.ListOpenWorkflowExecutions_args> request =
×
1600
          buildThriftRequest(
×
1601
              "ListOpenWorkflowExecutions",
1602
              new WorkflowService.ListOpenWorkflowExecutions_args(listRequest));
1603
      response = doRemoteCall(request);
×
1604
      WorkflowService.ListOpenWorkflowExecutions_result result =
×
1605
          response.getBody(WorkflowService.ListOpenWorkflowExecutions_result.class);
×
1606
      if (response.getResponseCode() == ResponseCode.OK) {
×
1607
        return result.getSuccess();
×
1608
      }
1609
      if (result.isSetBadRequestError()) {
×
1610
        throw result.getBadRequestError();
×
1611
      }
1612
      if (result.isSetEntityNotExistError()) {
×
1613
        throw result.getEntityNotExistError();
×
1614
      }
1615
      if (result.isSetServiceBusyError()) {
×
1616
        throw result.getServiceBusyError();
×
1617
      }
1618
      if (result.isSetLimitExceededError()) {
×
1619
        throw result.getLimitExceededError();
×
1620
      }
1621
      if (result.isSetClientVersionNotSupportedError()) {
×
1622
        throw result.getClientVersionNotSupportedError();
×
1623
      }
1624
      throw new TException("ListOpenWorkflowExecutions failed with unknown error:" + result);
×
1625
    } finally {
1626
      if (response != null) {
×
1627
        response.release();
×
1628
      }
1629
    }
1630
  }
1631

1632
  @Override
1633
  public ListClosedWorkflowExecutionsResponse ListClosedWorkflowExecutions(
1634
      ListClosedWorkflowExecutionsRequest request) throws TException {
1635
    return measureRemoteCall(
×
1636
        ServiceMethod.LIST_CLOSED_WORKFLOW_EXECUTIONS, () -> listClosedWorkflowExecutions(request));
×
1637
  }
1638

1639
  private ListClosedWorkflowExecutionsResponse listClosedWorkflowExecutions(
1640
      ListClosedWorkflowExecutionsRequest listRequest) throws TException {
1641
    ThriftResponse<WorkflowService.ListClosedWorkflowExecutions_result> response = null;
×
1642
    try {
1643
      ThriftRequest<WorkflowService.ListClosedWorkflowExecutions_args> request =
×
1644
          buildThriftRequest(
×
1645
              "ListClosedWorkflowExecutions",
1646
              new WorkflowService.ListClosedWorkflowExecutions_args(listRequest));
1647
      response = doRemoteCall(request);
×
1648
      WorkflowService.ListClosedWorkflowExecutions_result result =
×
1649
          response.getBody(WorkflowService.ListClosedWorkflowExecutions_result.class);
×
1650
      if (response.getResponseCode() == ResponseCode.OK) {
×
1651
        return result.getSuccess();
×
1652
      }
1653
      if (result.isSetBadRequestError()) {
×
1654
        throw result.getBadRequestError();
×
1655
      }
1656
      if (result.isSetEntityNotExistError()) {
×
1657
        throw result.getEntityNotExistError();
×
1658
      }
1659
      if (result.isSetServiceBusyError()) {
×
1660
        throw result.getServiceBusyError();
×
1661
      }
1662
      if (result.isSetClientVersionNotSupportedError()) {
×
1663
        throw result.getClientVersionNotSupportedError();
×
1664
      }
1665
      throw new TException("ListClosedWorkflowExecutions failed with unknown error:" + result);
×
1666
    } finally {
1667
      if (response != null) {
×
1668
        response.release();
×
1669
      }
1670
    }
1671
  }
1672

1673
  @Override
1674
  public ListWorkflowExecutionsResponse ListWorkflowExecutions(
1675
      ListWorkflowExecutionsRequest request)
1676
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1677
          ClientVersionNotSupportedError, TException {
1678
    return measureRemoteCall(
×
1679
        ServiceMethod.LIST_WORKFLOW_EXECUTIONS, () -> listWorkflowExecutions(request));
×
1680
  }
1681

1682
  private ListWorkflowExecutionsResponse listWorkflowExecutions(
1683
      ListWorkflowExecutionsRequest listRequest) throws TException {
1684
    ThriftResponse<WorkflowService.ListWorkflowExecutions_result> response = null;
×
1685
    try {
1686
      ThriftRequest<WorkflowService.ListWorkflowExecutions_args> request =
×
1687
          buildThriftRequest(
×
1688
              "ListWorkflowExecutions",
1689
              new WorkflowService.ListWorkflowExecutions_args(listRequest));
1690
      response = doRemoteCall(request);
×
1691
      WorkflowService.ListWorkflowExecutions_result result =
×
1692
          response.getBody(WorkflowService.ListWorkflowExecutions_result.class);
×
1693
      if (response.getResponseCode() == ResponseCode.OK) {
×
1694
        return result.getSuccess();
×
1695
      }
1696
      if (result.isSetBadRequestError()) {
×
1697
        throw result.getBadRequestError();
×
1698
      }
1699
      if (result.isSetEntityNotExistError()) {
×
1700
        throw result.getEntityNotExistError();
×
1701
      }
1702
      if (result.isSetServiceBusyError()) {
×
1703
        throw result.getServiceBusyError();
×
1704
      }
1705
      if (result.isSetClientVersionNotSupportedError()) {
×
1706
        throw result.getClientVersionNotSupportedError();
×
1707
      }
1708
      throw new TException("ListWorkflowExecutions failed with unknown error:" + result);
×
1709
    } finally {
1710
      if (response != null) {
×
1711
        response.release();
×
1712
      }
1713
    }
1714
  }
1715

1716
  @Override
1717
  public ListArchivedWorkflowExecutionsResponse ListArchivedWorkflowExecutions(
1718
      ListArchivedWorkflowExecutionsRequest listRequest)
1719
      throws BadRequestError, EntityNotExistsError, ServiceBusyError,
1720
          ClientVersionNotSupportedError, TException {
1721
    return measureRemoteCall(
×
1722
        ServiceMethod.LIST_ARCHIVED_WORKFLOW_EXECUTIONS,
1723
        () -> listArchivedWorkflowExecutions(listRequest));
×
1724
  }
1725

1726
  private ListArchivedWorkflowExecutionsResponse listArchivedWorkflowExecutions(
1727
      ListArchivedWorkflowExecutionsRequest listRequest) throws TException {
1728
    ThriftResponse<WorkflowService.ListArchivedWorkflowExecutions_result> response = null;
×
1729
    try {
1730
      ThriftRequest<WorkflowService.ListArchivedWorkflowExecutions_args> request =
×
1731
          buildThriftRequest(
×
1732
              "ListArchivedWorkflowExecutions",
1733
              new WorkflowService.ListArchivedWorkflowExecutions_args(listRequest),
1734
              options.getRpcListArchivedWorkflowTimeoutMillis());
×
1735
      response = doRemoteCall(request);
×
1736
      WorkflowService.ListArchivedWorkflowExecutions_result result =
×
1737
          response.getBody(WorkflowService.ListArchivedWorkflowExecutions_result.class);
×
1738
      if (response.getResponseCode() == ResponseCode.OK) {
×
1739
        return result.getSuccess();
×
1740
      }
1741
      if (result.isSetBadRequestError()) {
×
1742
        throw result.getBadRequestError();
×
1743
      }
1744
      if (result.isSetEntityNotExistError()) {
×
1745
        throw result.getEntityNotExistError();
×
1746
      }
1747
      if (result.isSetServiceBusyError()) {
×
1748
        throw result.getServiceBusyError();
×
1749
      }
1750
      if (result.isSetClientVersionNotSupportedError()) {
×
1751
        throw result.getClientVersionNotSupportedError();
×
1752
      }
1753
      throw new TException("ListArchivedWorkflowExecutions failed with unknown error:" + result);
×
1754
    } finally {
1755
      if (response != null) {
×
1756
        response.release();
×
1757
      }
1758
    }
1759
  }
1760

1761
  @Override
1762
  public ListWorkflowExecutionsResponse ScanWorkflowExecutions(
1763
      ListWorkflowExecutionsRequest request)
1764
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1765
          ClientVersionNotSupportedError, TException {
1766
    return measureRemoteCall(
×
1767
        ServiceMethod.SCAN_WORKFLOW_EXECUTIONS, () -> scanWorkflowExecutions(request));
×
1768
  }
1769

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

1804
  @Override
1805
  public CountWorkflowExecutionsResponse CountWorkflowExecutions(
1806
      CountWorkflowExecutionsRequest countRequest)
1807
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
1808
          ClientVersionNotSupportedError, TException {
1809
    return measureRemoteCall(
×
1810
        ServiceMethod.COUNT_WORKFLOW_EXECUTIONS, () -> countWorkflowExecutions(countRequest));
×
1811
  }
1812

1813
  private CountWorkflowExecutionsResponse countWorkflowExecutions(
1814
      CountWorkflowExecutionsRequest countRequest) throws TException {
1815
    ThriftResponse<WorkflowService.CountWorkflowExecutions_result> response = null;
×
1816
    try {
1817
      ThriftRequest<WorkflowService.CountWorkflowExecutions_args> request =
×
1818
          buildThriftRequest(
×
1819
              "CountWorkflowExecutions",
1820
              new WorkflowService.CountWorkflowExecutions_args(countRequest));
1821
      response = doRemoteCall(request);
×
1822
      WorkflowService.CountWorkflowExecutions_result result =
×
1823
          response.getBody(WorkflowService.CountWorkflowExecutions_result.class);
×
1824
      if (response.getResponseCode() == ResponseCode.OK) {
×
1825
        return result.getSuccess();
×
1826
      }
1827
      if (result.isSetBadRequestError()) {
×
1828
        throw result.getBadRequestError();
×
1829
      }
1830
      if (result.isSetEntityNotExistError()) {
×
1831
        throw result.getEntityNotExistError();
×
1832
      }
1833
      if (result.isSetServiceBusyError()) {
×
1834
        throw result.getServiceBusyError();
×
1835
      }
1836
      if (result.isSetClientVersionNotSupportedError()) {
×
1837
        throw result.getClientVersionNotSupportedError();
×
1838
      }
1839
      throw new TException("CountWorkflowExecutions failed with unknown error:" + result);
×
1840
    } finally {
1841
      if (response != null) {
×
1842
        response.release();
×
1843
      }
1844
    }
1845
  }
1846

1847
  @Override
1848
  public GetSearchAttributesResponse GetSearchAttributes()
1849
      throws InternalServiceError, ServiceBusyError, ClientVersionNotSupportedError, TException {
1850
    return measureRemoteCall(ServiceMethod.GET_SEARCH_ATTRIBUTES, () -> getSearchAttributes());
×
1851
  }
1852

1853
  private GetSearchAttributesResponse getSearchAttributes() throws TException {
1854
    ThriftResponse<WorkflowService.GetSearchAttributes_result> response = null;
×
1855
    try {
1856
      ThriftRequest<WorkflowService.GetSearchAttributes_args> request =
×
1857
          buildThriftRequest("GetSearchAttributes", new WorkflowService.GetSearchAttributes_args());
×
1858
      response = doRemoteCall(request);
×
1859
      WorkflowService.GetSearchAttributes_result result =
×
1860
          response.getBody(WorkflowService.GetSearchAttributes_result.class);
×
1861
      if (response.getResponseCode() == ResponseCode.OK) {
×
1862
        return result.getSuccess();
×
1863
      }
1864
      if (result.isSetServiceBusyError()) {
×
1865
        throw result.getServiceBusyError();
×
1866
      }
1867
      if (result.isSetClientVersionNotSupportedError()) {
×
1868
        throw result.getClientVersionNotSupportedError();
×
1869
      }
1870
      throw new TException("GetSearchAttributes failed with unknown error:" + result);
×
1871
    } finally {
1872
      if (response != null) {
×
1873
        response.release();
×
1874
      }
1875
    }
1876
  }
1877

1878
  @Override
1879
  public void RespondQueryTaskCompleted(RespondQueryTaskCompletedRequest request)
1880
      throws TException {
1881
    measureRemoteProc(
×
1882
        ServiceMethod.RESPOND_QUERY_TASK_COMPLETED, () -> respondQueryTaskCompleted(request));
×
1883
  }
×
1884

1885
  private void respondQueryTaskCompleted(RespondQueryTaskCompletedRequest completeRequest)
1886
      throws TException {
1887
    ThriftResponse<WorkflowService.RespondQueryTaskCompleted_result> response = null;
×
1888
    try {
1889
      ThriftRequest<WorkflowService.RespondQueryTaskCompleted_args> request =
×
1890
          buildThriftRequest(
×
1891
              "RespondQueryTaskCompleted",
1892
              new WorkflowService.RespondQueryTaskCompleted_args(completeRequest));
1893
      response = doRemoteCall(request);
×
1894
      WorkflowService.RespondQueryTaskCompleted_result result =
×
1895
          response.getBody(WorkflowService.RespondQueryTaskCompleted_result.class);
×
1896
      if (response.getResponseCode() == ResponseCode.OK) {
×
1897
        return;
×
1898
      }
1899
      if (result.isSetBadRequestError()) {
×
1900
        throw result.getBadRequestError();
×
1901
      }
1902
      if (result.isSetEntityNotExistError()) {
×
1903
        throw result.getEntityNotExistError();
×
1904
      }
1905
      if (result.isSetServiceBusyError()) {
×
1906
        throw result.getServiceBusyError();
×
1907
      }
1908
      if (result.isSetDomainNotActiveError()) {
×
1909
        throw result.getDomainNotActiveError();
×
1910
      }
1911
      if (result.isSetLimitExceededError()) {
×
1912
        throw result.getLimitExceededError();
×
1913
      }
1914
      if (result.isSetClientVersionNotSupportedError()) {
×
1915
        throw result.getClientVersionNotSupportedError();
×
1916
      }
1917
      throw new TException("RespondQueryTaskCompleted failed with unknown error:" + result);
×
1918
    } finally {
1919
      if (response != null) {
×
1920
        response.release();
×
1921
      }
1922
    }
1923
  }
1924

1925
  @Override
1926
  public QueryWorkflowResponse QueryWorkflow(QueryWorkflowRequest request) throws TException {
1927
    return measureRemoteCall(ServiceMethod.QUERY_WORKFLOW, () -> queryWorkflow(request));
×
1928
  }
1929

1930
  private QueryWorkflowResponse queryWorkflow(QueryWorkflowRequest queryRequest) throws TException {
1931
    ThriftResponse<WorkflowService.QueryWorkflow_result> response = null;
×
1932
    try {
1933
      ThriftRequest<WorkflowService.QueryWorkflow_args> request =
×
1934
          buildThriftRequest(
×
1935
              "QueryWorkflow",
1936
              new WorkflowService.QueryWorkflow_args(queryRequest),
1937
              options.getRpcQueryTimeoutMillis());
×
1938
      response = doRemoteCall(request);
×
1939
      WorkflowService.QueryWorkflow_result result =
×
1940
          response.getBody(WorkflowService.QueryWorkflow_result.class);
×
1941
      if (response.getResponseCode() == ResponseCode.OK) {
×
1942
        return result.getSuccess();
×
1943
      }
1944
      if (result.isSetBadRequestError()) {
×
1945
        throw result.getBadRequestError();
×
1946
      }
1947
      if (result.isSetEntityNotExistError()) {
×
1948
        throw result.getEntityNotExistError();
×
1949
      }
1950
      if (result.isSetQueryFailedError()) {
×
1951
        throw result.getQueryFailedError();
×
1952
      }
1953
      if (result.isSetClientVersionNotSupportedError()) {
×
1954
        throw result.getClientVersionNotSupportedError();
×
1955
      }
1956
      throw new TException("QueryWorkflow failed with unknown error:" + result);
×
1957
    } finally {
1958
      if (response != null) {
×
1959
        response.release();
×
1960
      }
1961
    }
1962
  }
1963

1964
  @Override
1965
  public ResetStickyTaskListResponse ResetStickyTaskList(ResetStickyTaskListRequest resetRequest)
1966
      throws BadRequestError, InternalServiceError, EntityNotExistsError, LimitExceededError,
1967
          WorkflowExecutionAlreadyCompletedError, ServiceBusyError, DomainNotActiveError,
1968
          TException {
1969
    return measureRemoteCall(
×
1970
        ServiceMethod.RESET_STICKY_TASK_LIST, () -> resetStickyTaskList(resetRequest));
×
1971
  }
1972

1973
  private ResetStickyTaskListResponse resetStickyTaskList(ResetStickyTaskListRequest queryRequest)
1974
      throws TException {
1975
    ThriftResponse<WorkflowService.ResetStickyTaskList_result> response = null;
×
1976
    try {
1977
      ThriftRequest<WorkflowService.ResetStickyTaskList_args> request =
×
1978
          buildThriftRequest(
×
1979
              "ResetStickyTaskList",
1980
              new WorkflowService.ResetStickyTaskList_args(queryRequest),
1981
              options.getRpcQueryTimeoutMillis());
×
1982
      response = doRemoteCall(request);
×
1983
      WorkflowService.ResetStickyTaskList_result result =
×
1984
          response.getBody(WorkflowService.ResetStickyTaskList_result.class);
×
1985
      if (response.getResponseCode() == ResponseCode.OK) {
×
1986
        return result.getSuccess();
×
1987
      }
1988
      if (result.isSetBadRequestError()) {
×
1989
        throw result.getBadRequestError();
×
1990
      }
1991
      if (result.isSetEntityNotExistError()) {
×
1992
        throw result.getEntityNotExistError();
×
1993
      }
1994
      if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
1995
        throw result.getWorkflowExecutionAlreadyCompletedError();
×
1996
      }
1997
      if (result.isSetServiceBusyError()) {
×
1998
        throw result.getServiceBusyError();
×
1999
      }
2000
      if (result.isSetDomainNotActiveError()) {
×
2001
        throw result.getDomainNotActiveError();
×
2002
      }
2003
      if (result.isSetLimitExceededError()) {
×
2004
        throw result.getLimitExceededError();
×
2005
      }
2006
      if (result.isSetClientVersionNotSupportedError()) {
×
2007
        throw result.getClientVersionNotSupportedError();
×
2008
      }
2009
      throw new TException("ResetStickyTaskList failed with unknown error:" + result);
×
2010
    } finally {
2011
      if (response != null) {
×
2012
        response.release();
×
2013
      }
2014
    }
2015
  }
2016

2017
  @Override
2018
  public DescribeWorkflowExecutionResponse DescribeWorkflowExecution(
2019
      DescribeWorkflowExecutionRequest request) throws TException {
2020
    return measureRemoteCall(
×
2021
        ServiceMethod.DESCRIBE_WORKFLOW_EXECUTION, () -> describeWorkflowExecution(request));
×
2022
  }
2023

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

2061
  @Override
2062
  public DescribeTaskListResponse DescribeTaskList(DescribeTaskListRequest request)
2063
      throws TException {
2064
    return measureRemoteCall(ServiceMethod.DESCRIBE_TASK_LIST, () -> describeTaskList(request));
×
2065
  }
2066

2067
  private DescribeTaskListResponse describeTaskList(DescribeTaskListRequest describeRequest)
2068
      throws TException {
2069
    ThriftResponse<WorkflowService.DescribeTaskList_result> response = null;
×
2070
    try {
2071
      ThriftRequest<WorkflowService.DescribeTaskList_args> request =
×
2072
          buildThriftRequest(
×
2073
              "DescribeTaskList", new WorkflowService.DescribeTaskList_args(describeRequest));
2074
      response = doRemoteCall(request);
×
2075
      WorkflowService.DescribeTaskList_result result =
×
2076
          response.getBody(WorkflowService.DescribeTaskList_result.class);
×
2077
      if (response.getResponseCode() == ResponseCode.OK) {
×
2078
        return result.getSuccess();
×
2079
      }
2080
      if (result.isSetBadRequestError()) {
×
2081
        throw result.getBadRequestError();
×
2082
      }
2083
      if (result.isSetEntityNotExistError()) {
×
2084
        throw result.getEntityNotExistError();
×
2085
      }
2086
      if (result.isSetServiceBusyError()) {
×
2087
        throw result.getServiceBusyError();
×
2088
      }
2089
      if (result.isSetLimitExceededError()) {
×
2090
        throw result.getLimitExceededError();
×
2091
      }
2092
      if (result.isSetClientVersionNotSupportedError()) {
×
2093
        throw result.getClientVersionNotSupportedError();
×
2094
      }
2095
      throw new TException("DescribeTaskList failed with unknown error:" + result);
×
2096
    } finally {
2097
      if (response != null) {
×
2098
        response.release();
×
2099
      }
2100
    }
2101
  }
2102

2103
  @Override
2104
  public ClusterInfo GetClusterInfo() throws InternalServiceError, ServiceBusyError, TException {
2105
    return measureRemoteCall(ServiceMethod.GET_CLUSTER_INFO, () -> getClusterInfo());
×
2106
  }
2107

2108
  private ClusterInfo getClusterInfo() throws TException {
2109
    ThriftResponse<WorkflowService.GetClusterInfo_result> response = null;
×
2110
    try {
2111
      ThriftRequest<WorkflowService.GetClusterInfo_args> request =
×
2112
          buildThriftRequest("GetClusterInfo", new WorkflowService.GetClusterInfo_args());
×
2113
      response = doRemoteCall(request);
×
2114
      WorkflowService.GetClusterInfo_result result =
×
2115
          response.getBody(WorkflowService.GetClusterInfo_result.class);
×
2116
      if (response.getResponseCode() == ResponseCode.OK) {
×
2117
        return result.getSuccess();
×
2118
      }
2119
      if (result.isSetServiceBusyError()) {
×
2120
        throw result.getServiceBusyError();
×
2121
      }
2122
      throw new TException("GetClusterInfo failed with unknown error:" + result);
×
2123
    } finally {
2124
      if (response != null) {
×
2125
        response.release();
×
2126
      }
2127
    }
2128
  }
2129

2130
  @Override
2131
  public ListTaskListPartitionsResponse ListTaskListPartitions(
2132
      ListTaskListPartitionsRequest request)
2133
      throws BadRequestError, EntityNotExistsError, LimitExceededError, ServiceBusyError,
2134
          TException {
2135
    return measureRemoteCall(
×
2136
        ServiceMethod.LIST_TASK_LIST_PARTITIONS, () -> listTaskListPartitions(request));
×
2137
  }
2138

2139
  @Override
2140
  public void RefreshWorkflowTasks(RefreshWorkflowTasksRequest refreshWorkflowTasks)
2141
      throws BadRequestError, DomainNotActiveError, ServiceBusyError, EntityNotExistsError,
2142
          TException {
2143
    ThriftResponse<WorkflowService.RefreshWorkflowTasks_result> response = null;
×
2144
    try {
2145
      ThriftRequest<WorkflowService.RefreshWorkflowTasks_args> request =
×
2146
          buildThriftRequest(
×
2147
              "RefreshWorkflowTasks",
2148
              new WorkflowService.RefreshWorkflowTasks_args(refreshWorkflowTasks));
2149
      response = doRemoteCall(request);
×
2150
      WorkflowService.RefreshWorkflowTasks_result result =
×
2151
          response.getBody(WorkflowService.RefreshWorkflowTasks_result.class);
×
2152
      if (result.isSetBadRequestError()) {
×
2153
        throw result.getBadRequestError();
×
2154
      }
2155
      if (result.isSetDomainNotActiveError()) {
×
2156
        throw result.getDomainNotActiveError();
×
2157
      }
2158
      if (result.isSetServiceBusyError()) {
×
2159
        throw result.getServiceBusyError();
×
2160
      }
2161
      if (result.isSetEntityNotExistError()) {
×
2162
        throw result.getEntityNotExistError();
×
2163
      }
2164
    } finally {
2165
      if (response != null) {
×
2166
        response.release();
×
2167
      }
2168
    }
2169
  }
×
2170

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

2205
  @Override
2206
  public void StartWorkflowExecution(
2207
      StartWorkflowExecutionRequest startRequest, AsyncMethodCallback resultHandler) {
2208
    startWorkflowExecution(startRequest, resultHandler, null);
×
2209
  }
×
2210

2211
  @Override
2212
  public void StartWorkflowExecutionWithTimeout(
2213
      StartWorkflowExecutionRequest startRequest,
2214
      AsyncMethodCallback resultHandler,
2215
      Long timeoutInMillis) {
2216
    startWorkflowExecution(startRequest, resultHandler, timeoutInMillis);
×
2217
  }
×
2218

2219
  private void startWorkflowExecution(
2220
      StartWorkflowExecutionRequest startRequest,
2221
      AsyncMethodCallback resultHandler,
2222
      Long timeoutInMillis) {
2223

2224
    startRequest.setRequestId(UUID.randomUUID().toString());
×
2225
    timeoutInMillis = validateAndUpdateTimeout(timeoutInMillis, options.getRpcTimeoutMillis());
×
2226
    ThriftRequest<WorkflowService.StartWorkflowExecution_args> request =
×
2227
        buildThriftRequest(
×
2228
            "StartWorkflowExecution",
2229
            new WorkflowService.StartWorkflowExecution_args(startRequest),
2230
            timeoutInMillis);
2231

2232
    CompletableFuture<ThriftResponse<WorkflowService.StartWorkflowExecution_result>> response =
×
2233
        doRemoteCallAsync(request);
×
2234
    response
×
2235
        .whenComplete(
×
2236
            (r, e) -> {
2237
              try {
2238
                if (e != null) {
×
2239
                  resultHandler.onError(CheckedExceptionWrapper.wrap(e));
×
2240
                  return;
×
2241
                }
2242
                WorkflowService.StartWorkflowExecution_result result =
×
2243
                    r.getBody(WorkflowService.StartWorkflowExecution_result.class);
×
2244
                if (r.getResponseCode() == ResponseCode.OK) {
×
2245
                  resultHandler.onComplete(result.getSuccess());
×
2246
                  return;
×
2247
                }
2248
                if (result.isSetBadRequestError()) {
×
2249
                  resultHandler.onError(result.getBadRequestError());
×
2250
                  return;
×
2251
                }
2252
                if (result.isSetSessionAlreadyExistError()) {
×
2253
                  resultHandler.onError(result.getSessionAlreadyExistError());
×
2254
                  return;
×
2255
                }
2256
                if (result.isSetServiceBusyError()) {
×
2257
                  resultHandler.onError(result.getServiceBusyError());
×
2258
                  return;
×
2259
                }
2260
                if (result.isSetDomainNotActiveError()) {
×
2261
                  resultHandler.onError(result.getDomainNotActiveError());
×
2262
                  return;
×
2263
                }
2264
                if (result.isSetLimitExceededError()) {
×
2265
                  resultHandler.onError(result.getLimitExceededError());
×
2266
                  return;
×
2267
                }
2268
                if (result.isSetEntityNotExistError()) {
×
2269
                  resultHandler.onError(result.getEntityNotExistError());
×
2270
                  return;
×
2271
                }
2272
                resultHandler.onError(
×
2273
                    new TException("StartWorkflowExecution failed with unknown error:" + result));
2274
              } finally {
2275
                if (r != null) {
×
2276
                  r.release();
×
2277
                }
2278
              }
2279
            })
×
2280
        .exceptionally(
×
2281
            (e) -> {
2282
              log.error("Unexpected error in StartWorkflowExecution", e);
×
2283
              return null;
×
2284
            });
2285
  }
×
2286

2287
  private Long validateAndUpdateTimeout(Long timeoutInMillis, Long defaultTimeoutInMillis) {
2288
    if (timeoutInMillis == null || timeoutInMillis <= 0 || timeoutInMillis == Long.MAX_VALUE) {
×
2289
      timeoutInMillis = defaultTimeoutInMillis;
×
2290
    } else {
2291
      timeoutInMillis = Math.min(timeoutInMillis, defaultTimeoutInMillis);
×
2292
    }
2293
    return timeoutInMillis;
×
2294
  }
2295

2296
  @SuppressWarnings({"unchecked", "FutureReturnValueIgnored"})
2297
  @Override
2298
  public void GetWorkflowExecutionHistoryWithTimeout(
2299
      GetWorkflowExecutionHistoryRequest getRequest,
2300
      AsyncMethodCallback resultHandler,
2301
      Long timeoutInMillis) {
2302

2303
    getWorkflowExecutionHistory(getRequest, resultHandler, timeoutInMillis);
×
2304
  }
×
2305

2306
  @SuppressWarnings({"unchecked", "FutureReturnValueIgnored"})
2307
  @Override
2308
  public void GetWorkflowExecutionHistory(
2309
      GetWorkflowExecutionHistoryRequest getRequest, AsyncMethodCallback resultHandler) {
2310

2311
    getWorkflowExecutionHistory(getRequest, resultHandler, null);
×
2312
  }
×
2313

2314
  private void getWorkflowExecutionHistory(
2315
      GetWorkflowExecutionHistoryRequest getRequest,
2316
      AsyncMethodCallback resultHandler,
2317
      Long timeoutInMillis) {
2318

2319
    ThriftRequest<WorkflowService.GetWorkflowExecutionHistory_args> request =
×
2320
        buildGetWorkflowExecutionHistoryThriftRequest(getRequest, timeoutInMillis);
×
2321

2322
    CompletableFuture<ThriftResponse<GetWorkflowExecutionHistory_result>> response =
×
2323
        doRemoteCallAsync(request);
×
2324
    response
×
2325
        .whenComplete(
×
2326
            (r, e) -> {
2327
              try {
2328
                if (e != null) {
×
2329
                  resultHandler.onError(CheckedExceptionWrapper.wrap(e));
×
2330
                  return;
×
2331
                }
2332
                WorkflowService.GetWorkflowExecutionHistory_result result =
×
2333
                    r.getBody(WorkflowService.GetWorkflowExecutionHistory_result.class);
×
2334

2335
                if (r.getResponseCode() == ResponseCode.OK) {
×
2336
                  GetWorkflowExecutionHistoryResponse res = result.getSuccess();
×
2337
                  if (res.getRawHistory() != null) {
×
2338
                    History history =
×
2339
                        InternalUtils.DeserializeFromBlobDataToHistory(
×
2340
                            res.getRawHistory(), getRequest.getHistoryEventFilterType());
×
2341
                    res.setHistory(history);
×
2342
                  }
2343
                  resultHandler.onComplete(res);
×
2344
                  return;
×
2345
                }
2346
                if (result.isSetBadRequestError()) {
×
2347
                  resultHandler.onError(result.getBadRequestError());
×
2348
                  return;
×
2349
                }
2350
                if (result.isSetEntityNotExistError()) {
×
2351
                  resultHandler.onError(result.getEntityNotExistError());
×
2352
                  return;
×
2353
                }
2354
                if (result.isSetServiceBusyError()) {
×
2355
                  resultHandler.onError(result.getServiceBusyError());
×
2356
                  return;
×
2357
                }
2358
                resultHandler.onError(
×
2359
                    new TException(
2360
                        "GetWorkflowExecutionHistory failed with unknown " + "error:" + result));
2361
              } catch (TException tException) {
×
2362
                resultHandler.onError(tException);
×
2363
              } finally {
2364
                if (r != null) {
×
2365
                  r.release();
×
2366
                }
2367
              }
2368
            })
×
2369
        .exceptionally(
×
2370
            (e) -> {
2371
              log.error("Unexpected error in GetWorkflowExecutionHistory", e);
×
2372
              return null;
×
2373
            });
2374
  }
×
2375

2376
  @Override
2377
  public void PollForDecisionTask(
2378
      PollForDecisionTaskRequest pollRequest, AsyncMethodCallback resultHandler) throws TException {
2379
    throw new UnsupportedOperationException("not implemented");
×
2380
  }
2381

2382
  @Override
2383
  public void RespondDecisionTaskCompleted(
2384
      RespondDecisionTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
2385
      throws TException {
2386
    throw new UnsupportedOperationException("not implemented");
×
2387
  }
2388

2389
  @Override
2390
  public void RespondDecisionTaskFailed(
2391
      RespondDecisionTaskFailedRequest failedRequest, AsyncMethodCallback resultHandler)
2392
      throws TException {
2393
    throw new UnsupportedOperationException("not implemented");
×
2394
  }
2395

2396
  @Override
2397
  public void PollForActivityTask(
2398
      PollForActivityTaskRequest pollRequest, AsyncMethodCallback resultHandler) throws TException {
2399
    throw new UnsupportedOperationException("not implemented");
×
2400
  }
2401

2402
  @Override
2403
  public void RecordActivityTaskHeartbeat(
2404
      RecordActivityTaskHeartbeatRequest heartbeatRequest, AsyncMethodCallback resultHandler)
2405
      throws TException {
2406
    throw new UnsupportedOperationException("not implemented");
×
2407
  }
2408

2409
  @Override
2410
  public void RecordActivityTaskHeartbeatByID(
2411
      RecordActivityTaskHeartbeatByIDRequest heartbeatRequest, AsyncMethodCallback resultHandler)
2412
      throws TException {
2413
    throw new UnsupportedOperationException("not implemented");
×
2414
  }
2415

2416
  @Override
2417
  public void RespondActivityTaskCompleted(
2418
      RespondActivityTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
2419
      throws TException {
2420
    throw new UnsupportedOperationException("not implemented");
×
2421
  }
2422

2423
  @Override
2424
  public void RespondActivityTaskCompletedByID(
2425
      RespondActivityTaskCompletedByIDRequest completeRequest, AsyncMethodCallback resultHandler)
2426
      throws TException {
2427
    throw new UnsupportedOperationException("not implemented");
×
2428
  }
2429

2430
  @Override
2431
  public void RespondActivityTaskFailed(
2432
      RespondActivityTaskFailedRequest failRequest, AsyncMethodCallback resultHandler)
2433
      throws TException {
2434
    throw new UnsupportedOperationException("not implemented");
×
2435
  }
2436

2437
  @Override
2438
  public void RespondActivityTaskFailedByID(
2439
      RespondActivityTaskFailedByIDRequest failRequest, AsyncMethodCallback resultHandler)
2440
      throws TException {
2441
    throw new UnsupportedOperationException("not implemented");
×
2442
  }
2443

2444
  @Override
2445
  public void RespondActivityTaskCanceled(
2446
      RespondActivityTaskCanceledRequest canceledRequest, AsyncMethodCallback resultHandler)
2447
      throws TException {
2448
    throw new UnsupportedOperationException("not implemented");
×
2449
  }
2450

2451
  @Override
2452
  public void RespondActivityTaskCanceledByID(
2453
      RespondActivityTaskCanceledByIDRequest canceledRequest, AsyncMethodCallback resultHandler)
2454
      throws TException {
2455
    throw new UnsupportedOperationException("not implemented");
×
2456
  }
2457

2458
  @Override
2459
  public void RequestCancelWorkflowExecution(
2460
      RequestCancelWorkflowExecutionRequest cancelRequest, AsyncMethodCallback resultHandler)
2461
      throws TException {
2462
    throw new UnsupportedOperationException("not implemented");
×
2463
  }
2464

2465
  @Override
2466
  public void SignalWorkflowExecution(
2467
      SignalWorkflowExecutionRequest signalRequest, AsyncMethodCallback resultHandler) {
2468
    signalWorkflowExecution(signalRequest, resultHandler, null);
×
2469
  }
×
2470

2471
  @Override
2472
  public void SignalWorkflowExecutionWithTimeout(
2473
      SignalWorkflowExecutionRequest signalRequest,
2474
      AsyncMethodCallback resultHandler,
2475
      Long timeoutInMillis) {
2476
    signalWorkflowExecution(signalRequest, resultHandler, timeoutInMillis);
×
2477
  }
×
2478

2479
  private void signalWorkflowExecution(
2480
      SignalWorkflowExecutionRequest signalRequest,
2481
      AsyncMethodCallback resultHandler,
2482
      Long timeoutInMillis) {
2483

2484
    timeoutInMillis = validateAndUpdateTimeout(timeoutInMillis, options.getRpcTimeoutMillis());
×
2485
    ThriftRequest<WorkflowService.SignalWorkflowExecution_args> request =
×
2486
        buildThriftRequest(
×
2487
            "SignalWorkflowExecution",
2488
            new WorkflowService.SignalWorkflowExecution_args(signalRequest),
2489
            timeoutInMillis);
2490
    CompletableFuture<ThriftResponse<WorkflowService.SignalWorkflowExecution_result>> response =
×
2491
        doRemoteCallAsync(request);
×
2492
    response
×
2493
        .whenComplete(
×
2494
            (r, e) -> {
2495
              try {
2496
                if (e != null) {
×
2497
                  resultHandler.onError(CheckedExceptionWrapper.wrap(e));
×
2498
                  return;
×
2499
                }
2500
                WorkflowService.SignalWorkflowExecution_result result =
×
2501
                    r.getBody(WorkflowService.SignalWorkflowExecution_result.class);
×
2502
                if (r.getResponseCode() == ResponseCode.OK) {
×
2503
                  resultHandler.onComplete(null);
×
2504
                  return;
×
2505
                }
2506
                if (result.isSetBadRequestError()) {
×
2507
                  resultHandler.onError(result.getBadRequestError());
×
2508
                  return;
×
2509
                }
2510
                if (result.isSetEntityNotExistError()) {
×
2511
                  resultHandler.onError(result.getEntityNotExistError());
×
2512
                  return;
×
2513
                }
2514
                if (result.isSetWorkflowExecutionAlreadyCompletedError()) {
×
2515
                  resultHandler.onError(result.getWorkflowExecutionAlreadyCompletedError());
×
2516
                  return;
×
2517
                }
2518
                if (result.isSetServiceBusyError()) {
×
2519
                  resultHandler.onError(result.getServiceBusyError());
×
2520
                  return;
×
2521
                }
2522
                if (result.isSetDomainNotActiveError()) {
×
2523
                  resultHandler.onError(result.getDomainNotActiveError());
×
2524
                  return;
×
2525
                }
2526
                if (result.isSetLimitExceededError()) {
×
2527
                  resultHandler.onError(result.getLimitExceededError());
×
2528
                  return;
×
2529
                }
2530
                if (result.isSetClientVersionNotSupportedError()) {
×
2531
                  resultHandler.onError(result.getClientVersionNotSupportedError());
×
2532
                  return;
×
2533
                }
2534
                resultHandler.onError(
×
2535
                    new TException("SignalWorkflowExecution failed with unknown error:" + result));
2536
              } finally {
2537
                if (r != null) {
×
2538
                  r.release();
×
2539
                }
2540
              }
2541
            })
×
2542
        .exceptionally(
×
2543
            (e) -> {
2544
              log.error("Unexpected error in SignalWorkflowExecution", e);
×
2545
              return null;
×
2546
            });
2547
  }
×
2548

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

2557
  @Override
2558
  public void ResetWorkflowExecution(
2559
      ResetWorkflowExecutionRequest resetRequest, AsyncMethodCallback resultHandler)
2560
      throws TException {
2561
    throw new UnsupportedOperationException("not implemented");
×
2562
  }
2563

2564
  @Override
2565
  public void TerminateWorkflowExecution(
2566
      TerminateWorkflowExecutionRequest terminateRequest, AsyncMethodCallback resultHandler)
2567
      throws TException {
2568
    throw new UnsupportedOperationException("not implemented");
×
2569
  }
2570

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

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

2585
  @Override
2586
  public void ListWorkflowExecutions(
2587
      ListWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2588
      throws TException {
2589
    throw new UnsupportedOperationException("not implemented");
×
2590
  }
2591

2592
  @Override
2593
  public void ListArchivedWorkflowExecutions(
2594
      ListArchivedWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2595
      throws TException {
2596
    throw new UnsupportedOperationException("not implemented");
×
2597
  }
2598

2599
  @Override
2600
  public void ScanWorkflowExecutions(
2601
      ListWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
2602
      throws TException {
2603
    throw new UnsupportedOperationException("not implemented");
×
2604
  }
2605

2606
  @Override
2607
  public void CountWorkflowExecutions(
2608
      CountWorkflowExecutionsRequest countRequest, AsyncMethodCallback resultHandler)
2609
      throws TException {
2610
    throw new UnsupportedOperationException("not implemented");
×
2611
  }
2612

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

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

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

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

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

2645
  @Override
2646
  public void DescribeTaskList(DescribeTaskListRequest request, AsyncMethodCallback resultHandler)
2647
      throws TException {
2648
    throw new UnsupportedOperationException("not implemented");
×
2649
  }
2650

2651
  @Override
2652
  public void GetClusterInfo(AsyncMethodCallback resultHandler) throws TException {}
×
2653

2654
  @Override
2655
  public void ListTaskListPartitions(
2656
      ListTaskListPartitionsRequest request, AsyncMethodCallback resultHandler) throws TException {}
×
2657

2658
  @Override
2659
  public void RefreshWorkflowTasks(
2660
      RefreshWorkflowTasksRequest request, AsyncMethodCallback resultHandler) throws TException {}
×
2661

2662
  @Override
2663
  public void RegisterDomain(
2664
      RegisterDomainRequest registerRequest, AsyncMethodCallback resultHandler) throws TException {
2665
    throw new UnsupportedOperationException("not implemented");
×
2666
  }
2667

2668
  @Override
2669
  public void DescribeDomain(
2670
      DescribeDomainRequest describeRequest, AsyncMethodCallback resultHandler) throws TException {
2671
    throw new UnsupportedOperationException("not implemented");
×
2672
  }
2673

2674
  @Override
2675
  public void ListDomains(ListDomainsRequest listRequest, AsyncMethodCallback resultHandler)
2676
      throws TException {
2677
    throw new UnsupportedOperationException("not implemented");
×
2678
  }
2679

2680
  @Override
2681
  public void UpdateDomain(UpdateDomainRequest updateRequest, AsyncMethodCallback resultHandler)
2682
      throws TException {
2683
    throw new UnsupportedOperationException("not implemented");
×
2684
  }
2685

2686
  @Override
2687
  public void DeprecateDomain(
2688
      DeprecateDomainRequest deprecateRequest, AsyncMethodCallback resultHandler)
2689
      throws TException {
2690
    throw new UnsupportedOperationException("not implemented");
×
2691
  }
2692

2693
  @Override
2694
  public void GetTaskListsByDomain(
2695
      GetTaskListsByDomainRequest request, AsyncMethodCallback resultHandler)
2696
      throws org.apache.thrift.TException {
2697
    throw new UnsupportedOperationException("not implemented");
×
2698
  }
2699
}
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

© 2026 Coveralls, Inc