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


Java HostEvent类代码示例

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


HostEvent类属于org.onosproject.net.host包,在下文中一共展示了HostEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: processHostAddedEvent

import org.onosproject.net.host.HostEvent; //导入依赖的package包/类
/**
 * Generate new ACL flow rules for new host following the given ACL rule.
 */
private void processHostAddedEvent(HostEvent event, AclRule rule) {
    DeviceId deviceId = event.subject().location().deviceId();
    for (IpAddress address : event.subject().ipAddresses()) {
        if ((rule.srcIp() != null) ?
                (checkIpInCidr(address.getIp4Address(), rule.srcIp())) :
                (checkIpInCidr(address.getIp4Address(), rule.dstIp()))) {
            if (!aclStore.checkIfRuleWorksInDevice(rule.id(), deviceId)) {
                List<RuleId> allowingRuleList = aclStore
                        .getAllowingRuleByDenyingRule(rule.id());
                if (allowingRuleList != null) {
                    for (RuleId allowingRuleId : allowingRuleList) {
                        generateAclFlow(aclStore.getAclRule(allowingRuleId), deviceId);
                    }
                }
                generateAclFlow(rule, deviceId);
            }
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:AclManager.java

示例3: testFourInterfacesThreeHostEventsSameVlan

import org.onosproject.net.host.HostEvent; //导入依赖的package包/类
/**
 * Checks the case in which six ports are configured with VLANs and
 * initially no hosts are registered by the HostService. The first three
 * ports have an interface configured on VLAN1, the other three have an
 * interface configured on VLAN2. When the module starts up, three hosts -
 * on device one, two and three - port 1 (both on VLAN1), are registered by
 * the HostService and events are sent to the application. sp2mp intents
 * are created for all interfaces configured and mp2sp intents are created
 * only for the hosts attached.
 * The number of intents expected is nine: six for VLAN1, three for VLAN2.
 * Six sp2mp intents, three mp2sp intents. IPs are added on the first two
 * hosts only to demonstrate it doesn't influence the number of intents
 * created.
 * An additional host is added on device seven, port one to demonstrate
 * that, even if it's on the same VLAN of other interfaces configured in
 * the system, it doesn't let the application generate intents, since it's
 * not connected to the interface configured.
 */
@Test
public void testFourInterfacesThreeHostEventsSameVlan() {
    vpls.activate();

    Host h1 = new DefaultHost(PID, HID1, MAC1, VLAN1, getLocation(1),
                              Collections.singleton(IP1));
    Host h2 = new DefaultHost(PID, HID2, MAC2, VLAN1, getLocation(2),
                              Collections.singleton(IP2));
    Host h3 = new DefaultHost(PID, HID3, MAC3, VLAN1, getLocation(3),
                              Collections.EMPTY_SET);
    Host h7 = new DefaultHost(PID, HID7, MAC7, VLAN1, getLocation(7),
                              Collections.EMPTY_SET);
    hostsAvailable.addAll(Sets.newHashSet(h1, h2, h3, h7));

    hostsAvailable.forEach(host ->
        hostListener.event(new HostEvent(HostEvent.Type.HOST_ADDED, host)));

    List<Intent> expectedIntents = new ArrayList<>();
    expectedIntents.addAll(generateVlanOneBrc());
    expectedIntents.addAll(generateVlanOneUni());
    expectedIntents.addAll(generateVlanTwoBrc());

    checkIntents(expectedIntents);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:43,代码来源:VplsTest.java

示例4: testFourInterfacesTwoHostEventsDifferentVlan

import org.onosproject.net.host.HostEvent; //导入依赖的package包/类
/**
 * Checks the case in which six ports are configured with VLANs and
 * initially no hosts are registered by the HostService. The first three
 * ports have an interface configured on VLAN1, the other three have an
 * interface configured on VLAN2. When the module starts up, two hosts -
 * on device one and four - port 1 (VLAN 1 and VLAN 2), are registered by
 * the HostService and events are sent to the application. sp2mp intents
 * are created for all interfaces configured and no mp2sp intents are created
 * at all, since the minimum number of hosts needed on the same vlan to
 * create mp2sp intents is 2.
 * The number of intents expected is six: three for VLAN1, three for VLAN2.
 * six sp2mp intents, zero mp2sp intents. IPs are added on the first host
 * only to demonstrate it doesn't influence the number of intents created.
 */
@Test
public void testFourInterfacesTwoHostEventsDifferentVlan() {
    vpls.activate();

    Host h1 = new DefaultHost(PID, HID1, MAC1, VLAN1, getLocation(1),
                              Collections.singleton(IP1));
    Host h4 = new DefaultHost(PID, HID4, MAC4, VLAN2, getLocation(4),
                              Collections.EMPTY_SET);
    hostsAvailable.addAll(Sets.newHashSet(h1, h4));

    hostsAvailable.forEach(host -> {
        hostListener.event(new HostEvent(HostEvent.Type.HOST_ADDED, host));
    });

    List<Intent> expectedIntents = new ArrayList<>();
    expectedIntents.addAll(generateVlanOneBrc());
    expectedIntents.addAll(generateVlanTwoBrc());

    checkIntents(expectedIntents);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:35,代码来源:VplsTest.java

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

示例6: createHost

import org.onosproject.net.host.HostEvent; //导入依赖的package包/类
private HostEvent createHost(ProviderId providerId, HostId hostId,
                             HostDescription descr, Timestamp timestamp) {
    synchronized (this) {
        StoredHost newhost = new StoredHost(timestamp, providerId, hostId,
                descr.hwAddress(),
                descr.vlan(),
                descr.location(),
                ImmutableSet.copyOf(descr.ipAddress()));
        StoredHost concAdd = hosts.putIfAbsent(hostId, newhost);
        if (concAdd != null) {
            // concurrent add detected, retry from start
            return updateHost(providerId, hostId, concAdd, descr, timestamp);
        }
        locations.put(descr.location(), newhost);
        return new HostEvent(HOST_ADDED, newhost);
    }
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:18,代码来源:GossipHostStore.java

示例7: testAddHost

import org.onosproject.net.host.HostEvent; //导入依赖的package包/类
/**
 * Adds hosts to a VPLS.
 */
@Test
public void testAddHost() {
    VplsData vplsData  = VplsData.of(VPLS1, NONE);
    vplsData.addInterface(V100H1);
    vplsData.state(ADDED);
    vplsStore.addVpls(vplsData);

    HostEvent hostEvent = new HostEvent(HostEvent.Type.HOST_ADDED, V100HOST1);
    hostService.postHostEvent(hostEvent);

    vplsData = vplsStore.getVpls(VPLS1);
    assertNotNull(vplsData);

    assertEquals(vplsData.state(), UPDATING);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:19,代码来源:VplsManagerTest.java

示例8: processHostMovedEvent

import org.onosproject.net.host.HostEvent; //导入依赖的package包/类
void processHostMovedEvent(HostEvent event) {
    MacAddress hostMac = event.subject().mac();
    VlanId hostVlanId = event.subject().vlan();
    Set<HostLocation> prevLocations = event.prevSubject().locations();
    Set<IpAddress> prevIps = event.prevSubject().ipAddresses();
    Set<HostLocation> newLocations = event.subject().locations();
    Set<IpAddress> newIps = event.subject().ipAddresses();

    // FIXME: Delay event handling a little bit to wait for the previous redirection flows to be completed
    //        The permanent solution would be introducing CompletableFuture and wait for it
    if (prevLocations.size() == 1 && newLocations.size() == 2) {
        log.debug("Delay event handling when host {}/{} moves from 1 to 2 locations", hostMac, hostVlanId);
        ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
        executorService.schedule(() ->
                processHostMoved(hostMac, hostVlanId, prevLocations, prevIps, newLocations, newIps),
                HOST_MOVED_DELAY_MS, TimeUnit.MILLISECONDS);
    } else {
        processHostMoved(hostMac, hostVlanId, prevLocations, prevIps, newLocations, newIps);
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:21,代码来源:HostHandler.java

示例9: testHostRemoved

import org.onosproject.net.host.HostEvent; //导入依赖的package包/类
@Test
public void testHostRemoved() throws Exception {
    Host subject = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_UNTAGGED,
            Sets.newHashSet(HOST_LOC11), Sets.newHashSet(HOST_IP11), false);

    // Add a host
    // Expect: add one routing rule and one bridging rule
    hostHandler.processHostAddedEvent(new HostEvent(HostEvent.Type.HOST_ADDED, subject));
    assertEquals(1, ROUTING_TABLE.size());
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP11.toIpPrefix())));
    assertEquals(1, BRIDGING_TABLE.size());
    assertNotNull(BRIDGING_TABLE.get(new MockBridgingTableKey(DEV1, HOST_MAC, INTF_VLAN_UNTAGGED)));

    // Remove the host
    // Expect: add the routing rule and the bridging rule
    hostHandler.processHostRemovedEvent(new HostEvent(HostEvent.Type.HOST_REMOVED, subject));
    assertEquals(0, ROUTING_TABLE.size());
    assertEquals(0, BRIDGING_TABLE.size());
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:20,代码来源:HostHandlerTest.java

示例10: testDualHomedHostRemoved

import org.onosproject.net.host.HostEvent; //导入依赖的package包/类
@Test
public void testDualHomedHostRemoved() throws Exception {
    // Add a dual-homed host that has 2 locations
    // Expect: add two routing rules and two bridging rules
    Host subject = new DefaultHost(PROVIDER_ID, HOST_ID_UNTAGGED, HOST_MAC, HOST_VLAN_UNTAGGED,
            Sets.newHashSet(HOST_LOC11, HOST_LOC21), Sets.newHashSet(HOST_IP11), false);
    hostHandler.processHostAddedEvent(new HostEvent(HostEvent.Type.HOST_ADDED, subject));
    assertEquals(2, ROUTING_TABLE.size());
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV1, HOST_IP11.toIpPrefix())));
    assertNotNull(ROUTING_TABLE.get(new MockRoutingTableKey(DEV2, HOST_IP11.toIpPrefix())));
    assertEquals(2, BRIDGING_TABLE.size());
    assertNotNull(BRIDGING_TABLE.get(new MockBridgingTableKey(DEV1, HOST_MAC, INTF_VLAN_UNTAGGED)));
    assertNotNull(BRIDGING_TABLE.get(new MockBridgingTableKey(DEV2, HOST_MAC, INTF_VLAN_UNTAGGED)));

    // Remove a dual-homed host that has 2 locations
    // Expect: all routing and bridging rules are removed
    hostHandler.processHostRemovedEvent(new HostEvent(HostEvent.Type.HOST_REMOVED, subject));
    assertEquals(0, ROUTING_TABLE.size());
    assertEquals(0, BRIDGING_TABLE.size());
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:21,代码来源:HostHandlerTest.java

示例11: testDualHomedSingleLocationFail

import org.onosproject.net.host.HostEvent; //导入依赖的package包/类
@Test
public void testDualHomedSingleLocationFail() throws Exception {
    testOneDualHomedAdded();

    HostEvent he = new HostEvent(HostEvent.Type.HOST_MOVED, H3S, H3D);
    routeHandler.processHostMovedEvent(he);

    assertEquals(2, ROUTING_TABLE.size());
    MockRoutingTableValue rtv1 = ROUTING_TABLE.get(new MockRoutingTableKey(CP1.deviceId(), P1));
    MockRoutingTableValue rtv2 = ROUTING_TABLE.get(new MockRoutingTableKey(CP2.deviceId(), P1));
    assertEquals(M3, rtv1.macAddress);
    assertEquals(M3, rtv2.macAddress);
    assertEquals(V3, rtv1.vlanId);
    assertEquals(V3, rtv2.vlanId);
    assertEquals(CP1.port(), rtv1.portNumber);
    assertEquals(P9, rtv2.portNumber);

    // ECMP route table hasn't changed
    assertEquals(2, SUBNET_TABLE.size());
    assertTrue(SUBNET_TABLE.get(CP1).contains(P1));
    assertTrue(SUBNET_TABLE.get(CP2).contains(P1));
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:23,代码来源:RouteHandlerTest.java

示例12: testAsyncRouteAdd

import org.onosproject.net.host.HostEvent; //导入依赖的package包/类
/**
 * Tests adding a route entry where the HostService does not immediately
 * know the MAC address of the next hop, but this is learnt later.
 */
@Test
public void testAsyncRouteAdd() {
    Route route = new Route(Route.Source.STATIC, V4_PREFIX1, V4_NEXT_HOP1);

    // Host service will reply with no hosts when asked
    reset(hostService);
    expect(hostService.getHostsByIp(anyObject(IpAddress.class))).andReturn(
            Collections.emptySet()).anyTimes();
    hostService.startMonitoringIp(V4_NEXT_HOP1);
    replay(hostService);

    // Initially when we add the route, no route event will be sent because
    // the host is not known
    replay(routeListener);

    routeManager.update(Collections.singleton(route));

    verify(routeListener);

    // Now when we send the event, we expect the FIB update to be sent
    reset(routeListener);
    routeListener.event(new RouteEvent(RouteEvent.Type.ROUTE_ADDED,
            new ResolvedRoute(route, MAC1)));
    replay(routeListener);

    // Send in the host event
    Host host = createHost(MAC1, V4_NEXT_HOP1);
    hostListener.event(new HostEvent(HostEvent.Type.HOST_ADDED, host));

    verify(routeListener);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:36,代码来源:RouteManagerTest.java

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

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

示例15: processHostUpdatedEvent

import org.onosproject.net.host.HostEvent; //导入依赖的package包/类
protected void processHostUpdatedEvent(HostEvent event) {
    MacAddress mac = event.subject().mac();
    VlanId vlanId = event.subject().vlan();
    HostLocation prevLocation = event.prevSubject().location();
    DeviceId prevDeviceId = prevLocation.deviceId();
    PortNumber prevPort = prevLocation.port();
    Set<IpAddress> prevIps = event.prevSubject().ipAddresses();
    HostLocation newLocation = event.subject().location();
    DeviceId newDeviceId = newLocation.deviceId();
    PortNumber newPort = newLocation.port();
    Set<IpAddress> newIps = event.subject().ipAddresses();
    log.debug("Host {}/{} is updated", mac, vlanId);

    if (accepted(event.prevSubject())) {
        // Revoke previous IP table entry
        prevIps.forEach(ip -> {
            if (ip.isIp4()) {
                removePerHostRoute(prevLocation, ip.getIp4Address());
                srManager.routingRulePopulator.revokeIpRuleForHost(
                        prevDeviceId, ip.getIp4Address(), mac, prevPort);
            }
        });
    }

    if (accepted(event.subject())) {
        // Populate new IP table entry
        newIps.forEach(ip -> {
            if (ip.isIp4()) {
                addPerHostRoute(newLocation, ip.getIp4Address());
                srManager.routingRulePopulator.populateIpRuleForHost(
                        newDeviceId, ip.getIp4Address(), mac, newPort);
            }
        });
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:36,代码来源:HostHandler.java


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