@@ -32,12 +32,16 @@ public static void InitPlanScheduler()
3232
3333 public string Hello ( )
3434 {
35+ string context = GetContext ( nameof ( Hello ) ) ;
36+ SynapseNodeService . Logger . Debug ( context ) ;
3537 return "Hello from SynapseNodeServer, World!" ;
3638 }
3739
38- public string WhosHere ( )
40+ public string WhoAmI ( )
3941 {
40- return "WhosHere from SynapseNodeServer, World!" ;
42+ string context = GetContext ( nameof ( WhoAmI ) ) ;
43+ SynapseNodeService . Logger . Debug ( context ) ;
44+ return "WhoAmI from SynapseNodeServer, World!" ;
4145 }
4246
4347 public ExecuteResult StartPlan ( string planInstanceId , bool dryRun , Plan plan )
@@ -60,22 +64,44 @@ public ExecuteResult StartPlan(string planInstanceId, bool dryRun, Plan plan)
6064
6165 public void StartPlanAsync ( string planInstanceId , bool dryRun , Plan plan )
6266 {
63- int planInstId = int . Parse ( planInstanceId ) ;
64-
65- SynapseNodeService . Logger . Info ( $ "StartPlanAsync: InstanceId: { planInstId } , Name: { plan . Name } " ) ;
67+ string context = GetContext ( nameof ( StartPlanAsync ) ,
68+ nameof ( plan ) , plan . Name , nameof ( dryRun ) , dryRun , nameof ( planInstanceId ) , planInstanceId ) ;
6669
67- PlanRuntimePod p = new PlanRuntimePod ( plan , dryRun , null , planInstId ) ;
68- _scheduler . StartPlan ( p ) ; //_scheduler.StartPlan( null, dryRun, plan );
70+ try
71+ {
72+ SynapseNodeService . Logger . Debug ( context ) ;
73+ int planInstId = int . Parse ( planInstanceId ) ;
74+ PlanRuntimePod p = new PlanRuntimePod ( plan , dryRun , null , planInstId ) ;
75+ _scheduler . StartPlan ( p ) ; //_scheduler.StartPlan( null, dryRun, plan );
76+ }
77+ catch ( Exception ex )
78+ {
79+ SynapseNodeService . Logger . Error (
80+ Utilities . UnwindException ( context , ex , asSingleLine : true ) ) ;
81+ throw ;
82+ }
6983 }
7084
7185 public void CancelPlan ( string planInstanceId )
7286 {
73- int planInstId = int . Parse ( planInstanceId ) ;
74- bool found = _scheduler . CancelPlan ( planInstId ) ;
75- string foundMsg = found ?
76- "Found executing Plan and signaled Cancel request." :
77- "Could not find executing Plan; Plan may have already completed execution." ;
78- SynapseNodeService . Logger . Info ( $ "CancelPlan { planInstId } : { foundMsg } " ) ;
87+ string context = GetContext ( nameof ( CancelPlan ) , nameof ( planInstanceId ) , planInstanceId ) ;
88+
89+ try
90+ {
91+ SynapseNodeService . Logger . Debug ( context ) ;
92+ int planInstId = int . Parse ( planInstanceId ) ;
93+ bool found = _scheduler . CancelPlan ( planInstId ) ;
94+ string foundMsg = found ?
95+ "Found executing Plan and signaled Cancel request." :
96+ "Could not find executing Plan; Plan may have already completed execution." ;
97+ SynapseNodeService . Logger . Info ( $ "CancelPlan { planInstId } : { foundMsg } " ) ;
98+ }
99+ catch ( Exception ex )
100+ {
101+ SynapseNodeService . Logger . Error (
102+ Utilities . UnwindException ( context , ex , asSingleLine : true ) ) ;
103+ throw ;
104+ }
79105 }
80106
81107 private static void Scheduler_PlanCompleted ( object sender , PlanCompletedEventArgs e )
@@ -85,28 +111,97 @@ private static void Scheduler_PlanCompleted(object sender, PlanCompletedEventArg
85111
86112 public void Drainstop ( bool shutdown )
87113 {
88- SynapseNodeService . Logger . Info ( $ "Drainstop starting, CurrentQueueDepth: { _scheduler . CurrentQueueDepth } . Shutdown when complete: { shutdown } ." ) ;
89- _scheduler . Drainstop ( ) ;
90- SynapseNodeService . Logger . Info ( $ "Drainstop complete, CurrentQueueDepth: { _scheduler . CurrentQueueDepth } " ) ;
91- if ( shutdown )
114+ string context = GetContext ( nameof ( Drainstop ) , nameof ( shutdown ) , shutdown ) ;
115+
116+ try
117+ {
118+ SynapseNodeService . Logger . Debug ( context ) ;
119+ SynapseNodeService . Logger . Info ( $ "Drainstop starting, CurrentQueueDepth: { _scheduler . CurrentQueueDepth } . Shutdown when complete: { shutdown } ." ) ;
120+ _scheduler . Drainstop ( ) ;
121+ SynapseNodeService . Logger . Info ( $ "Drainstop complete, CurrentQueueDepth: { _scheduler . CurrentQueueDepth } " ) ;
122+ if ( shutdown )
123+ {
124+ SynapseNodeService . Logger . Info ( $ "Drainstop initiating Shutdown." ) ;
125+ DrainstopCallback ? . Invoke ( ) ;
126+ }
127+ }
128+ catch ( Exception ex )
92129 {
93- SynapseNodeService . Logger . Info ( $ "Drainstop initiating Shutdown." ) ;
94- DrainstopCallback ? . Invoke ( ) ;
130+ SynapseNodeService . Logger . Error (
131+ Utilities . UnwindException ( context , ex , asSingleLine : true ) ) ;
132+ throw ;
95133 }
96134 }
97135
98136 public void Undrainstop ( )
99137 {
100- SynapseNodeService . Logger . Info ( $ "Undrainstop starting, CurrentQueueDepth: { _scheduler . CurrentQueueDepth } " ) ;
101- _scheduler . Undrainstop ( ) ;
102- SynapseNodeService . Logger . Info ( $ "Undrainstop complete, CurrentQueueDepth: { _scheduler . CurrentQueueDepth } " ) ;
138+ string context = GetContext ( nameof ( Undrainstop ) ) ;
139+
140+ try
141+ {
142+ SynapseNodeService . Logger . Debug ( context ) ;
143+ SynapseNodeService . Logger . Info ( $ "Undrainstop starting, CurrentQueueDepth: { _scheduler . CurrentQueueDepth } " ) ;
144+ _scheduler . Undrainstop ( ) ;
145+ SynapseNodeService . Logger . Info ( $ "Undrainstop complete, CurrentQueueDepth: { _scheduler . CurrentQueueDepth } " ) ;
146+ }
147+ catch ( Exception ex )
148+ {
149+ SynapseNodeService . Logger . Error (
150+ Utilities . UnwindException ( context , ex , asSingleLine : true ) ) ;
151+ throw ;
152+ }
153+ }
154+
155+ public bool GetIsDrainstopComplete ( )
156+ {
157+ string context = GetContext ( nameof ( GetIsDrainstopComplete ) ) ;
158+
159+ try
160+ {
161+ SynapseNodeService . Logger . Debug ( context ) ;
162+ return _scheduler . IsDrainstopComplete ;
163+ }
164+ catch ( Exception ex )
165+ {
166+ SynapseNodeService . Logger . Error (
167+ Utilities . UnwindException ( context , ex , asSingleLine : true ) ) ;
168+ throw ;
169+ }
103170 }
104171
105- public bool GetIsDrainstopComplete ( ) { return _scheduler . IsDrainstopComplete ; }
172+ public int GetCurrentQueueDepth ( )
173+ {
174+ string context = GetContext ( nameof ( GetCurrentQueueDepth ) ) ;
106175
107- public int GetCurrentQueueDepth ( ) { return _scheduler . CurrentQueueDepth ; }
176+ try
177+ {
178+ SynapseNodeService . Logger . Debug ( context ) ;
179+ return _scheduler . CurrentQueueDepth ;
180+ }
181+ catch ( Exception ex )
182+ {
183+ SynapseNodeService . Logger . Error (
184+ Utilities . UnwindException ( context , ex , asSingleLine : true ) ) ;
185+ throw ;
186+ }
187+ }
108188
109- public List < string > GetCurrentQueueItems ( ) { return _scheduler . CurrentQueue ; }
189+ public List < string > GetCurrentQueueItems ( )
190+ {
191+ string context = GetContext ( nameof ( GetCurrentQueueItems ) ) ;
192+
193+ try
194+ {
195+ SynapseNodeService . Logger . Debug ( context ) ;
196+ return _scheduler . CurrentQueue ;
197+ }
198+ catch ( Exception ex )
199+ {
200+ SynapseNodeService . Logger . Error (
201+ Utilities . UnwindException ( context , ex , asSingleLine : true ) ) ;
202+ throw ;
203+ }
204+ }
110205 #endregion
111206
112207
0 commit comments