Skip to content

Commit 57c071c

Browse files
committed
remove health check from this PR
1 parent f867d9b commit 57c071c

File tree

11 files changed

+9
-111
lines changed

11 files changed

+9
-111
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ dependencies {
5353
errorproneJavac('com.google.errorprone:javac:9+181-r4173-1')
5454
errorprone('com.google.errorprone:error_prone_core:2.3.4')
5555

56-
compile group: 'com.uber.tchannel', name: 'tchannel-core', version: '0.8.30'
56+
compile group: 'com.uber.tchannel', name: 'tchannel-core', version: '0.8.5'
5757
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
5858
compile group: 'org.apache.thrift', name: 'libthrift', version: '0.9.3'
5959
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.6'

src/main/java/com/uber/cadence/internal/sync/SyncWorkflowWorker.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@
3939
import java.lang.reflect.Type;
4040
import java.time.Duration;
4141
import java.util.Objects;
42-
import java.util.concurrent.*;
42+
import java.util.concurrent.Executors;
43+
import java.util.concurrent.ScheduledExecutorService;
44+
import java.util.concurrent.ThreadPoolExecutor;
45+
import java.util.concurrent.TimeUnit;
4346
import java.util.function.Consumer;
4447
import java.util.function.Function;
4548

@@ -56,7 +59,6 @@ public class SyncWorkflowWorker
5659
private final ScheduledExecutorService ldaHeartbeatExecutor = Executors.newScheduledThreadPool(4);
5760
private SuspendableWorker ldaWorker;
5861
private POJOActivityTaskHandler ldaTaskHandler;
59-
private final IWorkflowService service;
6062

6163
public SyncWorkflowWorker(
6264
IWorkflowService service,
@@ -72,7 +74,6 @@ public SyncWorkflowWorker(
7274
ThreadPoolExecutor workflowThreadPool) {
7375
Objects.requireNonNull(workflowThreadPool);
7476
this.dataConverter = workflowOptions.getDataConverter();
75-
this.service = service;
7677

7778
factory =
7879
new POJOWorkflowImplementationFactory(
@@ -251,8 +252,4 @@ public <R> R queryWorkflowExecution(
251252
public void accept(PollForDecisionTaskResponse pollForDecisionTaskResponse) {
252253
workflowWorker.accept(pollForDecisionTaskResponse);
253254
}
254-
255-
public CompletableFuture<Boolean> isHealthy() {
256-
return service.isHealthy();
257-
}
258255
}

src/main/java/com/uber/cadence/internal/sync/TestActivityEnvironmentInternal.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import java.util.Random;
4747
import java.util.UUID;
4848
import java.util.concurrent.CancellationException;
49-
import java.util.concurrent.CompletableFuture;
5049
import java.util.concurrent.Executors;
5150
import java.util.concurrent.ScheduledExecutorService;
5251
import java.util.concurrent.atomic.AtomicInteger;
@@ -318,11 +317,6 @@ private class WorkflowServiceWrapper implements IWorkflowService {
318317

319318
private final IWorkflowService impl;
320319

321-
@Override
322-
public CompletableFuture<Boolean> isHealthy() {
323-
return impl.isHealthy();
324-
}
325-
326320
private WorkflowServiceWrapper(IWorkflowService impl) {
327321
if (impl == null) {
328322
// Create empty implementation that just ignores all requests.

src/main/java/com/uber/cadence/internal/sync/TestWorkflowEnvironmentInternal.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,6 @@ public void GetWorkflowExecutionHistoryWithTimeout(
484484
impl.GetWorkflowExecutionHistoryWithTimeout(getRequest, resultHandler, timeoutInMillis);
485485
}
486486

487-
@Override
488-
public CompletableFuture<Boolean> isHealthy() {
489-
return impl.isHealthy();
490-
}
491-
492487
@Override
493488
public void PollForDecisionTask(
494489
PollForDecisionTaskRequest pollRequest, AsyncMethodCallback resultHandler)

src/main/java/com/uber/cadence/internal/testservice/TestWorkflowService.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -845,13 +845,6 @@ public void GetWorkflowExecutionHistoryWithTimeout(
845845
GetWorkflowExecutionHistory(getRequest, resultHandler);
846846
}
847847

848-
@Override
849-
public CompletableFuture<Boolean> isHealthy() {
850-
CompletableFuture<Boolean> rval = new CompletableFuture<>();
851-
rval.complete(Boolean.TRUE);
852-
return rval;
853-
}
854-
855848
@Override
856849
public void PollForDecisionTask(
857850
PollForDecisionTaskRequest pollRequest, AsyncMethodCallback resultHandler) throws TException {

src/main/java/com/uber/cadence/serviceclient/IWorkflowService.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.uber.cadence.StartWorkflowExecutionRequest;
2424
import com.uber.cadence.WorkflowService.AsyncIface;
2525
import com.uber.cadence.WorkflowService.Iface;
26-
import java.util.concurrent.CompletableFuture;
2726
import org.apache.thrift.TException;
2827
import org.apache.thrift.async.AsyncMethodCallback;
2928

@@ -71,7 +70,6 @@ void GetWorkflowExecutionHistoryWithTimeout(
7170
AsyncMethodCallback resultHandler,
7271
Long timeoutInMillis)
7372
throws TException;
74-
7573
/**
7674
* SignalWorkflowExecutionWithTimeout signal workflow same as SignalWorkflowExecution but with
7775
* timeout
@@ -86,6 +84,4 @@ void SignalWorkflowExecutionWithTimeout(
8684
AsyncMethodCallback resultHandler,
8785
Long timeoutInMillis)
8886
throws TException;
89-
90-
CompletableFuture<Boolean> isHealthy();
9187
}

src/main/java/com/uber/cadence/serviceclient/WorkflowServiceTChannel.java

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@
104104
import com.uber.tchannel.errors.ErrorType;
105105
import com.uber.tchannel.messages.ThriftRequest;
106106
import com.uber.tchannel.messages.ThriftResponse;
107-
import com.uber.tchannel.messages.generated.Meta;
108107
import java.net.InetAddress;
109108
import java.net.InetSocketAddress;
110109
import java.net.UnknownHostException;
@@ -128,7 +127,7 @@ public class WorkflowServiceTChannel implements IWorkflowService {
128127
private final ClientOptions options;
129128
private final Map<String, String> thriftHeaders;
130129
private final TChannel tChannel;
131-
private SubChannel subChannel;
130+
private final SubChannel subChannel;
132131

133132
/**
134133
* Creates Cadence client that connects to the specified host and port using specified options.
@@ -160,13 +159,6 @@ public WorkflowServiceTChannel(ClientOptions options) {
160159
+ Version.FEATURE_VERSION);
161160
}
162161

163-
public void resetSubchannelPeers() throws UnknownHostException {
164-
InetAddress address = InetAddress.getByName(options.getHost());
165-
ArrayList<InetSocketAddress> peers = new ArrayList<>();
166-
peers.add(new InetSocketAddress(address, options.getPort()));
167-
this.subChannel.setPeers(peers);
168-
}
169-
170162
/**
171163
* Creates Cadence client with specified sub channel and options.
172164
*
@@ -215,45 +207,6 @@ private <T> ThriftRequest<T> buildThriftRequest(String apiName, T body) {
215207
return buildThriftRequest(apiName, body, null);
216208
}
217209

218-
@Override
219-
public CompletableFuture<Boolean> isHealthy() {
220-
final ThriftRequest<Meta.health_args> req =
221-
new ThriftRequest.Builder<Meta.health_args>("cadence-frontend", "Meta::health")
222-
.setBody(new Meta.health_args())
223-
.build();
224-
final CompletableFuture<Boolean> result = new CompletableFuture<>();
225-
try {
226-
227-
final TFuture<ThriftResponse<Meta.health_result>> future = this.subChannel.send(req);
228-
future.addCallback(
229-
response -> {
230-
req.releaseQuietly();
231-
if (response.isError()) {
232-
try {
233-
this.resetSubchannelPeers();
234-
} catch (final Exception inner_e) {
235-
}
236-
result.completeExceptionally(new TException("Rpc error:" + response.getError()));
237-
} else {
238-
result.complete(response.getBody(Meta.health_result.class).getSuccess().isOk());
239-
}
240-
try {
241-
response.release();
242-
} catch (final Exception e) {
243-
// ignore
244-
}
245-
});
246-
} catch (final TChannelError e) {
247-
req.releaseQuietly();
248-
try {
249-
this.resetSubchannelPeers();
250-
} catch (final Exception inner_e) {
251-
}
252-
result.complete(Boolean.FALSE);
253-
}
254-
return result;
255-
}
256-
257210
private <T> ThriftRequest<T> buildThriftRequest(String apiName, T body, Long rpcTimeoutOverride) {
258211
String endpoint = getEndpoint(INTERFACE_NAME, apiName);
259212
ThriftRequest.Builder<T> builder =
@@ -284,11 +237,6 @@ private <T> ThriftResponse<T> doRemoteCall(ThriftRequest<?> request) throws TExc
284237
} catch (ExecutionException e) {
285238
throw new TException(e);
286239
} catch (TChannelError e) {
287-
try {
288-
resetSubchannelPeers();
289-
} catch (UnknownHostException uhe) {
290-
// do nothing?
291-
}
292240
throw new TException("Rpc error", e);
293241
}
294242
this.throwOnRpcError(response);
@@ -301,11 +249,6 @@ private <T> CompletableFuture<ThriftResponse<T>> doRemoteCallAsync(ThriftRequest
301249
try {
302250
future = subChannel.send(request);
303251
} catch (TChannelError tChannelError) {
304-
try {
305-
resetSubchannelPeers();
306-
} catch (UnknownHostException uhe) {
307-
// do nothing?
308-
}
309252
result.completeExceptionally(new TException(tChannelError));
310253
}
311254
future.addCallback(

src/main/java/com/uber/cadence/worker/Worker.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,4 @@ public void resumePolling() {
336336
public boolean isSuspended() {
337337
return workflowWorker.isSuspended() && activityWorker.isSuspended();
338338
}
339-
340-
public CompletableFuture<Boolean> isHealthy() {
341-
return workflowWorker.isHealthy();
342-
}
343339
}

src/main/java/com/uber/cadence/worker/WorkerFactory.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@
3939
import java.util.List;
4040
import java.util.Objects;
4141
import java.util.UUID;
42-
import java.util.concurrent.CompletableFuture;
4342
import java.util.concurrent.SynchronousQueue;
4443
import java.util.concurrent.ThreadPoolExecutor;
4544
import java.util.concurrent.TimeUnit;
4645
import java.util.concurrent.atomic.AtomicInteger;
47-
import java.util.stream.Collectors;
4846
import org.slf4j.Logger;
4947
import org.slf4j.LoggerFactory;
5048

@@ -289,16 +287,6 @@ public synchronized void shutdownNow() {
289287
}
290288
}
291289

292-
public CompletableFuture<Boolean> isHealthy() {
293-
List<CompletableFuture<Boolean>> healthyList =
294-
workers.stream().map(Worker::isHealthy).collect(Collectors.toList());
295-
CompletableFuture<Boolean> result = CompletableFuture.supplyAsync(() -> true);
296-
for (CompletableFuture<Boolean> future : healthyList) {
297-
result = result.thenCombine(future, (current, other) -> current && other);
298-
}
299-
return result;
300-
}
301-
302290
/**
303291
* Blocks until all tasks have completed execution after a shutdown request, or the timeout
304292
* occurs, or the current thread is interrupted, whichever happens first.

src/test/java/com/uber/cadence/workerFactory/WorkerFactoryTests.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
package com.uber.cadence.workerFactory;
1919

20-
import static org.junit.Assert.*;
20+
import static org.junit.Assert.assertFalse;
21+
import static org.junit.Assert.assertTrue;
2122

2223
import com.uber.cadence.client.WorkflowClient;
2324
import com.uber.cadence.serviceclient.ClientOptions;
@@ -64,11 +65,6 @@ public void whenAFactoryIsStartedAllWorkersStart() {
6465

6566
factory.start();
6667
assertTrue(factory.isStarted());
67-
try {
68-
assertTrue(factory.isHealthy().get());
69-
} catch (Exception e) {
70-
assertNull("Failed to check if cluster is health!", e);
71-
}
7268
factory.shutdown();
7369
factory.awaitTermination(1, TimeUnit.SECONDS);
7470
}

src/test/resources/logback-test.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@
2828
<root level="INFO">
2929
<appender-ref ref="STDOUT" />
3030
</root>
31-
</configuration>
31+
</configuration>

0 commit comments

Comments
 (0)