Skip to content

Commit 3ea1ad2

Browse files
Merge pull request #6 from ut-issl/cop-state-machene
Cop state machene
2 parents 16fa606 + 4899436 commit 3ea1ad2

File tree

13 files changed

+3664
-1265
lines changed

13 files changed

+3664
-1265
lines changed

gaia-stub/proto/cop.proto

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ message CopTaskStatus {
101101
tco_tmiv.Tco tco = 2;
102102
CopTaskStatusPattern status = 3;
103103
google.protobuf.Timestamp timestamp = 4;
104+
bool is_confirm_command = 5;
104105
}
105106

106107
enum CopTaskStatusPattern {
@@ -116,8 +117,8 @@ enum CopTaskStatusPattern {
116117

117118
message CopWorkerStatus {
118119
CopWorkerStatusPattern state = 1;
119-
bool is_auto_retransmit_enabled = 2;
120-
uint64 timeout_sec = 3;
120+
uint64 timeout_sec = 2;
121+
uint32 max_executing = 3;
121122
google.protobuf.Timestamp timestamp = 4;
122123
}
123124

@@ -126,11 +127,12 @@ enum CopWorkerStatusPattern {
126127
WORKER_IDLE = 1;
127128
WORKER_INITIALIZE = 2;
128129
WORKER_ACTIVE = 3;
129-
WORKER_LOCKOUT = 4;
130-
WORKER_UNLOCKING = 5;
131-
WORKER_TIMEOUT = 6;
132-
WORKER_FAILED = 7;
133-
WORKER_CANCELED = 8;
130+
WORKER_AUTO_RETRANSMIT_OFF = 4;
131+
WORKER_LOCKOUT = 5;
132+
WORKER_UNLOCKING = 6;
133+
WORKER_TIMEOUT = 7;
134+
WORKER_FAILED = 8;
135+
WORKER_CANCELED = 9;
134136
}
135137

136138
message CopQueueStatusSet {
@@ -141,6 +143,7 @@ message CopQueueStatusSet {
141143
uint32 vs_at_id0 = 5;
142144
google.protobuf.Timestamp oldest_arrival_time = 6;
143145
google.protobuf.Timestamp timestamp = 7;
146+
uint32 confirm_inc = 8;
144147
}
145148

146149
message CopQueueStatus {
@@ -155,8 +158,12 @@ message CopCommand {
155158
CopTerminateCommand terminate = 2;
156159
CopUnlockCommand unlock = 3;
157160
CopSetTimeoutCommand set_timeout = 4;
158-
CopSetAutoRetransmitEnableCommand set_auto_retransmit_enable = 5;
159-
CopSetAutoRetransmitDisableCommand set_auto_retransmit_disable = 6;
161+
CopSetMaxExecutingCommand set_max_executing = 5;
162+
CopSetAutoRetransmitEnableCommand set_auto_retransmit_enable = 6;
163+
CopSetAutoRetransmitDisableCommand set_auto_retransmit_disable = 7;
164+
CopSendSetVRCommand send_set_vr = 8;
165+
CopSendUnlockCommand send_unlock = 9;
166+
CopStatusUpdateCommand status_update = 10;
160167
}
161168
}
162169

@@ -174,8 +181,22 @@ message CopSetTimeoutCommand {
174181
uint32 timeout_sec = 1;
175182
}
176183

184+
message CopSetMaxExecutingCommand {
185+
uint32 max_executing = 1;
186+
}
187+
177188
message CopSetAutoRetransmitEnableCommand {
178189
}
179190

180191
message CopSetAutoRetransmitDisableCommand {
181192
}
193+
194+
message CopSendSetVRCommand {
195+
uint32 vr = 1;
196+
}
197+
198+
message CopSendUnlockCommand {
199+
}
200+
201+
message CopStatusUpdateCommand {
202+
}

gaia-stub/proto/tco_tmiv.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ syntax = "proto3";
33
package tco_tmiv;
44

55
import "google/protobuf/timestamp.proto";
6+
import "google/protobuf/wrappers.proto";
67

78
message Tco {
89
string name = 1;

gaia-stub/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub mod cop {
4747
super::CopWorkerStatusPattern::WorkerClcwUnreceived => "CLCW_UNRECEIVED".to_string(),
4848
super::CopWorkerStatusPattern::WorkerIdle => "IDLE".to_string(),
4949
super::CopWorkerStatusPattern::WorkerActive => "ACTIVE".to_string(),
50+
super::CopWorkerStatusPattern::WorkerAutoRetransmitOff => "AUTO_RETRANSMIT_OFF".to_string(),
5051
super::CopWorkerStatusPattern::WorkerInitialize => "INITIALIZE".to_string(),
5152
super::CopWorkerStatusPattern::WorkerCanceled => "CANCELED".to_string(),
5253
super::CopWorkerStatusPattern::WorkerFailed => "FAILED".to_string(),

gaia-tmtc/src/cop.rs

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl CopStatusStore {
8585
let id = status.task_id;
8686
let pattern = status.status();
8787
match pattern {
88-
CopTaskStatusPattern::Accepted | CopTaskStatusPattern::Canceled => {
88+
CopTaskStatusPattern::Accepted | CopTaskStatusPattern::Canceled | CopTaskStatusPattern::Failed | CopTaskStatusPattern::Lockout | CopTaskStatusPattern::Timeout => {
8989
let pop_item = {
9090
let mut completed = self.completed.write().await;
9191
if completed.len() == self.capacity {
@@ -108,15 +108,15 @@ impl CopStatusStore {
108108
}
109109

110110
pub async fn set_worker(&self, status: &CopWorkerStatus) {
111-
self.worker_status.write().await.clone_from(&status);
111+
self.worker_status.write().await.clone_from(status);
112112
}
113113

114114
pub async fn set_queue(&self, status: &CopQueueStatusSet) {
115-
self.queue_status.write().await.clone_from(&status);
115+
self.queue_status.write().await.clone_from(status);
116116
}
117117

118118
pub async fn set_vsvr(&self, status: &CopVsvr) {
119-
self.vsvr.write().await.clone_from(&status);
119+
self.vsvr.write().await.clone_from(status);
120120
}
121121
}
122122

@@ -201,15 +201,11 @@ impl<C> CopService<C> {
201201
}
202202
}
203203

204-
pub trait IsTimeout {
205-
fn is_timeout(&self) -> bool;
206-
}
207-
208204
#[tonic::async_trait]
209205
impl<C> Cop for CopService<C>
210206
where
211207
C: super::Handle<Arc<CopCommand>> + Send + Sync + 'static,
212-
C::Response: Send + IsTimeout + 'static,
208+
C::Response: Send + 'static,
213209
{
214210
type OpenTaskStatusStreamStream = stream::BoxStream<'static, Result<CopTaskStatusStreamResponse, Status>>;
215211
type OpenWorkerStatusStreamStream = stream::BoxStream<'static, Result<CopWorkerStatusStreamResponse, Status>>;
@@ -343,20 +339,12 @@ where
343339
Status::internal(format!("{:?}", e))
344340
}
345341

346-
let time_out: bool = self
347-
.cop_handler
342+
self.cop_handler
348343
.lock()
349344
.await
350345
.handle(Arc::new(cop_command))
351346
.await
352-
.map_err(internal_error)?
353-
.is_timeout();
354-
355-
if time_out {
356-
return Err(Status::deadline_exceeded(
357-
"command was not completed on time",
358-
));
359-
}
347+
.map_err(internal_error)?;
360348

361349
Ok(Response::new(PostCopCommandResponse {}))
362350
}

0 commit comments

Comments
 (0)