Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ public static WorkflowClient newInstance(
.getMetricsScope()
.tagged(MetricsTag.defaultTags(options.getNamespace()));
ExternalStorage externalStorage = options.getExternalStorage();
this.externalStorageRunner =
ExternalStorageRunner externalStorageRunner =
externalStorage == null ? null : ExternalStorageRunner.create(externalStorage);
this.externalStorageRunner = externalStorageRunner;
this.genericClient = new GenericWorkflowClientImpl(workflowServiceStubs, metricsScope);
this.interceptors = options.getInterceptors();
this.workflowClientCallsInvoker = initializeClientInvoker();
Expand All @@ -120,7 +121,8 @@ public static WorkflowClient newInstance(
workflowServiceStubs,
options.getNamespace(),
options.getIdentity(),
options.getDataConverter());
options.getDataConverter(),
externalStorageRunner);

java.time.Duration heartbeatInterval = options.getWorkerHeartbeatInterval();
if (!heartbeatInterval.isNegative()) {
Expand All @@ -133,7 +135,8 @@ public static WorkflowClient newInstance(

private WorkflowClientCallsInterceptor initializeClientInvoker() {
WorkflowClientCallsInterceptor workflowClientInvoker =
new RootWorkflowClientInvoker(genericClient, options, workerFactoryRegistry);
new RootWorkflowClientInvoker(
genericClient, options, workerFactoryRegistry, externalStorageRunner);
for (WorkflowClientInterceptor clientInterceptor : interceptors) {
workflowClientInvoker =
clientInterceptor.workflowClientCallsInterceptor(workflowClientInvoker);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.temporal.client;

import io.temporal.api.common.v1.Payload;
import io.temporal.api.workflowservice.v1.DescribeWorkflowExecutionResponse;
import io.temporal.common.converter.DataConverter;
import io.temporal.payload.context.WorkflowSerializationContext;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

Expand All @@ -29,15 +29,8 @@ public String getStaticSummary() {
if (!response.getExecutionConfig().getUserMetadata().hasSummary()) {
return null;
}
return dataConverter

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like fixing a separate pre-existing bug. I think it should be restored and then addressed separately.

.withContext(
new WorkflowSerializationContext(
response.getWorkflowExecutionInfo().getParentNamespaceId(),
response.getWorkflowExecutionInfo().getExecution().getWorkflowId()))
.fromPayload(
response.getExecutionConfig().getUserMetadata().getSummary(),
String.class,
String.class);
Payload summary = response.getExecutionConfig().getUserMetadata().getSummary();
return dataConverter.fromPayload(summary, String.class, String.class);
}

/**
Expand All @@ -51,15 +44,8 @@ public String getStaticDetails() {
if (!response.getExecutionConfig().getUserMetadata().hasDetails()) {
return null;
}
return dataConverter

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.withContext(
new WorkflowSerializationContext(
response.getWorkflowExecutionInfo().getParentNamespaceId(),
response.getWorkflowExecutionInfo().getExecution().getWorkflowId()))
.fromPayload(
response.getExecutionConfig().getUserMetadata().getDetails(),
String.class,
String.class);
Payload details = response.getExecutionConfig().getUserMetadata().getDetails();
return dataConverter.fromPayload(details, String.class, String.class);
}

/** Returns the raw response from the Temporal service. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import io.temporal.common.converter.DataConverter;
import io.temporal.internal.common.ProtobufTimeUtils;
import io.temporal.internal.common.SearchAttributesUtil;
import io.temporal.payload.context.WorkflowSerializationContext;
import java.lang.reflect.Type;
import java.time.Duration;
import java.time.Instant;
Expand Down Expand Up @@ -123,11 +122,7 @@ public <T> T getMemo(String key, Class<T> valueClass, Type genericType) {
if (memo == null) {
return null;
}
return dataConverter
.withContext(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new WorkflowSerializationContext(
info.getParentNamespaceId(), info.getExecution().getWorkflowId()))
.fromPayload(memo, valueClass, genericType);
return dataConverter.fromPayload(memo, valueClass, genericType);
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import io.temporal.client.WorkflowClient;
import io.temporal.common.converter.DataConverter;
import io.temporal.internal.client.external.ManualActivityCompletionClientFactory;
import io.temporal.internal.payload.storage.ExternalStorageRunner;
import java.nio.ByteBuffer;
import java.time.Duration;
import java.util.Arrays;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ScheduledExecutorService;
import javax.annotation.Nullable;

public class ActivityExecutionContextFactoryImpl implements ActivityExecutionContextFactory {
private final WorkflowClient client;
Expand All @@ -21,6 +23,7 @@ public class ActivityExecutionContextFactoryImpl implements ActivityExecutionCon
private final DataConverter dataConverter;
private final ScheduledExecutorService heartbeatExecutor;
private final ManualActivityCompletionClientFactory manualCompletionClientFactory;
private final @Nullable ExternalStorageRunner externalStorage;
private final ConcurrentMap<ByteBuffer, ActivityExecutionContextImpl> activeContexts =
new ConcurrentHashMap<>();

Expand All @@ -31,7 +34,8 @@ public ActivityExecutionContextFactoryImpl(
Duration maxHeartbeatThrottleInterval,
Duration defaultHeartbeatThrottleInterval,
DataConverter dataConverter,
ScheduledExecutorService heartbeatExecutor) {
ScheduledExecutorService heartbeatExecutor,
@Nullable ExternalStorageRunner externalStorage) {
this.client = Objects.requireNonNull(client);
this.identity = identity;
this.namespace = Objects.requireNonNull(namespace);
Expand All @@ -40,9 +44,10 @@ public ActivityExecutionContextFactoryImpl(
Objects.requireNonNull(defaultHeartbeatThrottleInterval);
this.dataConverter = Objects.requireNonNull(dataConverter);
this.heartbeatExecutor = Objects.requireNonNull(heartbeatExecutor);
this.externalStorage = externalStorage;
this.manualCompletionClientFactory =
ManualActivityCompletionClientFactory.newFactory(
client.getWorkflowServiceStubs(), namespace, identity, dataConverter);
client.getWorkflowServiceStubs(), namespace, identity, dataConverter, externalStorage);
}

@Override
Expand All @@ -63,7 +68,8 @@ public InternalActivityExecutionContext createContext(
identity,
maxHeartbeatThrottleInterval,
defaultHeartbeatThrottleInterval,
() -> cleanupContext(info.getTaskToken(), false));
() -> cleanupContext(info.getTaskToken(), false),
externalStorage);
activeContexts.put(taskToken, context);
return context;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.temporal.common.CancellationToken;
import io.temporal.common.converter.DataConverter;
import io.temporal.internal.client.external.ManualActivityCompletionClientFactory;
import io.temporal.internal.payload.storage.ExternalStorageRunner;
import io.temporal.payload.context.ActivitySerializationContext;
import io.temporal.workflow.Functions;
import java.lang.reflect.Type;
Expand All @@ -18,6 +19,7 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;

/**
Expand Down Expand Up @@ -55,7 +57,8 @@ class ActivityExecutionContextImpl implements InternalActivityExecutionContext {
String identity,
Duration maxHeartbeatThrottleInterval,
Duration defaultHeartbeatThrottleInterval,
Functions.Proc closeCallback) {
Functions.Proc closeCallback,
@Nullable ExternalStorageRunner externalStorage) {
this.client = client;
this.activity = activity;
this.metricsScope = metricsScope;
Expand All @@ -73,7 +76,8 @@ class ActivityExecutionContextImpl implements InternalActivityExecutionContext {
metricsScope,
identity,
maxHeartbeatThrottleInterval,
defaultHeartbeatThrottleInterval);
defaultHeartbeatThrottleInterval,
externalStorage);
}

/**
Expand Down Expand Up @@ -155,7 +159,10 @@ public ManualActivityCompletionClient useLocalManualCompletion() {
new ActivitySerializationContext(info);
return new CompletionAwareManualCompletionClient(
manualCompletionClientFactory.getClient(
info.getTaskToken(), metricsScope, activitySerializationContext),
info.getTaskToken(),
metricsScope,
activitySerializationContext,
HeartbeatContextImpl.storageTargetForActivity(info.getNamespace(), info)),
completionHandle);
} finally {
lock.unlock();
Expand Down
Loading
Loading