control.proto 4.24 KB
Newer Older
zxl's avatar
zxl committed
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
syntax = "proto3";
package scalebox;

option go_package="./;scalebox";
option java_multiple_files = true;

// option java_outer_classname = "ControlProto";
option java_package = "cn.scalebox.gprc";

import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";


service ControlService {
  // //////////////////////////////////////////////////////////////////
  //      agent client
  // //////////////////////////////////////////////////////////////////

  //  input : slot id('ON')
  // return : job-key of the task, id==0(NULL)
  //  task id : 'READY/-1' -> 'QUEUED/-2'
  rpc GetNextTask(google.protobuf.Int32Value) returns (TaskItem);

  //  input : task id('QUEUED/-2')
  //  return : ret_code : 0(OK), -1(task NOT FOUND), -2(WRONG STATUS)
  //  task_status_code:'QUEUED'/-2 -> 'RUNNING'/-3
  rpc SetTaskStarted(google.protobuf.Int64Value) returns (google.protobuf.Int32Value);

  //  input : TaskExecMessage
  //  return : ret_code : 0(OK), -1(task NOT FOUND), -2(task WRONG STATUS)
  //  task_status_code:'RUNNING'/-3 -> 'OK'/0, ...
  rpc SetTaskFinished(TaskExecMessage) returns (google.protobuf.Int32Value);

  //  slot exit automatically, called in agent side
  //  input : slot id
  //  return : ret_code : 0(OK), -1(slot NOT FOUND), -2(slot WRONG STATUS)
  //  slot : 'ON' -> 'OFF'
  rpc SetSlotTerminated(google.protobuf.Int32Value) returns (google.protobuf.Int32Value);

  // //////////////////////////////////////////////////////////////////
  //      actuator client
  // //////////////////////////////////////////////////////////////////

  //  input: token_string ?
  //  job:'RUNNING' && slot:'READY'
  rpc GetRunnableSlotList(google.protobuf.Empty) returns (CommandList);

  //  input : slot id
  //  return : ret_code : 0(OK), -1(slot NOT FOUND), -2(slot WRONG STATUS)
  //  slot: 'READY' -> 'ON'
  rpc SetSlotInitialized(google.protobuf.Int32Value) returns (google.protobuf.Int32Value);

  //  job:'PAUSED'/'ARCHIVED' && slot:'ON'
  rpc GetTerminableSlotList(google.protobuf.Empty) returns (CommandList);


  //  job:'RUNNING' && worker:'PAUSED'
  rpc GetRunnableWorkerList(google.protobuf.Empty) returns (CommandList);

  //  input : worker id
  //  return : ret_code : 0(OK), -1(worker NOT FOUND), -2(worker WRONG STATUS)
  //  worker: 'PAUSED' -> 'RUNNING'
  rpc SetWorkerInitialized(google.protobuf.Int32Value) returns (google.protobuf.Int32Value);

  //  job:'PAUSED' && worker:'RUNNING'
  rpc GetTerminableWorkerList(google.protobuf.Empty) returns (CommandList);

  //  input : worker id, return ret_code;
  //  return : ret_code : 0(OK), -1(worker NOT FOUND), -2(worker WRONG STATUS)
  //  worker : 'RUNNING' -> 'PAUSED'
  rpc SetWorkerTerminated(google.protobuf.Int32Value) returns (google.protobuf.Int32Value);

  // //////////////////////////////////////////////////////////////////
  //      app client , called by user app.
  // //////////////////////////////////////////////////////////////////

  //  send task-key to next job in current pipeline
  //  return : ret_code : 0(OK), -1(job NOT FOUND)
  //  task_status_code : 'INITIAL'/-9
  rpc SendJobMessage(JobKey) returns (google.protobuf.Int32Value);
  // rpc SendToNextJob(JobKey) returns (google.protobuf.Int32Value);

  rpc SendJobMessages(JobKeys) returns (google.protobuf.Int32Value);
}

message JobKey {
  message JobIdRef{
    // qualified name of job
    string sink_job_name=1;
    int32 current_job_id=2;
  }
  oneof jobId {
    int32 cross_app_job_id=1;
    JobIdRef builtin_job_id=2;
  }
  string key_text=10;
}

message JobKeys {
  // qualified name of job
  string next_job_name=1;
  repeated string key_texts=2;
  int32 current_job_id=3;
  // OR worker_id ?
}

message TaskItem {
  int64 id=1;
  string key=2;
}

message Command {
  // primary key of slot/worker table
  int32 id=1;
  string host=2;
  string command_text=3;
}

message CommandList {
  repeated Command command=1;
}

message TaskExecMessage {
  int32 slot=1;
  int32 status_code=2;
  int64 task_id=3;
  int64 input_bytes=4;
  int64 output_bytes=5;
  google.protobuf.Timestamp t0=6;
  google.protobuf.Timestamp t1=7;
  google.protobuf.Timestamp t2=8;
  google.protobuf.Timestamp t3=9;
  google.protobuf.Timestamp t4=10;
  repeated google.protobuf.Timestamp time_arr=11;
  string sys_out=12;
  string app_out=13;
}