| @@ 174-252 (lines=79) @@ | ||
| 171 | /** |
|
| 172 | * |
|
| 173 | */ |
|
| 174 | @Override |
|
| 175 | public void handleExecutionFailure(long tick, ExecutionFailureCause cause) |
|
| 176 | throws PlatformException |
|
| 177 | { |
|
| 178 | // convert tick to tau |
|
| 179 | long tau = this.executive.convertTickToTau(tick); |
|
| 180 | // manage uncontrollable tokens of the plan according to the feedbacks |
|
| 181 | while (this.hasObservations()) |
|
| 182 | { |
|
| 183 | // get next observation |
|
| 184 | ExecutionFeedback feedback = this.next(); |
|
| 185 | // get node |
|
| 186 | ExecutionNode node = feedback.getNode(); |
|
| 187 | // check node schedule |
|
| 188 | this.executive.checkSchedule(node); |
|
| 189 | // check execution result |
|
| 190 | switch (feedback.getType()) { |
|
| 191 | ||
| 192 | case PARTIALLY_CONTROLLABLE_TOKEN_COMPLETE : |
|
| 193 | case UNCONTROLLABLE_TOKEN_COMPLETE : { |
|
| 194 | ||
| 195 | // compute node duration of the token in execution |
|
| 196 | long duration = Math.max(1, tau - node.getStart()[0]); |
|
| 197 | // the node can be considered as executed |
|
| 198 | this.executive.updateNode(node, ExecutionNodeStatus.FAILURE); |
|
| 199 | // add repair information |
|
| 200 | cause.addRepairInfo(node, duration); |
|
| 201 | // info message |
|
| 202 | info("{Monitor} {tick: " + tick + "} {tau: " + tau + "} {FAILURE-HANDLING} -> Observed token execution with duration " + duration + " \n" |
|
| 203 | + "\t- node: " + node.getGroundSignature() + " (" + node + ")\n"); |
|
| 204 | } |
|
| 205 | break; |
|
| 206 | ||
| 207 | case UNCONTROLLABLE_TOKEN_START : { |
|
| 208 | ||
| 209 | // update node status |
|
| 210 | this.executive.updateNode(node, ExecutionNodeStatus.FAILURE); |
|
| 211 | info("{Monitor} {tick: " + tick + "} {tau: " + tau + "} {FAILURE-HANDLING} -> Observed token execution start at time " + tau + "\n" |
|
| 212 | + "\t- node: " + node.getGroundSignature() + " (" + node + ")\n"); |
|
| 213 | } |
|
| 214 | break; |
|
| 215 | ||
| 216 | case TOKEN_EXECUTION_FAILURE : { |
|
| 217 | ||
| 218 | // the node can be considered as executed |
|
| 219 | this.executive.updateNode(node, ExecutionNodeStatus.FAILURE); |
|
| 220 | info("{Monitor} {tick: " + tick + "} {tau: " + tau + "} {FAILURE-HANDLING} -> Observed execution failure at time " + tau + "\n" |
|
| 221 | + "\t- node: " + node.getGroundSignature() + " (" + node + ")\n"); |
|
| 222 | } |
|
| 223 | } |
|
| 224 | } |
|
| 225 | ||
| 226 | // manage controllable tokens of the plan |
|
| 227 | for (ExecutionNode node : this.executive.getNodes(ExecutionNodeStatus.IN_EXECUTION)) { |
|
| 228 | ||
| 229 | // check node controllability |
|
| 230 | if (node.getControllabilityType().equals(ControllabilityType.CONTROLLABLE)) { |
|
| 231 | ||
| 232 | // check end conditions |
|
| 233 | if (this.executive.canEnd(node)) { |
|
| 234 | ||
| 235 | // check schedule |
|
| 236 | this.executive.checkSchedule(node); |
|
| 237 | // check expected schedule |
|
| 238 | if (tau >= node.getEnd()[0]) { |
|
| 239 | ||
| 240 | // the node can be considered as executed |
|
| 241 | this.executive.updateNode(node, ExecutionNodeStatus.FAILURE); |
|
| 242 | // send stop command |
|
| 243 | this.executive.sendStopCommandSignalToPlatform(node); |
|
| 244 | // info message |
|
| 245 | debug("{Monitor} {tick: " + tick + "} {tau: " + tau + "} {FAILURE-HANDLING} -> Stopping execution of controllable token\n" |
|
| 246 | + "\t- node: " + node.getGroundSignature() + " (" + node + ")\n"); |
|
| 247 | ||
| 248 | } else { |
|
| 249 | ||
| 250 | // info message |
|
| 251 | debug("{Monitor} {tick: " + tick + "} {tau: " + tau + "} {FAILURE-HANDLING} -> Waiting stop condition for controllable token\n" |
|
| 252 | + "\t- node: " + node.getGroundSignature() + " (" + node + ")\n"); |
|
| 253 | } |
|
| 254 | } |
|
| 255 | } |
|
| @@ 167-245 (lines=79) @@ | ||
| 164 | /** |
|
| 165 | * |
|
| 166 | */ |
|
| 167 | @Override |
|
| 168 | public void handleExecutionFailure(long tick, ExecutionFailureCause cause) |
|
| 169 | throws PlatformException { |
|
| 170 | ||
| 171 | // convert tick to tau |
|
| 172 | long tau = this.executive.convertTickToTau(tick); |
|
| 173 | // check received feedbacks |
|
| 174 | while (this.hasObservations()) { |
|
| 175 | ||
| 176 | // get next observation |
|
| 177 | ExecutionFeedback feedback = this.next(); |
|
| 178 | // get node |
|
| 179 | ExecutionNode node = feedback.getNode(); |
|
| 180 | // check node schedule |
|
| 181 | this.executive.checkSchedule(node); |
|
| 182 | // check execution result |
|
| 183 | switch (feedback.getType()) { |
|
| 184 | ||
| 185 | case PARTIALLY_CONTROLLABLE_TOKEN_COMPLETE : |
|
| 186 | case UNCONTROLLABLE_TOKEN_COMPLETE : { |
|
| 187 | ||
| 188 | // compute node duration of the token in execution |
|
| 189 | long duration = Math.max(1, tau - node.getStart()[0]); |
|
| 190 | // the node can be considered as executed |
|
| 191 | this.executive.updateNode(node, ExecutionNodeStatus.FAILURE); |
|
| 192 | // add repair information |
|
| 193 | cause.addRepairInfo(node, duration); |
|
| 194 | // info message |
|
| 195 | debug("{Monitor} {tick: " + tick + "} {tau: " + tau + "} {FAILURE-HANDLING} -> Observed token execution with duration " + duration + " \n" |
|
| 196 | + "\t- node: " + node.getGroundSignature() + " (" + node + ")\n"); |
|
| 197 | } |
|
| 198 | break; |
|
| 199 | ||
| 200 | case UNCONTROLLABLE_TOKEN_START : { |
|
| 201 | ||
| 202 | // update node status |
|
| 203 | this.executive.updateNode(node, ExecutionNodeStatus.FAILURE); |
|
| 204 | info("{Monitor} {tick: " + tick + "} {tau: " + tau + "} {FAILURE-HANDLING} -> Observed token execution start at time " + tau + "\n" |
|
| 205 | + "\t- node: " + node.getGroundSignature() + " (" + node + ")\n"); |
|
| 206 | } |
|
| 207 | break; |
|
| 208 | ||
| 209 | case TOKEN_EXECUTION_FAILURE : { |
|
| 210 | ||
| 211 | // the node can be considered as executed |
|
| 212 | this.executive.updateNode(node, ExecutionNodeStatus.FAILURE); |
|
| 213 | info("{Monitor} {tick: " + tick + "} {tau: " + tau + "} {FAILURE-HANDLING} -> Observed execution failure at time " + tau + "\n" |
|
| 214 | + "\t- node: " + node.getGroundSignature() + " (" + node + ")\n"); |
|
| 215 | ||
| 216 | } |
|
| 217 | } |
|
| 218 | } |
|
| 219 | // manage controllable tokens of the plan |
|
| 220 | for (ExecutionNode node : this.executive.getNodes(ExecutionNodeStatus.IN_EXECUTION)) { |
|
| 221 | ||
| 222 | // check node controllability |
|
| 223 | if (node.getControllabilityType().equals(ControllabilityType.CONTROLLABLE)) { |
|
| 224 | ||
| 225 | // check if controllable node can stop |
|
| 226 | if (this.executive.canEnd(node)) { |
|
| 227 | ||
| 228 | // check node schedule |
|
| 229 | this.executive.checkSchedule(node); |
|
| 230 | // check expected schedule |
|
| 231 | if (tau >= node.getEnd()[0]) { |
|
| 232 | ||
| 233 | // the node can be considered as executed |
|
| 234 | this.executive.updateNode(node, ExecutionNodeStatus.FAILURE); |
|
| 235 | // send stop command |
|
| 236 | this.executive.sendStopCommandSignalToPlatform(node); |
|
| 237 | // info message |
|
| 238 | debug("{Monitor} {tick: " + tick + "} {tau: " + tau + "} {FAILURE-HANDLING} -> Stopping execution of controllable token\n" |
|
| 239 | + "\t- node: " + node.getGroundSignature() + " (" + node + ")\n"); |
|
| 240 | ||
| 241 | } else { |
|
| 242 | ||
| 243 | // info message |
|
| 244 | debug("{Monitor} {tick: " + tick + "} {tau: " + tau + "} {FAILURE-HANDLING} -> Waiting stop condition for controllable token\n" |
|
| 245 | + "\t- node: " + node.getGroundSignature() + " (" + node + ")\n"); |
|
| 246 | } |
|
| 247 | } |
|
| 248 | } |
|