12
12
import com .vip .saturn .job .console .service .ExecutorService ;
13
13
import com .vip .saturn .job .console .service .JobService ;
14
14
import com .vip .saturn .job .console .service .RegistryCenterService ;
15
+ import com .vip .saturn .job .console .service .SystemConfigService ;
16
+ import com .vip .saturn .job .console .service .helper .SystemConfigProperties ;
15
17
import com .vip .saturn .job .console .utils .ExecutorNodePath ;
16
18
import com .vip .saturn .job .console .utils .JobNodePath ;
17
19
import com .vip .saturn .job .console .utils .SaturnConsoleUtils ;
18
- import java .util .List ;
19
- import javax .annotation .Resource ;
20
20
import org .apache .commons .lang3 .StringUtils ;
21
21
import org .slf4j .Logger ;
22
22
import org .slf4j .LoggerFactory ;
23
- import org .springframework .stereotype .Service ;
24
23
import org .springframework .util .CollectionUtils ;
25
24
25
+ import javax .annotation .Resource ;
26
+ import java .util .List ;
27
+
26
28
/**
27
29
* Default implementation of ExecutorService.
28
30
*
@@ -33,6 +35,8 @@ public class ExecutorServiceImpl implements ExecutorService {
33
35
34
36
private static final Logger log = LoggerFactory .getLogger (ExecutorServiceImpl .class );
35
37
38
+ private static final int DEFAULT_MAX_SECONDS_FORCE_KILL_EXECUTOR = 300 ;
39
+
36
40
@ Resource
37
41
private CuratorRepository curatorRepository ;
38
42
@@ -42,6 +46,9 @@ public class ExecutorServiceImpl implements ExecutorService {
42
46
@ Resource
43
47
private RegistryCenterService registryCenterService ;
44
48
49
+ @ Resource
50
+ private SystemConfigService systemConfigService ;
51
+
45
52
@ Override
46
53
public List <ServerBriefInfo > getExecutors (String namespace ) throws SaturnJobConsoleException {
47
54
return getExecutors (namespace , null );
@@ -88,6 +95,22 @@ private ServerBriefInfo getServerBriefInfo(String executorName, CuratorFramework
88
95
} else {
89
96
executorInfo .setStatus (ServerStatus .OFFLINE );
90
97
}
98
+
99
+ String restartNodePath = ExecutorNodePath .getExecutorRestartNodePath (executorName );
100
+ long restartTriggerTime = curatorFrameworkOp .getCtime (restartNodePath );
101
+ long now = System .currentTimeMillis ();
102
+
103
+ long maxRestartInv = systemConfigService .getIntegerValue (SystemConfigProperties .MAX_SECONDS_FORCE_KILL_EXECUTOR ,
104
+ DEFAULT_MAX_SECONDS_FORCE_KILL_EXECUTOR ) * 1000L ;
105
+
106
+ // 如果executor在线并且restart结点存在,restarting结点存在的时间<300s,executor状态列显示RESTARTING;
107
+ if (0 != restartTriggerTime && now - restartTriggerTime < maxRestartInv
108
+ && ServerStatus .ONLINE .equals (executorInfo .getStatus ())) {
109
+ executorInfo .setRestarting (true );
110
+ } else {
111
+ executorInfo .setRestarting (false );
112
+ }
113
+
91
114
// 是否已被摘流量
92
115
executorInfo .setNoTraffic (curatorFrameworkOp
93
116
.checkExists (ExecutorNodePath .getExecutorNoTrafficNodePath (executorName )));
0 commit comments