-
Notifications
You must be signed in to change notification settings - Fork 995
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core,node,server: use common fn for graphman cli & server for unassig…
…n and reassign
- Loading branch information
1 parent
d0d7d5c
commit 38ceded
Showing
8 changed files
with
136 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
pub mod info; | ||
pub mod pause; | ||
pub mod reassign; | ||
pub mod restart; | ||
pub mod resume; | ||
pub mod unassign; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use std::sync::Arc; | ||
|
||
use anyhow::Result; | ||
use graph::prelude::NodeId; | ||
use graph_store_postgres::connection_pool::ConnectionPool; | ||
use graph_store_postgres::NotificationSender; | ||
use graphman::commands::deployment::reassign::{ | ||
load_deployment, reassign_deployment, ReassignResult, | ||
}; | ||
use graphman::deployment::DeploymentSelector; | ||
|
||
pub fn run( | ||
primary_pool: ConnectionPool, | ||
notification_sender: Arc<NotificationSender>, | ||
deployment: DeploymentSelector, | ||
node: &NodeId, | ||
) -> Result<()> { | ||
let deployment = load_deployment(primary_pool.clone(), &deployment)?; | ||
|
||
println!("Reassigning deployment {}", deployment.locator()); | ||
|
||
let reassign_result = | ||
reassign_deployment(primary_pool, notification_sender, &deployment, node)?; | ||
|
||
match reassign_result { | ||
ReassignResult::EmptyResponse => { | ||
println!( | ||
"Deployment {} assigned to node {}", | ||
deployment.locator(), | ||
node | ||
); | ||
} | ||
ReassignResult::CompletedWithWarnings(warnings) => { | ||
for msg in warnings { | ||
println!("{}", msg); | ||
} | ||
} | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use std::sync::Arc; | ||
|
||
use anyhow::Result; | ||
use graph_store_postgres::connection_pool::ConnectionPool; | ||
use graph_store_postgres::NotificationSender; | ||
use graphman::commands::deployment::unassign::load_assigned_deployment; | ||
use graphman::commands::deployment::unassign::unassign_deployment; | ||
use graphman::deployment::DeploymentSelector; | ||
|
||
pub fn run( | ||
primary_pool: ConnectionPool, | ||
notification_sender: Arc<NotificationSender>, | ||
deployment: DeploymentSelector, | ||
) -> Result<()> { | ||
let assigned_deployment = load_assigned_deployment(primary_pool.clone(), &deployment)?; | ||
|
||
println!("Unassigning deployment {}", assigned_deployment.locator()); | ||
|
||
unassign_deployment(primary_pool, notification_sender, assigned_deployment)?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 10 additions & 5 deletions
15
server/graphman/src/resolvers/deployment_mutation/reassign.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
use anyhow::Ok; | ||
use async_graphql::Result; | ||
use graph::prelude::NodeId; | ||
use graphman::commands::deployment::reassign::load_deployment; | ||
use graphman::commands::deployment::reassign::reassign_deployment; | ||
use graphman::commands::deployment::reassign::ReassignResult; | ||
use graphman::deployment::DeploymentSelector; | ||
|
||
use crate::resolvers::context::GraphmanContext; | ||
|
||
pub fn run(ctx: &GraphmanContext, deployment: &DeploymentSelector, node: &NodeId) -> Result<()> { | ||
pub fn run( | ||
ctx: &GraphmanContext, | ||
deployment: &DeploymentSelector, | ||
node: &NodeId, | ||
) -> Result<ReassignResult, anyhow::Error> { | ||
let deployment = load_deployment(ctx.primary_pool.clone(), deployment)?; | ||
reassign_deployment( | ||
let reassign_result = reassign_deployment( | ||
ctx.primary_pool.clone(), | ||
ctx.notification_sender.clone(), | ||
deployment, | ||
&deployment, | ||
&node, | ||
)?; | ||
|
||
Ok(()) | ||
Ok(reassign_result) | ||
} |