private int planItemCounter;
+ private boolean autoRead = true;
+
/**
* default ctor
*/
}
@Override
- public synchronized Future<RpcResult<BarrierOutput>> barrier(BarrierInput arg0) {
+ public synchronized Future<RpcResult<BarrierOutput>> barrier(
+ BarrierInput arg0) {
checkRpcAndNext(arg0, "barrier");
SettableFuture<RpcResult<BarrierOutput>> result = createAndRegisterRpcResult(arg0);
return result;
}
@Override
- public synchronized Future<RpcResult<GetAsyncOutput>> getAsync(GetAsyncInput arg0) {
+ public synchronized Future<RpcResult<GetAsyncOutput>> getAsync(
+ GetAsyncInput arg0) {
checkRpcAndNext(arg0, "echo");
Future<RpcResult<GetAsyncOutput>> result = createAndRegisterRpcResult(arg0);
return result;
}
@Override
- public synchronized Future<RpcResult<GetConfigOutput>> getConfig(GetConfigInput arg0) {
+ public synchronized Future<RpcResult<GetConfigOutput>> getConfig(
+ GetConfigInput arg0) {
checkRpcAndNext(arg0, "echo");
Future<RpcResult<GetConfigOutput>> result = createAndRegisterRpcResult(arg0);
return result;
@Override
public void checkListeners() {
- if (ofListener == null || systemListener == null || connectionReadyListener == null) {
+ if (ofListener == null || systemListener == null
+ || connectionReadyListener == null) {
occuredExceptions
.add(new IllegalStateException("missing listeners"));
}
throw new IllegalStateException("eventPlan already depleted");
}
- LOG.debug("checking rpc: name={}, ver={}, xid={}", rpcName, rpcInput.getVersion(), rpcInput.getXid());
+ LOG.debug("checking rpc: name={}, ver={}, xid={}", rpcName,
+ rpcInput.getVersion(), rpcInput.getXid());
if (!(eventPlan.peek() instanceof SwitchTestWaitForRpcEvent)
&& !(eventPlan.peek() instanceof SwitchTestWaitForAllEvent)) {
if (eventPlan.peek() instanceof SwitchTestNotificationEvent) {
- SwitchTestNotificationEvent notifEvent = (SwitchTestNotificationEvent) (eventPlan.peek());
- msg = "expected [notification: " +notifEvent.getPlannedNotification()+ "], got [" + rpcInput.getClass().getSimpleName()
- + "]";
+ SwitchTestNotificationEvent notifEvent = (SwitchTestNotificationEvent) (eventPlan
+ .peek());
+ msg = "expected [notification: "
+ + notifEvent.getPlannedNotification() + "], got ["
+ + rpcInput.getClass().getSimpleName() + "]";
} else if (eventPlan.peek() instanceof SwitchTestRcpResponseEvent) {
- SwitchTestRcpResponseEvent rpcEvent = (SwitchTestRcpResponseEvent) (eventPlan.peek());
- msg = "expected [rpc: " +rpcEvent.getPlannedRpcResponse()+ "], got [" + rpcInput.getClass().getSimpleName()
+ SwitchTestRcpResponseEvent rpcEvent = (SwitchTestRcpResponseEvent) (eventPlan
+ .peek());
+ msg = "expected [rpc: " + rpcEvent.getPlannedRpcResponse()
+ + "], got [" + rpcInput.getClass().getSimpleName()
+ "]";
}
} else {
if (eventPlan.peek() instanceof SwitchTestWaitForAllEvent) {
SwitchTestWaitForAllEvent switchTestWaitForAll = (SwitchTestWaitForAllEvent) eventPlan
.peek();
- Set<SwitchTestWaitForRpcEvent> eventBag = switchTestWaitForAll.getWaitEventBag();
+ Set<SwitchTestWaitForRpcEvent> eventBag = switchTestWaitForAll
+ .getWaitEventBag();
List<String> msgLot = new ArrayList<>();
if (eventBag == null || eventBag.isEmpty()) {
} else {
finished = false;
for (SwitchTestWaitForRpcEvent switchTestWaitForRpc : eventBag) {
- String msgPart = checkSingleRpcContent(rpcInput, rpcName, switchTestWaitForRpc);
+ String msgPart = checkSingleRpcContent(rpcInput,
+ rpcName, switchTestWaitForRpc);
if (msgPart != null) {
msgLot.add(msgPart);
} else if (eventPlan.peek() instanceof SwitchTestWaitForRpcEvent) {
SwitchTestWaitForRpcEvent switchTestRpcEvent = (SwitchTestWaitForRpcEvent) eventPlan
.peek();
- msg = checkSingleRpcContent(rpcInput, rpcName, switchTestRpcEvent);
+ msg = checkSingleRpcContent(rpcInput, rpcName,
+ switchTestRpcEvent);
}
}
if (msg != null) {
LOG.debug("rpc check .. FAILED: " + msg);
- occuredExceptions.add(new IllegalArgumentException("step:"+planItemCounter+" | "+msg));
+ occuredExceptions.add(new IllegalArgumentException("step:"
+ + planItemCounter + " | " + msg));
} else {
LOG.debug("rpc check .. OK");
}
* @param switchTestWaitForRpc
* @return
*/
- private static String checkSingleRpcContent(OfHeader rpcInput, String rpcName,
- SwitchTestWaitForRpcEvent switchTestWaitForRpc) {
+ private static String checkSingleRpcContent(OfHeader rpcInput,
+ String rpcName, SwitchTestWaitForRpcEvent switchTestWaitForRpc) {
String failureMsg = null;
if (!rpcName.equals(switchTestWaitForRpc.getRpcName())) {
- failureMsg = "expected rpc name [" + switchTestWaitForRpc.getRpcName()
- + "], got [" + rpcName + "]";
+ failureMsg = "expected rpc name ["
+ + switchTestWaitForRpc.getRpcName() + "], got [" + rpcName
+ + "]";
} else if (!rpcInput.getXid().equals(switchTestWaitForRpc.getXid())) {
- failureMsg = "expected "+rpcName+".xid [" + switchTestWaitForRpc.getXid()
- + "], got [" + rpcInput.getXid() + "]";
+ failureMsg = "expected " + rpcName + ".xid ["
+ + switchTestWaitForRpc.getXid() + "], got ["
+ + rpcInput.getXid() + "]";
}
return failureMsg;
* discard current event, execute next, if possible
*/
private void next() {
- LOG.debug("<---> STEPPING TO NEXT event in plan (leaving [{}] {})", planItemCounter, eventPlan.peek());
+ LOG.debug("<---> STEPPING TO NEXT event in plan (leaving [{}] {})",
+ planItemCounter, eventPlan.peek());
eventPlan.pop();
- planItemCounter ++;
+ planItemCounter++;
planTouched = true;
try {
Thread.sleep(JOB_DELAY);
*/
private synchronized void proceed() {
boolean processed = false;
- LOG.debug("proceeding plan item[{}]: {}", planItemCounter, eventPlan.peek());
+ LOG.debug("proceeding plan item[{}]: {}", planItemCounter,
+ eventPlan.peek());
if (eventPlan.peek() instanceof SwitchTestNotificationEvent) {
SwitchTestNotificationEvent notification = (SwitchTestNotificationEvent) eventPlan
.peek();
processRpcResponse(rpcResponse);
processed = true;
} else if (eventPlan.peek() instanceof SwitchTestCallbackEvent) {
- SwitchTestCallbackEvent callbackEvent = (SwitchTestCallbackEvent) eventPlan.peek();
+ SwitchTestCallbackEvent callbackEvent = (SwitchTestCallbackEvent) eventPlan
+ .peek();
try {
callbackEvent.getCallback().call();
} catch (Exception e) {
LOG.error(e.getMessage(), e);
- occuredExceptions.add(e);
+ occuredExceptions.add(e);
}
processed = true;
}
planTouched = false;
proceed();
if (!planTouched) {
- occuredExceptions.add(new IllegalStateException(
- "eventPlan STALLED, planItemCounter="+planItemCounter));
+ occuredExceptions
+ .add(new IllegalStateException(
+ "eventPlan STALLED, planItemCounter="
+ + planItemCounter));
break;
}
}
private synchronized void processNotification(
final SwitchTestNotificationEvent notificationEvent) {
- Notification notification = notificationEvent
- .getPlannedNotification();
+ Notification notification = notificationEvent.getPlannedNotification();
LOG.debug("notificating OF_LISTENER: "
+ notification.getClass().getSimpleName());
// system events
if (notification instanceof DisconnectEvent) {
- systemListener
- .onDisconnectEvent((DisconnectEvent) notification);
+ systemListener.onDisconnectEvent((DisconnectEvent) notification);
}
// of notifications
else if (notification instanceof EchoRequestMessage) {
- ofListener
- .onEchoRequestMessage((EchoRequestMessage) notification);
+ ofListener.onEchoRequestMessage((EchoRequestMessage) notification);
} else if (notification instanceof ErrorMessage) {
ofListener.onErrorMessage((ErrorMessage) notification);
} else if (notification instanceof ExperimenterMessage) {
ofListener
- .onExperimenterMessage((ExperimenterMessage) notification);
+ .onExperimenterMessage((ExperimenterMessage) notification);
} else if (notification instanceof FlowRemovedMessage) {
- ofListener
- .onFlowRemovedMessage((FlowRemovedMessage) notification);
+ ofListener.onFlowRemovedMessage((FlowRemovedMessage) notification);
} else if (notification instanceof HelloMessage) {
ofListener.onHelloMessage((HelloMessage) notification);
} else if (notification instanceof MultipartReplyMessage) {
ofListener
- .onMultipartReplyMessage((MultipartReplyMessage) notification);
+ .onMultipartReplyMessage((MultipartReplyMessage) notification);
} else if (notification instanceof PacketInMessage) {
- ofListener
- .onPacketInMessage((PacketInMessage) notification);
+ ofListener.onPacketInMessage((PacketInMessage) notification);
} else if (notification instanceof PortStatusMessage) {
- ofListener
- .onPortStatusMessage((PortStatusMessage) notification);
+ ofListener.onPortStatusMessage((PortStatusMessage) notification);
}
// default
else {
- occuredExceptions.add(new IllegalStateException("step:"+planItemCounter+" | " +
- "message listening not supported for type: "
- + notification.getClass()));
+ occuredExceptions.add(new IllegalStateException("step:"
+ + planItemCounter + " | "
+ + "message listening not supported for type: "
+ + notification.getClass()));
}
- LOG.debug("notification ["+notification.getClass().getSimpleName()+"] .. done");
+ LOG.debug("notification [" + notification.getClass().getSimpleName()
+ + "] .. done");
}
/**
* @param rpcResponse
*/
- private synchronized void processRpcResponse(final SwitchTestRcpResponseEvent rpcResponse) {
- OfHeader plannedRpcResponseValue = rpcResponse
- .getPlannedRpcResponse();
+ private synchronized void processRpcResponse(
+ final SwitchTestRcpResponseEvent rpcResponse) {
+ OfHeader plannedRpcResponseValue = rpcResponse.getPlannedRpcResponse();
LOG.debug("rpc-responding to OF_LISTENER: " + rpcResponse.getXid());
@SuppressWarnings("unchecked")
SettableFuture<RpcResult<?>> response = (SettableFuture<RpcResult<?>>) rpcResults
- .get(rpcResponse.getXid());
+ .get(rpcResponse.getXid());
if (response != null) {
boolean successful = plannedRpcResponseValue != null;
if (successful) {
errors = Collections.emptyList();
} else {
- errors = Lists
- .newArrayList(RpcErrors
- .getRpcError(
- "unit",
- "unit",
- "not requested",
- ErrorSeverity.ERROR,
- "planned response to RPC.id = "
- + rpcResponse.getXid(),
- ErrorType.RPC,
- new Exception(
- "rpc response failed (planned behavior)")));
+ errors = Lists.newArrayList(RpcErrors.getRpcError("unit",
+ "unit", "not requested", ErrorSeverity.ERROR,
+ "planned response to RPC.id = " + rpcResponse.getXid(),
+ ErrorType.RPC, new Exception(
+ "rpc response failed (planned behavior)")));
}
RpcResult<?> result = Rpcs.getRpcResult(successful,
plannedRpcResponseValue, errors);
response.set(result);
} else {
String msg = "RpcResponse not expected: xid="
- + rpcResponse.getXid()
- + ", "
- + plannedRpcResponseValue.getClass()
- .getSimpleName();
+ + rpcResponse.getXid() + ", "
+ + plannedRpcResponseValue.getClass().getSimpleName();
LOG.error(msg);
- occuredExceptions.add(new IllegalStateException("step:"+planItemCounter+" | " + msg));
+ occuredExceptions.add(new IllegalStateException("step:"
+ + planItemCounter + " | " + msg));
}
- LOG.debug("rpc ["+rpcResponse.getXid()+"] .. done");
+ LOG.debug("rpc [" + rpcResponse.getXid() + "] .. done");
}
/**
@Override
public void fireConnectionReadyNotification() {
- connectionReadyListener.onConnectionReady();
+ connectionReadyListener.onConnectionReady();
}
@Override
}
@Override
- public Future<RpcResult<Void>> multipartRequest(
- MultipartRequestInput arg0) {
+ public Future<RpcResult<Void>> multipartRequest(MultipartRequestInput arg0) {
checkRpcAndNext(arg0, "multipartRequestInput");
SettableFuture<RpcResult<Void>> result = createOneWayRpcResult();
return result;
return null;
}
+ @Override
+ public boolean isAutoRead() {
+ return autoRead;
+ }
+
+ @Override
+ public void setAutoRead(boolean autoRead) {
+ this.autoRead = autoRead;
+ }
+
}