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


Java NetworkId类代码示例

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


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

示例1: testPostVirtualDevice

import org.onosproject.incubator.net.virtual.NetworkId; //导入依赖的package包/类
/**
 * Tests adding of new virtual device using POST via JSON stream.
 */
@Test
public void testPostVirtualDevice() {
    NetworkId networkId = networkId3;
    DeviceId deviceId = devId2;
    expect(mockVnetAdminService.createVirtualDevice(networkId, deviceId)).andReturn(vdev2);
    expectLastCall();

    replay(mockVnetAdminService);

    WebTarget wt = target();
    InputStream jsonStream = VirtualNetworkWebResourceTest.class
            .getResourceAsStream("post-virtual-device.json");
    String reqLocation = "vnets/" + networkId.toString() + "/devices";
    Response response = wt.path(reqLocation).request(MediaType.APPLICATION_JSON_TYPE)
            .post(Entity.json(jsonStream));
    assertThat(response.getStatus(), is(HttpURLConnection.HTTP_CREATED));

    String location = response.getLocation().getPath();
    assertThat(location, Matchers.startsWith("/" + reqLocation + "/" + vdev2.id().toString()));

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

示例2: testPostVirtualDeviceNullJsonStream

import org.onosproject.incubator.net.virtual.NetworkId; //导入依赖的package包/类
/**
 * Tests adding of a null virtual device using POST via JSON stream.
 */
@Test
public void testPostVirtualDeviceNullJsonStream() {
    NetworkId networkId = networkId3;
    replay(mockVnetAdminService);

    WebTarget wt = target();
    try {
        String reqLocation = "vnets/" + networkId.toString() + "/devices";
        wt.path(reqLocation)
                .request(MediaType.APPLICATION_JSON_TYPE)
                .post(Entity.json(null), String.class);
        fail("POST of null virtual device did not throw an exception");
    } catch (BadRequestException ex) {
        assertThat(ex.getMessage(), containsString("HTTP 400 Bad Request"));
    }

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

示例3: testDeleteVirtualDevice

import org.onosproject.incubator.net.virtual.NetworkId; //导入依赖的package包/类
/**
 * Tests removing a virtual device with DELETE request.
 */
@Test
public void testDeleteVirtualDevice() {
    NetworkId networkId = networkId3;
    DeviceId deviceId = devId2;
    mockVnetAdminService.removeVirtualDevice(networkId, deviceId);
    expectLastCall();
    replay(mockVnetAdminService);

    WebTarget wt = target()
            .property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
    String reqLocation = "vnets/" + networkId.toString() + "/devices/" + deviceId.toString();
    Response response = wt.path(reqLocation)
            .request(MediaType.APPLICATION_JSON_TYPE)
            .delete();

    assertThat(response.getStatus(), is(HttpURLConnection.HTTP_NO_CONTENT));

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

示例4: testGetVirtualPortsEmptyArray

import org.onosproject.incubator.net.virtual.NetworkId; //导入依赖的package包/类
/**
 * Tests the result of the REST API GET when there are no virtual ports.
 */
@Test
public void testGetVirtualPortsEmptyArray() {
    NetworkId networkId = networkId4;
    DeviceId deviceId = devId2;
    expect(mockVnetService.getVirtualPorts(networkId, deviceId))
            .andReturn(ImmutableSet.of()).anyTimes();
    replay(mockVnetService);

    WebTarget wt = target();
    String location = "vnets/" + networkId.toString()
            + "/devices/" + deviceId.toString() + "/ports";
    String response = wt.path(location).request().get(String.class);
    assertThat(response, is("{\"ports\":[]}"));

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

示例5: testPostVirtualPort

import org.onosproject.incubator.net.virtual.NetworkId; //导入依赖的package包/类
/**
 * Tests adding of new virtual port using POST via JSON stream.
 */
@Test
public void testPostVirtualPort() {
    NetworkId networkId = networkId3;
    DeviceId deviceId = devId22;
    DefaultAnnotations annotations = DefaultAnnotations.builder().build();
    Device physDevice = new DefaultDevice(null, DeviceId.deviceId("dev1"),
                                          null, null, null, null, null, null, annotations);
    Port port1 = new DefaultPort(physDevice, portNumber(1), true);
    expect(mockVnetAdminService.createVirtualPort(networkId, deviceId, portNumber(22), port1))
            .andReturn(vport22);

    replay(mockVnetAdminService);

    WebTarget wt = target();
    InputStream jsonStream = VirtualNetworkWebResourceTest.class
            .getResourceAsStream("post-virtual-port.json");
    String reqLocation = "vnets/" + networkId.toString()
            + "/devices/" + deviceId.toString() + "/ports";
    Response response = wt.path(reqLocation).request(MediaType.APPLICATION_JSON_TYPE)
            .post(Entity.json(jsonStream));
    assertThat(response.getStatus(), is(HttpURLConnection.HTTP_CREATED));

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

示例6: testPostVirtualPortNullJsonStream

import org.onosproject.incubator.net.virtual.NetworkId; //导入依赖的package包/类
/**
 * Tests adding of a null virtual port using POST via JSON stream.
 */
@Test
public void testPostVirtualPortNullJsonStream() {
    NetworkId networkId = networkId3;
    DeviceId deviceId = devId2;
    replay(mockVnetAdminService);

    WebTarget wt = target();
    try {
        String reqLocation = "vnets/" + networkId.toString()
                + "/devices/" + deviceId.toString() + "/ports";
        wt.path(reqLocation)
                .request(MediaType.APPLICATION_JSON_TYPE)
                .post(Entity.json(null), String.class);
        fail("POST of null virtual port did not throw an exception");
    } catch (BadRequestException ex) {
        assertThat(ex.getMessage(), containsString("HTTP 400 Bad Request"));
    }

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

示例7: testDeleteVirtualPort

import org.onosproject.incubator.net.virtual.NetworkId; //导入依赖的package包/类
/**
 * Tests removing a virtual port with DELETE request.
 */
@Test
public void testDeleteVirtualPort() {
    NetworkId networkId = networkId3;
    DeviceId deviceId = devId2;
    PortNumber portNum = portNumber(2);
    mockVnetAdminService.removeVirtualPort(networkId, deviceId, portNum);
    expectLastCall();
    replay(mockVnetAdminService);

    WebTarget wt = target()
            .property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
    String reqLocation = "vnets/" + networkId.toString()
            + "/devices/" + deviceId.toString() + "/ports/" + portNum.toLong();
    Response response = wt.path(reqLocation)
            .request(MediaType.APPLICATION_JSON_TYPE)
            .delete();

    assertThat(response.getStatus(), is(HttpURLConnection.HTTP_NO_CONTENT));

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

示例8: testPostVirtualLink

import org.onosproject.incubator.net.virtual.NetworkId; //导入依赖的package包/类
/**
 * Tests adding of new virtual link using POST via JSON stream.
 */
@Test
public void testPostVirtualLink() {
    NetworkId networkId = networkId3;
    expect(mockVnetAdminService.createVirtualLink(networkId, cp22, cp11))
            .andReturn(vlink1);
    replay(mockVnetAdminService);

    WebTarget wt = target();
    InputStream jsonStream = VirtualNetworkWebResourceTest.class
            .getResourceAsStream("post-virtual-link.json");
    String reqLocation = "vnets/" + networkId.toString() + "/links";
    Response response = wt.path(reqLocation).request(MediaType.APPLICATION_JSON_TYPE)
            .post(Entity.json(jsonStream));
    assertThat(response.getStatus(), is(HttpURLConnection.HTTP_CREATED));

    String location = response.getLocation().getPath();
    assertThat(location, Matchers.startsWith("/" + reqLocation));

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

示例9: testPostVirtualLinkNullJsonStream

import org.onosproject.incubator.net.virtual.NetworkId; //导入依赖的package包/类
/**
 * Tests adding of a null virtual link using POST via JSON stream.
 */
@Test
public void testPostVirtualLinkNullJsonStream() {
    NetworkId networkId = networkId3;
    replay(mockVnetAdminService);

    WebTarget wt = target();
    try {
        String reqLocation = "vnets/" + networkId.toString() + "/links";
        wt.path(reqLocation)
                .request(MediaType.APPLICATION_JSON_TYPE)
                .post(Entity.json(null), String.class);
        fail("POST of null virtual link did not throw an exception");
    } catch (BadRequestException ex) {
        assertThat(ex.getMessage(), containsString("HTTP 400 Bad Request"));
    }

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

示例10: testDeleteVirtualLink

import org.onosproject.incubator.net.virtual.NetworkId; //导入依赖的package包/类
/**
 * Tests removing a virtual link with DELETE request.
 */
@Test
public void testDeleteVirtualLink() {
    NetworkId networkId = networkId3;
    mockVnetAdminService.removeVirtualLink(networkId, cp22, cp11);
    expectLastCall();
    replay(mockVnetAdminService);

    WebTarget wt = target()
            .property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
    InputStream jsonStream = VirtualNetworkWebResourceTest.class
            .getResourceAsStream("post-virtual-link.json");
    String reqLocation = "vnets/" + networkId.toString() + "/links";
    Response response = wt.path(reqLocation).request().method("DELETE", Entity.json(jsonStream));

    assertThat(response.getStatus(), is(HttpURLConnection.HTTP_NO_CONTENT));
    verify(mockVnetAdminService);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:VirtualNetworkWebResourceTest.java

示例11: createVirtualLink

import org.onosproject.incubator.net.virtual.NetworkId; //导入依赖的package包/类
@Override
public VirtualLink createVirtualLink(NetworkId networkId,
                                     ConnectPoint src, ConnectPoint dst) {
    checkNotNull(networkId, NETWORK_NULL);
    checkNotNull(src, LINK_POINT_NULL);
    checkNotNull(dst, LINK_POINT_NULL);
    VirtualLink virtualLink = store.addLink(networkId, src, dst, Link.State.INACTIVE, null);
    checkNotNull(virtualLink, VIRTUAL_LINK_NULL);

    if (virtualLink.providerId() != null) {
        VirtualNetworkProvider provider = getProvider(virtualLink.providerId());
        if (provider != null) {
            TunnelId tunnelId = provider.createTunnel(networkId, mapVirtualToPhysicalPort(networkId, src),
                                                      mapVirtualToPhysicalPort(networkId, dst));
            store.updateLink(virtualLink, tunnelId, Link.State.INACTIVE);
        }
    }
    return virtualLink;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:VirtualNetworkManager.java

示例12: createTunnel

import org.onosproject.incubator.net.virtual.NetworkId; //导入依赖的package包/类
@Override
public TunnelId createTunnel(NetworkId networkId, ConnectPoint src, ConnectPoint dst) {
    checkNotNull(networkId, NETWORK_ID_NULL);
    checkNotNull(src, CONNECT_POINT_NULL);
    checkNotNull(dst, CONNECT_POINT_NULL);
    Key intentKey = encodeKey(networkId, src, dst);

    List<Constraint> constraints = new ArrayList<>();
    constraints.add(new EncapsulationConstraint(EncapsulationType.VLAN));

    // TODO Currently there can only be one tunnel/intent between the src and dst across
    // all virtual networks. We may want to support multiple intents between the same src/dst pairs.
    PointToPointIntent intent = PointToPointIntent.builder()
            .key(intentKey)
            .appId(appId)
            .ingressPoint(src)
            .egressPoint(dst)
            .constraints(constraints)
            .build();
    intentService.submit(intent);

    // construct tunnelId from the key
    return TunnelId.valueOf(intentKey.toString());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:PtToPtIntentVirtualNetworkProvider.java

示例13: addNetwork

import org.onosproject.incubator.net.virtual.NetworkId; //导入依赖的package包/类
@Override
public VirtualNetwork addNetwork(TenantId tenantId) {

    checkState(tenantIdSet.contains(tenantId), "The tenant has not been registered. " + tenantId.id());
    VirtualNetwork virtualNetwork = new DefaultVirtualNetwork(genNetworkId(), tenantId);
    //TODO update both maps in one transaction.
    networkIdVirtualNetworkMap.put(virtualNetwork.id(), virtualNetwork);

    Set<NetworkId> networkIdSet = tenantIdNetworkIdSetMap.get(tenantId);
    if (networkIdSet == null) {
        networkIdSet = new HashSet<>();
    }
    networkIdSet.add(virtualNetwork.id());
    tenantIdNetworkIdSetMap.put(tenantId, networkIdSet);

    return virtualNetwork;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:DistributedVirtualNetworkStore.java

示例14: removeDevice

import org.onosproject.incubator.net.virtual.NetworkId; //导入依赖的package包/类
@Override
public void removeDevice(NetworkId networkId, DeviceId deviceId) {
    checkState(networkExists(networkId), "The network has not been added.");
    //TODO update both maps in one transaction.

    Set<DeviceId> deviceIdSet = new HashSet<>();
    networkIdDeviceIdSetMap.get(networkId).forEach(deviceId1 -> {
        if (deviceId1.equals(deviceId)) {
            deviceIdSet.add(deviceId1);
        }
    });

    if (deviceIdSet != null) {
        networkIdDeviceIdSetMap.compute(networkId, (id, existingDeviceIds) -> {
            if (existingDeviceIds == null || existingDeviceIds.isEmpty()) {
                return new HashSet<>();
            } else {
                return new HashSet<>(Sets.difference(existingDeviceIds, deviceIdSet));
            }
        });

        deviceIdVirtualDeviceMap.remove(deviceId);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:DistributedVirtualNetworkStore.java

示例15: addLink

import org.onosproject.incubator.net.virtual.NetworkId; //导入依赖的package包/类
@Override
public VirtualLink addLink(NetworkId networkId, ConnectPoint src, ConnectPoint dst,
                           Link.State state, TunnelId realizedBy) {
    checkState(networkExists(networkId), "The network has not been added.");
    Set<VirtualLink> virtualLinkSet = networkIdVirtualLinkSetMap.get(networkId);
    if (virtualLinkSet == null) {
        virtualLinkSet = new HashSet<>();
    }
    // validate that the link does not already exist in this network
    checkState(getLink(networkId, src, dst) == null, "The virtual link already exists");

    VirtualLink virtualLink = DefaultVirtualLink.builder()
            .networkId(networkId)
            .src(src)
            .dst(dst)
            .state(state)
            .tunnelId(realizedBy)
            .build();

    virtualLinkSet.add(virtualLink);
    networkIdVirtualLinkSetMap.put(networkId, virtualLinkSet);
    return virtualLink;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:DistributedVirtualNetworkStore.java


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