|
17 | 17 |
|
18 | 18 | package com.uber.cadence.serviceclient;
|
19 | 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 | + |
20 | 23 | import com.google.common.collect.ImmutableMap;
|
21 | 24 | import com.google.gson.Gson;
|
22 | 25 | import com.google.gson.GsonBuilder;
|
|
65 | 68 | import com.uber.cadence.RecordActivityTaskHeartbeatByIDRequest;
|
66 | 69 | import com.uber.cadence.RecordActivityTaskHeartbeatRequest;
|
67 | 70 | import com.uber.cadence.RecordActivityTaskHeartbeatResponse;
|
| 71 | +import com.uber.cadence.RefreshWorkflowTasksRequest; |
68 | 72 | import com.uber.cadence.RegisterDomainRequest;
|
69 | 73 | import com.uber.cadence.RequestCancelWorkflowExecutionRequest;
|
70 | 74 | import com.uber.cadence.ResetStickyTaskListRequest;
|
|
110 | 114 | import com.uber.tchannel.messages.ThriftRequest;
|
111 | 115 | import com.uber.tchannel.messages.ThriftResponse;
|
112 | 116 | import com.uber.tchannel.messages.generated.Meta;
|
113 |
| -import org.apache.thrift.TException; |
114 |
| -import org.apache.thrift.async.AsyncMethodCallback; |
115 |
| -import org.apache.thrift.transport.TTransportException; |
116 |
| -import org.slf4j.Logger; |
117 |
| -import org.slf4j.LoggerFactory; |
118 |
| - |
119 | 117 | import java.net.InetAddress;
|
120 | 118 | import java.net.InetSocketAddress;
|
121 | 119 | import java.net.UnknownHostException;
|
|
126 | 124 | import java.util.UUID;
|
127 | 125 | import java.util.concurrent.CompletableFuture;
|
128 | 126 | import java.util.concurrent.ExecutionException;
|
129 |
| - |
130 |
| -import static com.uber.cadence.internal.metrics.MetricsTagValue.REQUEST_TYPE_LONG_POLL; |
131 |
| -import static com.uber.cadence.internal.metrics.MetricsTagValue.REQUEST_TYPE_NORMAL; |
| 127 | +import org.apache.thrift.TException; |
| 128 | +import org.apache.thrift.async.AsyncMethodCallback; |
| 129 | +import org.apache.thrift.transport.TTransportException; |
| 130 | +import org.slf4j.Logger; |
| 131 | +import org.slf4j.LoggerFactory; |
132 | 132 |
|
133 | 133 | public class WorkflowServiceTChannel implements IWorkflowService {
|
134 | 134 | private static final Logger log = LoggerFactory.getLogger(WorkflowServiceTChannel.class);
|
@@ -363,7 +363,8 @@ private <T> T measureRemoteCall(String scopeName, RemoteCall<T> call) throws TEx
|
363 | 363 | return measureRemoteCallWithTags(scopeName, call, null);
|
364 | 364 | }
|
365 | 365 |
|
366 |
| - private <T> T measureRemoteCallWithTags(String scopeName, RemoteCall<T> call, Map<String, String> tags) throws TException { |
| 366 | + private <T> T measureRemoteCallWithTags( |
| 367 | + String scopeName, RemoteCall<T> call, Map<String, String> tags) throws TException { |
367 | 368 | Scope scope = options.getMetricsScope().subScope(scopeName);
|
368 | 369 | if (tags != null) {
|
369 | 370 | scope = scope.tagged(tags);
|
@@ -677,21 +678,27 @@ private StartWorkflowExecutionResponse startWorkflowExecution(
|
677 | 678 | @Override
|
678 | 679 | public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistoryWithTimeout(
|
679 | 680 | GetWorkflowExecutionHistoryRequest request, Long timeoutInMillis) throws TException {
|
680 |
| - Map<String, String> tags = ImmutableMap.of(MetricsTag.REQUEST_TYPE, request.isWaitForNewEvent() ? REQUEST_TYPE_LONG_POLL : REQUEST_TYPE_NORMAL); |
| 681 | + Map<String, String> tags = |
| 682 | + ImmutableMap.of( |
| 683 | + MetricsTag.REQUEST_TYPE, |
| 684 | + request.isWaitForNewEvent() ? REQUEST_TYPE_LONG_POLL : REQUEST_TYPE_NORMAL); |
681 | 685 | return measureRemoteCallWithTags(
|
682 |
| - ServiceMethod.GET_WORKFLOW_EXECUTION_HISTORY, |
683 |
| - () -> getWorkflowExecutionHistory(request, timeoutInMillis), |
684 |
| - tags); |
| 686 | + ServiceMethod.GET_WORKFLOW_EXECUTION_HISTORY, |
| 687 | + () -> getWorkflowExecutionHistory(request, timeoutInMillis), |
| 688 | + tags); |
685 | 689 | }
|
686 | 690 |
|
687 | 691 | @Override
|
688 | 692 | public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistory(
|
689 | 693 | GetWorkflowExecutionHistoryRequest request) throws TException {
|
690 |
| - Map<String, String> tags = ImmutableMap.of(MetricsTag.REQUEST_TYPE, request.isWaitForNewEvent() ? REQUEST_TYPE_LONG_POLL : REQUEST_TYPE_NORMAL); |
| 694 | + Map<String, String> tags = |
| 695 | + ImmutableMap.of( |
| 696 | + MetricsTag.REQUEST_TYPE, |
| 697 | + request.isWaitForNewEvent() ? REQUEST_TYPE_LONG_POLL : REQUEST_TYPE_NORMAL); |
691 | 698 | return measureRemoteCallWithTags(
|
692 |
| - ServiceMethod.GET_WORKFLOW_EXECUTION_HISTORY, |
693 |
| - () -> getWorkflowExecutionHistory(request, null), |
694 |
| - tags); |
| 699 | + ServiceMethod.GET_WORKFLOW_EXECUTION_HISTORY, |
| 700 | + () -> getWorkflowExecutionHistory(request, null), |
| 701 | + tags); |
695 | 702 | }
|
696 | 703 |
|
697 | 704 | private GetWorkflowExecutionHistoryResponse getWorkflowExecutionHistory(
|
@@ -2156,6 +2163,38 @@ public ListTaskListPartitionsResponse ListTaskListPartitions(
|
2156 | 2163 | ServiceMethod.LIST_TASK_LIST_PARTITIONS, () -> listTaskListPartitions(request));
|
2157 | 2164 | }
|
2158 | 2165 |
|
| 2166 | + @Override |
| 2167 | + public void RefreshWorkflowTasks(RefreshWorkflowTasksRequest refreshWorkflowTasks) |
| 2168 | + throws BadRequestError, DomainNotActiveError, ServiceBusyError, EntityNotExistsError, |
| 2169 | + TException { |
| 2170 | + ThriftResponse<WorkflowService.RefreshWorkflowTasks_result> response = null; |
| 2171 | + try { |
| 2172 | + ThriftRequest<WorkflowService.RefreshWorkflowTasks_args> request = |
| 2173 | + buildThriftRequest( |
| 2174 | + "RefreshWorkflowTasks", |
| 2175 | + new WorkflowService.RefreshWorkflowTasks_args(refreshWorkflowTasks)); |
| 2176 | + response = doRemoteCall(request); |
| 2177 | + WorkflowService.RefreshWorkflowTasks_result result = |
| 2178 | + response.getBody(WorkflowService.RefreshWorkflowTasks_result.class); |
| 2179 | + if (result.isSetBadRequestError()) { |
| 2180 | + throw result.getBadRequestError(); |
| 2181 | + } |
| 2182 | + if (result.isSetDomainNotActiveError()) { |
| 2183 | + throw result.getDomainNotActiveError(); |
| 2184 | + } |
| 2185 | + if (result.isSetServiceBusyError()) { |
| 2186 | + throw result.getServiceBusyError(); |
| 2187 | + } |
| 2188 | + if (result.isSetEntityNotExistError()) { |
| 2189 | + throw result.getEntityNotExistError(); |
| 2190 | + } |
| 2191 | + } finally { |
| 2192 | + if (response != null) { |
| 2193 | + response.release(); |
| 2194 | + } |
| 2195 | + } |
| 2196 | + } |
| 2197 | + |
2159 | 2198 | private ListTaskListPartitionsResponse listTaskListPartitions(
|
2160 | 2199 | ListTaskListPartitionsRequest listRequest) throws TException {
|
2161 | 2200 | ThriftResponse<WorkflowService.ListTaskListPartitions_result> response = null;
|
@@ -2643,6 +2682,10 @@ public void GetClusterInfo(AsyncMethodCallback resultHandler) throws TException
|
2643 | 2682 | public void ListTaskListPartitions(
|
2644 | 2683 | ListTaskListPartitionsRequest request, AsyncMethodCallback resultHandler) throws TException {}
|
2645 | 2684 |
|
| 2685 | + @Override |
| 2686 | + public void RefreshWorkflowTasks( |
| 2687 | + RefreshWorkflowTasksRequest request, AsyncMethodCallback resultHandler) throws TException {} |
| 2688 | + |
2646 | 2689 | @Override
|
2647 | 2690 | public void RegisterDomain(
|
2648 | 2691 | RegisterDomainRequest registerRequest, AsyncMethodCallback resultHandler) throws TException {
|
|
0 commit comments