asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ti...@apache.org
Subject asterixdb git commit: small refactoring
Date Tue, 23 Aug 2016 21:40:35 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 98526fedd -> de9ade641


small refactoring

Change-Id: I37eab1645416e3aad6119bba527c5e3b4b98fddc
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1052
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/de9ade64
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/de9ade64
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/de9ade64

Branch: refs/heads/master
Commit: de9ade64192a5a3aee284e828eecd2ff892bd9e0
Parents: 98526fe
Author: Till Westmann <tillw@apache.org>
Authored: Fri Aug 5 12:37:13 2016 -0700
Committer: Till Westmann <tillw@apache.org>
Committed: Tue Aug 23 14:40:11 2016 -0700

----------------------------------------------------------------------
 .../dataflow/FeedRecordDataFlowController.java  | 36 ++++++++++++--------
 1 file changed, 21 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/de9ade64/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FeedRecordDataFlowController.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FeedRecordDataFlowController.java
b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FeedRecordDataFlowController.java
index 4189dbf..10e9125 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FeedRecordDataFlowController.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataflow/FeedRecordDataFlowController.java
@@ -54,7 +54,7 @@ public class FeedRecordDataFlowController<T> extends AbstractFeedDataFlowControl
     protected final boolean sendMarker;
     protected boolean failed = false;
     private FeedRecordDataFlowController<T>.DataflowMarker dataflowMarker;
-    private Future<?> result;
+    private Future<?> dataflowMarkerResult;
 
     public FeedRecordDataFlowController(IHyracksTaskContext ctx, FeedTupleForwarder tupleForwarder,
             @Nonnull FeedLogManager feedLogManager, int numOfOutputFields, @Nonnull IRecordDataParser<T>
dataParser,
@@ -69,12 +69,7 @@ public class FeedRecordDataFlowController<T> extends AbstractFeedDataFlowControl
 
     @Override
     public void start(IFrameWriter writer) throws HyracksDataException {
-        ExecutorService executorService = sendMarker ? Executors.newSingleThreadExecutor()
: null;
-        if (sendMarker && dataflowMarker == null) {
-            dataflowMarker = new DataflowMarker(recordReader.getProgressReporter(),
-                    TaskUtils.<VSizeFrame> get(HyracksConstants.KEY_MESSAGE, ctx));
-            result = executorService.submit(dataflowMarker);
-        }
+        startDataflowMarker();
         HyracksDataException hde = null;
         try {
             failed = false;
@@ -102,9 +97,7 @@ public class FeedRecordDataFlowController<T> extends AbstractFeedDataFlowControl
             LOGGER.warn("Failure while operating a feed source", e);
             throw new HyracksDataException(e);
         }
-        if(dataflowMarker != null){
-            dataflowMarker.stop();
-        }
+        stopDataflowMarker();
         try {
             tupleForwarder.close();
         } catch (Throwable th) {
@@ -117,8 +110,8 @@ public class FeedRecordDataFlowController<T> extends AbstractFeedDataFlowControl
             hde = ExternalDataExceptionUtils.suppressIntoHyracksDataException(hde, th);
         } finally {
             closeSignal();
-            if (sendMarker && result != null) {
-                result.cancel(true);
+            if (sendMarker && dataflowMarkerResult != null) {
+                dataflowMarkerResult.cancel(true);
             }
         }
         if (hde != null) {
@@ -149,6 +142,21 @@ public class FeedRecordDataFlowController<T> extends AbstractFeedDataFlowControl
     protected void addPrimaryKeys(ArrayTupleBuilder tb, IRawRecord<? extends T> record)
throws IOException {
     }
 
+    private void startDataflowMarker() {
+        ExecutorService executorService = sendMarker ? Executors.newSingleThreadExecutor()
: null;
+        if (sendMarker && dataflowMarker == null) {
+            dataflowMarker = new DataflowMarker(recordReader.getProgressReporter(),
+                    TaskUtils.<VSizeFrame> get(HyracksConstants.KEY_MESSAGE, ctx));
+            dataflowMarkerResult = executorService.submit(dataflowMarker);
+        }
+    }
+
+    private void stopDataflowMarker() {
+        if (dataflowMarker != null) {
+            dataflowMarker.stop();
+        }
+    }
+
     private void closeSignal() {
         synchronized (closed) {
             closed.set(true);
@@ -166,9 +174,7 @@ public class FeedRecordDataFlowController<T> extends AbstractFeedDataFlowControl
 
     @Override
     public boolean stop() throws HyracksDataException {
-        if (dataflowMarker != null) {
-            dataflowMarker.stop();
-        }
+        stopDataflowMarker();
         HyracksDataException hde = null;
         if (recordReader.stop()) {
             if (failed) {


Mime
View raw message