Skip to content

Commit

Permalink
Remove num_roles from schedule info, as it doesn't work any more
Browse files Browse the repository at this point in the history
Temporary `num_roles` is `0` in status.
  • Loading branch information
tailhook committed Jul 2, 2018
1 parent a172d4c commit 4909fd3
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/daemon/frontend/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ pub fn serve<S: 'static>(state: &SharedState, config: &Arc<Config>,
peers: peers.peers.len(),
peers_timestamp: Some(peers.timestamp),
leader: leader,
roles: schedule.map(|x| x.num_roles).unwrap_or(0),
// TODO(tailhook)
roles: 0,
last_stable_timestamp: election.last_stable_timestamp,
num_errors: errors.len() + failed_roles.len(),
errors: &*errors,
Expand Down
2 changes: 0 additions & 2 deletions src/daemon/scheduler/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use hash::hash;
use id::Id;
use peer::Peer;
use scheduler::{self, Schedule};
use scheduler::state::num_roles;
use shared::{SharedState};
use time_util::ToMsec;
use watchdog::{self, Alarm};
Expand Down Expand Up @@ -240,7 +239,6 @@ pub fn main(state: SharedState, settings: Settings) -> !
info!("New schedule {}, done in {} ms", hash,
SCHEDULING_TIME.get());
state.set_schedule_by_leader(cookie, Schedule {
num_roles: num_roles(&result.schedule),
timestamp: timestamp.to_msec(),
hash: hash,
data: result.schedule,
Expand Down
19 changes: 0 additions & 19 deletions src/daemon/scheduler/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use serde_json::Value as Json;

use hash::hash;
use id::Id;
use itertools::Itertools;

pub type ScheduleId = String; // temporarily

Expand All @@ -12,23 +11,6 @@ pub struct Schedule {
pub hash: ScheduleId,
pub data: Json,
pub origin: Id,
pub num_roles: usize,
}

pub fn num_roles(json: &Json) -> usize {
(
json.get("roles")
.and_then(|x| x.as_object())
.map(|x| x.keys())
).into_iter().chain(
json.get("nodes")
.and_then(|x| x.as_object())
.map(|x| x.values().filter_map(|x|
x.get("roles")
.and_then(|x| x.as_object())
.map(|x| x.keys())))
.into_iter().flat_map(|x| x)
).kmerge().dedup().count()
}

pub fn from_json(json: Json) -> Result<Schedule, String> {
Expand All @@ -50,7 +32,6 @@ pub fn from_json(json: Json) -> Result<Schedule, String> {
Err(format!("Invalid hash {:?} data {}", h, d))
} else {
Ok(Schedule {
num_roles: num_roles(&d),
timestamp: t,
hash: h.to_string(),
data: d,
Expand Down

0 comments on commit 4909fd3

Please sign in to comment.