Skip to content

Commit 44296d2

Browse files
authored
Disabled stickyness by default until needed service change is released (#221)
* Fixed deduping of metric and logging test
1 parent 50700e7 commit 44296d2

File tree

5 files changed

+14
-37
lines changed

5 files changed

+14
-37
lines changed

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import com.uber.cadence.workflow.WorkflowInfo;
3838
import com.uber.cadence.workflow.WorkflowInterceptor;
3939
import com.uber.cadence.workflow.WorkflowMethod;
40-
import com.uber.m3.tally.Scope;
4140
import java.lang.reflect.InvocationTargetException;
4241
import java.lang.reflect.Method;
4342
import java.util.Collections;
@@ -67,19 +66,16 @@ final class POJOWorkflowImplementationFactory implements ReplayWorkflowFactory {
6766
Collections.synchronizedMap(new HashMap<>());
6867

6968
private final ExecutorService threadPool;
70-
private final Scope metricsScope;
7169
private DeciderCache cache;
7270

7371
POJOWorkflowImplementationFactory(
7472
DataConverter dataConverter,
7573
ExecutorService threadPool,
7674
Function<WorkflowInterceptor, WorkflowInterceptor> interceptorFactory,
77-
Scope metricsScope,
7875
DeciderCache cache) {
7976
this.dataConverter = Objects.requireNonNull(dataConverter);
8077
this.threadPool = Objects.requireNonNull(threadPool);
8178
this.interceptorFactory = Objects.requireNonNull(interceptorFactory);
82-
this.metricsScope = metricsScope;
8379
this.cache = cache;
8480
}
8581

@@ -320,7 +316,7 @@ void logSerializationException(
320316
+ eventId
321317
+ ". Dropping it.",
322318
exception);
323-
metricsScope.counter(MetricsType.CORRUPTED_SIGNALS_COUNTER).inc(1);
319+
Workflow.getMetricsScope().counter(MetricsType.CORRUPTED_SIGNALS_COUNTER).inc(1);
324320
}
325321

326322
static WorkflowExecutionException mapToWorkflowExecutionException(

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ public SyncWorkflowWorker(
5858

5959
factory =
6060
new POJOWorkflowImplementationFactory(
61-
options.getDataConverter(),
62-
workflowThreadPool,
63-
interceptorFactory,
64-
this.options.getMetricsScope(),
65-
cache);
61+
options.getDataConverter(), workflowThreadPool, interceptorFactory, cache);
6662

6763
DecisionTaskHandler taskHandler =
6864
new ReplayDecisionTaskHandler(

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,8 @@ enum State {
595595

596596
public static class FactoryOptions {
597597
public static class Builder {
598-
private boolean disableStickyExecution;
598+
// TODO: Enable by default as soon the service is released
599+
private boolean disableStickyExecution = true;
599600
private int stickyDecisionScheduleToStartTimeoutInSeconds = 5;
600601
private int cacheMaximumSize = 600;
601602
private int maxWorkflowThreadCount = 600;

src/test/java/com/uber/cadence/worker/StickyWorkerTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,16 @@
5757
import java.util.Queue;
5858
import java.util.Random;
5959
import org.junit.Assert;
60+
import org.junit.Ignore;
6061
import org.junit.Rule;
6162
import org.junit.Test;
6263
import org.junit.rules.TestName;
63-
import org.junit.runner.RunWith;
6464
import org.junit.runners.Parameterized;
6565
import org.slf4j.Logger;
6666
import org.slf4j.LoggerFactory;
6767

68-
@RunWith(Parameterized.class)
68+
// @RunWith(Parameterized.class)
69+
@Ignore
6970
public class StickyWorkerTest {
7071
public static final String DOMAIN = "UnitTest";
7172

src/test/java/com/uber/cadence/workflow/LoggerTest.java

+7-24
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,11 @@
3030
import com.uber.cadence.testing.TestWorkflowEnvironment;
3131
import com.uber.cadence.worker.Worker;
3232
import java.time.Duration;
33-
import java.util.Arrays;
34-
import java.util.Collection;
33+
import java.util.UUID;
3534
import org.junit.Test;
36-
import org.junit.runner.RunWith;
37-
import org.junit.runners.Parameterized;
38-
import org.junit.runners.Parameterized.Parameter;
39-
import org.junit.runners.Parameterized.Parameters;
4035
import org.slf4j.Logger;
4136
import org.slf4j.LoggerFactory;
4237

43-
@RunWith(Parameterized.class)
4438
public class LoggerTest {
4539

4640
private static final ListAppender<ILoggingEvent> listAppender = new ListAppender<>();
@@ -54,29 +48,15 @@ public class LoggerTest {
5448
}
5549

5650
private static final String taskList = "logger-test";
57-
private static final Logger workflowLogger = Workflow.getLogger(TestLoggingInWorkflow.class);
58-
private static final Logger childWorkflowLogger =
59-
Workflow.getLogger(TestLoggerInChildWorkflow.class);
60-
61-
@Parameters
62-
public static Collection<Object[]> data() {
63-
return Arrays.asList(new Object[][] {{false, "wf-1", 1}, {true, "wf-2", 3}});
64-
}
65-
66-
@Parameter public boolean loggingEnabledInReplay;
67-
68-
@Parameter(1)
69-
public String wfID;
70-
71-
@Parameter(2)
72-
public int startLinesExpected;
7351

7452
public interface TestWorkflow {
7553
@WorkflowMethod
7654
void execute(String id);
7755
}
7856

7957
public static class TestLoggingInWorkflow implements LoggerTest.TestWorkflow {
58+
private final Logger workflowLogger = Workflow.getLogger(TestLoggingInWorkflow.class);
59+
8060
@Override
8161
public void execute(String id) {
8262
workflowLogger.info("Start executing workflow {}.", id);
@@ -95,6 +75,8 @@ public interface TestChildWorkflow {
9575
}
9676

9777
public static class TestLoggerInChildWorkflow implements LoggerTest.TestChildWorkflow {
78+
private static final Logger childWorkflowLogger =
79+
Workflow.getLogger(TestLoggerInChildWorkflow.class);
9880

9981
@Override
10082
public void executeChild(String id) {
@@ -107,7 +89,7 @@ public void testWorkflowLogger() {
10789
TestEnvironmentOptions testOptions =
10890
new TestEnvironmentOptions.Builder()
10991
.setDomain(WorkflowTest.DOMAIN)
110-
.setEnableLoggingInReplay(loggingEnabledInReplay)
92+
.setEnableLoggingInReplay(false)
11193
.build();
11294
TestWorkflowEnvironment env = TestWorkflowEnvironment.newInstance(testOptions);
11395
Worker worker = env.newWorker(taskList);
@@ -123,6 +105,7 @@ public void testWorkflowLogger() {
123105
.build();
124106
LoggerTest.TestWorkflow workflow =
125107
workflowClient.newWorkflowStub(LoggerTest.TestWorkflow.class, options);
108+
String wfID = UUID.randomUUID().toString();
126109
workflow.execute(wfID);
127110

128111
assertEquals(1, matchingLines(String.format("Start executing workflow %s.", wfID)));

0 commit comments

Comments
 (0)