use of com.uber.m3.tally.NoopScope in project sdk-java by temporalio.
the class MemoTest method testMemo.
@Test
public void testMemo() {
if (testWorkflowRule.getTestEnvironment() == null) {
return;
}
WorkflowOptions workflowOptions = SDKTestOptions.newWorkflowOptionsWithTimeouts(testWorkflowRule.getTaskQueue()).toBuilder().setTaskQueue(testWorkflowRule.getTaskQueue()).setMemo(MEMO).build();
TestNoArgsWorkflowFunc stubF = testWorkflowRule.getWorkflowClient().newWorkflowStub(TestNoArgsWorkflowFunc.class, workflowOptions);
WorkflowExecution executionF = WorkflowClient.start(stubF::func);
GetWorkflowExecutionHistoryResponse historyResp = WorkflowClientHelper.getHistoryPage(testWorkflowRule.getTestEnvironment().getWorkflowService(), SDKTestWorkflowRule.NAMESPACE, executionF, ByteString.EMPTY, new NoopScope());
HistoryEvent startEvent = historyResp.getHistory().getEvents(0);
Memo memoFromEvent = startEvent.getWorkflowExecutionStartedEventAttributes().getMemo();
Payload memoBytes = memoFromEvent.getFieldsMap().get(MEMO_KEY);
String memoRetrieved = GsonJsonPayloadConverter.getInstance().fromData(memoBytes, String.class, String.class);
assertEquals(MEMO_VALUE, memoRetrieved);
}
use of com.uber.m3.tally.NoopScope in project sdk-java by temporalio.
the class ReplayWorkflowRunTaskHandlerCacheTests method evictAnyWillNotInvalidateItself.
@Test
public void evictAnyWillNotInvalidateItself() throws Exception {
// Arrange
WorkflowExecutorCache cache = new WorkflowExecutorCache(50, new NoopScope());
PollWorkflowTaskQueueResponse workflowTask1 = HistoryUtils.generateWorkflowTaskWithInitialHistory();
// Act
WorkflowRunTaskHandler workflowRunTaskHandler = cache.getOrCreate(workflowTask1, metricsScope, () -> createFakeExecutor(workflowTask1));
WorkflowExecution execution = workflowTask1.getWorkflowExecution();
cache.addToCache(execution, workflowRunTaskHandler);
assertEquals(1, cache.size());
cache.evictAnyNotInProcessing(execution, metricsScope);
// Assert
assertEquals(1, cache.size());
}
use of com.uber.m3.tally.NoopScope in project cadence-client by uber-java.
the class ShadowingWorkerTest method init.
@Before
public void init() {
WorkflowClientOptions clientOptions = WorkflowClientOptions.newBuilder().setMetricsScope(new NoopScope()).build();
when(mockClient.getOptions()).thenReturn(clientOptions);
when(mockClient.getService()).thenReturn(mockService);
}
use of com.uber.m3.tally.NoopScope in project cadence-client by uber-java.
the class NoopScope method getInstance.
public static synchronized Scope getInstance() {
if (noopScope == null) {
noopCounter = delta -> {
};
noopGauge = value -> {
};
noopTimer = new Timer() {
@Override
public void record(Duration interval) {
}
@Override
public Stopwatch start() {
return new Stopwatch(0, stopwatchStart -> {
});
}
};
noopHistogram = new Histogram() {
@Override
public void recordValue(double value) {
}
@Override
public void recordDuration(Duration value) {
}
@Override
public Stopwatch start() {
return new Stopwatch(0, stopwatchStart -> {
});
}
};
noopScope = new NoopScope();
}
return noopScope;
}
use of com.uber.m3.tally.NoopScope in project sdk-java by temporalio.
the class ReplayWorkflowRunTaskHandlerTaskHandlerTests method ifStickyExecutionAttributesAreSetThenWorkflowsAreCached.
@Test
public void ifStickyExecutionAttributesAreSetThenWorkflowsAreCached() throws Throwable {
// Arrange
WorkflowExecutorCache cache = new WorkflowExecutorCache(10, new NoopScope());
WorkflowTaskHandler taskHandler = new ReplayWorkflowTaskHandler("namespace", setUpMockWorkflowFactory(), cache, SingleWorkerOptions.newBuilder().build(), "sticky", Duration.ofSeconds(5), service, null);
PollWorkflowTaskQueueResponse workflowTask = HistoryUtils.generateWorkflowTaskWithInitialHistory();
WorkflowTaskHandler.Result result = taskHandler.handleWorkflowTask(workflowTask);
assertTrue(result.isCompletionCommand());
// do not cache if completion command
assertEquals(0, cache.size());
assertNotNull(result.getTaskCompleted());
StickyExecutionAttributes attributes = result.getTaskCompleted().getStickyAttributes();
assertEquals("sticky", attributes.getWorkerTaskQueue().getName());
assertEquals(Durations.fromSeconds(5), attributes.getScheduleToStartTimeout());
}
Aggregations