[
https://issues.apache.org/jira/browse/BEAM-6672?focusedWorklogId=198989&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-198989
]
ASF GitHub Bot logged work on BEAM-6672:
----------------------------------------
Author: ASF GitHub Bot
Created on: 14/Feb/19 22:26
Start Date: 14/Feb/19 22:26
Worklog Time Spent: 10m
Work Description: rohdesamuel commented on pull request #7847:
[BEAM-6672] Add the StateRequestHandlerImpl and test
URL: https://github.com/apache/beam/pull/7847#discussion_r257038532
##########
File path:
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/fn/control/StateRequestHandlerImpl.java
##########
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.dataflow.worker.fn.control;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.ConcurrentHashMap;
+import org.apache.beam.model.fnexecution.v1.BeamFnApi;
+import org.apache.beam.runners.core.StateNamespaces;
+import org.apache.beam.runners.core.StateTags;
+import org.apache.beam.runners.dataflow.worker.ByteStringCoder;
+import org.apache.beam.runners.dataflow.worker.DataflowExecutionContext;
+import org.apache.beam.runners.fnexecution.state.StateRequestHandler;
+import org.apache.beam.sdk.state.BagState;
+import org.apache.beam.sdk.transforms.windowing.GlobalWindow;
+import org.apache.beam.vendor.grpc.v1p13p1.com.google.protobuf.ByteString;
+
+public class StateRequestHandlerImpl implements StateRequestHandler {
+
+ private DataflowExecutionContext.DataflowStepContext ctxt;
+ private ConcurrentHashMap<BeamFnApi.StateKey, BagState<ByteString>>
userStateData;
+
+ public StateRequestHandlerImpl(DataflowExecutionContext.DataflowStepContext
ctxt) {
+ this.ctxt = ctxt;
+ this.userStateData = new ConcurrentHashMap<>();
+ }
+
+ @Override
+ public CompletionStage<BeamFnApi.StateResponse.Builder>
handle(BeamFnApi.StateRequest request)
+ throws Exception {
+ switch (request.getStateKey().getTypeCase()) {
+ case BAG_USER_STATE:
+ return handleBagUserState(request);
+ default:
+ throw new UnsupportedOperationException(
+ String.format(
+ "Dataflow does not handle StateRequests of type %s",
+ request.getStateKey().getTypeCase()));
+ }
+ }
+
+ public void finish() {
+ userStateData.clear();
+ }
+
+ private CompletionStage<BeamFnApi.StateResponse.Builder> handleBagUserState(
+ BeamFnApi.StateRequest request) {
+ BeamFnApi.StateKey.BagUserState bagUserStateKey =
request.getStateKey().getBagUserState();
+ // TODO: We should not be required to hold onto a pointer to the bag
states for the
Review comment:
Done
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 198989)
Time Spent: 1.5h (was: 1h 20m)
> Make bundle execution with ExecutableStage support user states
> --------------------------------------------------------------
>
> Key: BEAM-6672
> URL: https://issues.apache.org/jira/browse/BEAM-6672
> Project: Beam
> Issue Type: Improvement
> Components: runner-dataflow
> Reporter: Sam Rohde
> Assignee: Sam Rohde
> Priority: Major
> Time Spent: 1.5h
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)