Skip to content

Commit 7cbfb7b

Browse files
author
Liang Mei
committed
Revert "Integration get raw history #443 (#472)"
This reverts commit 3c8c4fa.
1 parent 3c8c4fa commit 7cbfb7b

File tree

5 files changed

+11
-83
lines changed

5 files changed

+11
-83
lines changed

src/main/idls

Submodule idls updated from 8e3046c to 56ca0b5

src/main/java/com/uber/cadence/internal/common/InternalUtils.java

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,19 @@
1818
package com.uber.cadence.internal.common;
1919

2020
import com.google.common.base.Defaults;
21-
import com.uber.cadence.DataBlob;
22-
import com.uber.cadence.History;
23-
import com.uber.cadence.HistoryEvent;
24-
import com.uber.cadence.HistoryEventFilterType;
2521
import com.uber.cadence.SearchAttributes;
2622
import com.uber.cadence.TaskList;
2723
import com.uber.cadence.TaskListKind;
28-
import com.uber.cadence.EntityNotExistsError;
2924
import com.uber.cadence.converter.DataConverter;
3025
import com.uber.cadence.converter.JsonDataConverter;
3126
import com.uber.cadence.internal.worker.Shutdownable;
3227
import com.uber.cadence.workflow.WorkflowMethod;
3328
import java.lang.reflect.Method;
3429
import java.nio.ByteBuffer;
35-
import java.util.Arrays;
36-
import java.util.ArrayList;
37-
import java.util.List;
3830
import java.util.HashMap;
3931
import java.util.Map;
4032
import java.util.concurrent.ExecutorService;
4133
import java.util.concurrent.TimeUnit;
42-
import org.apache.thrift.TDeserializer;
43-
import org.apache.thrift.TException;
44-
import org.apache.thrift.TSerializer;
4534

