Skip to content

Commit

Permalink
NodeService: updated intermediate status reporting to send full Actio…
Browse files Browse the repository at this point in the history
…nItem (issue #1)
  • Loading branch information
steveshortt committed Jan 29, 2017
1 parent 56622e6 commit 7b86046
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
14 changes: 7 additions & 7 deletions Synapse.NodeService.HttpClient/NodeServiceHttpApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public async Task<string> WhoAmIAsync()
}


public ExecuteResult StartPlanFile(int planInstanceId, bool dryRun, string filePath)
public ExecuteResult StartPlanFile(long planInstanceId, bool dryRun, string filePath)
{
return StartPlanAsync( planInstanceId, dryRun, filePath ).Result;
return StartPlanFileAsync( planInstanceId, dryRun, filePath ).Result;
}

public async Task<ExecuteResult> StartPlanFileAsync(int planInstanceId, bool dryRun, string filePath)
public async Task<ExecuteResult> StartPlanFileAsync(long planInstanceId, bool dryRun, string filePath)
{
if( File.Exists( filePath ) )
{
Expand All @@ -52,12 +52,12 @@ public async Task<ExecuteResult> StartPlanFileAsync(int planInstanceId, bool dry
throw new FileNotFoundException( "Unable to start Plan.", filePath );
}

public ExecuteResult StartPlan(int planInstanceId, bool dryRun, string filePath)
public ExecuteResult StartPlan(long planInstanceId, bool dryRun, string filePath)
{
return StartPlanAsync( planInstanceId, dryRun, filePath ).Result;
}

public async Task<ExecuteResult> StartPlanAsync(int planInstanceId, bool dryRun, string filePath)
public async Task<ExecuteResult> StartPlanAsync(long planInstanceId, bool dryRun, string filePath)
{
if( File.Exists( filePath ) )
{
Expand All @@ -69,12 +69,12 @@ public async Task<ExecuteResult> StartPlanAsync(int planInstanceId, bool dryRun,
throw new FileNotFoundException( "Unable to start Plan.", filePath );
}

public ExecuteResult StartPlan(int planInstanceId, bool dryRun, Plan plan)
public ExecuteResult StartPlan(long planInstanceId, bool dryRun, Plan plan)
{
return StartPlanAsync( planInstanceId, dryRun, plan ).Result;
}

public async Task<ExecuteResult> StartPlanAsync(int planInstanceId, bool dryRun, Plan plan)
public async Task<ExecuteResult> StartPlanAsync(long planInstanceId, bool dryRun, Plan plan)
{
string requestUri = $"{_rootPath}/execute/{planInstanceId}/?action=start&dryRun={dryRun}";
return await PostAsync<Plan, ExecuteResult>( plan, requestUri );
Expand Down
7 changes: 5 additions & 2 deletions Synapse.NodeService/Classes/PlanRuntimePod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public void Start(CancellationToken token, Action<IPlanRuntimeContainer> callbac
if( SynapseNodeService.Config.SerializeResultPlan )
File.WriteAllText( $"{_logRootPath.FullName}\\{_ticks}_{Plan.Name}.result.yaml", Plan.ResultPlan.ToYaml() );

//send final message home
_controllerService.SetPlanStatusAsync( Plan.Name, PlanInstanceId, Plan.ResultPlan );

callback?.Invoke( this );
}

Expand All @@ -77,8 +80,8 @@ private void Plan_Progress(object sender, HandlerProgressCancelEventArgs e)
if( _wantsCancel )
e.Cancel = true;

//todo: send a message home
_controllerService.SetPlanStatusAsync( Plan.Name, PlanInstanceId, e.SerializeSimple() );
//send intermediate message home
_controllerService.SetPlanActionStatusAsync( Plan.Name, PlanInstanceId, e.ToActionItem() );
}

private void Plan_LogMessage(object sender, LogMessageEventArgs e)
Expand Down
10 changes: 5 additions & 5 deletions Synapse.NodeService/Classes/SynapseNodeServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public void StartPlanAsync(string planInstanceId, bool dryRun, Plan plan)
}
}

private static void Scheduler_PlanCompleted(object sender, PlanCompletedEventArgs e)
{
SynapseNodeService.Logger.Info( $"Plan Completed: InstanceId: {e.PlanContainer.PlanInstanceId}, Name: {e.PlanContainer.Plan.Name}" ); //, At: {e.TimeCompleted}
}

public void CancelPlan(string planInstanceId)
{
string context = GetContext( nameof( CancelPlan ), nameof( planInstanceId ), planInstanceId );
Expand All @@ -104,11 +109,6 @@ public void CancelPlan(string planInstanceId)
}
}

private static void Scheduler_PlanCompleted(object sender, PlanCompletedEventArgs e)
{
SynapseNodeService.Logger.Info( $"Plan Completed: InstanceId: {e.PlanContainer.PlanInstanceId}, Name: {e.PlanContainer.Plan.Name}" ); //, At: {e.TimeCompleted}
}

public void Drainstop(bool shutdown)
{
string context = GetContext( nameof( Drainstop ), nameof( shutdown ), shutdown );
Expand Down

0 comments on commit 7b86046

Please sign in to comment.