void processWrittenOFMessage(OFMessage m) { switch(m.getType()) { case ROLE_REQUEST: processOFRoleRequest((OFRoleRequest) m); break; case EXPERIMENTER: if (m instanceof OFNiciraControllerRoleRequest) { processOFNiciraControllerRoleRequest((OFNiciraControllerRoleRequest) m); } break; default: /* * no-op: * we can send any request at any time */ break; } }
@Override public final void sendRoleRequest(OFMessage msg) { if (msg instanceof OFRoleRequest || msg instanceof OFNiciraControllerRoleRequest) { sendMsgsOnChannel(Collections.singletonList(msg)); return; } throw new IllegalArgumentException("Someone is trying to send " + "a non role request message"); }
void processWrittenOFMessage(OFMessage m) { switch(m.getType()) { case ROLE_REQUEST: processOFRoleRequest((OFRoleRequest) m); break; case EXPERIMENTER: if (m instanceof OFNiciraControllerRoleRequest) { processOFNiciraControllerRoleRequest((OFNiciraControllerRoleRequest) m); } break; default: break; } }
@Override void processOFNiciraControllerRoleRequest(OFNiciraControllerRoleRequest m) { OFControllerRole role; switch (m.getRole()) { case ROLE_MASTER: role = OFControllerRole.ROLE_MASTER; break; case ROLE_SLAVE: role = OFControllerRole.ROLE_SLAVE; break; case ROLE_OTHER: role = OFControllerRole.ROLE_EQUAL; break; default: log.error("Attempted to change to invalid Nicira role {}.", m.getRole().toString()); return; } /* * This will get converted back to the correct factory of the switch later. * We will use OFRoleRequest though to simplify the API between OF versions. */ sendRoleRequest(OFFactories.getFactory(OFVersion.OF_13).buildRoleRequest() .setGenerationId(U64.ZERO) .setXid(m.getXid()) .setRole(role) .build()); }
void processWrittenOFMessage(OFMessage m) { switch(m.getType()) { case ROLE_REQUEST: processOFRoleRequest((OFRoleRequest) m); break; case EXPERIMENTER: if (m instanceof OFNiciraControllerRoleRequest) { processOFNiciraControllerRoleRequest((OFNiciraControllerRoleRequest) m); } break; default: illegalMessageReceived(m); break; } }
void processOFNiciraControllerRoleRequest(OFNiciraControllerRoleRequest m) { unhandledMessageWritten(m); }
@Override Class<?> getRoleRequestClass() { return OFNiciraControllerRoleRequest.class; }
@Override public void verifyRoleRequest(OFMessage m, OFControllerRole expectedRole) { assertThat(m.getType(), equalTo(OFType.EXPERIMENTER)); OFNiciraControllerRoleRequest roleRequest = (OFNiciraControllerRoleRequest)m; assertThat(roleRequest.getRole(), equalTo(NiciraRoleUtils.ofRoleToNiciraRole(expectedRole))); }