4635
/** Utility functions shared by the implementation code. */
4736
public final class InternalUtils {
@@ -154,56 +143,6 @@ public static SearchAttributes convertMapToSearchAttributes(
154143
return new SearchAttributes().setIndexedFields(mapOfByteBuffer);
155144
}
156145

157-
// This method deserialize the DataBlob data to the HistoriyEvent data
158-
public static History DeserializeFromBlobToHistoryEvents(
159-
List<DataBlob> blobData, HistoryEventFilterType historyEventFilterType) throws TException {
160-
161-
List<HistoryEvent> events = new ArrayList<HistoryEvent>();
162-
for (DataBlob data : blobData) {
163-
History history = new History();
164-
try {
165-
byte[] dataByte = data.getData();
166-
dataByte = Arrays.copyOfRange(dataByte, 1, dataByte.length);
167-
deSerializer.deserialize(history, dataByte);
168-
169-
if (history == null || history.getEvents() == null || history.getEvents().size() == 0) {
170-
return null;
171-
}
172-
} catch (org.apache.thrift.TException err) {
173-
throw new TException("Deserialize blob data to history event failed with unknown error");
174-
}
175-
176-
events.addAll(history.getEvents());
177-
}
178-
179-
if (events.size() > 0 && historyEventFilterType == HistoryEventFilterType.CLOSE_EVENT) {
180-
events = events.subList(events.size() - 1, events.size());
181-
}
182-
183-
return new History().setEvents(events);
184-
}
185-
186-
// This method deserialize the history event data to blob data
187-
public static List<DataBlob> DeserializeFromHistoryEventToBlobData(List<HistoryEvent> events)
188-
throws EntityNotExistsError {
189-
190-
List<DataBlob> blobs = new ArrayList<DataBlob>();
191-
for (HistoryEvent event : events) {
192-
DataBlob blob = new DataBlob();
193-
try {
194-
blob.setData(serializer.serialize(event));
195-
} catch (org.apache.thrift.TException err) {
196-
throw new EntityNotExistsError("Deserialize blob data to history event failed with unknown error");
197-
}
198-
blobs.add(blob);
199-
}
200-
201-
return blobs;
202-
}
203-
204-
private static final TDeserializer deSerializer = new TDeserializer();
205-
private static final TSerializer serializer = new TSerializer();
206-
207146
/** Prohibit instantiation */
208147
private InternalUtils() {}
209148
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import java.util.List;
3232
import java.util.Objects;
3333
import java.util.Optional;
34-
import org.apache.thrift.TException;
3534

3635
interface TestWorkflowStore {
3736

@@ -156,7 +155,8 @@ void sendQueryTask(ExecutionId executionId, TaskListId taskList, PollForDecision
156155
throws EntityNotExistsError;
157156

158157
GetWorkflowExecutionHistoryResponse getWorkflowExecutionHistory(
159-
ExecutionId executionId, GetWorkflowExecutionHistoryRequest getRequest) throws EntityNotExistsError;
158+
ExecutionId executionId, GetWorkflowExecutionHistoryRequest getRequest)
159+
throws EntityNotExistsError;
160160

161161
void getDiagnostics(StringBuilder result);
162162

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import com.uber.cadence.BadRequestError;
2121
import com.uber.cadence.EntityNotExistsError;
2222
import com.uber.cadence.EventType;
23-
import com.uber.cadence.DataBlob;
24-
import com.uber.cadence.internal.common.InternalUtils;
2523
import com.uber.cadence.GetWorkflowExecutionHistoryRequest;
2624
import com.uber.cadence.GetWorkflowExecutionHistoryResponse;
2725
import com.uber.cadence.History;
@@ -49,7 +47,6 @@
4947
import java.util.concurrent.locks.Condition;
5048
import java.util.concurrent.locks.Lock;
5149
import java.util.concurrent.locks.ReentrantLock;
52-
import org.apache.thrift.TException;
5350

5451
class TestWorkflowStoreImpl implements TestWorkflowStore {
5552

@@ -338,7 +335,8 @@ public void sendQueryTask(
338335

339336
@Override
340337
public GetWorkflowExecutionHistoryResponse getWorkflowExecutionHistory(
341-
ExecutionId executionId, GetWorkflowExecutionHistoryRequest getRequest) throws EntityNotExistsError {
338+
ExecutionId executionId, GetWorkflowExecutionHistoryRequest getRequest)
339+
throws EntityNotExistsError {
342340
HistoryStore history;
343341
// Used to eliminate the race condition on waitForNewEvents
344342
long expectedNextEventId;
@@ -348,23 +346,20 @@ public GetWorkflowExecutionHistoryResponse getWorkflowExecutionHistory(
348346
if (!getRequest.isWaitForNewEvent()
349347
&& getRequest.getHistoryEventFilterType() != HistoryEventFilterType.CLOSE_EVENT) {
350348
List<HistoryEvent> events = history.getEventsLocked();
351-
List<DataBlob> blobs = InternalUtils.DeserializeFromHistoryEventToBlobData(events);
352349
// Copy the list as it is mutable. Individual events assumed immutable.
353350
ArrayList<HistoryEvent> eventsCopy = new ArrayList<>(events);
354351
return new GetWorkflowExecutionHistoryResponse()
355-
.setHistory(new History().setEvents(eventsCopy)).setRawHistory(blobs);
352+
.setHistory(new History().setEvents(eventsCopy));
356353
}
357354
expectedNextEventId = history.getNextEventIdLocked();
358355
} finally {
359356
lock.unlock();
360357
}
361358
List<HistoryEvent> events =
362359
history.waitForNewEvents(expectedNextEventId, getRequest.getHistoryEventFilterType());
363-
List<DataBlob> blobs = InternalUtils.DeserializeFromHistoryEventToBlobData(events);
364360
GetWorkflowExecutionHistoryResponse result = new GetWorkflowExecutionHistoryResponse();
365361
if (events != null) {
366362
result.setHistory(new History().setEvents(events));
367-
result.setRawHistory(blobs);
368363
}
369364
return result;
370365
}

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import com.uber.cadence.GetSearchAttributesResponse;
3838
import com.uber.cadence.GetWorkflowExecutionHistoryRequest;
3939
import com.uber.cadence.GetWorkflowExecutionHistoryResponse;
40-
import com.uber.cadence.History;
4140
import com.uber.cadence.InternalServiceError;
4241
import com.uber.cadence.LimitExceededError;
4342
import com.uber.cadence.ListArchivedWorkflowExecutionsRequest;
@@ -91,7 +90,6 @@
9190
import com.uber.cadence.WorkflowService.GetWorkflowExecutionHistory_result;
9291
import com.uber.cadence.internal.Version;
9392
import com.uber.cadence.internal.common.CheckedExceptionWrapper;
94-
import com.uber.cadence.internal.common.InternalUtils;
9593
import com.uber.cadence.internal.metrics.MetricsType;
9694
import com.uber.cadence.internal.metrics.NoopScope;
9795
import com.uber.cadence.internal.metrics.ServiceMethod;
@@ -108,7 +106,10 @@
108106
import java.net.InetAddress;
109107
import java.net.InetSocketAddress;
110108
import java.net.UnknownHostException;
111-
import java.util.*;
109+
import java.util.ArrayList;
110+
import java.util.HashMap;
111+
import java.util.Map;
112+
import java.util.UUID;
112113
import java.util.concurrent.CompletableFuture;
113114
import java.util.concurrent.ExecutionException;
114115
import org.apache.thrift.TException;
@@ -852,14 +853,7 @@ private GetWorkflowExecutionHistoryResponse getWorkflowExecutionHistory(
852853
WorkflowService.GetWorkflowExecutionHistory_result result =
853854
response.getBody(WorkflowService.GetWorkflowExecutionHistory_result.class);
854855
if (response.getResponseCode() == ResponseCode.OK) {
855-
GetWorkflowExecutionHistoryResponse res = result.getSuccess();
856-
if (res.getRawHistory() != null) {
857-
History history =
858-
InternalUtils.DeserializeFromBlobToHistoryEvents(
859-
res.getRawHistory(), getRequest.getHistoryEventFilterType());
860-
res.setHistory(history);
861-
}
862-
return res;
856+
return result.getSuccess();
863857
}
864858
if (result.isSetBadRequestError()) {
865859
throw result.getBadRequestError();

0 commit comments

Comments
 (0)