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


Java OFControllerRole.ROLE_MASTER属性代码示例

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


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

示例1: parseRole

private static OFControllerRole parseRole(String role) {
	if (role == null || role.isEmpty()) {
		return OFControllerRole.ROLE_NOCHANGE;
	} 

	role = role.toUpperCase();		

	if (role.contains(STR_ROLE_MASTER)) {
		return OFControllerRole.ROLE_MASTER;
	} else if (role.contains(STR_ROLE_SLAVE)) {
		return OFControllerRole.ROLE_SLAVE;
	} else if (role.contains(STR_ROLE_EQUAL) || role.contains(STR_ROLE_OTHER)) {
		return OFControllerRole.ROLE_EQUAL;
	} else {
		return OFControllerRole.ROLE_NOCHANGE;
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:17,代码来源:SwitchRoleResource.java

示例2: sendRoleRequestIfNotPending

/**
 * Send a role request for the given role only if no other role
 * request is currently pending.
 * @param role The role to send to the switch.
 * @throws IOException
 */
synchronized void sendRoleRequestIfNotPending(OFControllerRole role, long xid)
		throws IOException {
	long now = System.nanoTime();
	if (now - lastAssertTimeNs < assertTimeIntervalNs) {
		return;
	}

	lastAssertTimeNs = now;
	if (assertTimeIntervalNs < MAX_ASSERT_TIME_INTERVAL_NS) { // 2 minutes max
		assertTimeIntervalNs <<= 1;
	} else if (role == OFControllerRole.ROLE_MASTER){
		log.warn("Reasserting master role on switch {}, " +
				"likely a switch config error with multiple masters",
				role, sw);
	}
	if (!requestPending)
		sendRoleRequest(role, xid);
	else
		switchManagerCounters.roleNotResentBecauseRolePending.increment();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:26,代码来源:OFSwitchHandshakeHandler.java

示例3: enterState

@Override
void enterState() {
	if (OFSwitchManager.clearTablesOnEachTransitionToMaster) {
		log.info("Clearing flow tables of {} on upcoming transition to MASTER.", sw.getId().toString());
		clearAllTables();
	} else if (OFSwitchManager.clearTablesOnInitialConnectAsMaster && initialRole == null) { /* don't do it if we were slave first */
		initialRole = OFControllerRole.ROLE_MASTER;
		log.info("Clearing flow tables of {} on upcoming initial role as MASTER.", sw.getId().toString());
		clearAllTables();
	}

	sendBarrier(); /* Need to make sure the tables are clear before adding default flows */
	addDefaultFlows();

	/*
	 * We also need a barrier between adding flows and notifying modules of the
	 * transition to master. Some modules might modify the flow tables and expect 
	 * the clear/default flow operations above to have completed.
	 */
	sendBarrier();

	setSwitchStatus(SwitchStatus.MASTER);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:23,代码来源:OFSwitchHandshakeHandler.java

示例4: notifyPortChanged

@Override
public synchronized void notifyPortChanged(IOFSwitchBackend sw,
		OFPortDesc port,
		PortChangeType changeType) {
	Preconditions.checkNotNull(sw, "switch must not be null");
	Preconditions.checkNotNull(port, "port must not be null");
	Preconditions.checkNotNull(changeType, "changeType must not be null");

	if (role != OFControllerRole.ROLE_MASTER) {
		counters.invalidPortsChanged.increment();
		return;
	}
	if (!this.switches.containsKey(sw.getId())) {
		counters.invalidPortsChanged.increment();
		return;
	}

	if(sw.getStatus().isVisible()) {
		// no need to count here. SwitchUpdate.dispatch will count
		// the portchanged
		SwitchUpdate update = new SwitchUpdate(sw.getId(),
				SwitchUpdateType.PORTCHANGED,
				port, changeType);
		addUpdateToQueue(update);
	}
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:26,代码来源:OFSwitchManager.java

示例5: sendOF13RoleRequest

private int sendOF13RoleRequest(RoleState role) throws IOException {
    // Convert the role enum to the appropriate role to send
    OFControllerRole roleToSend = OFControllerRole.ROLE_NOCHANGE;
    switch (role) {
    case EQUAL:
        roleToSend = OFControllerRole.ROLE_EQUAL;
        break;
    case MASTER:
        roleToSend = OFControllerRole.ROLE_MASTER;
        break;
    case SLAVE:
        roleToSend = OFControllerRole.ROLE_SLAVE;
        break;
    default:
        log.warn("Sending default role.noChange to switch {}."
                + " Should only be used for queries.", sw);
    }

    int xid = sw.getNextTransactionId();
    OFRoleRequest rrm = OFFactories.getFactory(OFVersion.OF_13)
            .buildRoleRequest()
            .setRole(roleToSend)
            .setXid(xid)
            //FIXME fix below when we actually use generation ids
            .setGenerationId(U64.ZERO)
            .build();

    sw.sendRoleRequest(rrm);
    return xid;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:RoleManager.java

示例6: hasAnotherMaster

@Override
public boolean hasAnotherMaster() {

	//TODO: refactor get connection to not throw illegal arg exceptions
	IOFConnection mainCxn = this.getConnection(OFAuxId.MAIN);

	if(mainCxn != null) {

		// Determine the local URI
		InetSocketAddress address = (InetSocketAddress) mainCxn.getLocalInetAddress();
		URI localURI = URIUtil.createURI(address.getHostName(), address.getPort());

		for(Entry<URI,Map<OFAuxId, OFBsnControllerConnection>> entry : this.controllerConnections.entrySet()) {

			// Don't check our own controller connections
			URI uri = entry.getKey();
			if(!localURI.equals(uri)){

				// We only care for the MAIN connection
				Map<OFAuxId, OFBsnControllerConnection> cxns = this.controllerConnections.get(uri);
				OFBsnControllerConnection controllerCxn = cxns.get(OFAuxId.MAIN);

				if(controllerCxn != null) {
					// If the controller id disconnected or not master we know it is not connected
					if(controllerCxn.getState() == OFBsnControllerConnectionState.BSN_CONTROLLER_CONNECTION_STATE_CONNECTED
							&& controllerCxn.getRole() == OFControllerRole.ROLE_MASTER){
						return true;
					}
				} else {
					log.warn("Unable to find controller connection with aux id "
							+ "MAIN for switch {} on controller with URI {}.",
							this, uri);
				}
			}
		}
	}
	return false;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:38,代码来源:OFSwitch.java

示例7: processOFNiciraControllerRoleRequest

@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());
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:27,代码来源:OFSwitchHandshakeHandler.java

示例8: niciraToOFRole

public static OFControllerRole niciraToOFRole(OFNiciraControllerRoleReply roleReply) {
    switch(roleReply.getRole()) {
        case ROLE_MASTER:
            return OFControllerRole.ROLE_MASTER;
        case ROLE_OTHER:
            return OFControllerRole.ROLE_EQUAL;
        case ROLE_SLAVE:
            return OFControllerRole.ROLE_SLAVE;
        default:
            throw new IllegalArgumentException("unknown Nicira role value: " + roleReply.getRole());
    }
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:12,代码来源:NiciraRoleUtils.java

示例9: sendRoleRequestIfNotPending

/**
 * Send a role request for the given role only if no other role
 * request is currently pending.
 * @param role The role to send to the switch.
 * @throws IOException
 */
@LogMessageDoc(level="WARN",
		message="Reasserting master role on switch {SWITCH}, " +
				"likely a configruation error with multiple masters",
				explanation="The controller keeps getting permission error " +
						"from switch, likely due to switch connected to another " +
						"controller also in master mode",
						recommendation=LogMessageDoc.CHECK_SWITCH)
synchronized void sendRoleRequestIfNotPending(OFControllerRole role, long xid)
		throws IOException {
	long now = System.nanoTime();
	if (now - lastAssertTimeNs < assertTimeIntervalNs) {
		return;
	}

	lastAssertTimeNs = now;
	if (assertTimeIntervalNs < MAX_ASSERT_TIME_INTERVAL_NS) { // 2 minutes max
		assertTimeIntervalNs <<= 1;
	} else if (role == OFControllerRole.ROLE_MASTER){
		log.warn("Reasserting master role on switch {}, " +
				"likely a switch config error with multiple masters",
				role, sw);
	}
	if (!requestPending)
		sendRoleRequest(role, xid);
	else
		switchManagerCounters.roleNotResentBecauseRolePending.increment();
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:33,代码来源:OFSwitchHandshakeHandler.java

示例10: enterState

@Override
void enterState() {
	setSwitchStatus(SwitchStatus.MASTER);
	if (OFSwitchManager.clearTablesOnEachTransitionToMaster) {
		log.info("Clearing flow tables of {} on recent transition to MASTER.", sw.getId().toString());
		clearAllTables();
	} else if (OFSwitchManager.clearTablesOnInitialConnectAsMaster && initialRole == null) { /* don't do it if we were slave first */
		initialRole = OFControllerRole.ROLE_MASTER;
		log.info("Clearing flow tables of {} on initial role as MASTER.", sw.getId().toString());
		clearAllTables();
	}
	addDefaultFlows();
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:13,代码来源:OFSwitchHandshakeHandler.java

示例11: isActive

@Override
public boolean isActive() {
	// no lock needed since we use volatile
	return isConnected() && (this.role == OFControllerRole.ROLE_MASTER || this.role == OFControllerRole.ROLE_EQUAL);
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:5,代码来源:OFSwitch.java

示例12: 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

示例13: 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


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