当前位置: 首页>>代码示例>>Java>>正文


Java SwitchStatus.MASTER属性代码示例

本文整理汇总了Java中net.floodlightcontroller.core.IOFSwitch.SwitchStatus.MASTER属性的典型用法代码示例。如果您正苦于以下问题:Java SwitchStatus.MASTER属性的具体用法?Java SwitchStatus.MASTER怎么用?Java SwitchStatus.MASTER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在net.floodlightcontroller.core.IOFSwitch.SwitchStatus的用法示例。


在下文中一共展示了SwitchStatus.MASTER属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupSwitchRoleChangeUnsupported

/**
    * Setup the mock switch for a role change request where the switch
    * does not support roles.
    *
    * Needs to verify and reset the controller since we need to set
    * an expectation
    */
   @SuppressWarnings("unchecked")
private void setupSwitchRoleChangeUnsupported(int xid,
                                                 OFControllerRole role) {
       SwitchStatus newStatus = role != OFControllerRole.ROLE_SLAVE ? SwitchStatus.MASTER : SwitchStatus.SLAVE;
       boolean supportsNxRole = false;
       verify(switchManager);
       reset(sw, switchManager);
       expect(sw.getAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE))
               .andReturn(supportsNxRole).atLeastOnce();
       // TODO: hmmm. While it's not incorrect that we set the attribute
       // again it looks odd. Maybe change
       expect(sw.getOFFactory()).andReturn(factory).anyTimes();
       sw.write(anyObject(OFMessage.class));
       expectLastCall().anyTimes();
       sw.write(anyObject(Iterable.class));
       expectLastCall().anyTimes();
       expect(sw.getTables()).andStubReturn((short)0);
       sw.setAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE, supportsNxRole);
       expectLastCall().anyTimes();
       sw.setControllerRole(role);
       expectLastCall().once();

       if (role == OFControllerRole.ROLE_SLAVE) {
           sw.disconnect();
           expectLastCall().once();
       } else {
           expect(sw.getStatus()).andReturn(SwitchStatus.HANDSHAKE).once();
           sw.setStatus(newStatus);
           expectLastCall().once();
           switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, newStatus);
       }
       replay(sw, switchManager);

       switchHandler.sendRoleRequest(role);

       verify(sw, switchManager);
   }
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:44,代码来源:OFSwitchHandlerTestBase.java

示例2: switchStatusChanged

