Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement MatchingEngineStateManager #1041

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nativelink-scheduler/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ rust_library(
"src/scheduler_state/awaited_action.rs",
"src/scheduler_state/client_action_state_result.rs",
"src/scheduler_state/completed_action.rs",
"src/scheduler_state/matching_engine_action_state_result.rs",
"src/scheduler_state/metrics.rs",
"src/scheduler_state/mod.rs",
"src/scheduler_state/state_manager.rs",
Expand Down
2 changes: 1 addition & 1 deletion nativelink-scheduler/src/operation_state_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub trait MatchingEngineStateManager {

/// Update that state of an operation.
async fn update_operation(
&self,
&mut self,
operation_id: OperationId,
worker_id: Option<WorkerId>,
action_stage: Result<ActionStage, Error>,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright 2024 The NativeLink Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use std::sync::Arc;

use async_trait::async_trait;
use nativelink_error::Error;
use nativelink_util::action_messages::{ActionInfo, ActionState};
use tokio::sync::watch;

use crate::operation_state_manager::ActionStateResult;

pub struct MatchingEngineActionStateResult {
pub action_info: Arc<ActionInfo>,
}
impl MatchingEngineActionStateResult {
pub(crate) fn new(action_info: Arc<ActionInfo>) -> Self {
Self { action_info }
}
}

#[async_trait]
impl ActionStateResult for MatchingEngineActionStateResult {
async fn as_state(&self) -> Result<Arc<ActionState>, Error> {
unimplemented!()
}

async fn as_receiver(&self) -> Result<&'_ watch::Receiver<Arc<ActionState>>, Error> {
unimplemented!()
}

async fn as_action_info(&self) -> Result<Arc<ActionInfo>, Error> {
Ok(self.action_info.clone())
}
}
38 changes: 38 additions & 0 deletions nativelink-scheduler/src/scheduler_state/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,43 @@ impl Metrics {
vec![("result".into(), "from_wrong_worker".into())],
);
}
{
c.publish(
"workers_evicted_total",
&self.workers_evicted,
"The number of workers evicted from scheduler.",
);
c.publish(
"workers_evicted_with_running_action",
&self.workers_evicted_with_running_action,
"The number of jobs cancelled because worker was evicted from scheduler.",
);
}
{
c.publish_with_labels(
"retry_action",
&self.retry_action,
"Stats about retry_action().",
vec![("result".into(), "success".into())],
);
c.publish_with_labels(
"retry_action",
&self.retry_action_max_attempts_reached,
"Stats about retry_action().",
vec![("result".into(), "max_attempts_reached".into())],
);
c.publish_with_labels(
"retry_action",
&self.retry_action_no_more_listeners,
"Stats about retry_action().",
vec![("result".into(), "no_more_listeners".into())],
);
c.publish_with_labels(
"retry_action",
&self.retry_action_but_action_missing,
"Stats about retry_action().",
vec![("result".into(), "action_missing".into())],
);
}
}
}
1 change: 1 addition & 0 deletions nativelink-scheduler/src/scheduler_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
pub(crate) mod awaited_action;
pub(crate) mod client_action_state_result;
pub(crate) mod completed_action;
pub(crate) mod matching_engine_action_state_result;
pub(crate) mod metrics;
pub(crate) mod state_manager;
pub(crate) mod workers;
Loading
Loading