Browse Source

优化API

wangwei 5 years ago
parent
commit
017b1b98f7

+ 13 - 2
src/main/java/cn/com/qmth/examcloud/commons/helpers/pipeline/NodeExecuter.java

@@ -17,7 +17,18 @@ import cn.com.qmth.examcloud.commons.helpers.KeyValuePair;
  */
  */
 public interface NodeExecuter<KEYIN, VALUEIN, KEYOUT, VALUEOUT> {
 public interface NodeExecuter<KEYIN, VALUEIN, KEYOUT, VALUEOUT> {
 
 
-	List<KeyValuePair<KEYOUT, VALUEOUT>> execute(KEYIN key, VALUEIN value, TaskContext context)
-			throws Exception;
+	/**
+	 * 执行
+	 *
+	 * @author WANGWEI
+	 * @param key
+	 * @param value
+	 * @param outList
+	 * @param removable
+	 * @param context
+	 * @throws Exception
+	 */
+	void execute(KEYIN key, VALUEIN value, List<KeyValuePair<KEYOUT, VALUEOUT>> outList,
+			Boolean removable, TaskContext context) throws Exception;
 
 
 }
 }

+ 9 - 3
src/main/java/cn/com/qmth/examcloud/commons/helpers/pipeline/SimpleNode.java

@@ -7,6 +7,8 @@ import java.util.concurrent.TimeUnit;
 
 
 import org.apache.logging.log4j.ThreadContext;
 import org.apache.logging.log4j.ThreadContext;
 
 
+import com.google.common.collect.Lists;
+
 import cn.com.qmth.examcloud.commons.helpers.KeyValuePair;
 import cn.com.qmth.examcloud.commons.helpers.KeyValuePair;
 import cn.com.qmth.examcloud.commons.logging.ExamCloudLog;
 import cn.com.qmth.examcloud.commons.logging.ExamCloudLog;
 import cn.com.qmth.examcloud.commons.logging.ExamCloudLogFactory;
 import cn.com.qmth.examcloud.commons.logging.ExamCloudLogFactory;
@@ -123,7 +125,9 @@ public class SimpleNode<KEYIN, VALUEIN, KEYOUT, VALUEOUT>
 						.append(null == value ? null : value.toString()).toString());
 						.append(null == value ? null : value.toString()).toString());
 			}
 			}
 			counter.incrementTotal();
 			counter.incrementTotal();
-			List<KeyValuePair<KEYOUT, VALUEOUT>> outList = executer.execute(key, value, context);
+			List<KeyValuePair<KEYOUT, VALUEOUT>> outList = Lists.newLinkedList();
+			Boolean removable = true;
+			executer.execute(key, value, outList, removable, context);
 
 
 			if (null != outList && null != getLowerStorer()) {
 			if (null != outList && null != getLowerStorer()) {
 				for (KeyValuePair<KEYOUT, VALUEOUT> pair : outList) {
 				for (KeyValuePair<KEYOUT, VALUEOUT> pair : outList) {
@@ -131,8 +135,10 @@ public class SimpleNode<KEYIN, VALUEIN, KEYOUT, VALUEOUT>
 				}
 				}
 			}
 			}
 
 
-			if (null != key) {
-				getStorer().remove(key);
+			if (removable) {
+				if (null != key) {
+					getStorer().remove(key);
+				}
 			}
 			}
 
 
 			counter.incrementSuccessAmount();
 			counter.incrementSuccessAmount();