@Override
public synchronized void switchStatusChanged(IOFSwitchBackend sw, SwitchStatus oldStatus, SwitchStatus newStatus) {
	DatapathId dpid = sw.getId();
	IOFSwitchBackend presentSw = this.switches.get(dpid);

	if (presentSw != sw)  {
		// Note == for object equality, not .equals for value
		counters.errorActivatedSwitchNotPresent
		.increment();
		log.debug("Switch {} status change but not present in sync manager", sw);
		return;
	}
	evSwitch.newEventWithFlush(new SwitchEvent(dpid,
			String.format("%s -> %s",
					oldStatus,
					newStatus)));

	if(newStatus == SwitchStatus.MASTER  && role != OFControllerRole.ROLE_MASTER) {
		counters.invalidSwitchActivatedWhileSlave.increment();
		log.error("Switch {} activated but controller not MASTER", sw);
		sw.disconnect();
		return; // only react to switch connections when master
	}

	if(!oldStatus.isVisible() && newStatus.isVisible()) {
		// the switch has just become visible. Send 'add' notification to our
		// listeners
		addUpdateToQueue(new SwitchUpdate(dpid, SwitchUpdateType.ADDED));
	} else if((oldStatus.isVisible() && !newStatus.isVisible())) {
		addUpdateToQueue(new SwitchUpdate(dpid, SwitchUpdateType.REMOVED));
	}

	// note: no else if - both may be true
	if(oldStatus != SwitchStatus.MASTER && newStatus == SwitchStatus.MASTER ) {
		counters.switchActivated.increment();
		addUpdateToQueue(new SwitchUpdate(dpid,
				SwitchUpdateType.ACTIVATED));
	} else if(oldStatus == SwitchStatus.MASTER && newStatus != SwitchStatus.MASTER ) {
		counters.switchDeactivated.increment();
		addUpdateToQueue(new SwitchUpdate(dpid, SwitchUpdateType.DEACTIVATED));
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:42,代码来源:OFSwitchManager.java

示例3: setupSwitchRoleChangeUnsupported

/**
 * Setup the mock switch for a role change request where the switch
 * does not support roles.
 *
 * Needs to verify and reset the controller since we need to set
 * an expectation
 */
@SuppressWarnings("unchecked")
private void setupSwitchRoleChangeUnsupported(int xid,
		OFControllerRole role) {
	SwitchStatus newStatus = role != OFControllerRole.ROLE_SLAVE ? SwitchStatus.MASTER : SwitchStatus.SLAVE;
	boolean supportsNxRole = false;
	verify(switchManager);
	reset(sw, switchManager);
	expect(sw.getAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE))
	.andReturn(supportsNxRole).atLeastOnce();
	// TODO: hmmm. While it's not incorrect that we set the attribute
	// again it looks odd. Maybe change
	expect(sw.getOFFactory()).andReturn(factory).anyTimes();
	expect(sw.write(anyObject(OFMessage.class))).andReturn(true).anyTimes();
	expect(sw.write(anyObject(Iterable.class))).andReturn(Collections.EMPTY_LIST).anyTimes();
	expect(sw.getNumTables()).andStubReturn((short)0);
	sw.setAttribute(IOFSwitch.SWITCH_SUPPORTS_NX_ROLE, supportsNxRole);
	expectLastCall().anyTimes();
	if (SwitchStatus.MASTER == newStatus) {
		if (factory.getVersion().compareTo(OFVersion.OF_13) >= 0) {
			expect(sw.getTables()).andReturn(Collections.EMPTY_LIST).once();
			expect(sw.getTableFeatures(TableId.ZERO)).andReturn(TableFeatures.of(createTableFeaturesStatsReply().getEntries().get(0))).anyTimes();
		}
	}

	sw.setControllerRole(role);
	expectLastCall().once();

	if (role == OFControllerRole.ROLE_SLAVE) {
		sw.disconnect();
		expectLastCall().once();
	} else {
		expect(sw.getStatus()).andReturn(SwitchStatus.HANDSHAKE).once();
		sw.setStatus(newStatus);
		expectLastCall().once();
		switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, newStatus);
	}
	replay(sw, switchManager);
	
	switchHandler.sendRoleRequest(role);
	
	/* Now, trigger transition to master */
	OFBarrierReply br = getFactory().buildBarrierReply()
			.build();
	switchHandler.processOFMessage(br);

	verify(sw, switchManager);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:54,代码来源:OFSwitchHandlerTestBase.java

示例4: switchStatusChanged

@LogMessageDocs({
	@LogMessageDoc(level="ERROR",
			message="Switch {switch} activated but was already active",
			explanation="A switch that was already activated was " +
					"activated again. This should not happen.",
					recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG
			),
			@LogMessageDoc(level="WARN",
			message="New switch added {switch} for already-added switch {switch}",
			explanation="A switch with the same DPID as another switch " +
					"connected to the controller.  This can be caused by " +
					"multiple switches configured with the same DPID, or " +
					"by a switch reconnected very quickly after " +
					"disconnecting.",
					recommendation="If this happens repeatedly, it is likely there " +
							"are switches with duplicate DPIDs on the network.  " +
							"Reconfigure the appropriate switches.  If it happens " +
							"very rarely, then it is likely this is a transient " +
							"network problem that can be ignored."
					)
})
@Override
public synchronized void switchStatusChanged(IOFSwitchBackend sw, SwitchStatus oldStatus, SwitchStatus newStatus) {
	DatapathId dpid = sw.getId();
	IOFSwitchBackend presentSw = this.switches.get(dpid);

	if (presentSw != sw)  {
		// Note == for object equality, not .equals for value
		counters.errorActivatedSwitchNotPresent
		.increment();
		log.debug("Switch {} status change but not present in sync manager", sw);
		return;
	}
	evSwitch.newEventWithFlush(new SwitchEvent(dpid,
			String.format("%s -> %s",
					oldStatus,
					newStatus)));

	if(newStatus == SwitchStatus.MASTER  && role != OFControllerRole.ROLE_MASTER) {
		counters.invalidSwitchActivatedWhileSlave.increment();
		log.error("Switch {} activated but controller not MASTER", sw);
		sw.disconnect();
		return; // only react to switch connections when master
	}

	if(!oldStatus.isVisible() && newStatus.isVisible()) {
		// the switch has just become visible. Send 'add' notification to our
		// listeners
		addUpdateToQueue(new SwitchUpdate(dpid, SwitchUpdateType.ADDED));
	} else if((oldStatus.isVisible() && !newStatus.isVisible())) {
		addUpdateToQueue(new SwitchUpdate(dpid, SwitchUpdateType.REMOVED));
	}

	// note: no else if - both may be true
	if(oldStatus != SwitchStatus.MASTER && newStatus == SwitchStatus.MASTER ) {
		counters.switchActivated.increment();
		addUpdateToQueue(new SwitchUpdate(dpid,
				SwitchUpdateType.ACTIVATED));
	} else if(oldStatus == SwitchStatus.MASTER && newStatus != SwitchStatus.MASTER ) {
		counters.switchDeactivated.increment();
		addUpdateToQueue(new SwitchUpdate(dpid, SwitchUpdateType.DEACTIVATED));
	}
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:63,代码来源:OFSwitchManager.java


注:本文中的net.floodlightcontroller.core.IOFSwitch.SwitchStatus.MASTER属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。