OFSwitchImpl implements IOFSwitch { protected boolean checkFirstPendingRoleRequestCookie(long cookie) { synchronized(pendingRoleRequests) { PendingRoleRequestEntry head = pendingRoleRequests.peek(); if (head == null) return false; else return head.cookie == cookie; } } OFSwitchImpl(); @Override Object getAttribute(String name); @Override void setAttribute(String name, Object value); @Override Object removeAttribute(String name); @Override boolean hasAttribute(String name); @Override @JsonIgnore Channel getChannel(); @JsonIgnore void setChannel(Channel channel); @Override void write(OFMessage m, FloodlightContext bc); @Override @LogMessageDoc(level="WARN", message="Sending OF message that modifies switch " + "state while in the slave role: {switch}", explanation="An application has sent a message to a switch " + "that is not valid when the switch is in a slave role", recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG) void write(List<OFMessage> msglist, 
                      FloodlightContext bc); void write(List<OFMessage> msglist); @Override void disconnectOutputStream(); @Override @JsonIgnore void setFeaturesReply(OFFeaturesReply featuresReply); @Override @JsonIgnore Collection<OFPhysicalPort> getEnabledPorts(); @Override @JsonIgnore Collection<Short> getEnabledPortNumbers(); @Override OFPhysicalPort getPort(short portNumber); @Override OFPhysicalPort getPort(String portName); @Override @JsonIgnore void setPort(OFPhysicalPort port); @Override @JsonProperty("ports") Collection<OFPhysicalPort> getPorts(); @Override void deletePort(short portNumber); @Override void deletePort(String portName); @Override boolean portEnabled(short portNumber); @Override boolean portEnabled(String portName); @Override boolean portEnabled(OFPhysicalPort port); @Override @JsonSerialize(using=DPIDSerializer.class) @JsonProperty("dpid") long getId(); @JsonIgnore @Override String getStringId(); @Override String toString(); @Override ConcurrentMap<Object, Object> getAttributes(); @Override Date getConnectedSince(); @JsonIgnore @Override int getNextTransactionId(); @Override void sendStatsQuery(OFStatisticsRequest request, int xid,
                                IOFMessageListener caller); @Override Future<List<OFStatistics>> getStatistics(OFStatisticsRequest request); @Override void deliverStatisticsReply(OFMessage reply); @Override void cancelStatisticsReply(int transactionId); @Override void cancelAllStatisticsReplies(); @JsonIgnore void setFloodlightProvider(IFloodlightProviderService floodlightProvider); @JsonIgnore void setThreadPoolService(IThreadPoolService tp); @JsonIgnore @Override synchronized boolean isConnected(); @Override @JsonIgnore synchronized void setConnected(boolean connected); @Override Role getRole(); @JsonIgnore @Override boolean isActive(); @Override @JsonIgnore void setSwitchProperties(OFDescriptionStatistics description); @Override @LogMessageDoc(level="ERROR", message="Failed to clear all flows on switch {switch}", explanation="An I/O error occured while trying to clear " + "flows on the switch.", recommendation=LogMessageDoc.CHECK_SWITCH) void clearAllFlowMods(); @Override boolean updateBroadcastCache(Long entry, Short port); @Override @JsonIgnore Map<Short, Long> getPortBroadcastHits(); @Override void flush(); static void flush_all(); @JsonIgnore Lock getListenerReadLock(); @JsonIgnore Lock getListenerWriteLock(); @JsonSerialize(using=ToStringSerializer.class) SocketAddress getInetAddress(); @Override Future<OFFeaturesReply> getFeaturesReplyFromSwitch(); @Override void deliverOFFeaturesReply(OFMessage reply); @Override void cancelFeaturesReply(int transactionId); @Override int getBuffers(); @Override int getActions(); @Override int getCapabilities(); @Override byte getTables(); static IOFSwitchFeatures switchFeatures; }
@Test public void testCheckFirstPendingRoleRequestCookie() { PendingRoleRequestEntry pending = new PendingRoleRequestEntry( 54321, Role.MASTER, 232323); replay(sw.channel); sw.pendingRoleRequests.add(pending); assertEquals(true, sw.checkFirstPendingRoleRequestCookie(232323)); assertEquals(false, sw.checkFirstPendingRoleRequestCookie(0)); sw.pendingRoleRequests.clear(); assertEquals(false, sw.checkFirstPendingRoleRequestCookie(232323)); verify(sw.channel); }