Skip to content

Commit

Permalink
cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
vavi committed Oct 8, 2022
1 parent 51d18fd commit c265ef4
Show file tree
Hide file tree
Showing 26 changed files with 239 additions and 261 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ public boolean enter(ExecutionContext context, PvmActivity pvmActivity) {
//由于这里仅是服务编排,所以这里直接返回`暂停`信号。
return true;

}else {
} else {

return processDefaultLogic(context, pvmActivity, parallelGateway);

return defaultLogic(context, pvmActivity, parallelGateway);
}


Expand All @@ -80,7 +80,7 @@ public boolean enter(ExecutionContext context, PvmActivity pvmActivity) {



private boolean defaultLogic(ExecutionContext context, PvmActivity pvmActivity, ParallelGateway parallelGateway) {
private boolean processDefaultLogic(ExecutionContext context, PvmActivity pvmActivity, ParallelGateway parallelGateway) {


Map<String, PvmTransition> incomeTransitions = pvmActivity.getIncomeTransitions();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.alibaba.smart.framework.engine.configuration.impl;

import com.alibaba.smart.framework.engine.behavior.ActivityBehavior;
import com.alibaba.smart.framework.engine.bpmn.behavior.gateway.GatewaySticker;
import com.alibaba.smart.framework.engine.common.util.MapUtil;
import com.alibaba.smart.framework.engine.configuration.ExceptionProcessor;
import com.alibaba.smart.framework.engine.configuration.ParallelServiceOrchestration;
Expand Down Expand Up @@ -69,7 +68,7 @@ public void orchestrateService(ExecutionContext context, PvmActivity pvmActivity

List<Future<PvmActivity>> futureExecutionResultList = invoke(latchWaitTime, isSkipTimeout, executeStrategy, executorService, pvmActivityTaskList);

accquireFutureResult(context, processEngineConfiguration, latchWaitTime, isSkipTimeout, futureExecutionResultList);
acquireFutureResult(context, processEngineConfiguration, latchWaitTime, isSkipTimeout, futureExecutionResultList);

// // 获取第一个成功执行的future
// Future<PvmActivity> pvmActivityFuture = getSuccessFuture(futureExecutionResultList, isSkipTimeoutExp);
Expand Down Expand Up @@ -145,7 +144,7 @@ protected PvmActivity initMultiTaskRequestAndFindOutJoinActivity(ExecutionContex
return finalJoinParallelGateWayPvmActivity;
}

private void accquireFutureResult(ExecutionContext context, ProcessEngineConfiguration processEngineConfiguration, Long latchWaitTime, boolean isSkipTimeoutExp, List<Future<PvmActivity>> futureExecutionResultList) throws TimeoutException {
private void acquireFutureResult(ExecutionContext context, ProcessEngineConfiguration processEngineConfiguration, Long latchWaitTime, boolean isSkipTimeoutExp, List<Future<PvmActivity>> futureExecutionResultList) throws TimeoutException {
//注意这里的逻辑:这里假设是子线程在执行某个fork分支的逻辑后,然后会在join节点时返回。这个join节点就是 futureJoinParallelGateWay。
// 当await 执行结束后,这里的假设不变式:所有子线程都已经到达了join节点。
ExceptionProcessor exceptionProcessor = processEngineConfiguration.getExceptionProcessor();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.alibaba.smart.framework.engine.test.cases;
package com.alibaba.smart.framework.engine.test.parallelgateway;

import java.util.HashMap;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.alibaba.smart.framework.engine.test;
package com.alibaba.smart.framework.engine.test.parallelgateway.deprecated;

import java.text.SimpleDateFormat;
import java.util.Date;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.alibaba.smart.framework.engine.test;
package com.alibaba.smart.framework.engine.test.parallelgateway.deprecated;

import java.util.ArrayList;
import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.alibaba.smart.framework.engine.test.parallelgateway;
package com.alibaba.smart.framework.engine.test.parallelgateway.orchestration;

import java.util.Map;

import com.alibaba.smart.framework.engine.context.ExecutionContext;
import com.alibaba.smart.framework.engine.delegation.JavaDelegation;
import com.alibaba.smart.framework.engine.exception.EngineException;

import com.alibaba.smart.framework.engine.test.parallelgateway.single.thread.ServiceTaskDelegation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.alibaba.smart.framework.engine.test.parallelgateway;
package com.alibaba.smart.framework.engine.test.parallelgateway.orchestration;

import java.util.HashMap;
import java.util.List;
Expand All @@ -13,14 +13,12 @@
import java.util.concurrent.TimeoutException;

import com.alibaba.smart.framework.engine.configuration.ConfigurationOption;
import com.alibaba.smart.framework.engine.configuration.LockStrategy;
import com.alibaba.smart.framework.engine.configuration.impl.DefaultProcessEngineConfiguration;
import com.alibaba.smart.framework.engine.constant.RequestMapSpecialKeyConstant;
import com.alibaba.smart.framework.engine.model.assembly.ProcessDefinition;
import com.alibaba.smart.framework.engine.model.instance.ExecutionInstance;
import com.alibaba.smart.framework.engine.model.instance.InstanceStatus;
import com.alibaba.smart.framework.engine.model.instance.ProcessInstance;
import com.alibaba.smart.framework.engine.test.DoNothingLockStrategy;
import com.alibaba.smart.framework.engine.test.cases.CustomBaseTestCase;

import org.junit.Assert;
Expand Down Expand Up @@ -315,7 +313,7 @@ public void testSkipTimeoutWithAttribute() {



//dont use in production code
//do NOT use in production code
private static ExecutorService newFixedThreadPool(int nThreads) {
return new ThreadPoolExecutor(nThreads, nThreads,
0, TimeUnit.MILLISECONDS,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.alibaba.smart.framework.engine.test.parallelgateway;
package com.alibaba.smart.framework.engine.test.parallelgateway.orchestration;

import lombok.AllArgsConstructor;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.alibaba.smart.framework.engine.test.parallelgateway;
package com.alibaba.smart.framework.engine.test.parallelgateway.orchestration.delegation;

import java.util.Map;

import com.alibaba.smart.framework.engine.context.ExecutionContext;
import com.alibaba.smart.framework.engine.delegation.JavaDelegation;
import com.alibaba.smart.framework.engine.exception.EngineException;

import com.alibaba.smart.framework.engine.test.parallelgateway.orchestration.ThreadExecutionResult;
import com.alibaba.smart.framework.engine.test.parallelgateway.single.thread.ServiceTaskDelegation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.alibaba.smart.framework.engine.test.parallelgateway;
package com.alibaba.smart.framework.engine.test.parallelgateway.orchestration.delegation;

import java.util.Map;

import com.alibaba.smart.framework.engine.context.ExecutionContext;
import com.alibaba.smart.framework.engine.delegation.JavaDelegation;
import com.alibaba.smart.framework.engine.exception.EngineException;

import com.alibaba.smart.framework.engine.test.parallelgateway.orchestration.ThreadExecutionResult;
import com.alibaba.smart.framework.engine.test.parallelgateway.single.thread.ServiceTaskDelegation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.alibaba.smart.framework.engine.test.parallelgateway;
package com.alibaba.smart.framework.engine.test.parallelgateway.orchestration.delegation;

import java.util.Map;

import com.alibaba.smart.framework.engine.context.ExecutionContext;
import com.alibaba.smart.framework.engine.delegation.JavaDelegation;
import com.alibaba.smart.framework.engine.exception.EngineException;

import com.alibaba.smart.framework.engine.test.parallelgateway.orchestration.ThreadExecutionResult;
import com.alibaba.smart.framework.engine.test.parallelgateway.single.thread.ServiceTaskDelegation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.alibaba.smart.framework.engine.test.parallelgateway;
package com.alibaba.smart.framework.engine.test.parallelgateway.orchestration.delegation;

public class ServiceTaskTimeoutOrchestrationDelegationOne extends ServiceTaskTimeoutOrchestrationDelegation {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.alibaba.smart.framework.engine.test.parallelgateway;
package com.alibaba.smart.framework.engine.test.parallelgateway.orchestration.delegation;

public class ServiceTaskTimeoutOrchestrationDelegationTwo extends ServiceTaskTimeoutOrchestrationDelegation {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.alibaba.smart.framework.engine.test.parallelgateway;
package com.alibaba.smart.framework.engine.test.parallelgateway.single.thread;

import java.util.HashMap;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,36 @@
package com.alibaba.smart.framework.engine.test.parallelgateway;
package com.alibaba.smart.framework.engine.test.parallelgateway.single.thread;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.alibaba.smart.framework.engine.context.ExecutionContext;
import com.alibaba.smart.framework.engine.delegation.JavaDelegation;
import com.alibaba.smart.framework.engine.delegation.TccDelegation;
import com.alibaba.smart.framework.engine.delegation.TccResult;

import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ServiceTaskDelegation implements TccDelegation {
public class ServiceTaskDelegation implements JavaDelegation {

private static final Logger LOGGER = LoggerFactory.getLogger(ServiceTaskDelegation.class);

@Getter
private static List<String> arrayList = new ArrayList<String>();

@Override
public TccResult tryExecute(ExecutionContext executionContext) {
public void execute(ExecutionContext executionContext) {
Map<String, Object> request = executionContext.getRequest();
if (null != request) {
Object o = request.get("input");
if (o != null) {
String input = o.toString();
arrayList.add(input);
//LOGGER.info("request input"+arrayList);
}
}

return null;
}

@Override
public TccResult confirmExecute(ExecutionContext executionContext) {
return null;

}

@Override
public TccResult cancelExecute(ExecutionContext executionContext) {
return null;

}
}
Loading

0 comments on commit c265ef4

Please sign in to comment.