use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project bgpcep by opendaylight.
the class ProgrammingServiceImplTest method testScheduleDependingInstruction.
@Test
public void testScheduleDependingInstruction() throws Exception {
this.testedProgrammingService.scheduleInstruction(getMockedSubmitInstructionInput("mockedSubmit1"));
final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2", "mockedSubmit1");
this.testedProgrammingService.scheduleInstruction(mockedSubmit2);
this.mockedExecutorWrapper.assertSubmittedTasksSize(2);
// First is in state scheduled, so second could not be scheduled yet
this.mockedNotificationServiceWrapper.assertNotificationsCount(1);
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project bgpcep by opendaylight.
the class ProgrammingServiceImplTest method testSuccessExecutingWithDependenciesTransaction.
// TODO test deadline with state Queued
@Test
public void testSuccessExecutingWithDependenciesTransaction() throws Exception {
final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1");
final ListenableFuture<Instruction> future = this.testedProgrammingService.scheduleInstruction(mockedSubmit1);
final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2", "mockedSubmit1");
final ListenableFuture<Instruction> future2 = this.testedProgrammingService.scheduleInstruction(mockedSubmit2);
this.mockedNotificationServiceWrapper.assertNotificationsCount(1);
Instruction instruction = future.get();
instruction.checkedExecutionStart();
instruction.executionCompleted(InstructionStatus.Successful, getDetails());
this.mockedNotificationServiceWrapper.assertNotificationsCount(4);
this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(), InstructionStatus.Executing);
this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(2, mockedSubmit1.getId(), InstructionStatus.Successful);
this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(3, mockedSubmit2.getId(), InstructionStatus.Scheduled);
instruction = future2.get();
instruction.checkedExecutionStart();
instruction.executionCompleted(InstructionStatus.Successful, getDetails());
this.mockedNotificationServiceWrapper.assertNotificationsCount(6);
this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(4, mockedSubmit2.getId(), InstructionStatus.Executing);
this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(5, mockedSubmit2.getId(), InstructionStatus.Successful);
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project bgpcep by opendaylight.
the class NeighborUtil method buildCapabilityState.
/**
* Builds Neighbor State containing Capabilities State, session State.
*
* @return Neighbor State
*/
public static NeighborStateAugmentation buildCapabilityState(@Nonnull final BGPSessionState neighbor) {
final List<Class<? extends BgpCapability>> supportedCapabilities = buildSupportedCapabilities(neighbor);
SessionState sessionState = null;
switch(neighbor.getSessionState()) {
case IDLE:
sessionState = SessionState.IDLE;
break;
case UP:
sessionState = SessionState.ESTABLISHED;
break;
case OPEN_CONFIRM:
sessionState = SessionState.OPENCONFIRM;
break;
default:
}
return new NeighborStateAugmentationBuilder().setSupportedCapabilities(supportedCapabilities).setSessionState(sessionState).build();
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project bgpcep by opendaylight.
the class Stateful07ErrorMessageParser method insertObject.
private static State insertObject(final State state, final Object obj, final List<Errors> errorObjects, final List<Rps> requestParameters, final List<Srps> srps, final PcerrMessageBuilder b) {
switch(state) {
case ERROR_IN:
if (obj instanceof ErrorObject) {
final ErrorObject o = (ErrorObject) obj;
errorObjects.add(new ErrorsBuilder().setErrorObject(o).build());
return State.ERROR_IN;
}
case RP_IN:
if (obj instanceof Rp) {
final Rp o = (Rp) obj;
requestParameters.add(new RpsBuilder().setRp(o).build());
return State.RP_IN;
}
case SRP_IN:
if (obj instanceof Srp) {
final Srp o = (Srp) obj;
srps.add(new SrpsBuilder().setSrp(o).build());
return State.SRP_IN;
}
case OPEN:
if (obj instanceof Open) {
b.setErrorType(new SessionCaseBuilder().setSession(new SessionBuilder().setOpen((Open) obj).build()).build());
return State.OPEN_IN;
}
case ERROR:
if (obj instanceof ErrorObject) {
final ErrorObject o = (ErrorObject) obj;
errorObjects.add(new ErrorsBuilder().setErrorObject(o).build());
return State.ERROR;
}
case OPEN_IN:
case END:
return State.END;
default:
return state;
}
}
use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.State in project bgpcep by opendaylight.
the class PCEPSessionImpl method close.
/**
* Closes PCEP session, cancels all timers, returns to state Idle, sends the Close Message. KeepAlive and DeadTimer
* are cancelled if the state of the session changes to IDLE. This method is used to close the PCEP session from
* inside the session or from the listener, therefore the parent of this session should be informed.
*/
@Override
public synchronized void close(final TerminationReason reason) {
if (this.closed.getAndSet(true)) {
LOG.debug("Session is already closed.");
return;
}
// only send close message when the reason is provided
if (reason != null) {
LOG.info("Closing PCEP session with reason {}: {}", reason, this);
sendMessage(new CloseBuilder().setCCloseMessage(new CCloseMessageBuilder().setCClose(new CCloseBuilder().setReason(reason.getShortValue()).build()).build()).build());
} else {
LOG.info("Closing PCEP session: {}", this);
}
closeChannel();
}
Aggregations