From 60e478e3d41240b4d9ae0e0bae93547c7e803934 Mon Sep 17 00:00:00 2001 From: Terry Bolt Date: Mon, 26 Mar 2018 13:18:41 +0100 Subject: [PATCH 01/33] WIP --- manager/src/optparse.rs | 12 ++ manager/src/scheduler/mod.rs | 114 +++++++++++-------- manager/src/{settings/mod.rs => settings.rs} | 7 ++ manager/src/splitting/mod.rs | 8 +- 4 files changed, 87 insertions(+), 54 deletions(-) rename manager/src/{settings/mod.rs => settings.rs} (91%) diff --git a/manager/src/optparse.rs b/manager/src/optparse.rs index 24ca126..8af0cf0 100644 --- a/manager/src/optparse.rs +++ b/manager/src/optparse.rs @@ -17,6 +17,12 @@ Each chunk corresponds to one map task, so this can be used to scale the job.", ) .takes_value(true), ) + .arg( + Arg::with_name("scheduler.input_queue_size") + .help("The size of the buffer to the input queue of the scheduler.") + .long("scheduler-input-queue-size") + .takes_value(true), + ) .arg( Arg::with_name("broker.address") .help("The address of the broker server the manager should connect to.") @@ -35,5 +41,11 @@ Each chunk corresponds to one map task, so this can be used to scale the job.", .long("server-port") .takes_value(true), ) + .arg( + Arg::with_name("broker_queue_name") + .help("The name to register with the broker for the task processing queue.") + .long("broker-queue-name") + .takes_value(true), + ) .get_matches() } diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index 7a373ea..6c90903 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -1,20 +1,39 @@ -use std::fmt; -use std::fmt::Display; +//! Module containing the `Scheduler`, a struct which manages the pipeline of the manager and links +//! all of the other components together. +use chrono::Utc; use failure::*; use futures::sync::mpsc; +use futures::*; +use lapin::channel::{BasicProperties, BasicPublishOptions, Channel}; +use protobuf::Message; +use tokio::net::TcpStream; use heracles_proto::datatypes::*; +use settings::SETTINGS; +use splitting; +/// Manages the entire data pipeline of the manager and links together all of the manager's +/// components. pub struct Scheduler { - broker_handle: mpsc::Sender, + broker_channel: Channel, + rx: mpsc::Receiver, + tx: mpsc::Sender, } impl Scheduler { - pub fn new(handle: mpsc::Sender) -> Self { - Scheduler { - broker_handle: handle, - } + /// Construct a new `Scheduler`. + /// + /// Takes a handle to a [`heracles_manager_lib::broker::Broker`] which it uses to send + /// [`Task`]s to workers for execution. + pub fn new(broker_channel: Channel) -> Result { + let (tx, rx) = + mpsc::channel::(SETTINGS.read().unwrap().get("scheduler.input_queue_size")?); + Ok(Scheduler { + broker_channel, + rx, + tx, + }) } pub fn schedule(&self, _job: &Job) -> Result { @@ -24,51 +43,50 @@ impl Scheduler { pub fn cancel(&self, _job_id: &str) -> Result<(), SchedulerError> { unimplemented!() } -} - -#[derive(Copy, Clone, Eq, PartialEq, Debug, Fail)] -pub enum SchedulerErrorKind { - #[fail(display = "Undefined")] - Undefined, -} - -#[derive(Debug)] -pub struct SchedulerError { - inner: Context, -} - -impl SchedulerError { - pub fn kind(&self) -> SchedulerErrorKind { - *self.inner.get_context() - } -} -impl Fail for SchedulerError { - fn cause(&self) -> Option<&Fail> { - self.inner.cause() + fn process_job(&self, job: Job) -> impl Future { + lazy(|| done(splitting::map::split(&job))).and_then(|tasks| { + future::join_all(tasks.into_iter().map(|task| self.process_task(task))) + }) } - fn backtrace(&self) -> Option<&Backtrace> { - self.inner.backtrace() + fn process_task<'a>(&'a self, mut task: Task) -> impl Future + 'a { + // This unwrap should be safe as we set a default for this value. + let queue_name = SETTINGS.read().unwrap().get("broker_queue_name").unwrap(); + let task_id = task.get_id().to_string(); + lazy(|| done(task.write_to_bytes())) + .map_err(move |e| e.context(SchedulerError::TaskSerialisationFailure { task_id })) + .from_err() + .and_then(move |bytes| { + self.broker_channel + .basic_publish( + "", + queue_name, + &bytes, + &BasicPublishOptions::default(), + BasicProperties::default(), + ) + .from_err() + }) + .and_then(|ack| { + if let Some(completed) = ack { + if completed { + task.set_status(TaskStatus::TASK_DONE); + } else { + task.set_status(TaskStatus::TASK_FAILED); + } + } else { + task.set_status(TaskStatus::TASK_UNKNOWN); + panic!("Queue was not confirm queue. This should not happen."); + } + task.set_time_done(Utc::now().timestamp() as u64); + future::ok(task) + }) } } -impl Display for SchedulerError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - Display::fmt(&self.inner, f) - } -} - -impl From for SchedulerError { - fn from(kind: SchedulerErrorKind) -> SchedulerError { - SchedulerError { - inner: Context::new(kind), - } - } -} - -impl From> for SchedulerError { - fn from(inner: Context) -> SchedulerError { - SchedulerError { inner } - } +#[derive(Debug, Fail)] +pub enum SchedulerError { + #[fail(display = "failed to serialise task with id {}", task_id)] + TaskSerialisationFailure { task_id: String }, } diff --git a/manager/src/settings/mod.rs b/manager/src/settings.rs similarity index 91% rename from manager/src/settings/mod.rs rename to manager/src/settings.rs index d937566..0e1ac2c 100644 --- a/manager/src/settings/mod.rs +++ b/manager/src/settings.rs @@ -50,6 +50,12 @@ fn set_options<'a>(settings: &mut Config, opts: &ArgMatches<'a>) -> Result<(), E if let Some(value) = opts.value_of("broker.address") { settings.set("broker.address", value)?; } + if let Some(value) = opts.value_of("scheduler.input_queue_size") { + let v = value + .parse::() + .context(SettingsErrorKind::OptionParseFailed)?; + settings.set("scheduler.input_queue_size", v)?; + } if let Some(value) = opts.value_of("server_port") { let v = value .parse::() @@ -65,6 +71,7 @@ fn set_options<'a>(settings: &mut Config, opts: &ArgMatches<'a>) -> Result<(), E fn set_defaults(settings: &mut Config) -> Result<(), Error> { settings.set_default("broker.queue_name", "heracles_tasks")?; settings.set_default("input_chunk_size", 67_108_864_i64)?; // 64 MiB + settings.set_default("scheduler.input_queue_size", 4)?; settings.set_default("server.port", 8081)?; settings.set_default("server.thread_pool_size", 8)?; Ok(()) diff --git a/manager/src/splitting/mod.rs b/manager/src/splitting/mod.rs index d27484f..363fa30 100644 --- a/manager/src/splitting/mod.rs +++ b/manager/src/splitting/mod.rs @@ -1,5 +1,5 @@ -mod map; -mod reduce; +pub mod map; +pub mod reduce; use std::fmt; use std::fmt::Display; @@ -8,10 +8,6 @@ use failure::*; use heracles_proto::datatypes::{Job, Task}; -pub fn split(job: &Job) -> Result, Error> { - map::split(job) -} - #[derive(Copy, Clone, Eq, PartialEq, Debug, Fail)] pub enum SplitterErrorKind { #[fail(display = "Failed to open input file for processing.")] From 41ed70eb9e08667aab8f69fc2844a7a024dc747b Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Thu, 12 Apr 2018 20:26:19 +0100 Subject: [PATCH 02/33] WIP --- manager/src/scheduler/mod.rs | 45 +++++++++++++++--------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index 6c90903..2af8a1c 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -12,13 +12,14 @@ use tokio::net::TcpStream; use heracles_proto::datatypes::*; use settings::SETTINGS; use splitting; +use broker::BrokerConnection; +use state::State; /// Manages the entire data pipeline of the manager and links together all of the manager's /// components. pub struct Scheduler { - broker_channel: Channel, - rx: mpsc::Receiver, - tx: mpsc::Sender, + broker: BrokerConnection, + state: State, } impl Scheduler { @@ -26,13 +27,10 @@ impl Scheduler { /// /// Takes a handle to a [`heracles_manager_lib::broker::Broker`] which it uses to send /// [`Task`]s to workers for execution. - pub fn new(broker_channel: Channel) -> Result { - let (tx, rx) = - mpsc::channel::(SETTINGS.read().unwrap().get("scheduler.input_queue_size")?); + pub fn new(broker: BrokerConnection, store: State) -> Result { Ok(Scheduler { - broker_channel, - rx, - tx, + broker, + store, }) } @@ -51,23 +49,13 @@ impl Scheduler { } fn process_task<'a>(&'a self, mut task: Task) -> impl Future + 'a { - // This unwrap should be safe as we set a default for this value. - let queue_name = SETTINGS.read().unwrap().get("broker_queue_name").unwrap(); - let task_id = task.get_id().to_string(); - lazy(|| done(task.write_to_bytes())) - .map_err(move |e| e.context(SchedulerError::TaskSerialisationFailure { task_id })) + task.set_time_started(Utc::now().timestamp() as u64); + task.set_status(TaskStatus::TASK_IN_PROGRESS); + self.state.save_task(task); + + self.broker.send(task) + .map_err(|e| e.context(BrokerSendFailure)) .from_err() - .and_then(move |bytes| { - self.broker_channel - .basic_publish( - "", - queue_name, - &bytes, - &BasicPublishOptions::default(), - BasicProperties::default(), - ) - .from_err() - }) .and_then(|ack| { if let Some(completed) = ack { if completed { @@ -77,10 +65,11 @@ impl Scheduler { } } else { task.set_status(TaskStatus::TASK_UNKNOWN); - panic!("Queue was not confirm queue. This should not happen."); + panic!("ack of task failed. this should not happen"); } task.set_time_done(Utc::now().timestamp() as u64); - future::ok(task) + self.state.save_task(task); + future::ok(task); }) } } @@ -89,4 +78,6 @@ impl Scheduler { pub enum SchedulerError { #[fail(display = "failed to serialise task with id {}", task_id)] TaskSerialisationFailure { task_id: String }, + #[fail(display = "failed to send task to broker")] + BrokerSendFailure, } From da5dc087f40a0044a0956ae4cf31ef43cd3bf3e6 Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Fri, 13 Apr 2018 17:55:23 +0100 Subject: [PATCH 03/33] WIP --- manager/src/scheduler/mod.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index 2af8a1c..a564346 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -18,8 +18,8 @@ use state::State; /// Manages the entire data pipeline of the manager and links together all of the manager's /// components. pub struct Scheduler { - broker: BrokerConnection, - state: State, + broker: Box, + store: Box, } impl Scheduler { @@ -27,7 +27,7 @@ impl Scheduler { /// /// Takes a handle to a [`heracles_manager_lib::broker::Broker`] which it uses to send /// [`Task`]s to workers for execution. - pub fn new(broker: BrokerConnection, store: State) -> Result { + pub fn new(broker: Box, store: Box) -> Result { Ok(Scheduler { broker, store, @@ -51,10 +51,10 @@ impl Scheduler { fn process_task<'a>(&'a self, mut task: Task) -> impl Future + 'a { task.set_time_started(Utc::now().timestamp() as u64); task.set_status(TaskStatus::TASK_IN_PROGRESS); - self.state.save_task(task); + self.store.save_task(&task); - self.broker.send(task) - .map_err(|e| e.context(BrokerSendFailure)) + self.broker.send(&task) + .map_err(|e| e.context(SchedulerError::BrokerSendFailure)) .from_err() .and_then(|ack| { if let Some(completed) = ack { @@ -68,7 +68,7 @@ impl Scheduler { panic!("ack of task failed. this should not happen"); } task.set_time_done(Utc::now().timestamp() as u64); - self.state.save_task(task); + self.store.save_task(&task); future::ok(task); }) } @@ -76,8 +76,6 @@ impl Scheduler { #[derive(Debug, Fail)] pub enum SchedulerError { - #[fail(display = "failed to serialise task with id {}", task_id)] - TaskSerialisationFailure { task_id: String }, #[fail(display = "failed to send task to broker")] BrokerSendFailure, } From fd2ada7409c4ff98ceedefb561a23ae7ee7b3f6e Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Sat, 14 Apr 2018 12:49:44 +0100 Subject: [PATCH 04/33] WIP --- manager/src/scheduler/mod.rs | 24 ++++++++++++++++-------- manager/src/server/jobscheduler.rs | 6 ++++-- manager/src/server/mod.rs | 4 +++- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index a564346..a7ccb94 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -9,6 +9,8 @@ use lapin::channel::{BasicProperties, BasicPublishOptions, Channel}; use protobuf::Message; use tokio::net::TcpStream; +use std::sync::Arc; + use heracles_proto::datatypes::*; use settings::SETTINGS; use splitting; @@ -18,8 +20,8 @@ use state::State; /// Manages the entire data pipeline of the manager and links together all of the manager's /// components. pub struct Scheduler { - broker: Box, - store: Box, + broker: Arc, + store: Arc, } impl Scheduler { @@ -27,7 +29,7 @@ impl Scheduler { /// /// Takes a handle to a [`heracles_manager_lib::broker::Broker`] which it uses to send /// [`Task`]s to workers for execution. - pub fn new(broker: Box, store: Box) -> Result { + pub fn new(broker: Arc, store: Arc) -> Result { Ok(Scheduler { broker, store, @@ -42,9 +44,15 @@ impl Scheduler { unimplemented!() } - fn process_job(&self, job: Job) -> impl Future { + fn process_job<'a>(&'a self, job: Job) -> impl Future { lazy(|| done(splitting::map::split(&job))).and_then(|tasks| { - future::join_all(tasks.into_iter().map(|task| self.process_task(task))) + future::join_all(tasks.into_iter().map(|task| { + self.process_task(task) + })) + .and_then(move |_| { + // TODO: Run reduce + future::ok(job) + }) }) } @@ -54,8 +62,8 @@ impl Scheduler { self.store.save_task(&task); self.broker.send(&task) - .map_err(|e| e.context(SchedulerError::BrokerSendFailure)) - .from_err() + // .map_err(|e| e.context(SchedulerError::BrokerSendFailure)) + // .from_err() .and_then(|ack| { if let Some(completed) = ack { if completed { @@ -69,7 +77,7 @@ impl Scheduler { } task.set_time_done(Utc::now().timestamp() as u64); self.store.save_task(&task); - future::ok(task); + future::ok(task) }) } } diff --git a/manager/src/server/jobscheduler.rs b/manager/src/server/jobscheduler.rs index 3113647..7814ca5 100644 --- a/manager/src/server/jobscheduler.rs +++ b/manager/src/server/jobscheduler.rs @@ -5,12 +5,14 @@ use heracles_proto::mapreduce as pb; use heracles_proto::mapreduce_grpc as grpc_pb; use scheduler::Scheduler; +use std::sync::Arc; + pub struct JobScheduleService { - scheduler: Scheduler, + scheduler: Arc, } impl JobScheduleService { - pub fn new(scheduler: Scheduler) -> Self { + pub fn new(scheduler: Arc) -> Self { JobScheduleService { scheduler } } } diff --git a/manager/src/server/mod.rs b/manager/src/server/mod.rs index f503531..b9b1e19 100644 --- a/manager/src/server/mod.rs +++ b/manager/src/server/mod.rs @@ -10,12 +10,14 @@ use heracles_proto::mapreduce_grpc; use scheduler::Scheduler; use settings::SETTINGS; +use std::sync::Arc; + pub struct Server { server: grpc::Server, } impl Server { - pub fn new(scheduler: Scheduler) -> Result { + pub fn new(scheduler: Arc) -> Result { let mut builder = grpc::ServerBuilder::new_plain(); builder .http From 2ddeba8bf7abc4a443d9fed0510692077698fdc8 Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Sat, 14 Apr 2018 14:25:45 +0100 Subject: [PATCH 05/33] WIP --- manager/src/scheduler/mod.rs | 48 +++++++++++++++++++++--------------- manager/src/state/mod.rs | 2 +- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index a7ccb94..a5e9a8c 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -1,18 +1,14 @@ //! Module containing the `Scheduler`, a struct which manages the pipeline of the manager and links //! all of the other components together. +use std::sync::Arc; + use chrono::Utc; use failure::*; -use futures::sync::mpsc; use futures::*; -use lapin::channel::{BasicProperties, BasicPublishOptions, Channel}; -use protobuf::Message; -use tokio::net::TcpStream; - -use std::sync::Arc; use heracles_proto::datatypes::*; -use settings::SETTINGS; + use splitting; use broker::BrokerConnection; use state::State; @@ -36,24 +32,34 @@ impl Scheduler { }) } - pub fn schedule(&self, _job: &Job) -> Result { + pub fn schedule<'a>(&'a self, _job: &Job) -> Result { unimplemented!() } - pub fn cancel(&self, _job_id: &str) -> Result<(), SchedulerError> { + pub fn cancel<'a>(&'a self, _job_id: &str) -> Result<(), SchedulerError> { unimplemented!() } - fn process_job<'a>(&'a self, job: Job) -> impl Future { - lazy(|| done(splitting::map::split(&job))).and_then(|tasks| { - future::join_all(tasks.into_iter().map(|task| { - self.process_task(task) - })) - .and_then(move |_| { - // TODO: Run reduce - future::ok(job) - }) - }) + fn process_job<'a>(&'a self, job: Job) -> impl Future + 'a { + // lazy(|| done(splitting::map::split(&job))) + // .map_err(|e| e.context(SchedulerError::MapSplitFailure)) + // .from_err() + // .and_then(|tasks| { + + // future::join_all(tasks.as_slice().iter().map(|task| { + // self.process_task(task) + // })) + // .and_then(|_| { + // // TODO: Run reduce + // future::ok(job) + // }) + // }) + + // lazy(|| done(splitting::map::split(&job))) + // .and_then(|_| { + // future::ok(job) + // }) + future::ok(job) } fn process_task<'a>(&'a self, mut task: Task) -> impl Future + 'a { @@ -77,13 +83,15 @@ impl Scheduler { } task.set_time_done(Utc::now().timestamp() as u64); self.store.save_task(&task); - future::ok(task) + Ok(task) }) } } #[derive(Debug, Fail)] pub enum SchedulerError { + #[fail(display = "failed to split job into map tasks")] + MapSplitFailure, #[fail(display = "failed to send task to broker")] BrokerSendFailure, } diff --git a/manager/src/state/mod.rs b/manager/src/state/mod.rs index 39d40bc..7fb6ce8 100644 --- a/manager/src/state/mod.rs +++ b/manager/src/state/mod.rs @@ -1,6 +1,6 @@ mod file; -use self::file::FileStore; +pub use self::file::FileStore; use std::fmt; use std::fmt::Display; From 894fb8be759a39d333493d3333509636d0cbfe11 Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Sat, 14 Apr 2018 15:08:54 +0100 Subject: [PATCH 06/33] WIP --- manager/src/scheduler/mod.rs | 6 +++--- manager/src/server/jobscheduler.rs | 6 +++--- manager/src/server/mod.rs | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index a5e9a8c..fc9bc54 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -16,8 +16,8 @@ use state::State; /// Manages the entire data pipeline of the manager and links together all of the manager's /// components. pub struct Scheduler { - broker: Arc, - store: Arc, + broker: Box, + store: Box, } impl Scheduler { @@ -25,7 +25,7 @@ impl Scheduler { /// /// Takes a handle to a [`heracles_manager_lib::broker::Broker`] which it uses to send /// [`Task`]s to workers for execution. - pub fn new(broker: Arc, store: Arc) -> Result { + pub fn new(broker: Box, store: Box) -> Result { Ok(Scheduler { broker, store, diff --git a/manager/src/server/jobscheduler.rs b/manager/src/server/jobscheduler.rs index 7814ca5..ac80243 100644 --- a/manager/src/server/jobscheduler.rs +++ b/manager/src/server/jobscheduler.rs @@ -5,14 +5,14 @@ use heracles_proto::mapreduce as pb; use heracles_proto::mapreduce_grpc as grpc_pb; use scheduler::Scheduler; -use std::sync::Arc; +// use std::sync::Arc; pub struct JobScheduleService { - scheduler: Arc, + scheduler: Scheduler, } impl JobScheduleService { - pub fn new(scheduler: Arc) -> Self { + pub fn new(scheduler: Scheduler) -> Self { JobScheduleService { scheduler } } } diff --git a/manager/src/server/mod.rs b/manager/src/server/mod.rs index b9b1e19..e4ddf4c 100644 --- a/manager/src/server/mod.rs +++ b/manager/src/server/mod.rs @@ -10,14 +10,13 @@ use heracles_proto::mapreduce_grpc; use scheduler::Scheduler; use settings::SETTINGS; -use std::sync::Arc; pub struct Server { server: grpc::Server, } impl Server { - pub fn new(scheduler: Arc) -> Result { + pub fn new(scheduler: Scheduler) -> Result { let mut builder = grpc::ServerBuilder::new_plain(); builder .http From c6f40c87c82c54bb23ac1a3ca3d390a64a51fc6f Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Sat, 14 Apr 2018 15:18:17 +0100 Subject: [PATCH 07/33] WIP --- manager/src/scheduler/mod.rs | 11 ++++------- manager/src/server/jobscheduler.rs | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index fc9bc54..1286736 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -1,8 +1,5 @@ //! Module containing the `Scheduler`, a struct which manages the pipeline of the manager and links //! all of the other components together. - -use std::sync::Arc; - use chrono::Utc; use failure::*; use futures::*; @@ -16,8 +13,8 @@ use state::State; /// Manages the entire data pipeline of the manager and links together all of the manager's /// components. pub struct Scheduler { - broker: Box, - store: Box, + broker: Box, + store: Box, } impl Scheduler { @@ -25,7 +22,7 @@ impl Scheduler { /// /// Takes a handle to a [`heracles_manager_lib::broker::Broker`] which it uses to send /// [`Task`]s to workers for execution. - pub fn new(broker: Box, store: Box) -> Result { + pub fn new(broker: Box, store: Box) -> Result { Ok(Scheduler { broker, store, @@ -70,7 +67,7 @@ impl Scheduler { self.broker.send(&task) // .map_err(|e| e.context(SchedulerError::BrokerSendFailure)) // .from_err() - .and_then(|ack| { + .and_then(move |ack| { if let Some(completed) = ack { if completed { task.set_status(TaskStatus::TASK_DONE); diff --git a/manager/src/server/jobscheduler.rs b/manager/src/server/jobscheduler.rs index ac80243..60f1ec6 100644 --- a/manager/src/server/jobscheduler.rs +++ b/manager/src/server/jobscheduler.rs @@ -55,7 +55,7 @@ impl grpc_pb::JobScheduleService for JobScheduleService { fn describe( &self, _: RequestOptions, - req: pb::DescribeRequest, + _req: pb::DescribeRequest, ) -> SingleResponse { unimplemented!() } From 59a10b87c3a3f61eb21116fd36ac395dce5f2929 Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Sat, 14 Apr 2018 15:50:42 +0100 Subject: [PATCH 08/33] WIP --- manager/src/scheduler/mod.rs | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index 1286736..0599d8f 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -38,28 +38,24 @@ impl Scheduler { } fn process_job<'a>(&'a self, job: Job) -> impl Future + 'a { - // lazy(|| done(splitting::map::split(&job))) - // .map_err(|e| e.context(SchedulerError::MapSplitFailure)) - // .from_err() - // .and_then(|tasks| { - - // future::join_all(tasks.as_slice().iter().map(|task| { - // self.process_task(task) - // })) - // .and_then(|_| { - // // TODO: Run reduce - // future::ok(job) - // }) - // }) + lazy(|| done(splitting::map::split(&job))) + .and_then(|tasks| self.run_tasks(tasks)) + .and_then(move |_| future::ok(splitting::reduce::split(&job))) + .and_then(|tasks| self.run_tasks(tasks)) + .and_then(move |_| { + // mark job as done + future::ok(job) + }) + } - // lazy(|| done(splitting::map::split(&job))) - // .and_then(|_| { - // future::ok(job) - // }) - future::ok(job) + fn run_tasks<'a>(&self, tasks: Vec) -> impl Future + 'a { + future::join_all(tasks.iter().map(|task| self.process_task(task))) + .and_then(|_| { + future::ok(()) + }) } - fn process_task<'a>(&'a self, mut task: Task) -> impl Future + 'a { + fn process_task<'a>(&'a self, mut task: &'a Task) -> impl Future + 'a { task.set_time_started(Utc::now().timestamp() as u64); task.set_status(TaskStatus::TASK_IN_PROGRESS); self.store.save_task(&task); @@ -80,7 +76,7 @@ impl Scheduler { } task.set_time_done(Utc::now().timestamp() as u64); self.store.save_task(&task); - Ok(task) + future::ok(()) }) } } From 481cf361cde1003d2f84f76bfe048a4aaa36c4bd Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Sat, 14 Apr 2018 17:23:52 +0100 Subject: [PATCH 09/33] WIP --- manager/src/scheduler/mod.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index 0599d8f..357c69e 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -38,24 +38,28 @@ impl Scheduler { } fn process_job<'a>(&'a self, job: Job) -> impl Future + 'a { - lazy(|| done(splitting::map::split(&job))) - .and_then(|tasks| self.run_tasks(tasks)) - .and_then(move |_| future::ok(splitting::reduce::split(&job))) - .and_then(|tasks| self.run_tasks(tasks)) + lazy(move || done(splitting::map::split(&job.clone()))) + .and_then(move |tasks| self.run_tasks(tasks)) + .and_then(move |_| future::ok(splitting::reduce::split(&job.clone()))) + .and_then(move |tasks| self.run_tasks(tasks)) .and_then(move |_| { // mark job as done future::ok(job) }) } - fn run_tasks<'a>(&self, tasks: Vec) -> impl Future + 'a { - future::join_all(tasks.iter().map(|task| self.process_task(task))) - .and_then(|_| { - future::ok(()) - }) + fn run_tasks<'a>(&'a self, tasks: Vec) -> impl Future + 'a { + // Normally we would do `.into_iter()` on the task, but it looks like there is a problem + // with it currently. This issue describes the error we are having: + // https://github.com/rust-lang/rust/issues/49926 + let mut task_futures = vec![]; + for mut task in tasks { + task_futures.push(self.process_task(&mut task.clone())); + } + future::join_all(task_futures).and_then(|_| future::ok(())) } - fn process_task<'a>(&'a self, mut task: &'a Task) -> impl Future + 'a { + fn process_task<'a>(&'a self, task: &'a mut Task) -> impl Future + 'a { task.set_time_started(Utc::now().timestamp() as u64); task.set_status(TaskStatus::TASK_IN_PROGRESS); self.store.save_task(&task); From e39d1384dff9d469fe38ee8eca2f723706c20a84 Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Sat, 14 Apr 2018 18:09:42 +0100 Subject: [PATCH 10/33] It finally compiles! --- manager/src/broker/amqp.rs | 2 +- manager/src/broker/mod.rs | 2 +- manager/src/scheduler/mod.rs | 16 ++++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/manager/src/broker/amqp.rs b/manager/src/broker/amqp.rs index c256677..6d2b561 100644 --- a/manager/src/broker/amqp.rs +++ b/manager/src/broker/amqp.rs @@ -20,7 +20,7 @@ impl BrokerConnection for AMQPBrokerConnection { /// /// The `Option` returned represents whether the message was acked (`Some(true)`), nacked /// (`Some(false)`), or the queue is not a confirm queue (`None`). - fn send<'a>(&'a self, task: &'a Task) -> Box, Error = Error> + 'a> { + fn send<'a>(&'a self, task: Task) -> Box, Error = Error> + 'a> { let task_id = task.get_id().to_string(); let ret = future::lazy(move || future::done(task.write_to_bytes())) .map_err(|e| e.context(BrokerError::TaskSerialisationFailure { task_id })) diff --git a/manager/src/broker/mod.rs b/manager/src/broker/mod.rs index 1f9d1f3..120cf4a 100644 --- a/manager/src/broker/mod.rs +++ b/manager/src/broker/mod.rs @@ -6,7 +6,7 @@ use futures::Future; use heracles_proto::datatypes::Task; pub trait BrokerConnection { - fn send<'a>(&'a self, &'a Task) -> Box, Error = Error> + 'a>; + fn send<'a>(&'a self, Task) -> Box, Error = Error> + 'a>; } #[derive(Debug, Fail)] diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index 357c69e..be78d22 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -38,13 +38,17 @@ impl Scheduler { } fn process_job<'a>(&'a self, job: Job) -> impl Future + 'a { - lazy(move || done(splitting::map::split(&job.clone()))) + // TODO: Refactor this ugly code. This should not be cloned so many times. + let job1 = job.clone(); + let job2 = job.clone(); + let job3 = job.clone(); + lazy(move || done(splitting::map::split(&job1))) .and_then(move |tasks| self.run_tasks(tasks)) - .and_then(move |_| future::ok(splitting::reduce::split(&job.clone()))) + .and_then(move |_| future::ok(splitting::reduce::split(&job2))) .and_then(move |tasks| self.run_tasks(tasks)) .and_then(move |_| { // mark job as done - future::ok(job) + future::ok(job3) }) } @@ -54,17 +58,17 @@ impl Scheduler { // https://github.com/rust-lang/rust/issues/49926 let mut task_futures = vec![]; for mut task in tasks { - task_futures.push(self.process_task(&mut task.clone())); + task_futures.push(self.process_task(task.clone())); } future::join_all(task_futures).and_then(|_| future::ok(())) } - fn process_task<'a>(&'a self, task: &'a mut Task) -> impl Future + 'a { + fn process_task<'a>(&'a self, mut task: Task) -> impl Future + 'a { task.set_time_started(Utc::now().timestamp() as u64); task.set_status(TaskStatus::TASK_IN_PROGRESS); self.store.save_task(&task); - self.broker.send(&task) + self.broker.send(task.clone()) // .map_err(|e| e.context(SchedulerError::BrokerSendFailure)) // .from_err() .and_then(move |ack| { From a805b951a012e637c5d12d4a1a5885bd8d1b9e0d Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Sat, 14 Apr 2018 19:49:27 +0100 Subject: [PATCH 11/33] WIP --- manager/src/scheduler/mod.rs | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index be78d22..a777d70 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -3,18 +3,22 @@ use chrono::Utc; use failure::*; use futures::*; +use futures::sync::mpsc; +use uuid::Uuid; use heracles_proto::datatypes::*; - use splitting; use broker::BrokerConnection; use state::State; +use settings::SETTINGS; /// Manages the entire data pipeline of the manager and links together all of the manager's /// components. pub struct Scheduler { broker: Box, store: Box, + rx: mpsc::Receiver, + tx: mpsc::Sender, } impl Scheduler { @@ -23,20 +27,36 @@ impl Scheduler { /// Takes a handle to a [`heracles_manager_lib::broker::Broker`] which it uses to send /// [`Task`]s to workers for execution. pub fn new(broker: Box, store: Box) -> Result { + let (tx, rx) = + mpsc::channel::(SETTINGS.read().unwrap().get("scheduler.input_queue_size")?); Ok(Scheduler { broker, store, + rx, + tx, }) } - pub fn schedule<'a>(&'a self, _job: &Job) -> Result { - unimplemented!() + pub fn schedule<'a>(&'a self, job: &Job) -> Result { + let id = Uuid::new_v4().to_string(); + job.set_id(id); + // TODO: Scheduling time + + self.tx.send(job.clone()); + + Ok(id) } pub fn cancel<'a>(&'a self, _job_id: &str) -> Result<(), SchedulerError> { unimplemented!() } + pub fn run(&self) -> Result<(), SchedulerError> { + self.rx + .map_err(|e| e) + .for_each(|job| self.process_job(job)) + } + fn process_job<'a>(&'a self, job: Job) -> impl Future + 'a { // TODO: Refactor this ugly code. This should not be cloned so many times. let job1 = job.clone(); @@ -95,4 +115,6 @@ pub enum SchedulerError { MapSplitFailure, #[fail(display = "failed to send task to broker")] BrokerSendFailure, + #[fail(display = "error receiving")] + RxFailure, } From 9822c08915c2ef2c67125d0eff6ca89ae343b209 Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Sat, 14 Apr 2018 23:23:01 +0100 Subject: [PATCH 12/33] WIP --- manager/src/scheduler/mod.rs | 21 ++++++++++++++------- manager/src/server/jobscheduler.rs | 2 +- manager/src/splitting/mod.rs | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index a777d70..2d2eb86 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -5,6 +5,7 @@ use failure::*; use futures::*; use futures::sync::mpsc; use uuid::Uuid; +use tokio; use heracles_proto::datatypes::*; use splitting; @@ -37,11 +38,14 @@ impl Scheduler { }) } - pub fn schedule<'a>(&'a self, job: &Job) -> Result { + pub fn schedule<'a>(&'a self, req: Job) -> Result { + let mut job = req.clone(); + let id = Uuid::new_v4().to_string(); - job.set_id(id); + job.set_id(id.clone()); // TODO: Scheduling time + self.store.save_job(&job.clone()); self.tx.send(job.clone()); Ok(id) @@ -51,13 +55,14 @@ impl Scheduler { unimplemented!() } - pub fn run(&self) -> Result<(), SchedulerError> { + pub fn run<'a>(&'a self) -> impl Future + 'a { self.rx - .map_err(|e| e) - .for_each(|job| self.process_job(job)) + .map_err(|_| unreachable!("should never happen")) + .for_each(move |job| self.process_job(job)) + .map_err(|_| SchedulerError::RxFailure.into()) } - fn process_job<'a>(&'a self, job: Job) -> impl Future + 'a { + fn process_job<'a>(&'a self, job: Job) -> impl Future + 'a { // TODO: Refactor this ugly code. This should not be cloned so many times. let job1 = job.clone(); let job2 = job.clone(); @@ -68,7 +73,9 @@ impl Scheduler { .and_then(move |tasks| self.run_tasks(tasks)) .and_then(move |_| { // mark job as done - future::ok(job3) + + self.store.save_job(&job3); + future::ok(()) }) } diff --git a/manager/src/server/jobscheduler.rs b/manager/src/server/jobscheduler.rs index 60f1ec6..3f29b2b 100644 --- a/manager/src/server/jobscheduler.rs +++ b/manager/src/server/jobscheduler.rs @@ -23,7 +23,7 @@ impl grpc_pb::JobScheduleService for JobScheduleService { _: RequestOptions, req: pb::ScheduleRequest, ) -> SingleResponse { - match self.scheduler.schedule(req.get_job()) { + match self.scheduler.schedule(req.get_job().clone()) { Ok(job_id) => { let mut res = pb::ScheduleResponse::new(); res.set_job_id(job_id); diff --git a/manager/src/splitting/mod.rs b/manager/src/splitting/mod.rs index 363fa30..5a49d6a 100644 --- a/manager/src/splitting/mod.rs +++ b/manager/src/splitting/mod.rs @@ -6,7 +6,7 @@ use std::fmt::Display; use failure::*; -use heracles_proto::datatypes::{Job, Task}; +// use heracles_proto::datatypes::{Job, Task}; #[derive(Copy, Clone, Eq, PartialEq, Debug, Fail)] pub enum SplitterErrorKind { From 52702efc467c78db997f1f05e53aa5c3e692451b Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Sat, 14 Apr 2018 23:26:28 +0100 Subject: [PATCH 13/33] WIP --- manager/src/scheduler/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index 2d2eb86..0e086e4 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -46,7 +46,8 @@ impl Scheduler { // TODO: Scheduling time self.store.save_job(&job.clone()); - self.tx.send(job.clone()); + + self.tx.clone().send(job.clone()); Ok(id) } From 86ea26ca7dfcce78a6e21265b817b55cccca11a2 Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Sun, 15 Apr 2018 13:36:46 +0100 Subject: [PATCH 14/33] WIP --- manager/src/main.rs | 13 +++++++++++-- manager/src/scheduler/mod.rs | 16 +++++++++++----- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/manager/src/main.rs b/manager/src/main.rs index 77f9785..ccb7c9d 100644 --- a/manager/src/main.rs +++ b/manager/src/main.rs @@ -10,7 +10,9 @@ use failure::*; use tokio::prelude::*; use heracles_manager::settings::SETTINGS; -use heracles_manager::{broker, optparse, settings}; +use heracles_manager::{broker, optparse, scheduler, server, state, settings}; + +use std::path::PathBuf; fn main() { if let Err(err) = run() { @@ -30,10 +32,17 @@ fn run() -> Result<(), Error> { let broker_addr = SETTINGS.read().unwrap().get("broker_address")?; let broker_conn = broker::amqp::connect(broker_addr); + // let store = state::FileStore::new(PathBuf::from_str("/tmp"))?; // replace with settings + + // let schdlr = scheduler::Scheduler::new(Box::new(broker_conn), Box::new(store))?; + + // let srv = server::Server::new(schdlr)?; + info!("Starting main event loop."); // We give this an empty future so that it will never terminate and continue driving other // futures to completion. - tokio::run(future::empty()); + // tokio::run(schdlr.run()); + tokio::run(futures::empty()); Ok(()) } diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index 0e086e4..2bbc860 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -1,5 +1,7 @@ //! Module containing the `Scheduler`, a struct which manages the pipeline of the manager and links //! all of the other components together. +use std::cell::RefCell; + use chrono::Utc; use failure::*; use futures::*; @@ -18,7 +20,7 @@ use settings::SETTINGS; pub struct Scheduler { broker: Box, store: Box, - rx: mpsc::Receiver, + rx: RefCell>>, tx: mpsc::Sender, } @@ -31,10 +33,10 @@ impl Scheduler { let (tx, rx) = mpsc::channel::(SETTINGS.read().unwrap().get("scheduler.input_queue_size")?); Ok(Scheduler { - broker, - store, - rx, - tx, + broker: broker, + store: store, + rx: RefCell::new(Some(rx)), + tx: tx, }) } @@ -58,9 +60,13 @@ impl Scheduler { pub fn run<'a>(&'a self) -> impl Future + 'a { self.rx + .borrow_mut() + .take() + .unwrap() .map_err(|_| unreachable!("should never happen")) .for_each(move |job| self.process_job(job)) .map_err(|_| SchedulerError::RxFailure.into()) + // future::ok(()) } fn process_job<'a>(&'a self, job: Job) -> impl Future + 'a { From 5c89efcc7292109928f986ec2b21881b17f632bb Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Sun, 15 Apr 2018 14:23:25 +0100 Subject: [PATCH 15/33] WIP --- manager/src/scheduler/mod.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index 2bbc860..dfa9714 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -20,7 +20,7 @@ use settings::SETTINGS; pub struct Scheduler { broker: Box, store: Box, - rx: RefCell>>, + rx: Option>, tx: mpsc::Sender, } @@ -35,7 +35,7 @@ impl Scheduler { Ok(Scheduler { broker: broker, store: store, - rx: RefCell::new(Some(rx)), + rx: Some(rx), tx: tx, }) } @@ -58,9 +58,8 @@ impl Scheduler { unimplemented!() } - pub fn run<'a>(&'a self) -> impl Future + 'a { + pub fn run<'a>(&'a mut self) -> impl Future + 'a { self.rx - .borrow_mut() .take() .unwrap() .map_err(|_| unreachable!("should never happen")) From 41ed497cb36b15817f24e48273e0a89333c2f7c9 Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Mon, 16 Apr 2018 13:51:33 +0100 Subject: [PATCH 16/33] Got the scheduler to maybe work... --- manager/src/main.rs | 9 +++++---- manager/src/scheduler/mod.rs | 10 ++++++---- manager/src/settings.rs | 3 ++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/manager/src/main.rs b/manager/src/main.rs index ccb7c9d..f6141cd 100644 --- a/manager/src/main.rs +++ b/manager/src/main.rs @@ -29,12 +29,13 @@ fn run() -> Result<(), Error> { let arg_matches = optparse::parse_cmd_options(); settings::init(&arg_matches)?; - let broker_addr = SETTINGS.read().unwrap().get("broker_address")?; + let broker_addr = SETTINGS.read().unwrap().get("broker.address")?; let broker_conn = broker::amqp::connect(broker_addr); - // let store = state::FileStore::new(PathBuf::from_str("/tmp"))?; // replace with settings + let state_location: &str = SETTINGS.read().unwrap().get("state.location")?; + let store = state::FileStore::new(&PathBuf::from(state_location.to_string()))?; - // let schdlr = scheduler::Scheduler::new(Box::new(broker_conn), Box::new(store))?; + let schdlr = scheduler::Scheduler::new(Box::new(broker_conn), Box::new(store))?; // let srv = server::Server::new(schdlr)?; @@ -42,7 +43,7 @@ fn run() -> Result<(), Error> { // We give this an empty future so that it will never terminate and continue driving other // futures to completion. // tokio::run(schdlr.run()); - tokio::run(futures::empty()); + tokio::run(future::empty()); Ok(()) } diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index dfa9714..4b8b996 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -1,6 +1,6 @@ //! Module containing the `Scheduler`, a struct which manages the pipeline of the manager and links //! all of the other components together. -use std::cell::RefCell; +use std::sync::{Mutex, Arc}; use chrono::Utc; use failure::*; @@ -20,7 +20,7 @@ use settings::SETTINGS; pub struct Scheduler { broker: Box, store: Box, - rx: Option>, + rx: Arc>>>, tx: mpsc::Sender, } @@ -35,7 +35,7 @@ impl Scheduler { Ok(Scheduler { broker: broker, store: store, - rx: Some(rx), + rx: Arc::new(Mutex::new(Some(rx))), tx: tx, }) } @@ -58,8 +58,10 @@ impl Scheduler { unimplemented!() } - pub fn run<'a>(&'a mut self) -> impl Future + 'a { + pub fn run<'a>(&'a self) -> impl Future + 'a { self.rx + .lock() + .unwrap() .take() .unwrap() .map_err(|_| unreachable!("should never happen")) diff --git a/manager/src/settings.rs b/manager/src/settings.rs index 0e1ac2c..dea7630 100644 --- a/manager/src/settings.rs +++ b/manager/src/settings.rs @@ -56,7 +56,7 @@ fn set_options<'a>(settings: &mut Config, opts: &ArgMatches<'a>) -> Result<(), E .context(SettingsErrorKind::OptionParseFailed)?; settings.set("scheduler.input_queue_size", v)?; } - if let Some(value) = opts.value_of("server_port") { + if let Some(value) = opts.value_of("server.port") { let v = value .parse::() .context(SettingsErrorKind::OptionParseFailed)?; @@ -74,6 +74,7 @@ fn set_defaults(settings: &mut Config) -> Result<(), Error> { settings.set_default("scheduler.input_queue_size", 4)?; settings.set_default("server.port", 8081)?; settings.set_default("server.thread_pool_size", 8)?; + settings.set_default("state.location", "/tmp"); Ok(()) } From 9ea5321dc7b4633b9e8fcec6f1047e068f3f9880 Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Mon, 16 Apr 2018 14:16:17 +0100 Subject: [PATCH 17/33] WIP --- manager/src/broker/mod.rs | 2 +- manager/src/main.rs | 11 ++++++----- manager/src/scheduler/mod.rs | 6 +++--- manager/src/state/mod.rs | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/manager/src/broker/mod.rs b/manager/src/broker/mod.rs index 120cf4a..ca51738 100644 --- a/manager/src/broker/mod.rs +++ b/manager/src/broker/mod.rs @@ -5,7 +5,7 @@ use futures::Future; use heracles_proto::datatypes::Task; -pub trait BrokerConnection { +pub trait BrokerConnection: Send + Sync { fn send<'a>(&'a self, Task) -> Box, Error = Error> + 'a>; } diff --git a/manager/src/main.rs b/manager/src/main.rs index f6141cd..3198f91 100644 --- a/manager/src/main.rs +++ b/manager/src/main.rs @@ -13,6 +13,7 @@ use heracles_manager::settings::SETTINGS; use heracles_manager::{broker, optparse, scheduler, server, state, settings}; use std::path::PathBuf; +use std::sync::Arc; fn main() { if let Err(err) = run() { @@ -30,20 +31,20 @@ fn run() -> Result<(), Error> { settings::init(&arg_matches)?; let broker_addr = SETTINGS.read().unwrap().get("broker.address")?; - let broker_conn = broker::amqp::connect(broker_addr); + let broker_conn = broker::amqp::connect(broker_addr).wait()?; let state_location: &str = SETTINGS.read().unwrap().get("state.location")?; let store = state::FileStore::new(&PathBuf::from(state_location.to_string()))?; - let schdlr = scheduler::Scheduler::new(Box::new(broker_conn), Box::new(store))?; + let schdlr = scheduler::Scheduler::new(Arc::new(broker_conn), Arc::new(store))?; - // let srv = server::Server::new(schdlr)?; + let srv = server::Server::new(schdlr)?; info!("Starting main event loop."); // We give this an empty future so that it will never terminate and continue driving other // futures to completion. - // tokio::run(schdlr.run()); - tokio::run(future::empty()); + tokio::run(schdlr.run()); + // tokio::run(future::empty()); Ok(()) } diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index 4b8b996..1c37473 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -18,8 +18,8 @@ use settings::SETTINGS; /// Manages the entire data pipeline of the manager and links together all of the manager's /// components. pub struct Scheduler { - broker: Box, - store: Box, + broker: Arc, + store: Arc, rx: Arc>>>, tx: mpsc::Sender, } @@ -29,7 +29,7 @@ impl Scheduler { /// /// Takes a handle to a [`heracles_manager_lib::broker::Broker`] which it uses to send /// [`Task`]s to workers for execution. - pub fn new(broker: Box, store: Box) -> Result { + pub fn new(broker: Arc, store: Arc) -> Result { let (tx, rx) = mpsc::channel::(SETTINGS.read().unwrap().get("scheduler.input_queue_size")?); Ok(Scheduler { diff --git a/manager/src/state/mod.rs b/manager/src/state/mod.rs index 7fb6ce8..9789b44 100644 --- a/manager/src/state/mod.rs +++ b/manager/src/state/mod.rs @@ -12,7 +12,7 @@ use heracles_proto::datatypes::{Job, Task, TaskKind}; #[allow(doc_markdown)] /// Interface for creating connections to state stores, such as etcd or TiKV etc. -pub trait State { +pub trait State: Send + Sync { /// Serialize the job and save it in the state store so it can be loaded later. fn save_job(&self, job: &Job) -> Result<(), StateError>; /// Adds a task to the list of tasks and add it to pending From 6c850c3b2be5868be395f299a4698f30e9990169 Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Mon, 16 Apr 2018 15:26:15 +0100 Subject: [PATCH 18/33] WIP --- manager/src/main.rs | 2 +- manager/src/scheduler/mod.rs | 5 ++--- manager/src/settings.rs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/manager/src/main.rs b/manager/src/main.rs index 3198f91..eb9c250 100644 --- a/manager/src/main.rs +++ b/manager/src/main.rs @@ -38,7 +38,7 @@ fn run() -> Result<(), Error> { let schdlr = scheduler::Scheduler::new(Arc::new(broker_conn), Arc::new(store))?; - let srv = server::Server::new(schdlr)?; + server::Server::new(schdlr)?; info!("Starting main event loop."); // We give this an empty future so that it will never terminate and continue driving other diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index 1c37473..e8b10c0 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -47,7 +47,7 @@ impl Scheduler { job.set_id(id.clone()); // TODO: Scheduling time - self.store.save_job(&job.clone()); + self.store.save_job(&job.clone()).unwrap(); self.tx.clone().send(job.clone()); @@ -66,8 +66,7 @@ impl Scheduler { .unwrap() .map_err(|_| unreachable!("should never happen")) .for_each(move |job| self.process_job(job)) - .map_err(|_| SchedulerError::RxFailure.into()) - // future::ok(()) + .map_err(|_| panic!("should not happen")) } fn process_job<'a>(&'a self, job: Job) -> impl Future + 'a { diff --git a/manager/src/settings.rs b/manager/src/settings.rs index dea7630..11d06f5 100644 --- a/manager/src/settings.rs +++ b/manager/src/settings.rs @@ -74,7 +74,7 @@ fn set_defaults(settings: &mut Config) -> Result<(), Error> { settings.set_default("scheduler.input_queue_size", 4)?; settings.set_default("server.port", 8081)?; settings.set_default("server.thread_pool_size", 8)?; - settings.set_default("state.location", "/tmp"); + settings.set_default("state.location", "/tmp")?; Ok(()) } From 3a2cf3e444f47fe04e62acb5b68c53c374b0b17a Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Mon, 16 Apr 2018 18:57:14 +0100 Subject: [PATCH 19/33] Updated dependencies --- Cargo.lock | 501 +++++++++++++---------------- manager/Cargo.toml | 8 +- manager/src/broker/amqp.rs | 2 +- manager/src/broker/mod.rs | 2 +- manager/src/main.rs | 4 +- manager/src/scheduler/mod.rs | 2 +- manager/src/server/jobscheduler.rs | 4 +- manager/src/server/mod.rs | 3 +- proto/Cargo.toml | 7 +- proto/src/lib.rs | 1 - 10 files changed, 246 insertions(+), 288 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 628f937..16c2a69 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,7 +21,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "amq-protocol-codegen 0.27.0 (registry+https://github.com/rust-lang/crates.io-index)", "amq-protocol-types 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", - "cookie-factory 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cookie-factory 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -33,9 +33,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "amq-protocol-types 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "handlebars 0.27.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -43,17 +43,20 @@ name = "amq-protocol-types" version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cookie-factory 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cookie-factory 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ansi_term" -version = "0.9.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "arrayvec" @@ -75,7 +78,7 @@ dependencies = [ [[package]] name = "backtrace" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -90,7 +93,7 @@ name = "backtrace-sys" version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -99,7 +102,7 @@ name = "base64" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -107,15 +110,10 @@ name = "base64" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "safemem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "bitflags" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "bitflags" version = "1.0.1" @@ -126,22 +124,22 @@ name = "bson" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "hostname 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "byteorder" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -149,13 +147,13 @@ name = "bytes" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cc" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -163,15 +161,15 @@ name = "cerberus" version = "0.3.0" dependencies = [ "bson 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -182,24 +180,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "chrono" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "clap" -version = "2.26.2" +version = "2.31.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -211,16 +209,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", "serde-hjson 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "yaml-rust 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cookie-factory" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -294,15 +292,6 @@ name = "either" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "env_logger" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "env_logger" version = "0.4.3" @@ -312,22 +301,12 @@ dependencies = [ "regex 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "errno" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "error-chain" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -335,7 +314,7 @@ name = "failure" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "backtrace 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "backtrace 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -373,7 +352,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "futures" -version = "0.1.19" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -381,7 +360,7 @@ name = "futures-cpupool" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -392,41 +371,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "grpc" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "base64 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "httpbis 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "httpbis 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tls-api 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "tls-api-stub 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-core 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tls-api 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tls-api-stub 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tls-api 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tls-api 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "grpc-compiler" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "protobuf 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "grpc-rust" -version = "0.1.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "errno 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", - "semver 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -439,40 +406,39 @@ dependencies = [ "pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "heracles-proto" version = "0.3.0" dependencies = [ - "grpc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "grpc-rust 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protoc-rust-grpc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tls-api 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "grpc 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "protoc-rust-grpc 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tls-api 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "heracles_manager" version = "0.4.0" dependencies = [ - "chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)", "config 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "fern 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", - "grpc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "grpc 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "heracles-proto 0.3.0", - "lapin-futures 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lapin-futures 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "uuid 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -491,20 +457,22 @@ dependencies = [ [[package]] name = "httpbis" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "net2 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", - "tls-api 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "tls-api-stub 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-core 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "tls-api 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tls-api-stub 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-tls-api 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tls-api 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-uds 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "unix_socket 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -543,27 +511,26 @@ dependencies = [ [[package]] name = "lapin-async" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "amq-protocol 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cookie-factory 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cookie-factory 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "sasl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "lapin-futures" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "amq-protocol 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "cookie-factory 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", - "lapin-async 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cookie-factory 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "lapin-async 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -671,6 +638,15 @@ dependencies = [ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "mio-uds" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "miow" version = "0.2.1" @@ -705,16 +681,6 @@ dependencies = [ "memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "num" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", - "num-iter 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "num-integer" version = "0.1.36" @@ -723,15 +689,6 @@ dependencies = [ "num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "num-iter" -version = "0.1.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "num-traits" version = "0.1.43" @@ -765,7 +722,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "0.2.3" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -773,7 +730,7 @@ dependencies = [ [[package]] name = "protobuf" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -781,7 +738,7 @@ dependencies = [ [[package]] name = "protoc" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -789,23 +746,23 @@ dependencies = [ [[package]] name = "protoc-rust" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "protobuf 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protoc 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "protoc 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "protoc-rust-grpc" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "grpc-compiler 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "protobuf 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protoc 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "protoc-rust 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "grpc-compiler 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "protobuf 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "protoc 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "protoc-rust 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -821,10 +778,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "quote" -version = "0.4.2" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -900,7 +857,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -912,7 +869,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "regex-syntax" -version = "0.5.3" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -971,23 +928,6 @@ name = "scopeguard" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "semver" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver-parser 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver-parser" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "serde" version = "0.8.23" @@ -995,7 +935,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.36" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1012,34 +952,34 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.36" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive_internals 0.22.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.12.14 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive_internals 0.23.1 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_derive_internals" -version = "0.22.2" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.12.14 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_json" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1062,7 +1002,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "strsim" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1077,11 +1017,11 @@ dependencies = [ [[package]] name = "syn" -version = "0.12.14" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1111,16 +1051,6 @@ dependencies = [ "remove_dir_all 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "term_size" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "termion" version = "1.5.1" @@ -1133,10 +1063,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1178,7 +1107,7 @@ dependencies = [ [[package]] name = "tls-api" -version = "0.1.14" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1186,52 +1115,53 @@ dependencies = [ [[package]] name = "tls-api-stub" -version = "0.1.14" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "tls-api 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", + "tls-api 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-tcp 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-threadpool 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-udp 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-core" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "scoped-tls 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "tokio-executor" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1240,7 +1170,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1249,11 +1179,11 @@ name = "tokio-reactor" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1263,7 +1193,7 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1272,15 +1202,15 @@ dependencies = [ [[package]] name = "tokio-threadpool" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crossbeam-deque 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-executor 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1288,18 +1218,27 @@ name = "tokio-timer" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-timer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-executor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "tokio-tls-api" -version = "0.1.14" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", - "tls-api 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "tokio-core 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "tls-api 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1309,19 +1248,35 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-reactor 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio-uds" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", + "mio-uds 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "toml" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1357,6 +1312,15 @@ name = "unicode-xid" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "unix_socket" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "unreachable" version = "1.0.0" @@ -1395,7 +1359,7 @@ dependencies = [ [[package]] name = "uuid" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1472,24 +1436,23 @@ dependencies = [ "checksum amq-protocol 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e2d184a888a73cd6bd867e41aa56e223b631a7b373d3704d21f8c3b229013e4d" "checksum amq-protocol-codegen 0.27.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fb1bce967c7863ed5431646e025ce57aa07658535cdb886abaca0ccd08823af8" "checksum amq-protocol-types 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a4b5afab1d27f606a50f24b1cf336cdc5d71f7f3e9effd6d6da56f2ceb314629" -"checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6" +"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" "checksum atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "af80143d6f7608d746df1520709e5d141c96f240b0e62b0aa41bdfb53374d9d4" -"checksum backtrace 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbbf59b1c43eefa8c3ede390fcc36820b4999f7914104015be25025e0d62af2" +"checksum backtrace 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ebbe525f66f42d207968308ee86bc2dd60aa5fab535b22e616323a173d097d8e" "checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661" "checksum base64 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "30e93c03064e7590d0466209155251b90c22e37fab1daf2771582598b5827557" "checksum base64 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "229d032f1a99302697f10b27167ae6d03d49d032e6a8e2550e8d3fc13356d2b4" -"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" "checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf" "checksum bson 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "97a88dc284b4f4fa28e8d874a5fde53291290bace25f68f3e7bbd6653afc1a50" -"checksum byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "652805b7e73fada9d85e9a6682a4abd490cb52d96aeecc12e33a0de34dfd0d23" +"checksum byteorder 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "73b5bdfe7ee3ad0b99c9801d58807a9dbc9e09196365b0203853b99889ab3c87" "checksum bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1b7db437d718977f6dc9b2e3fd6fc343c02ac6b899b73fdd2179163447bd9ce9" -"checksum cc 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "2b4911e4bdcb4100c7680e7e854ff38e23f1b34d4d9e079efae3da2801341ffc" +"checksum cc 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8b9d2900f78631a5876dc5d6c9033ede027253efcd33dd36b1309fc6cab97ee0" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" -"checksum chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c20ebe0b2b08b0aeddba49c609fe7957ba2e33449882cb186a180bc60682fa9" -"checksum clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3451e409013178663435d6f15fdb212f14ee4424a3d74f979d081d0a66b6f1f2" +"checksum chrono 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1cce36c92cb605414e9b824f866f5babe0a0368e39ea07393b9b63cf3844c0e6" +"checksum clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0f16b89cbb9ee36d87483dc939fe9f1e13c05898d56d7b230a0d4dff033a536" "checksum config 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e595d1735d8ab6b04906bbdcfc671cce2a5e609b6f8e92865e67331cc2f41ba4" -"checksum cookie-factory 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3f4b504d3887e69bdfc41233a0fde2518b9dad6f6228c342d7334ebc32833f1e" +"checksum cookie-factory 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9179f80d506c86cf782c3cf98f306199fccc91eb1e06d649fbeb8c1e5e24e6ab" "checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" "checksum crossbeam-deque 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c1bdc73742c36f7f35ebcda81dbb33a7e0d33757d03a06d9ddca762712ec5ea2" "checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150" @@ -1498,31 +1461,28 @@ dependencies = [ "checksum crossbeam-utils 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d636a8b3bcc1b409d7ffd3facef8f21dcb4009626adbd0c5e6c4305c07253c7b" "checksum dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "09c3753c3db574d215cba4ea76018483895d7bff25a31b49ba45db21c48e50ab" "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" -"checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f" "checksum env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3ddf21e73e016298f5cb37d6ef8e8da8e39f91f9ec8b0df44b7deb16a9f8cd5b" -"checksum errno 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1e2b2decb0484e15560df3210cf0d78654bb0864b2c138977c07e377a1bae0e2" "checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3" "checksum failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "934799b6c1de475a012a02dab0ace1ace43789ee4b99bcfbf1a2e3e8ced5de82" "checksum failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cdda555bb90c9bb67a3b670a0f42de8e73f5981524123ad8578aafec8ddb8b" "checksum fern 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "de237898aa785d93b869e965132f62a525b90cce5c0bf2a395f03e62e085bc5c" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum futures 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f32b9e9aaa890fe8b9453b27ebbf3d11136a5ce59032500effd0e707bbcd80" +"checksum futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "1a70b146671de62ec8c8ed572219ca5d594d9b06c0b364d5e67b722fc559b48c" "checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" -"checksum grpc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fc6251c5d191eb0d122a4b4fdc24dfa0095b4f54e1f70de5c3913e0332054662" -"checksum grpc-compiler 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b80ef06aa3e174f24eb688358e83afc50e328798de258b29e8abd27d6b9fc3c" -"checksum grpc-rust 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "795c3f654333803efdab3a51f228456d08981731ddfb753741090a13783833a1" +"checksum grpc 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b12fce14faf4649193a7b7e50902a95da0055f49c219a7569abfc27defb39c88" +"checksum grpc-compiler 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d5c64f7e21b08125b26f5cac7a93969244c447b5c3f32dabf1dbc497097a8e59" "checksum handlebars 0.27.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef7567daf271a32e60301e4821fcb5b51a5b535167115d1ce04f46c3f0a15f0b" "checksum hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6a22814455d41612f41161581c2883c0c6a1c41852729b17d5ed88f01e153aa" "checksum hostname 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "58fab6e177434b0bb4cd344a4dabaa5bd6d7a8d792b1885aebcae7af1091d1cb" -"checksum httpbis 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73dde194d197eaa5b49bb58d212ed4a99a713cf47fc77a9d0471b76c0f73fcf0" +"checksum httpbis 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "28cb592a1222b6d1c96ca1744a2e746296a5c4ed59a4f61557d1cbebfe97d333" "checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" "checksum itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c069bbec61e1ca5a596166e55dfe4773ff745c3d16b700013bcaff9a6df2c682" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum lapin-async 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1eea43a8d4489a50230e2e26af176a2ea2b72eeef8abc4b2d9ebbf062c80f987" -"checksum lapin-futures 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "050ad737d0ebe4a55735e4537768ea3bacc164da2e9add9283ed4625620c78f1" +"checksum lapin-async 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "59cffea6249e21446e5004a220dba7f96cd065e0a0ad36249a98394830c2dd77" +"checksum lapin-futures 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa2fbb4837cb9878a1f66d633ab2be93294c69b34f2e4bae025c7297c49564bf" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" "checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d" "checksum lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a6f08839bc70ef4a3fe1d566d5350f519c5912ea86be0df1740a7d247c7fc0ef" @@ -1537,26 +1497,25 @@ dependencies = [ "checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)" = "6d771e3ef92d58a8da8df7d6976bfca9371ed1de6619d9d5a5ce5b1f29b85bfe" +"checksum mio-uds 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1731a873077147b626d89cc6c2a0db6288d607496c5d10c0cfcf3adc697ec673" "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum net2 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)" = "9044faf1413a1057267be51b5afba8eb1090bd2231c693664aa1db716fe1eae0" "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" "checksum nom 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05aec50c70fd288702bcd93284a8444607f3292dbdf2a30de5ea5dcdbe72287b" -"checksum num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e" "checksum num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f8d26da319fb45674985c78f1d1caf99aa4941f785d384a2ae36d0740bc3e2fe" -"checksum num-iter 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "4b226df12c5a59b63569dd57fafb926d91b385dfce33d8074a412411b689d593" "checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" "checksum num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dee092fcdf725aee04dd7da1d21debff559237d49ef1cb3e69bcb8ece44c7364" "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0a6dda33d67c26f0aac90d324ab2eb7239c819fc7b2552fe9faa4fe88441edc8" -"checksum proc-macro2 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cd07deb3c6d1d9ff827999c7f9b04cdfd66b1b17ae508e14fe47b620f2282ae0" -"checksum protobuf 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab7fa36fe9d86e36aafc3bd360569694fa698c233c095269768acf849c680edf" -"checksum protoc 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4c7aa91b209584865f6343efa3c9750e2edb06bcf0665ca7eb7f6bdb1d58ad53" -"checksum protoc-rust 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "86a5847ababf22a606960b7c8286dfb770cbfd72513ac4c2039db1e73170ce3a" -"checksum protoc-rust-grpc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "68bc8fa6685f274fe41d6d47e3c7d702662ff7c268e5bfa8d5e7a809784418c6" +"checksum proc-macro2 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "49b6a521dc81b643e9a51e0d1cf05df46d5a2f3c0280ea72bcb68276ba64a118" +"checksum protobuf 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40e2484e639dcae0985fc483ad76ce7ad78ee5aa092751d7d538f0b20d76486b" +"checksum protoc 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2ac0ab190b8aa83df8f04895432ec5eecfcf914d5645b47e08e099038c2f17aa" +"checksum protoc-rust 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c2477e34e0fdc624babdd3e3106bacbc710d7729012616f1b7d3dc13bf1bb68" +"checksum protoc-rust-grpc 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9ffb804de72b0278f4d8d6362a95e2910e637bec526238c3a3692b19ba43fe" "checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" -"checksum quote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1eca14c727ad12702eb4b6bfb5a232287dcf8385cb8ca83a3eeaf6519c44c408" +"checksum quote 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7b0ff51282f28dc1b53fd154298feaa2e77c5ea0dba68e1fd8b03b72fbe13d2a" "checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1" "checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" "checksum rayon 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80e811e76f1dbf68abf87a759083d34600017fc4e10b6bd5ad84a700f9dba4b1" @@ -1566,7 +1525,7 @@ dependencies = [ "checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" "checksum regex 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "aec3f58d903a7d2a9dc2bf0e41a746f4530e0cab6b615494e058f67a3ef947fb" "checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" -"checksum regex-syntax 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b2550876c31dc914696a6c2e01cbce8afba79a93c8ae979d2fe051c0230b3756" +"checksum regex-syntax 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bd90079345f4a4c3409214734ae220fd773c6f2e8a543d07370c6c1c369cfbfb" "checksum remove_dir_all 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "dfc5b3ce5d5ea144bb04ebd093a9e14e9765bcfec866aecda9b6dec43b3d1e24" "checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" "checksum rustc-demangle 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11fb43a206a04116ffd7cfcf9bcb941f8eb6cc7ff667272246b0a1c74259a3cb" @@ -1575,55 +1534,55 @@ dependencies = [ "checksum sasl 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3164e2c4ce845bdebdff343dc5125a84a2bde241c7e8a68a0a17a63365231927" "checksum scoped-tls 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8674d439c964889e2476f474a3bf198cc9e199e77499960893bac5de7e9218a4" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" -"checksum semver 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ca1c06afc03e8a202bc5c1db01524cceb7e1b1ca062d959d83a61b20d76e394e" -"checksum semver-parser 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d8fff3c9c5a54636ab95acd8c1349926e04cb1eb8cd70b5adced8a1d1f703a67" "checksum serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" -"checksum serde 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)" = "c70142ae874a42c70e03c63c6a49abe2ea0079b090bf6e136e99252fc1974bd6" +"checksum serde 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)" = "4c36359ac1a823e00db02a243376ced650f088dc1f6259bbf828e4668e3c7399" "checksum serde-hjson 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a2376ebb8976138927f48b49588ef73cde2f6591b8b3df22f4063e0f27b9bec" -"checksum serde_derive 1.0.36 (registry+https://github.com/rust-lang/crates.io-index)" = "6fffe22d41dbddcead5b2c380c4714d44f2eb39292f7e7a0d966d2d45bf56408" -"checksum serde_derive_internals 0.22.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d2f04ed291686ce195a5c8f554aaf36e50a721fbf829ee3b6151e6f85eccf945" -"checksum serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "5c508584d9913df116b91505eec55610a2f5b16e9ed793c46e4d0152872b3e74" +"checksum serde_derive 1.0.38 (registry+https://github.com/rust-lang/crates.io-index)" = "f0477feff739386f5bca8e13fa43d96a4e834904d538f503906c8179f9205f50" +"checksum serde_derive_internals 0.23.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9d30c4596450fd7bbda79ef15559683f9a79ac0193ea819db90000d7e1cae794" +"checksum serde_json 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "8f6f1f77b969caa064f347544d703efacaf4854b84831096a5dc206a8aedbc27" "checksum serde_test 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "110b3dbdf8607ec493c22d5d947753282f3bae73c0f56d322af1e8c78e4c23d5" "checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23" "checksum slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdeff4cd9ecff59ec7e3744cbca73dfe5ac35c2aedb2cfba8a1c715a18912e9d" -"checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694" +"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" -"checksum syn 0.12.14 (registry+https://github.com/rust-lang/crates.io-index)" = "8c5bc2d6ff27891209efa5f63e9de78648d7801f085e4653701a692ce938d6fd" +"checksum syn 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "91b52877572087400e83d24b9178488541e3d535259e04ff17a63df1e5ceff59" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd" "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" -"checksum term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e5b9a66db815dcfd2da92db471106457082577c3c278d4138ab3e3b4e189327" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" -"checksum textwrap 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df8e08afc40ae3459e4838f303e465aa50d823df8d7f83ca88108f6d3afe7edd" +"checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693" "checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" "checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" "checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963" "checksum time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "a15375f1df02096fb3317256ce2cee6a1f42fc84ea5ad5fc8c421cfe40c73098" -"checksum tls-api 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "a2424af93d25301cead84cc8225f119918e63d44ee494a0209338dcf7d1eec18" -"checksum tls-api-stub 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "f8cf9d37d193ad3e78efb7c85b6c00311d90ed32755a16c62080d1711c1d99fb" -"checksum tokio 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "65bd27f59c223e7c9e406bcdadb453e143bcf1242e162ae6c0f0eb6d14487306" -"checksum tokio-core 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "799492ccba3d8ed5e41f2520a7cfd504cb65bbfe5fbbbd0012e335ae5f188051" -"checksum tokio-executor 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3aca092a94dc6e736819347a990a86ed734a6543a9d6f817929fa4dc8c4334e2" +"checksum tls-api 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "b433ee8bde283064ac414932e5c8d0ce20f9820b344a09398538ec240373e8c9" +"checksum tls-api-stub 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "a7029e7c7ebdfc065c10fe4a065f52837fd0907551f7b3565d406c119b46c42a" +"checksum tokio 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "be15ef40f675c9fe66e354d74c73f3ed012ca1aa14d65846a33ee48f1ae8d922" +"checksum tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "aeeffbbb94209023feaef3c196a41cbcdafa06b4a6f893f68779bb5e53796f71" +"checksum tokio-executor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8cac2a7883ff3567e9d66bb09100d09b33d90311feca0206c7ca034bc0c55113" "checksum tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6af9eb326f64b2d6b68438e1953341e00ab3cf54de7e35d92bfc73af8555313a" "checksum tokio-reactor 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3cedc8e5af5131dc3423ffa4f877cce78ad25259a9a62de0613735a13ebc64b" "checksum tokio-tcp 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ec9b094851aadd2caf83ba3ad8e8c4ce65a42104f7b94d9e6550023f0407853f" -"checksum tokio-threadpool 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2057ff8a75d33639f9ea1b4b85cb113c7bbf4e06d132f148521d12cb6daa1a22" +"checksum tokio-threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3d05cdd6a78005e535d2b27c21521bdf91fbb321027a62d8e178929d18966d" "checksum tokio-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6131e780037787ff1b3f8aad9da83bca02438b72277850dd6ad0d455e0e20efc" -"checksum tokio-tls-api 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "a47b126d55dc5f9407eeba619a305ca70a8ba8f7d6b813bfaf93e924afe27ce1" +"checksum tokio-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "29a89e4ad0c8f1e4c9860e605c38c69bfdad3cccd4ea446e58ff588c1c07a397" +"checksum tokio-tls-api 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "e00c40dfac88e87b728026c72426a0e2d4319fa8386eae9003093a3e00aee83e" "checksum tokio-udp 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "137bda266504893ac4774e0ec4c2108f7ccdbcb7ac8dced6305fe9e4e0b5041a" -"checksum toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e" +"checksum tokio-uds 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "65ae5d255ce739e8537221ed2942e0445f4b3b813daebac1c0050ddaaa3587f9" +"checksum toml 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a0263c6c02c4db6c8f7681f9fd35e90de799ebd4cfdeab77a38f4ff6b3d8c0d9" "checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "51ccda9ef9efa3f7ef5d91e8f9b83bbe6955f9bf86aec89d5cce2c874625920f" "checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" +"checksum unix_socket 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6aa2700417c405c38f5e6902d699345241c28c0b7ade4abaad71e35a87eb1564" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" "checksum url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f808aadd8cfec6ef90e4a14eb46f24511824d1ac596b9682703c87056c8678b7" "checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" "checksum uuid 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc7e3b898aa6f6c08e5295b6c89258d1331e9ac578cc992fb818759951bdc22" -"checksum uuid 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4670e1e935f7edd193a413f802e2ee52274aed62a09ccaab1656515c9c53a66" +"checksum uuid 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8630752f979f1b6b87c49830a5e3784082545de63920d59fbaac252474319447" "checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" diff --git a/manager/Cargo.toml b/manager/Cargo.toml index 4d66e74..bf638ac 100644 --- a/manager/Cargo.toml +++ b/manager/Cargo.toml @@ -16,13 +16,13 @@ clap = "2.26" config = "0.8.0" failure = "0.1.1" fern = "0.5.3" -futures = "0.1.18" -grpc = "0.2.1" +futures = "0.1.20" +grpc = "0.3.0" heracles-proto = { path = "../proto"} -lapin-futures = "0.10.0" +lapin-futures = "0.11.1" lazy_static = "1.0" log = "0.4" protobuf = "1.4" rayon = "1.0.0" -tokio = "0.1.4" +tokio = "0.1.5" uuid = { version = "0.6", features = ["v4"] } diff --git a/manager/src/broker/amqp.rs b/manager/src/broker/amqp.rs index 6d2b561..dbda827 100644 --- a/manager/src/broker/amqp.rs +++ b/manager/src/broker/amqp.rs @@ -20,7 +20,7 @@ impl BrokerConnection for AMQPBrokerConnection { /// /// The `Option` returned represents whether the message was acked (`Some(true)`), nacked /// (`Some(false)`), or the queue is not a confirm queue (`None`). - fn send<'a>(&'a self, task: Task) -> Box, Error = Error> + 'a> { + fn send<'a>(&'a self, task: Task) -> Box, Error = Error> + Send + 'a> { let task_id = task.get_id().to_string(); let ret = future::lazy(move || future::done(task.write_to_bytes())) .map_err(|e| e.context(BrokerError::TaskSerialisationFailure { task_id })) diff --git a/manager/src/broker/mod.rs b/manager/src/broker/mod.rs index ca51738..ae40362 100644 --- a/manager/src/broker/mod.rs +++ b/manager/src/broker/mod.rs @@ -6,7 +6,7 @@ use futures::Future; use heracles_proto::datatypes::Task; pub trait BrokerConnection: Send + Sync { - fn send<'a>(&'a self, Task) -> Box, Error = Error> + 'a>; + fn send<'a>(&'a self, Task) -> Box, Error = Error> + Send + 'a>; } #[derive(Debug, Fail)] diff --git a/manager/src/main.rs b/manager/src/main.rs index eb9c250..77f707e 100644 --- a/manager/src/main.rs +++ b/manager/src/main.rs @@ -36,9 +36,9 @@ fn run() -> Result<(), Error> { let state_location: &str = SETTINGS.read().unwrap().get("state.location")?; let store = state::FileStore::new(&PathBuf::from(state_location.to_string()))?; - let schdlr = scheduler::Scheduler::new(Arc::new(broker_conn), Arc::new(store))?; + let schdlr = Arc::new(scheduler::Scheduler::new(Arc::new(broker_conn), Arc::new(store))?); - server::Server::new(schdlr)?; + server::Server::new(Arc::clone(&schdlr))?; info!("Starting main event loop."); // We give this an empty future so that it will never terminate and continue driving other diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index e8b10c0..aadf3a9 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -58,7 +58,7 @@ impl Scheduler { unimplemented!() } - pub fn run<'a>(&'a self) -> impl Future + 'a { + pub fn run<'a>(&'a self) -> impl Future + 'a { self.rx .lock() .unwrap() diff --git a/manager/src/server/jobscheduler.rs b/manager/src/server/jobscheduler.rs index 3f29b2b..237e574 100644 --- a/manager/src/server/jobscheduler.rs +++ b/manager/src/server/jobscheduler.rs @@ -8,11 +8,11 @@ use scheduler::Scheduler; // use std::sync::Arc; pub struct JobScheduleService { - scheduler: Scheduler, + scheduler: Arc, } impl JobScheduleService { - pub fn new(scheduler: Scheduler) -> Self { + pub fn new(scheduler: Arc) -> Self { JobScheduleService { scheduler } } } diff --git a/manager/src/server/mod.rs b/manager/src/server/mod.rs index e4ddf4c..077891d 100644 --- a/manager/src/server/mod.rs +++ b/manager/src/server/mod.rs @@ -2,6 +2,7 @@ mod jobscheduler; use std::fmt; use std::fmt::Display; +use std::sync::Arc; use failure::*; use grpc; @@ -16,7 +17,7 @@ pub struct Server { } impl Server { - pub fn new(scheduler: Scheduler) -> Result { + pub fn new(scheduler: Arc) -> Result { let mut builder = grpc::ServerBuilder::new_plain(); builder .http diff --git a/proto/Cargo.toml b/proto/Cargo.toml index 1173707..3635fd3 100644 --- a/proto/Cargo.toml +++ b/proto/Cargo.toml @@ -5,9 +5,8 @@ build = "build.rs" [dependencies] protobuf = "1.4.1" -grpc = "0.2.1" -grpc-rust = "0.1.0" -tls-api = "0.1.10" +grpc = "0.3.0" +tls-api = "0.1.19" [build-dependencies] -protoc-rust-grpc = "0.2.1" +protoc-rust-grpc = "0.3.0" diff --git a/proto/src/lib.rs b/proto/src/lib.rs index 78a3cf8..bdef7a8 100644 --- a/proto/src/lib.rs +++ b/proto/src/lib.rs @@ -1,5 +1,4 @@ extern crate grpc; -extern crate grpc_rust; extern crate protobuf; extern crate tls_api; From cf1cfa11325c00af8b6b757232f303d26b5e0ff6 Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Mon, 16 Apr 2018 19:29:26 +0100 Subject: [PATCH 20/33] WIP --- manager/src/main.rs | 8 ++++---- manager/src/optparse.rs | 6 ------ manager/src/scheduler/mod.rs | 11 ++++++----- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/manager/src/main.rs b/manager/src/main.rs index 77f707e..faa1a80 100644 --- a/manager/src/main.rs +++ b/manager/src/main.rs @@ -31,14 +31,14 @@ fn run() -> Result<(), Error> { settings::init(&arg_matches)?; let broker_addr = SETTINGS.read().unwrap().get("broker.address")?; - let broker_conn = broker::amqp::connect(broker_addr).wait()?; + let broker_conn = Arc::new(broker::amqp::connect(broker_addr).wait()?); let state_location: &str = SETTINGS.read().unwrap().get("state.location")?; - let store = state::FileStore::new(&PathBuf::from(state_location.to_string()))?; + let store = Arc::new(state::FileStore::new(&PathBuf::from(state_location.to_string()))?); - let schdlr = Arc::new(scheduler::Scheduler::new(Arc::new(broker_conn), Arc::new(store))?); + let schdlr = Arc::new(scheduler::Scheduler::new(broker_conn, store)?); - server::Server::new(Arc::clone(&schdlr))?; + server::Server::new(schdlr.clone())?; info!("Starting main event loop."); // We give this an empty future so that it will never terminate and continue driving other diff --git a/manager/src/optparse.rs b/manager/src/optparse.rs index 8af0cf0..16373dd 100644 --- a/manager/src/optparse.rs +++ b/manager/src/optparse.rs @@ -41,11 +41,5 @@ Each chunk corresponds to one map task, so this can be used to scale the job.", .long("server-port") .takes_value(true), ) - .arg( - Arg::with_name("broker_queue_name") - .help("The name to register with the broker for the task processing queue.") - .long("broker-queue-name") - .takes_value(true), - ) .get_matches() } diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index aadf3a9..2a1820e 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -7,7 +7,6 @@ use failure::*; use futures::*; use futures::sync::mpsc; use uuid::Uuid; -use tokio; use heracles_proto::datatypes::*; use splitting; @@ -21,7 +20,7 @@ pub struct Scheduler { broker: Arc, store: Arc, rx: Arc>>>, - tx: mpsc::Sender, + tx: Arc>>>, } impl Scheduler { @@ -36,7 +35,7 @@ impl Scheduler { broker: broker, store: store, rx: Arc::new(Mutex::new(Some(rx))), - tx: tx, + tx: Arc::new(Mutex::new(Some(tx))), }) } @@ -49,7 +48,9 @@ impl Scheduler { self.store.save_job(&job.clone()).unwrap(); - self.tx.clone().send(job.clone()); + // self.tx.borrow_mut().take().unwrap().send(job.clone()); + + self.tx.lock().unwrap().take().unwrap().clone().send(job.clone()); Ok(id) } @@ -58,7 +59,7 @@ impl Scheduler { unimplemented!() } - pub fn run<'a>(&'a self) -> impl Future + 'a { + pub fn run(&'static self) -> impl Future + 'static { self.rx .lock() .unwrap() From d452b2b9e92f327be15a260020f13b8d09720286 Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Mon, 16 Apr 2018 19:36:31 +0100 Subject: [PATCH 21/33] WIP --- manager/src/scheduler/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index 2a1820e..a8129bc 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -59,8 +59,9 @@ impl Scheduler { unimplemented!() } - pub fn run(&'static self) -> impl Future + 'static { + pub fn run(&self) -> impl Future { self.rx + .clone() .lock() .unwrap() .take() From 1842cca0e8bf37a0f1ec4e88b0889132678aae21 Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Mon, 16 Apr 2018 19:45:12 +0100 Subject: [PATCH 22/33] WIP --- manager/src/broker/amqp.rs | 2 +- manager/src/broker/mod.rs | 2 +- manager/src/scheduler/mod.rs | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/manager/src/broker/amqp.rs b/manager/src/broker/amqp.rs index dbda827..1493cf2 100644 --- a/manager/src/broker/amqp.rs +++ b/manager/src/broker/amqp.rs @@ -20,7 +20,7 @@ impl BrokerConnection for AMQPBrokerConnection { /// /// The `Option` returned represents whether the message was acked (`Some(true)`), nacked /// (`Some(false)`), or the queue is not a confirm queue (`None`). - fn send<'a>(&'a self, task: Task) -> Box, Error = Error> + Send + 'a> { + fn send(&self, task: Task) -> Box, Error = Error> + Send + 'static> { let task_id = task.get_id().to_string(); let ret = future::lazy(move || future::done(task.write_to_bytes())) .map_err(|e| e.context(BrokerError::TaskSerialisationFailure { task_id })) diff --git a/manager/src/broker/mod.rs b/manager/src/broker/mod.rs index ae40362..c6b2d75 100644 --- a/manager/src/broker/mod.rs +++ b/manager/src/broker/mod.rs @@ -6,7 +6,7 @@ use futures::Future; use heracles_proto::datatypes::Task; pub trait BrokerConnection: Send + Sync { - fn send<'a>(&'a self, Task) -> Box, Error = Error> + Send + 'a>; + fn send(&self, Task) -> Box, Error = Error> + Send + 'static>; } #[derive(Debug, Fail)] diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index a8129bc..756b52e 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -39,7 +39,7 @@ impl Scheduler { }) } - pub fn schedule<'a>(&'a self, req: Job) -> Result { + pub fn schedule(&self, req: Job) -> Result { let mut job = req.clone(); let id = Uuid::new_v4().to_string(); @@ -55,7 +55,7 @@ impl Scheduler { Ok(id) } - pub fn cancel<'a>(&'a self, _job_id: &str) -> Result<(), SchedulerError> { + pub fn cancel(&self, _job_id: &str) -> Result<(), SchedulerError> { unimplemented!() } @@ -71,7 +71,7 @@ impl Scheduler { .map_err(|_| panic!("should not happen")) } - fn process_job<'a>(&'a self, job: Job) -> impl Future + 'a { + fn process_job(&self, job: Job) -> impl Future + 'static { // TODO: Refactor this ugly code. This should not be cloned so many times. let job1 = job.clone(); let job2 = job.clone(); @@ -88,7 +88,7 @@ impl Scheduler { }) } - fn run_tasks<'a>(&'a self, tasks: Vec) -> impl Future + 'a { + fn run_tasks(&self, tasks: Vec) -> impl Future + 'static { // Normally we would do `.into_iter()` on the task, but it looks like there is a problem // with it currently. This issue describes the error we are having: // https://github.com/rust-lang/rust/issues/49926 @@ -99,7 +99,7 @@ impl Scheduler { future::join_all(task_futures).and_then(|_| future::ok(())) } - fn process_task<'a>(&'a self, mut task: Task) -> impl Future + 'a { + fn process_task(&self, mut task: Task) -> impl Future + 'static { task.set_time_started(Utc::now().timestamp() as u64); task.set_status(TaskStatus::TASK_IN_PROGRESS); self.store.save_task(&task); From 4907037903d3113cb80037d896e8504743eeba38 Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Mon, 16 Apr 2018 19:49:50 +0100 Subject: [PATCH 23/33] WIP --- manager/src/scheduler/mod.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index 756b52e..dc7e4ca 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -67,7 +67,7 @@ impl Scheduler { .take() .unwrap() .map_err(|_| unreachable!("should never happen")) - .for_each(move |job| self.process_job(job)) + .for_each(|job| self.process_job(job)) .map_err(|_| panic!("should not happen")) } @@ -76,11 +76,11 @@ impl Scheduler { let job1 = job.clone(); let job2 = job.clone(); let job3 = job.clone(); - lazy(move || done(splitting::map::split(&job1))) - .and_then(move |tasks| self.run_tasks(tasks)) - .and_then(move |_| future::ok(splitting::reduce::split(&job2))) - .and_then(move |tasks| self.run_tasks(tasks)) - .and_then(move |_| { + lazy(|| done(splitting::map::split(&job1))) + .and_then(|tasks| self.run_tasks(tasks)) + .and_then(|_| future::ok(splitting::reduce::split(&job2))) + .and_then(|tasks| self.run_tasks(tasks)) + .and_then(|_| { // mark job as done self.store.save_job(&job3); @@ -107,7 +107,7 @@ impl Scheduler { self.broker.send(task.clone()) // .map_err(|e| e.context(SchedulerError::BrokerSendFailure)) // .from_err() - .and_then(move |ack| { + .and_then(|ack| { if let Some(completed) = ack { if completed { task.set_status(TaskStatus::TASK_DONE); From bca68e896d933b4eadcd8142f2074b5e9cbad4de Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Mon, 16 Apr 2018 20:59:14 +0100 Subject: [PATCH 24/33] WIP --- manager/src/broker/amqp.rs | 6 ++++-- manager/src/scheduler/mod.rs | 13 +++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/manager/src/broker/amqp.rs b/manager/src/broker/amqp.rs index 1493cf2..fd29033 100644 --- a/manager/src/broker/amqp.rs +++ b/manager/src/broker/amqp.rs @@ -1,4 +1,5 @@ use std::net::SocketAddr; +use std::sync::Arc; use lapin::channel::{BasicProperties, BasicPublishOptions, Channel, QueueDeclareOptions}; use lapin::client::{Client, ConnectionOptions}; @@ -11,7 +12,7 @@ use super::*; use settings::SETTINGS; pub struct AMQPBrokerConnection { - channel: Channel, + channel: Arc>, queue_name: String, } @@ -27,6 +28,7 @@ impl BrokerConnection for AMQPBrokerConnection { .from_err() .and_then(move |bytes| { self.channel + .clone() .basic_publish( "", &self.queue_name, @@ -61,7 +63,7 @@ pub fn connect(addr: SocketAddr) -> impl Future) -> impl Future { +// // Normally we would do `.into_iter()` on the task, but it looks like there is a problem +// // with it currently. This issue describes the error we are having: +// // https://github.com/rust-lang/rust/issues/49926 +// let mut task_futures = vec![]; +// for mut task in tasks { +// task_futures.push(self.process_task(task.clone())); +// } +// future::join_all(task_futures).and_then(|_| future::ok(())) +// } + +// fn process_task() + #[derive(Debug, Fail)] pub enum SchedulerError { #[fail(display = "failed to split job into map tasks")] From 6482723e58dad02d747b7a37b02631f0476aaafc Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Mon, 16 Apr 2018 21:03:29 +0100 Subject: [PATCH 25/33] WIP --- manager/src/broker/amqp.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/manager/src/broker/amqp.rs b/manager/src/broker/amqp.rs index fd29033..2228f48 100644 --- a/manager/src/broker/amqp.rs +++ b/manager/src/broker/amqp.rs @@ -23,20 +23,20 @@ impl BrokerConnection for AMQPBrokerConnection { /// (`Some(false)`), or the queue is not a confirm queue (`None`). fn send(&self, task: Task) -> Box, Error = Error> + Send + 'static> { let task_id = task.get_id().to_string(); + let ch = self.channel.clone(); + let queue_name = &self.queue_name.clone(); + let ret = future::lazy(move || future::done(task.write_to_bytes())) .map_err(|e| e.context(BrokerError::TaskSerialisationFailure { task_id })) .from_err() .and_then(move |bytes| { - self.channel - .clone() - .basic_publish( - "", - &self.queue_name, - &bytes, - &BasicPublishOptions::default(), - BasicProperties::default(), - ) - .from_err() + ch.basic_publish( + "", + queue_name, + &bytes, + &BasicPublishOptions::default(), + BasicProperties::default(), + ).from_err() }); Box::new(ret) } From 7da1c0cfd3b63e02c21f61d7b6cc5f47508a55a9 Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Mon, 16 Apr 2018 21:07:40 +0100 Subject: [PATCH 26/33] WIP --- manager/src/scheduler/mod.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index 8ebbd44..bd967b1 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -76,6 +76,8 @@ impl Scheduler { let job1 = job.clone(); let job2 = job.clone(); let job3 = job.clone(); + + let store = self.store.clone(); lazy(|| done(splitting::map::split(&job1))) .and_then(|tasks| self.run_tasks(tasks)) .and_then(|_| future::ok(splitting::reduce::split(&job2))) @@ -83,7 +85,7 @@ impl Scheduler { .and_then(|_| { // mark job as done - self.store.save_job(&job3); + store.save_job(&job3); future::ok(()) }) } @@ -102,7 +104,9 @@ impl Scheduler { fn process_task(&self, mut task: Task) -> impl Future + 'static { task.set_time_started(Utc::now().timestamp() as u64); task.set_status(TaskStatus::TASK_IN_PROGRESS); - self.store.save_task(&task); + + let store = self.store.clone(); + store.save_task(&task); self.broker.send(task.clone()) // .map_err(|e| e.context(SchedulerError::BrokerSendFailure)) @@ -119,7 +123,7 @@ impl Scheduler { panic!("ack of task failed. this should not happen"); } task.set_time_done(Utc::now().timestamp() as u64); - self.store.save_task(&task); + store.save_task(&task); future::ok(()) }) } From 1c8dbbd4190cf97f24da8344e11661b555b01395 Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Mon, 16 Apr 2018 21:27:54 +0100 Subject: [PATCH 27/33] WIP --- manager/src/scheduler/mod.rs | 120 +++++++++++++++++++++++++---------- 1 file changed, 88 insertions(+), 32 deletions(-) diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler/mod.rs index bd967b1..4f8b298 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler/mod.rs @@ -16,6 +16,7 @@ use settings::SETTINGS; /// Manages the entire data pipeline of the manager and links together all of the manager's /// components. +#[derive(Clone)] pub struct Scheduler { broker: Arc, store: Arc, @@ -39,50 +40,56 @@ impl Scheduler { }) } - pub fn schedule(&self, req: Job) -> Result { + pub fn schedule(self, req: Job) -> Result { + let sch = self.clone(); + let mut job = req.clone(); let id = Uuid::new_v4().to_string(); job.set_id(id.clone()); // TODO: Scheduling time - self.store.save_job(&job.clone()).unwrap(); + sch.store.save_job(&job.clone()).unwrap(); // self.tx.borrow_mut().take().unwrap().send(job.clone()); - self.tx.lock().unwrap().take().unwrap().clone().send(job.clone()); + sch.tx.lock().unwrap().take().unwrap().clone().send(job.clone()); Ok(id) } - pub fn cancel(&self, _job_id: &str) -> Result<(), SchedulerError> { + pub fn cancel(self, _job_id: &str) -> Result<(), SchedulerError> { unimplemented!() } - pub fn run(&self) -> impl Future { - self.rx + pub fn run(self) -> impl Future { + let sch = self.clone(); + + sch.rx .clone() .lock() .unwrap() .take() .unwrap() .map_err(|_| unreachable!("should never happen")) - .for_each(|job| self.process_job(job)) + .for_each(|job| sch.process_job(job)) .map_err(|_| panic!("should not happen")) } - fn process_job(&self, job: Job) -> impl Future + 'static { + fn process_job(self, job: Job) -> impl Future + 'static { + let sch = self.clone(); + // TODO: Refactor this ugly code. This should not be cloned so many times. let job1 = job.clone(); let job2 = job.clone(); let job3 = job.clone(); - let store = self.store.clone(); - lazy(|| done(splitting::map::split(&job1))) - .and_then(|tasks| self.run_tasks(tasks)) - .and_then(|_| future::ok(splitting::reduce::split(&job2))) - .and_then(|tasks| self.run_tasks(tasks)) - .and_then(|_| { + let store = sch.store.clone(); + lazy(move || done(splitting::map::split(&job1))) + .and_then(move |tasks| sch.run_tasks(tasks)) + .and_then(move |_| future::ok(splitting::reduce::split(&job2))) + .and_then(move |tasks| sch.run_tasks(tasks)) + .and_then(move |_| { // mark job as done store.save_job(&job3); @@ -90,28 +97,32 @@ impl Scheduler { }) } - fn run_tasks(&self, tasks: Vec) -> impl Future + 'static { + fn run_tasks(self, tasks: Vec) -> impl Future + 'static { + let sch = self.clone(); + // Normally we would do `.into_iter()` on the task, but it looks like there is a problem // with it currently. This issue describes the error we are having: // https://github.com/rust-lang/rust/issues/49926 let mut task_futures = vec![]; for mut task in tasks { - task_futures.push(self.process_task(task.clone())); + task_futures.push(sch.process_task(task.clone())); } future::join_all(task_futures).and_then(|_| future::ok(())) } fn process_task(&self, mut task: Task) -> impl Future + 'static { + let sch = self.clone(); + task.set_time_started(Utc::now().timestamp() as u64); task.set_status(TaskStatus::TASK_IN_PROGRESS); - let store = self.store.clone(); + let store = sch.store.clone(); store.save_task(&task); - self.broker.send(task.clone()) + sch.broker.send(task.clone()) // .map_err(|e| e.context(SchedulerError::BrokerSendFailure)) // .from_err() - .and_then(|ack| { + .and_then(move |ack| { if let Some(completed) = ack { if completed { task.set_status(TaskStatus::TASK_DONE); @@ -129,19 +140,6 @@ impl Scheduler { } } -// fn run_tasks(tasks: Vec) -> impl Future { -// // Normally we would do `.into_iter()` on the task, but it looks like there is a problem -// // with it currently. This issue describes the error we are having: -// // https://github.com/rust-lang/rust/issues/49926 -// let mut task_futures = vec![]; -// for mut task in tasks { -// task_futures.push(self.process_task(task.clone())); -// } -// future::join_all(task_futures).and_then(|_| future::ok(())) -// } - -// fn process_task() - #[derive(Debug, Fail)] pub enum SchedulerError { #[fail(display = "failed to split job into map tasks")] @@ -151,3 +149,61 @@ pub enum SchedulerError { #[fail(display = "error receiving")] RxFailure, } + + +// fn process_job(&job: Job) -> impl Future + 'static { +// // TODO: Refactor this ugly code. This should not be cloned so many times. +// let job1 = job.clone(); +// let job2 = job.clone(); +// let job3 = job.clone(); + +// let store = self.store.clone(); +// let broker = self.broker.clone(); +// lazy(|| done(splitting::map::split(&job1))) +// .and_then(|tasks| run_tasks(tasks, broker, store)) +// .and_then(|_| future::ok(splitting::reduce::split(&job2))) +// .and_then(|tasks| run_tasks(tasks, broker, store)) +// .and_then(|_| { +// // mark job as done + +// store.save_job(&job3); +// future::ok(()) +// }) +// } + +// fn run_tasks(tasks: Vec, broker: Arc, store: Arc) -> impl Future { +// // Normally we would do `.into_iter()` on the task, but it looks like there is a problem +// // with it currently. This issue describes the error we are having: +// // https://github.com/rust-lang/rust/issues/49926 +// let mut task_futures = vec![]; +// for mut task in tasks { +// task_futures.push(process_task(task.clone(), broker, store)); +// } +// future::join_all(task_futures).and_then(|_| future::ok(())) +// } + +// fn process_task(mut task: Task, broker: Arc, store: Arc) -> impl Future + 'static { +// task.set_time_started(Utc::now().timestamp() as u64); +// task.set_status(TaskStatus::TASK_IN_PROGRESS); + +// store.save_task(&task); + +// broker.send(task.clone()) +// // .map_err(|e| e.context(SchedulerError::BrokerSendFailure)) +// // .from_err() +// .and_then(|ack| { +// if let Some(completed) = ack { +// if completed { +// task.set_status(TaskStatus::TASK_DONE); +// } else { +// task.set_status(TaskStatus::TASK_FAILED); +// } +// } else { +// task.set_status(TaskStatus::TASK_UNKNOWN); +// panic!("ack of task failed. this should not happen"); +// } +// task.set_time_done(Utc::now().timestamp() as u64); +// store.save_task(&task); +// future::ok(()) +// }) +// } \ No newline at end of file From fa30955ac6f74e17e05b969cf96c8b1ec7fb4404 Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Mon, 16 Apr 2018 21:54:18 +0100 Subject: [PATCH 28/33] WIP --- manager/src/{scheduler/mod.rs => scheduler.rs} | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) rename manager/src/{scheduler/mod.rs => scheduler.rs} (94%) diff --git a/manager/src/scheduler/mod.rs b/manager/src/scheduler.rs similarity index 94% rename from manager/src/scheduler/mod.rs rename to manager/src/scheduler.rs index 4f8b298..1ecf4e0 100644 --- a/manager/src/scheduler/mod.rs +++ b/manager/src/scheduler.rs @@ -16,7 +16,6 @@ use settings::SETTINGS; /// Manages the entire data pipeline of the manager and links together all of the manager's /// components. -#[derive(Clone)] pub struct Scheduler { broker: Arc, store: Arc, @@ -86,9 +85,9 @@ impl Scheduler { let store = sch.store.clone(); lazy(move || done(splitting::map::split(&job1))) - .and_then(move |tasks| sch.run_tasks(tasks)) + .and_then(move |tasks| sch.clone().run_tasks(tasks)) .and_then(move |_| future::ok(splitting::reduce::split(&job2))) - .and_then(move |tasks| sch.run_tasks(tasks)) + .and_then(move |tasks| sch.clone().run_tasks(tasks)) .and_then(move |_| { // mark job as done @@ -140,6 +139,19 @@ impl Scheduler { } } +impl Copy for Scheduler {} + +impl Clone for Scheduler { + fn clone(&self) -> Scheduler { + Scheduler{ + broker: self.broker.clone(), + store: self.store.clone(), + rx: self.rx.clone(), + tx: self.tx.clone(), + } + } +} + #[derive(Debug, Fail)] pub enum SchedulerError { #[fail(display = "failed to split job into map tasks")] From dfe5663850f73ee1b00c4e00c72e29b8e7f7805d Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Mon, 16 Apr 2018 22:33:10 +0100 Subject: [PATCH 29/33] WIP --- manager/src/scheduler.rs | 19 +++++++++++-------- manager/src/server/jobscheduler.rs | 8 ++++++-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/manager/src/scheduler.rs b/manager/src/scheduler.rs index 1ecf4e0..505b6f3 100644 --- a/manager/src/scheduler.rs +++ b/manager/src/scheduler.rs @@ -61,17 +61,19 @@ impl Scheduler { unimplemented!() } - pub fn run(self) -> impl Future { + pub fn run(self) -> impl Future + 'static{ let sch = self.clone(); + let sch1 = sch.clone(); - sch.rx - .clone() + let rx = sch.rx.clone(); + + rx .lock() .unwrap() .take() .unwrap() .map_err(|_| unreachable!("should never happen")) - .for_each(|job| sch.process_job(job)) + .for_each(|job| sch1.process_job(job)) .map_err(|_| panic!("should not happen")) } @@ -83,11 +85,14 @@ impl Scheduler { let job2 = job.clone(); let job3 = job.clone(); + let sch1 = sch.clone(); + let sch2 = sch.clone(); + let store = sch.store.clone(); lazy(move || done(splitting::map::split(&job1))) - .and_then(move |tasks| sch.clone().run_tasks(tasks)) + .and_then(move |tasks| sch1.run_tasks(tasks)) .and_then(move |_| future::ok(splitting::reduce::split(&job2))) - .and_then(move |tasks| sch.clone().run_tasks(tasks)) + .and_then(move |tasks| sch2.run_tasks(tasks)) .and_then(move |_| { // mark job as done @@ -139,8 +144,6 @@ impl Scheduler { } } -impl Copy for Scheduler {} - impl Clone for Scheduler { fn clone(&self) -> Scheduler { Scheduler{ diff --git a/manager/src/server/jobscheduler.rs b/manager/src/server/jobscheduler.rs index 237e574..c263d05 100644 --- a/manager/src/server/jobscheduler.rs +++ b/manager/src/server/jobscheduler.rs @@ -23,7 +23,9 @@ impl grpc_pb::JobScheduleService for JobScheduleService { _: RequestOptions, req: pb::ScheduleRequest, ) -> SingleResponse { - match self.scheduler.schedule(req.get_job().clone()) { + let scheduler = self.scheduler.clone(); + + match scheduler.schedule(req.get_job().clone()) { Ok(job_id) => { let mut res = pb::ScheduleResponse::new(); res.set_job_id(job_id); @@ -41,7 +43,9 @@ impl grpc_pb::JobScheduleService for JobScheduleService { _: RequestOptions, req: pb::CancelRequest, ) -> SingleResponse { - match self.scheduler.cancel(req.get_job_id()) { + let scheduler = self.scheduler.clone(); + + match scheduler.cancel(req.get_job_id()) { Ok(_) => { return SingleResponse::completed(pb::EmptyMessage::new()); } From d003f10df88898a87084c035b39b7fc8302c1962 Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Mon, 16 Apr 2018 23:24:28 +0100 Subject: [PATCH 30/33] WIP --- manager/src/broker/amqp.rs | 12 +- manager/src/optparse.rs | 4 +- manager/src/scheduler.rs | 291 +++++++++++++++++++------------------ manager/src/settings.rs | 37 +++-- 4 files changed, 182 insertions(+), 162 deletions(-) diff --git a/manager/src/broker/amqp.rs b/manager/src/broker/amqp.rs index 2228f48..02886b7 100644 --- a/manager/src/broker/amqp.rs +++ b/manager/src/broker/amqp.rs @@ -13,7 +13,6 @@ use settings::SETTINGS; pub struct AMQPBrokerConnection { channel: Arc>, - queue_name: String, } impl BrokerConnection for AMQPBrokerConnection { @@ -24,7 +23,7 @@ impl BrokerConnection for AMQPBrokerConnection { fn send(&self, task: Task) -> Box, Error = Error> + Send + 'static> { let task_id = task.get_id().to_string(); let ch = self.channel.clone(); - let queue_name = &self.queue_name.clone(); + let queue_name: &str = SETTINGS.read().unwrap().get("broker.queue_name").unwrap(); let ret = future::lazy(move || future::done(task.write_to_bytes())) .map_err(|e| e.context(BrokerError::TaskSerialisationFailure { task_id })) @@ -32,7 +31,7 @@ impl BrokerConnection for AMQPBrokerConnection { .and_then(move |bytes| { ch.basic_publish( "", - queue_name, + &queue_name, &bytes, &BasicPublishOptions::default(), BasicProperties::default(), @@ -43,7 +42,7 @@ impl BrokerConnection for AMQPBrokerConnection { } pub fn connect(addr: SocketAddr) -> impl Future { - let queue_name = SETTINGS.read().unwrap().get("broker_queue_name").unwrap(); + let queue_name: &str = SETTINGS.read().unwrap().get("broker.queue_name").unwrap(); let queue_options = QueueDeclareOptions { durable: true, ..Default::default() @@ -54,9 +53,9 @@ pub fn connect(addr: SocketAddr) -> impl Future impl Future() -> ArgMatches<'a> { .author("Heracles Authors ") .about("Scheduling service for the Heracles network.") .arg( - Arg::with_name("input_chunk_size") + Arg::with_name("scheduler.input_chunk_size") .help("The size (in MiB) of the chunks created from the input files.") .long("input-chunk-size") .long_help( @@ -36,7 +36,7 @@ Each chunk corresponds to one map task, so this can be used to scale the job.", .takes_value(true), ) .arg( - Arg::with_name("server_port") + Arg::with_name("server.port") .help("Port on which the gRPC server is running") .long("server-port") .takes_value(true), diff --git a/manager/src/scheduler.rs b/manager/src/scheduler.rs index 505b6f3..c0c71f1 100644 --- a/manager/src/scheduler.rs +++ b/manager/src/scheduler.rs @@ -16,6 +16,7 @@ use settings::SETTINGS; /// Manages the entire data pipeline of the manager and links together all of the manager's /// components. +#[derive(Clone)] pub struct Scheduler { broker: Arc, store: Arc, @@ -39,7 +40,7 @@ impl Scheduler { }) } - pub fn schedule(self, req: Job) -> Result { + pub fn schedule<'a>(&'a self, req: Job) -> Result { let sch = self.clone(); let mut job = req.clone(); @@ -57,102 +58,101 @@ impl Scheduler { Ok(id) } - pub fn cancel(self, _job_id: &str) -> Result<(), SchedulerError> { + pub fn cancel<'a>(&'a self, _job_id: &str) -> Result<(), SchedulerError> { unimplemented!() } - pub fn run(self) -> impl Future + 'static{ - let sch = self.clone(); - let sch1 = sch.clone(); - - let rx = sch.rx.clone(); - - rx - .lock() - .unwrap() - .take() - .unwrap() - .map_err(|_| unreachable!("should never happen")) - .for_each(|job| sch1.process_job(job)) - .map_err(|_| panic!("should not happen")) - } + // pub fn run(self) -> impl Future + 'static{ + // let sch = self.clone(); + // let sch1 = sch.clone(); - fn process_job(self, job: Job) -> impl Future + 'static { - let sch = self.clone(); + // let rx = sch.rx.clone(); - // TODO: Refactor this ugly code. This should not be cloned so many times. - let job1 = job.clone(); - let job2 = job.clone(); - let job3 = job.clone(); - - let sch1 = sch.clone(); - let sch2 = sch.clone(); - - let store = sch.store.clone(); - lazy(move || done(splitting::map::split(&job1))) - .and_then(move |tasks| sch1.run_tasks(tasks)) - .and_then(move |_| future::ok(splitting::reduce::split(&job2))) - .and_then(move |tasks| sch2.run_tasks(tasks)) - .and_then(move |_| { - // mark job as done - - store.save_job(&job3); - future::ok(()) - }) - } + // rx + // .lock() + // .unwrap() + // .take() + // .unwrap() + // .map_err(|_| unreachable!("should never happen")) + // .for_each(|job| sch1.process_job(job)) + // .map_err(|_| panic!("should not happen")) + // } - fn run_tasks(self, tasks: Vec) -> impl Future + 'static { + pub fn run(&self) -> impl Future + 'static { let sch = self.clone(); - // Normally we would do `.into_iter()` on the task, but it looks like there is a problem - // with it currently. This issue describes the error we are having: - // https://github.com/rust-lang/rust/issues/49926 - let mut task_futures = vec![]; - for mut task in tasks { - task_futures.push(sch.process_task(task.clone())); - } - future::join_all(task_futures).and_then(|_| future::ok(())) + // let rx = sch.rx.clone().to_owned(); + self.rx.lock().unwrap().take().unwrap() + .map_err(|_| unreachable!("should never happen")) + .for_each(move |job| process_job(job, sch.clone().broker.clone(), sch.clone().store.clone())) + .map_err(|_| panic!("should not happen")) } - fn process_task(&self, mut task: Task) -> impl Future + 'static { - let sch = self.clone(); - - task.set_time_started(Utc::now().timestamp() as u64); - task.set_status(TaskStatus::TASK_IN_PROGRESS); - - let store = sch.store.clone(); - store.save_task(&task); - - sch.broker.send(task.clone()) - // .map_err(|e| e.context(SchedulerError::BrokerSendFailure)) - // .from_err() - .and_then(move |ack| { - if let Some(completed) = ack { - if completed { - task.set_status(TaskStatus::TASK_DONE); - } else { - task.set_status(TaskStatus::TASK_FAILED); - } - } else { - task.set_status(TaskStatus::TASK_UNKNOWN); - panic!("ack of task failed. this should not happen"); - } - task.set_time_done(Utc::now().timestamp() as u64); - store.save_task(&task); - future::ok(()) - }) - } -} - -impl Clone for Scheduler { - fn clone(&self) -> Scheduler { - Scheduler{ - broker: self.broker.clone(), - store: self.store.clone(), - rx: self.rx.clone(), - tx: self.tx.clone(), - } - } + // fn process_job(self, job: Job) -> impl Future + 'static { + // let sch = self.clone(); + + // // TODO: Refactor this ugly code. This should not be cloned so many times. + // let job1 = job.clone(); + // let job2 = job.clone(); + // let job3 = job.clone(); + + // let sch1 = sch.clone(); + // let sch2 = sch.clone(); + + // let store = sch.store.clone(); + // lazy(move || done(splitting::map::split(&job1))) + // .and_then(move |tasks| sch1.run_tasks(tasks)) + // .and_then(move |_| future::ok(splitting::reduce::split(&job2))) + // .and_then(move |tasks| sch2.run_tasks(tasks)) + // .and_then(move |_| { + // // mark job as done + + // store.save_job(&job3); + // future::ok(()) + // }) + // } + + // fn run_tasks(self, tasks: Vec) -> impl Future + 'static { + // let sch = self.clone(); + + // // Normally we would do `.into_iter()` on the task, but it looks like there is a problem + // // with it currently. This issue describes the error we are having: + // // https://github.com/rust-lang/rust/issues/49926 + // let mut task_futures = vec![]; + // for mut task in tasks { + // task_futures.push(sch.process_task(task.clone())); + // } + // future::join_all(task_futures).and_then(|_| future::ok(())) + // } + + // fn process_task(&self, mut task: Task) -> impl Future + 'static { + // let sch = self.clone(); + + // task.set_time_started(Utc::now().timestamp() as u64); + // task.set_status(TaskStatus::TASK_IN_PROGRESS); + + // let store = sch.store.clone(); + // store.save_task(&task); + + // sch.broker.send(task.clone()) + // // .map_err(|e| e.context(SchedulerError::BrokerSendFailure)) + // // .from_err() + // .and_then(move |ack| { + // if let Some(completed) = ack { + // if completed { + // task.set_status(TaskStatus::TASK_DONE); + // } else { + // task.set_status(TaskStatus::TASK_FAILED); + // } + // } else { + // task.set_status(TaskStatus::TASK_UNKNOWN); + // panic!("ack of task failed. this should not happen"); + // } + // task.set_time_done(Utc::now().timestamp() as u64); + // store.save_task(&task); + // future::ok(()) + // }) + // } } #[derive(Debug, Fail)] @@ -166,59 +166,64 @@ pub enum SchedulerError { } -// fn process_job(&job: Job) -> impl Future + 'static { -// // TODO: Refactor this ugly code. This should not be cloned so many times. -// let job1 = job.clone(); -// let job2 = job.clone(); -// let job3 = job.clone(); - -// let store = self.store.clone(); -// let broker = self.broker.clone(); -// lazy(|| done(splitting::map::split(&job1))) -// .and_then(|tasks| run_tasks(tasks, broker, store)) -// .and_then(|_| future::ok(splitting::reduce::split(&job2))) -// .and_then(|tasks| run_tasks(tasks, broker, store)) -// .and_then(|_| { -// // mark job as done - -// store.save_job(&job3); -// future::ok(()) -// }) -// } - -// fn run_tasks(tasks: Vec, broker: Arc, store: Arc) -> impl Future { -// // Normally we would do `.into_iter()` on the task, but it looks like there is a problem -// // with it currently. This issue describes the error we are having: -// // https://github.com/rust-lang/rust/issues/49926 -// let mut task_futures = vec![]; -// for mut task in tasks { -// task_futures.push(process_task(task.clone(), broker, store)); -// } -// future::join_all(task_futures).and_then(|_| future::ok(())) -// } - -// fn process_task(mut task: Task, broker: Arc, store: Arc) -> impl Future + 'static { -// task.set_time_started(Utc::now().timestamp() as u64); -// task.set_status(TaskStatus::TASK_IN_PROGRESS); - -// store.save_task(&task); - -// broker.send(task.clone()) -// // .map_err(|e| e.context(SchedulerError::BrokerSendFailure)) -// // .from_err() -// .and_then(|ack| { -// if let Some(completed) = ack { -// if completed { -// task.set_status(TaskStatus::TASK_DONE); -// } else { -// task.set_status(TaskStatus::TASK_FAILED); -// } -// } else { -// task.set_status(TaskStatus::TASK_UNKNOWN); -// panic!("ack of task failed. this should not happen"); -// } -// task.set_time_done(Utc::now().timestamp() as u64); -// store.save_task(&task); -// future::ok(()) -// }) -// } \ No newline at end of file +fn process_job(job: Job, broker: Arc, store: Arc) -> impl Future + 'static { + // TODO: Refactor this ugly code. This should not be cloned so many times. + let job1 = job.clone(); + let job2 = job.clone(); + let job3 = job.clone(); + + let broker1 = broker.clone(); + let broker2 = broker.clone(); + + let store1 = store.clone(); + let store2 = store.clone(); + let store3 = store.clone(); + + lazy(move || done(splitting::map::split(&job1))) + .and_then(move |tasks| run_tasks(tasks, broker1.clone(), store1.clone())) + .and_then(move |_| future::ok(splitting::reduce::split(&job2))) + .and_then(move |tasks| run_tasks(tasks, broker2.clone(), store2.clone())) + .and_then(move |_| { + // mark job as done + + store3.clone().save_job(&job3); + future::ok(()) + }) + } + +fn run_tasks(tasks: Vec, broker: Arc, store: Arc) -> impl Future { + // Normally we would do `.into_iter()` on the task, but it looks like there is a problem + // with it currently. This issue describes the error we are having: + // https://github.com/rust-lang/rust/issues/49926 + let mut task_futures = vec![]; + for mut task in tasks { + task_futures.push(process_task(task.clone(), broker.clone(), store.clone())); + } + future::join_all(task_futures).and_then(|_| future::ok(())) +} + +fn process_task(mut task: Task, broker: Arc, store: Arc) -> impl Future + 'static { + task.set_time_started(Utc::now().timestamp() as u64); + task.set_status(TaskStatus::TASK_IN_PROGRESS); + + store.save_task(&task); + + broker.send(task.clone()) + // .map_err(|e| e.context(SchedulerError::BrokerSendFailure)) + // .from_err() + .and_then(move |ack| { + if let Some(completed) = ack { + if completed { + task.set_status(TaskStatus::TASK_DONE); + } else { + task.set_status(TaskStatus::TASK_FAILED); + } + } else { + task.set_status(TaskStatus::TASK_UNKNOWN); + panic!("ack of task failed. this should not happen"); + } + task.set_time_done(Utc::now().timestamp() as u64); + store.save_task(&task); + future::ok(()) + }) +} \ No newline at end of file diff --git a/manager/src/settings.rs b/manager/src/settings.rs index 11d06f5..33432ba 100644 --- a/manager/src/settings.rs +++ b/manager/src/settings.rs @@ -10,6 +10,23 @@ use config; use config::Config; use failure::*; +// #[derive(Debug, Deserialize)] +// struct Scheduler { +// input_chunk_size: i64, +// input_queue_size: i64, +// } + +// #[derive(Debug, Deserialize)] +// struct Server { +// port: i64, +// } + +// #[derive(Debug, Deserialize)] +// struct Broker { +// address: String, +// queue_name: String, +// } + lazy_static! { pub static ref SETTINGS: RwLock = RwLock::new(Config::default()); } @@ -28,24 +45,24 @@ pub fn init<'a>(opts: &ArgMatches<'a>) -> Result<(), Error> { // priority. set_options(&mut settings, opts)?; - debug!( - "{:?}", - settings - .clone() - .try_into::>() - .unwrap() - ); + // debug!( + // "{:?}", + // settings + // .clone() + // .try_into::>() + // .unwrap() + // ); Ok(()) } /// Read through the command line arguments and assign settings from there. fn set_options<'a>(settings: &mut Config, opts: &ArgMatches<'a>) -> Result<(), Error> { - if let Some(value) = opts.value_of("input_chunk_size") { + if let Some(value) = opts.value_of("scheduler.input_chunk_size") { let v = value .parse::() .context(SettingsErrorKind::OptionParseFailed)?; - settings.set("input_chunk_size", v)?; + settings.set("scheduler.input_chunk_size", v)?; } if let Some(value) = opts.value_of("broker.address") { settings.set("broker.address", value)?; @@ -70,7 +87,7 @@ fn set_options<'a>(settings: &mut Config, opts: &ArgMatches<'a>) -> Result<(), E fn set_defaults(settings: &mut Config) -> Result<(), Error> { settings.set_default("broker.queue_name", "heracles_tasks")?; - settings.set_default("input_chunk_size", 67_108_864_i64)?; // 64 MiB + settings.set_default("scheduler.input_chunk_size", 67_108_864_i64)?; // 64 MiB settings.set_default("scheduler.input_queue_size", 4)?; settings.set_default("server.port", 8081)?; settings.set_default("server.thread_pool_size", 8)?; From 095e24c7143c2513e04445da6e879ea5fd77227d Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Tue, 17 Apr 2018 13:47:09 +0100 Subject: [PATCH 31/33] WIP --- hrctl/app/parser.go | 2 +- manager/src/broker/amqp.rs | 10 +++++----- manager/src/main.rs | 13 ++++++++++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/hrctl/app/parser.go b/hrctl/app/parser.go index 5736975..a5dc7a3 100644 --- a/hrctl/app/parser.go +++ b/hrctl/app/parser.go @@ -101,7 +101,7 @@ func schedule(c *cli.Context) error { return errors.Wrap(err, "unable to get job from file") } - conn, err := connect(c.String("manager")) + conn, err := connect(c.GlobalString("manager")) if err != nil { return errors.Wrap(err, "unable to connect to manager") } diff --git a/manager/src/broker/amqp.rs b/manager/src/broker/amqp.rs index 02886b7..135332f 100644 --- a/manager/src/broker/amqp.rs +++ b/manager/src/broker/amqp.rs @@ -23,7 +23,7 @@ impl BrokerConnection for AMQPBrokerConnection { fn send(&self, task: Task) -> Box, Error = Error> + Send + 'static> { let task_id = task.get_id().to_string(); let ch = self.channel.clone(); - let queue_name: &str = SETTINGS.read().unwrap().get("broker.queue_name").unwrap(); + let queue_name: String = SETTINGS.read().unwrap().get("broker.queue_name").unwrap(); let ret = future::lazy(move || future::done(task.write_to_bytes())) .map_err(|e| e.context(BrokerError::TaskSerialisationFailure { task_id })) @@ -31,7 +31,7 @@ impl BrokerConnection for AMQPBrokerConnection { .and_then(move |bytes| { ch.basic_publish( "", - &queue_name, + &queue_name.as_str(), &bytes, &BasicPublishOptions::default(), BasicProperties::default(), @@ -42,7 +42,7 @@ impl BrokerConnection for AMQPBrokerConnection { } pub fn connect(addr: SocketAddr) -> impl Future { - let queue_name: &str = SETTINGS.read().unwrap().get("broker.queue_name").unwrap(); + let queue_name: String = SETTINGS.read().unwrap().get("broker.queue_name").unwrap(); let queue_options = QueueDeclareOptions { durable: true, ..Default::default() @@ -53,9 +53,9 @@ pub fn connect(addr: SocketAddr) -> impl Future Result<(), Error> { let broker_addr = SETTINGS.read().unwrap().get("broker.address")?; let broker_conn = Arc::new(broker::amqp::connect(broker_addr).wait()?); - let state_location: &str = SETTINGS.read().unwrap().get("state.location")?; - let store = Arc::new(state::FileStore::new(&PathBuf::from(state_location.to_string()))?); + let state_location: String = SETTINGS.read().unwrap().get("state.location")?; + let store = Arc::new(state::FileStore::new(&PathBuf::from(state_location))?); let schdlr = Arc::new(scheduler::Scheduler::new(broker_conn, store)?); - server::Server::new(schdlr.clone())?; + let srv = server::Server::new(schdlr.clone())?; + + thread::spawn(move || { + loop { + srv.is_alive(); + } + }); info!("Starting main event loop."); // We give this an empty future so that it will never terminate and continue driving other From 37044bdcb4762a22e4d299517e25bdf94a72e32e Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Tue, 17 Apr 2018 14:36:58 +0100 Subject: [PATCH 32/33] Working until the broker --- manager/src/scheduler.rs | 128 ++++++------------------------ manager/src/splitting/map/text.rs | 2 +- 2 files changed, 25 insertions(+), 105 deletions(-) diff --git a/manager/src/scheduler.rs b/manager/src/scheduler.rs index c0c71f1..c1bb558 100644 --- a/manager/src/scheduler.rs +++ b/manager/src/scheduler.rs @@ -40,7 +40,7 @@ impl Scheduler { }) } - pub fn schedule<'a>(&'a self, req: Job) -> Result { + pub fn schedule<'a>(&'a self, req: Job) -> Result { let sch = self.clone(); let mut job = req.clone(); @@ -49,35 +49,19 @@ impl Scheduler { job.set_id(id.clone()); // TODO: Scheduling time - sch.store.save_job(&job.clone()).unwrap(); + sch.store.save_job(&job.clone())?; - // self.tx.borrow_mut().take().unwrap().send(job.clone()); + sch.tx.lock().unwrap().take().unwrap().send(job.clone()).wait()?; - sch.tx.lock().unwrap().take().unwrap().clone().send(job.clone()); + info!("have send the job to be executed. Returning the ID"); Ok(id) } - pub fn cancel<'a>(&'a self, _job_id: &str) -> Result<(), SchedulerError> { + pub fn cancel<'a>(&'a self, _job_id: &str) -> Result<(), Error> { unimplemented!() } - // pub fn run(self) -> impl Future + 'static{ - // let sch = self.clone(); - // let sch1 = sch.clone(); - - // let rx = sch.rx.clone(); - - // rx - // .lock() - // .unwrap() - // .take() - // .unwrap() - // .map_err(|_| unreachable!("should never happen")) - // .for_each(|job| sch1.process_job(job)) - // .map_err(|_| panic!("should not happen")) - // } - pub fn run(&self) -> impl Future + 'static { let sch = self.clone(); @@ -85,87 +69,10 @@ impl Scheduler { self.rx.lock().unwrap().take().unwrap() .map_err(|_| unreachable!("should never happen")) .for_each(move |job| process_job(job, sch.clone().broker.clone(), sch.clone().store.clone())) - .map_err(|_| panic!("should not happen")) + .map_err(|e| error!("{}", e)) } - - // fn process_job(self, job: Job) -> impl Future + 'static { - // let sch = self.clone(); - - // // TODO: Refactor this ugly code. This should not be cloned so many times. - // let job1 = job.clone(); - // let job2 = job.clone(); - // let job3 = job.clone(); - - // let sch1 = sch.clone(); - // let sch2 = sch.clone(); - - // let store = sch.store.clone(); - // lazy(move || done(splitting::map::split(&job1))) - // .and_then(move |tasks| sch1.run_tasks(tasks)) - // .and_then(move |_| future::ok(splitting::reduce::split(&job2))) - // .and_then(move |tasks| sch2.run_tasks(tasks)) - // .and_then(move |_| { - // // mark job as done - - // store.save_job(&job3); - // future::ok(()) - // }) - // } - - // fn run_tasks(self, tasks: Vec) -> impl Future + 'static { - // let sch = self.clone(); - - // // Normally we would do `.into_iter()` on the task, but it looks like there is a problem - // // with it currently. This issue describes the error we are having: - // // https://github.com/rust-lang/rust/issues/49926 - // let mut task_futures = vec![]; - // for mut task in tasks { - // task_futures.push(sch.process_task(task.clone())); - // } - // future::join_all(task_futures).and_then(|_| future::ok(())) - // } - - // fn process_task(&self, mut task: Task) -> impl Future + 'static { - // let sch = self.clone(); - - // task.set_time_started(Utc::now().timestamp() as u64); - // task.set_status(TaskStatus::TASK_IN_PROGRESS); - - // let store = sch.store.clone(); - // store.save_task(&task); - - // sch.broker.send(task.clone()) - // // .map_err(|e| e.context(SchedulerError::BrokerSendFailure)) - // // .from_err() - // .and_then(move |ack| { - // if let Some(completed) = ack { - // if completed { - // task.set_status(TaskStatus::TASK_DONE); - // } else { - // task.set_status(TaskStatus::TASK_FAILED); - // } - // } else { - // task.set_status(TaskStatus::TASK_UNKNOWN); - // panic!("ack of task failed. this should not happen"); - // } - // task.set_time_done(Utc::now().timestamp() as u64); - // store.save_task(&task); - // future::ok(()) - // }) - // } -} - -#[derive(Debug, Fail)] -pub enum SchedulerError { - #[fail(display = "failed to split job into map tasks")] - MapSplitFailure, - #[fail(display = "failed to send task to broker")] - BrokerSendFailure, - #[fail(display = "error receiving")] - RxFailure, } - fn process_job(job: Job, broker: Arc, store: Arc) -> impl Future + 'static { // TODO: Refactor this ugly code. This should not be cloned so many times. let job1 = job.clone(); @@ -179,14 +86,15 @@ fn process_job(job: Job, broker: Arc, store: Arc) -> im let store2 = store.clone(); let store3 = store.clone(); + info!("Begining the job processing pipeline"); + lazy(move || done(splitting::map::split(&job1))) .and_then(move |tasks| run_tasks(tasks, broker1.clone(), store1.clone())) .and_then(move |_| future::ok(splitting::reduce::split(&job2))) .and_then(move |tasks| run_tasks(tasks, broker2.clone(), store2.clone())) .and_then(move |_| { // mark job as done - - store3.clone().save_job(&job3); + store3.clone().save_job(&job3).unwrap(); future::ok(()) }) } @@ -206,7 +114,9 @@ fn process_task(mut task: Task, broker: Arc, store: Arc task.set_time_started(Utc::now().timestamp() as u64); task.set_status(TaskStatus::TASK_IN_PROGRESS); - store.save_task(&task); + store.save_task(&task).unwrap(); + + info!("Sending task to broker"); broker.send(task.clone()) // .map_err(|e| e.context(SchedulerError::BrokerSendFailure)) @@ -223,7 +133,17 @@ fn process_task(mut task: Task, broker: Arc, store: Arc panic!("ack of task failed. this should not happen"); } task.set_time_done(Utc::now().timestamp() as u64); - store.save_task(&task); + store.save_task(&task).unwrap(); future::ok(()) }) -} \ No newline at end of file +} + +#[derive(Debug, Fail, Copy, Clone)] +pub enum SchedulerError { + #[fail(display = "failed to split job into map tasks")] + MapSplitFailure, + #[fail(display = "failed to send task to broker")] + BrokerSendFailure, + #[fail(display = "error receiving")] + RxFailure, +} diff --git a/manager/src/splitting/map/text.rs b/manager/src/splitting/map/text.rs index db4b54a..77e46bf 100644 --- a/manager/src/splitting/map/text.rs +++ b/manager/src/splitting/map/text.rs @@ -56,7 +56,7 @@ impl LineSplitter { let reader = BufReader::new(f); let mut amount_read_this_chunk: u64 = 0; let mut chunk_start_index: u64 = 0; - let task_input_size: u64 = SETTINGS.read().unwrap().get("task_input_size")?; + let task_input_size: u64 = SETTINGS.read().unwrap().get("scheduler.input_chunk_size")?; for line in reader.lines() { let line = line.context(SplitterErrorKind::FileReadFailed)?; From 2b82a231f8c36f9f7f8dfdc1b3e6053592cc6c92 Mon Sep 17 00:00:00 2001 From: Wojtek Bednarzak Date: Tue, 17 Apr 2018 19:20:05 +0100 Subject: [PATCH 33/33] Bad attempt at broker connection running --- manager/src/broker/amqp.rs | 65 ++++++++++++++++++++++++++++++++------ manager/src/main.rs | 8 +++-- manager/src/scheduler.rs | 19 ++++++++--- 3 files changed, 75 insertions(+), 17 deletions(-) diff --git a/manager/src/broker/amqp.rs b/manager/src/broker/amqp.rs index 135332f..b0476fc 100644 --- a/manager/src/broker/amqp.rs +++ b/manager/src/broker/amqp.rs @@ -1,5 +1,6 @@ use std::net::SocketAddr; use std::sync::Arc; +use std::thread; use lapin::channel::{BasicProperties, BasicPublishOptions, Channel, QueueDeclareOptions}; use lapin::client::{Client, ConnectionOptions}; @@ -7,6 +8,7 @@ use lapin::types::FieldTable; use protobuf::Message; use tokio::net::TcpStream; use tokio::prelude::*; +use tokio; use super::*; use settings::SETTINGS; @@ -29,6 +31,8 @@ impl BrokerConnection for AMQPBrokerConnection { .map_err(|e| e.context(BrokerError::TaskSerialisationFailure { task_id })) .from_err() .and_then(move |bytes| { + info!("publishing task"); + ch.basic_publish( "", &queue_name.as_str(), @@ -41,28 +45,69 @@ impl BrokerConnection for AMQPBrokerConnection { } } -pub fn connect(addr: SocketAddr) -> impl Future { +// pub fn connect(addr: SocketAddr) -> Result { +// let queue_name: String = SETTINGS.read().unwrap().get("broker.queue_name").unwrap(); +// let queue_options = QueueDeclareOptions { +// durable: true, +// ..Default::default() +// }; + +// tokio::run(TcpStream::connect(&addr) +// .and_then(|stream| Client::connect(stream, &ConnectionOptions::default())) +// .and_then(|(client, _)| client.create_channel()) +// .and_then(move |channel| { +// channel +// .queue_declare(&queue_name.as_str(), &queue_options, &FieldTable::new()) +// .and_then(move |_| { +// info!("AMQP queue `{}` successfully declared.", queue_name); +// future::ok(channel) +// }) +// }) +// .map_err(|e| e.context(BrokerError::ConnectionFailed).into()) +// .and_then(move |channel| { +// AMQPBrokerConnection { +// channel: Arc::new(channel), +// } +// })) +// } + + +pub fn connect(addr: SocketAddr) -> Result { let queue_name: String = SETTINGS.read().unwrap().get("broker.queue_name").unwrap(); let queue_options = QueueDeclareOptions { durable: true, ..Default::default() }; - TcpStream::connect(&addr) + // I assume this can't actually be here. + // let mut bc = AMQPBrokerConnection{ + // channel: Arc::new(), + // }; + + let broker_conn = TcpStream::connect(&addr) .and_then(|stream| Client::connect(stream, &ConnectionOptions::default())) .and_then(|(client, _)| client.create_channel()) .and_then(move |channel| { channel .queue_declare(&queue_name.as_str(), &queue_options, &FieldTable::new()) .and_then(move |_| { - info!("AMQP queue `{}` successfully declared.", queue_name); future::ok(channel) }) }) - .map_err(|e| e.context(BrokerError::ConnectionFailed).into()) - .and_then(move |channel| { - future::ok(AMQPBrokerConnection { - channel: Arc::new(channel), - }) - }) -} + // .map_err(|e| e.context(BrokerError::ConnectionFailed).into()) + .map_err(|e| error!("{}", e)) + .and_then(|channel| { + // Add the channel to the broker connection + // bc.channel = Arc::new(channel); + future::ok(()) + }); + + // This is definatelly bad, but we can't just do run because it will block + thread::spawn(move || { + tokio::run(broker_conn); + }); + + Ok(AMQPBrokerConnection{ + channel: Arc::new(broker_conn), + }) +} \ No newline at end of file diff --git a/manager/src/main.rs b/manager/src/main.rs index 0c7f2ee..fcfdb22 100644 --- a/manager/src/main.rs +++ b/manager/src/main.rs @@ -32,7 +32,7 @@ fn run() -> Result<(), Error> { settings::init(&arg_matches)?; let broker_addr = SETTINGS.read().unwrap().get("broker.address")?; - let broker_conn = Arc::new(broker::amqp::connect(broker_addr).wait()?); + let broker_conn = Arc::new(broker::amqp::connect(broker_addr)?); let state_location: String = SETTINGS.read().unwrap().get("state.location")?; let store = Arc::new(state::FileStore::new(&PathBuf::from(state_location))?); @@ -47,11 +47,15 @@ fn run() -> Result<(), Error> { } }); + // thread::spawn(move || { + // tokio::spawn(broker_conn.channel.clone()); + // }); + info!("Starting main event loop."); // We give this an empty future so that it will never terminate and continue driving other // futures to completion. tokio::run(schdlr.run()); - // tokio::run(future::empty()); + // tokio::run(schdl.run(broker_conn)) Ok(()) } diff --git a/manager/src/scheduler.rs b/manager/src/scheduler.rs index c1bb558..7f5122a 100644 --- a/manager/src/scheduler.rs +++ b/manager/src/scheduler.rs @@ -7,6 +7,7 @@ use failure::*; use futures::*; use futures::sync::mpsc; use uuid::Uuid; +use futures::Future; use heracles_proto::datatypes::*; use splitting; @@ -18,6 +19,7 @@ use settings::SETTINGS; /// components. #[derive(Clone)] pub struct Scheduler { + // broker: Arc, broker: Arc, store: Arc, rx: Arc>>>, @@ -30,6 +32,9 @@ impl Scheduler { /// Takes a handle to a [`heracles_manager_lib::broker::Broker`] which it uses to send /// [`Task`]s to workers for execution. pub fn new(broker: Arc, store: Arc) -> Result { + // pub fn new(broker: &mut B, store: Arc) -> Result + // where B: IntoFuture + // { let (tx, rx) = mpsc::channel::(SETTINGS.read().unwrap().get("scheduler.input_queue_size")?); Ok(Scheduler { @@ -62,14 +67,18 @@ impl Scheduler { unimplemented!() } + // pub fn run(&self, broker: B) -> impl Future + 'static + // where B: IntoFuture + // { pub fn run(&self) -> impl Future + 'static { let sch = self.clone(); - // let rx = sch.rx.clone().to_owned(); - self.rx.lock().unwrap().take().unwrap() - .map_err(|_| unreachable!("should never happen")) - .for_each(move |job| process_job(job, sch.clone().broker.clone(), sch.clone().store.clone())) - .map_err(|e| error!("{}", e)) + // broker.and_then(|bc| { + self.rx.lock().unwrap().take().unwrap() + .map_err(|_| unreachable!("should never happen")) + .for_each(move |job| process_job(job, sch.clone().broker.clone(), sch.clone().store.clone())) + .map_err(|e| error!("{}", e)) + // }) } }