Merge "BUG-223: Support having multiple RIB instances"
[bgpcep.git] / programming / spi / src / main / java / org / opendaylight / bgpcep / programming / spi / Instruction.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.bgpcep.programming.spi;
9
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev130930.InstructionStatus;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev130930.instruction.status.changed.Details;
12
13 /**
14  *
15  */
16 public interface Instruction {
17         /**
18          * Instruction executors are required to call this method prior to
19          * starting executing on the instruction. Implementations of this method
20          * are required to transition into Executing state and return true, or
21          * into Cancelled state and return false.
22          * 
23          * @return Indication whether the instruction execution should proceed.
24          */
25         boolean checkedExecutionStart();
26
27         /**
28          * Instruction executors can inform about execution hold ups which
29          * prevent an otherwise-ready instruction from executing by calling this
30          * method. It is recommended they check the return of this method to
31          * detect if a cancellation occurred asynchronously.
32          * 
33          * @param details Details which execution is held up
34          * @return Indication whether the instruction execution should proceed.
35          *         If this method returns false, all subsequent calls to this
36          *         method as well as {@link checkedExecutionStart()} will return
37          *         false.
38          */
39         boolean executionHeldUp(Details details);
40
41         /**
42          * Instruction executors are required to call this method when execution
43          * has finished to provide the execution result to the end.
44          * 
45          * @param status Execution result
46          * @param details Execution result details
47          */
48         void executionCompleted(InstructionStatus status, Details details);
49 }