forked from chrislusf/glow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathagent_server_executor_status.go
54 lines (41 loc) · 1.62 KB
/
agent_server_executor_status.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package agent
import (
"time"
"github.com/chrislusf/glow/driver"
"github.com/chrislusf/glow/driver/cmd"
"github.com/golang/protobuf/proto"
)
func (as *AgentServer) handleGetStatusRequest(getStatusRequest *cmd.GetStatusRequest) *cmd.GetStatusResponse {
requestId := getStatusRequest.GetStartRequestHash()
stat := as.localExecutorManager.getExecutorStatus(requestId)
reply := &cmd.GetStatusResponse{
StartRequestHash: proto.Uint32(requestId),
InputStatuses: driver.ToProto(stat.InputChannelStatuses),
OutputStatuses: driver.ToProto(stat.OutputChannelStatuses),
RequestTime: proto.Int64(stat.RequestTime.Unix()),
StartTime: proto.Int64(stat.StartTime.Unix()),
StopTime: proto.Int64(stat.StopTime.Unix()),
}
return reply
}
func (as *AgentServer) handleLocalStatusReportRequest(localStatusRequest *cmd.LocalStatusReportRequest) *cmd.LocalStatusReportResponse {
requestId := localStatusRequest.GetStartRequestHash()
stat := as.localExecutorManager.getExecutorStatus(requestId)
stat.InputChannelStatuses = driver.FromProto(localStatusRequest.GetInputStatuses())
stat.OutputChannelStatuses = driver.FromProto(localStatusRequest.GetOutputStatuses())
stat.LastAccessTime = time.Now()
reply := &cmd.LocalStatusReportResponse{}
return reply
}
func (as *AgentServer) handleStopRequest(stopRequest *cmd.StopRequest) *cmd.StopResponse {
requestId := stopRequest.GetStartRequestHash()
stat := as.localExecutorManager.getExecutorStatus(requestId)
if stat.Process != nil {
stat.Process.Kill()
stat.Process = nil
}
reply := &cmd.StopResponse{
StartRequestHash: proto.Uint32(requestId),
}
return reply
}