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


Java HostEvent.subject方法代码示例

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


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

示例1: hostMessage

import org.onosproject.net.host.HostEvent; //导入方法依赖的package包/类
protected ObjectNode hostMessage(HostEvent event) {
    Host host = event.subject();
    Host prevHost = event.prevSubject();
    String hostType = host.annotations().value(AnnotationKeys.TYPE);

    ObjectNode payload = objectNode()
            .put("id", host.id().toString())
            .put("type", isNullOrEmpty(hostType) ? "endstation" : hostType)
            .put("ingress", compactLinkString(edgeLink(host, true)))
            .put("egress", compactLinkString(edgeLink(host, false)));
    payload.set("cp", hostConnect(host.location()));
    if (prevHost != null && prevHost.location() != null) {
        payload.set("prevCp", hostConnect(prevHost.location()));
    }
    payload.set("labels", labels(ip(host.ipAddresses()),
                                 host.mac().toString()));
    payload.set("props", props(host.annotations()));
    addGeoLocation(host, payload);
    addMetaUi(host.id().toString(), payload);

    String type = HOST_EVENT.get(event.type());
    return JsonUtils.envelope(type, 0, payload);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:TopologyViewMessageHandlerBase.java

示例2: hostMessage

import org.onosproject.net.host.HostEvent; //导入方法依赖的package包/类
protected ObjectNode hostMessage(HostEvent event) {
    Host host = event.subject();
    String hostType = host.annotations().value(AnnotationKeys.TYPE);
    ObjectNode payload = mapper.createObjectNode()
            .put("id", host.id().toString())
            .put("type", isNullOrEmpty(hostType) ? "endstation" : hostType)
            .put("ingress", compactLinkString(edgeLink(host, true)))
            .put("egress", compactLinkString(edgeLink(host, false)));
    payload.set("cp", hostConnect(mapper, host.location()));
    payload.set("labels", labels(mapper, ip(host.ipAddresses()),
                                 host.mac().toString()));
    payload.set("props", props(host.annotations()));
    addGeoLocation(host, payload);
    addMetaUi(host.id().toString(), payload);

    String type = (event.type() == HOST_ADDED) ? "addHost" :
            ((event.type() == HOST_REMOVED) ? "removeHost" : "updateHost");
    return envelope(type, 0, payload);
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:20,代码来源:TopologyViewMessages.java

示例3: peerAdded

import org.onosproject.net.host.HostEvent; //导入方法依赖的package包/类
private void peerAdded(HostEvent event) {
    Host peer = event.subject();
    Optional<Interface> peerIntf =
            interfaceService.getInterfacesByPort(peer.location()).stream()
            .filter(intf -> interfaces.isEmpty() || interfaces.contains(intf.name()))
            .filter(intf -> peer.vlan().equals(intf.vlan()))
            .findFirst();
    if (!peerIntf.isPresent()) {
        log.debug("Adding peer {}/{} on {} but the interface is not configured",
                peer.mac(), peer.vlan(), peer.location());
        return;
    }

    // Generate L3 Unicast groups and store it in the map
    int toRouterL3Unicast = createPeerGroup(peer.mac(), peerIntf.get().mac(),
            peer.vlan(), peer.location().deviceId(), controlPlaneConnectPoint.port());
    int toPeerL3Unicast = createPeerGroup(peerIntf.get().mac(), peer.mac(),
            peer.vlan(), peer.location().deviceId(), peer.location().port());
    peerNextId.put(peer, ImmutableSortedSet.of(toRouterL3Unicast, toPeerL3Unicast));

    // From peer to router
    peerIntf.get().ipAddresses().forEach(routerIp -> {
        flowObjectiveService.forward(peer.location().deviceId(),
                createPeerObjBuilder(toRouterL3Unicast, routerIp.ipAddress().toIpPrefix()).add());
    });

    // From router to peer
    peer.ipAddresses().forEach(peerIp -> {
        flowObjectiveService.forward(peer.location().deviceId(),
                createPeerObjBuilder(toPeerL3Unicast, peerIp.toIpPrefix()).add());
    });
}
 
开发者ID:shlee89,项目名称:athena,代码行数:33,代码来源:ControlPlaneRedirectManager.java

示例4: peerRemoved

import org.onosproject.net.host.HostEvent; //导入方法依赖的package包/类
private void peerRemoved(HostEvent event) {
    Host peer = event.subject();
    Optional<Interface> peerIntf =
            interfaceService.getInterfacesByPort(peer.location()).stream()
                    .filter(intf -> interfaces.isEmpty() || interfaces.contains(intf.name()))
                    .filter(intf -> peer.vlan().equals(intf.vlan()))
                    .findFirst();
    if (!peerIntf.isPresent()) {
        log.debug("Removing peer {}/{} on {} but the interface is not configured",
                peer.mac(), peer.vlan(), peer.location());
        return;
    }

    Set<Integer> nextIds = peerNextId.get(peer);
    checkState(peerNextId.get(peer) != null,
            "Peer nextId should not be null");
    checkState(peerNextId.get(peer).size() == 2,
            "Wrong nextId associated with the peer");
    Iterator<Integer> iter = peerNextId.get(peer).iterator();
    int toRouterL3Unicast = iter.next();
    int toPeerL3Unicast = iter.next();

    // From peer to router
    peerIntf.get().ipAddresses().forEach(routerIp -> {
        flowObjectiveService.forward(peer.location().deviceId(),
                createPeerObjBuilder(toRouterL3Unicast, routerIp.ipAddress().toIpPrefix()).remove());
    });

    // From router to peer
    peer.ipAddresses().forEach(peerIp -> {
        flowObjectiveService.forward(peer.location().deviceId(),
                createPeerObjBuilder(toPeerL3Unicast, peerIp.toIpPrefix()).remove());
    });
}
 
开发者ID:shlee89,项目名称:athena,代码行数:35,代码来源:ControlPlaneRedirectManager.java

示例5: handle

import org.onosproject.net.host.HostEvent; //导入方法依赖的package包/类
private void handle(HostEvent event) {
    Host host = event.subject();
    if (!mastershipService.isLocalMaster(host.location().deviceId())) {
        // do not allow to proceed without mastership
        return;
    }

    Instance instance = Instance.of(host);
    if (!netTypes.isEmpty() && !netTypes.contains(instance.netType())) {
        // not my service network instance, do nothing
        return;
    }

    switch (event.type()) {
    case HOST_UPDATED:
        instanceUpdated(instance);
        break;
    case HOST_ADDED:
        instanceDetected(instance);
        break;
    case HOST_REMOVED:
        instanceRemoved(instance);
        break;
    default:
        break;
    }
}
 
开发者ID:opencord,项目名称:vtn,代码行数:28,代码来源:AbstractInstanceHandler.java

示例6: event

import org.onosproject.net.host.HostEvent; //导入方法依赖的package包/类
@Override
public void event(HostEvent hostEvent) {
	if (hostEvent.type() == HostEvent.Type.HOST_ADDED) {
		Host host = hostEvent.subject();
		ObjectNode hostMessage = objectNode();
		hostMessage.put("mac", host.mac().toString());
		hostMessage.put("vlan", host.vlan().toShort());
		hostMessage.put("ip", host.ipAddresses().toString());
		connection().sendMessage("hostEvent", 0, hostMessage);
	}
}
 
开发者ID:ShakhMoves,项目名称:ShakhSDVPN,代码行数:12,代码来源:SDVPNWebHandler.java

示例7: event

import org.onosproject.net.host.HostEvent; //导入方法依赖的package包/类
/**
 *
 * @param hostEvent Host event that we use to detect adding new hosts to the network
    */
@Override
public void event(HostEvent hostEvent) {
	if (hostEvent.type() == HostEvent.Type.HOST_ADDED) {
		Host host = hostEvent.subject();
		ObjectNode hostMessage = objectNode();
		hostMessage.put("mac", host.mac().toString());
		hostMessage.put("vlan", host.vlan().toShort());
		hostMessage.put("ip", host.ipAddresses().toString());
		connection().sendMessage("hostEvent", 0, hostMessage);
	}
}
 
开发者ID:eljalalpour,项目名称:SDVPN,代码行数:16,代码来源:SDVPNWebHandler.java

示例8: hostMessage

import org.onosproject.net.host.HostEvent; //导入方法依赖的package包/类
protected ObjectNode hostMessage(HostEvent event) {
    Host host = event.subject();
    Host prevHost = event.prevSubject();
    String hostType = host.annotations().value(AnnotationKeys.UI_TYPE);
    String ip = ip(host.ipAddresses());

    ObjectNode payload = objectNode()
            .put("id", host.id().toString())
            .put("type", isNullOrEmpty(hostType) ? "endstation" : hostType);

    // set most recent connect point (and previous if we know it)
    payload.set("cp", hostConnect(host.location()));
    if (prevHost != null && prevHost.location() != null) {
        payload.set("prevCp", hostConnect(prevHost.location()));
    }

    // set ALL connect points
    addAllCps(host.locations(), payload);

    payload.set("labels", labels(nameForHost(host), ip, host.mac().toString(), ""));
    payload.set("props", props(host.annotations()));
    addGeoLocation(host, payload);
    addMetaUi(host.id().toString(), payload);

    String type = HOST_EVENT.get(event.type());
    return JsonUtils.envelope(type, payload);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:28,代码来源:TopologyViewMessageHandlerBase.java

示例9: isRelevant

import org.onosproject.net.host.HostEvent; //导入方法依赖的package包/类
@Override
public boolean isRelevant(HostEvent event) {
    Host host = event.subject();
    if (!isValidHost(host)) {
        log.debug("Invalid host detected, ignore it {}", host);
        return false;
    }
    return true;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:10,代码来源:HostBasedInstancePortManager.java

示例10: processHostUpdatedEvent

import org.onosproject.net.host.HostEvent; //导入方法依赖的package包/类
void processHostUpdatedEvent(HostEvent event) {
    Host host = event.subject();
    MacAddress hostMac = host.mac();
    VlanId hostVlanId = host.vlan();
    Set<HostLocation> locations = host.locations();
    Set<IpAddress> prevIps = event.prevSubject().ipAddresses();
    Set<IpAddress> newIps = host.ipAddresses();
    log.info("Host {}/{} is updated", hostMac, hostVlanId);

    locations.stream().filter(srManager::isMasterOf).forEach(location -> {
        Sets.difference(prevIps, newIps).forEach(ip ->
                processRoutingRule(location.deviceId(), location.port(), hostMac, hostVlanId, ip, true)
        );
        Sets.difference(newIps, prevIps).forEach(ip ->
                processRoutingRule(location.deviceId(), location.port(), hostMac, hostVlanId, ip, false)
        );
    });

    // Use the pair link temporarily before the second location of a dual-homed host shows up.
    // This do not affect single-homed hosts since the flow will be blocked in
    // processBridgingRule or processRoutingRule due to VLAN or IP mismatch respectively
    locations.forEach(location ->
        srManager.getPairDeviceId(location.deviceId()).ifPresent(pairDeviceId -> {
            if (srManager.mastershipService.isLocalMaster(pairDeviceId) &&
                    locations.stream().noneMatch(l -> l.deviceId().equals(pairDeviceId))) {
                Set<IpAddress> ipsToAdd = Sets.difference(newIps, prevIps);
                Set<IpAddress> ipsToRemove = Sets.difference(prevIps, newIps);

                srManager.getPairLocalPorts(pairDeviceId).ifPresent(pairRemotePort -> {
                    // NOTE: Since the pairLocalPort is trunk port, use assigned vlan of original port
                    //       when the host is untagged
                    VlanId vlanId = Optional.ofNullable(srManager.getInternalVlanId(location)).orElse(hostVlanId);

                    ipsToRemove.forEach(ip ->
                            processRoutingRule(pairDeviceId, pairRemotePort, hostMac, vlanId, ip, true)
                    );
                    ipsToAdd.forEach(ip ->
                            processRoutingRule(pairDeviceId, pairRemotePort, hostMac, vlanId, ip, false)
                    );

                    if (srManager.activeProbing) {
                        probe(host, location, pairDeviceId, pairRemotePort);
                    }
                });
            }
        })
    );
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:49,代码来源:HostHandler.java


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