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


Java HostToHostIntent类代码示例

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


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

示例1: getIntentById

import org.onosproject.net.intent.HostToHostIntent; //导入依赖的package包/类
/**
 * Gets intent by application and key.
 * Returns details of the specified intent.
 *
 * @param appId application identifier
 * @param key   intent key
 * @return 200 OK with intent data
 * @onos.rsModel Intents
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{appId}/{key}")
public Response getIntentById(@PathParam("appId") String appId,
                              @PathParam("key") String key) {
    final ApplicationId app = get(CoreService.class).getAppId(appId);

    Intent intent = get(IntentService.class).getIntent(Key.of(key, app));
    if (intent == null) {
        long numericalKey = Long.decode(key);
        intent = get(IntentService.class).getIntent(Key.of(numericalKey, app));
    }
    nullIsNotFound(intent, INTENT_NOT_FOUND);

    final ObjectNode root;
    if (intent instanceof HostToHostIntent) {
        root = codec(HostToHostIntent.class).encode((HostToHostIntent) intent, this);
    } else if (intent instanceof PointToPointIntent) {
        root = codec(PointToPointIntent.class).encode((PointToPointIntent) intent, this);
    } else {
        root = codec(Intent.class).encode(intent, this);
    }
    return ok(root).build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:34,代码来源:IntentsWebResource.java

示例2: process

import org.onosproject.net.intent.HostToHostIntent; //导入依赖的package包/类
@Override
public void process(long sid, ObjectNode payload) {
    // TODO: add protection against device ids and non-existent hosts.
    HostId one = hostId(string(payload, ONE));
    HostId two = hostId(string(payload, TWO));

    HostToHostIntent intent = HostToHostIntent.builder()
            .appId(appId)
            .one(one)
            .two(two)
            .build();

    intentService.submit(intent);
    if (overlayCache.isActive(TrafficOverlay.TRAFFIC_ID)) {
        traffic.monitor(intent);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:TopologyViewMessageHandler.java

示例3: generateIntents

import org.onosproject.net.intent.HostToHostIntent; //导入依赖的package包/类
private Collection<Intent> generateIntents() {
    List<Host> hosts = Lists.newArrayList(hostService.getHosts());
    List<Intent> fullMesh = Lists.newArrayList();
    for (int i = 0; i < hosts.size(); i++) {
        for (int j = i + 1; j < hosts.size(); j++) {
            fullMesh.add(HostToHostIntent.builder()
                    .appId(appId())
                    .one(hosts.get(i).id())
                    .two(hosts.get(j).id())
                    .build());

        }
    }
    Collections.shuffle(fullMesh);
    return fullMesh.subList(0, Math.min(count, fullMesh.size()));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:RandomIntentCommand.java

示例4: execute

import org.onosproject.net.intent.HostToHostIntent; //导入依赖的package包/类
@Override
protected void execute() {
    IntentService service = get(IntentService.class);

    HostId oneId = HostId.hostId(one);
    HostId twoId = HostId.hostId(two);

    TrafficSelector selector = buildTrafficSelector();
    TrafficTreatment treatment = buildTrafficTreatment();
    List<Constraint> constraints = buildConstraints();

    HostToHostIntent intent = HostToHostIntent.builder()
            .appId(appId())
            .key(key())
            .one(oneId)
            .two(twoId)
            .selector(selector)
            .treatment(treatment)
            .constraints(constraints)
            .priority(priority())
            .build();
    service.submit(intent);
    print("Host to Host intent submitted:\n%s", intent.toString());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:AddHostToHostIntentCommand.java

示例5: run

import org.onosproject.net.intent.HostToHostIntent; //导入依赖的package包/类
@Override
public void run() {
    TrafficSelector selector = DefaultTrafficSelector.emptySelector();
    TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
    List<Constraint> constraint = Lists.newArrayList();
    List<Host> hosts = Lists.newArrayList(hostService.getHosts());
    while (!hosts.isEmpty()) {
        Host src = hosts.remove(0);
        for (Host dst : hosts) {
            HostToHostIntent intent = HostToHostIntent.builder()
                    .appId(appId)
                    .one(src.id())
                    .two(dst.id())
                    .selector(selector)
                    .treatment(treatment)
                    .constraints(constraint)
                    .build();
            existingIntents.add(intent);
            intentService.submit(intent);
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:DemoInstaller.java

示例6: decode

import org.onosproject.net.intent.HostToHostIntent; //导入依赖的package包/类
@Override
public Intent decode(ObjectNode json, CodecContext context) {
    checkNotNull(json, "JSON cannot be null");

    String type = nullIsIllegal(json.get(TYPE),
            TYPE + MISSING_MEMBER_MESSAGE).asText();

    if (type.equals(PointToPointIntent.class.getSimpleName())) {
        return context.codec(PointToPointIntent.class).decode(json, context);
    } else if (type.equals(HostToHostIntent.class.getSimpleName())) {
        return context.codec(HostToHostIntent.class).decode(json, context);
    }

    throw new IllegalArgumentException("Intent type "
            + type + " is not supported");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:IntentCodec.java

示例7: decode

import org.onosproject.net.intent.HostToHostIntent; //导入依赖的package包/类
@Override
public HostToHostIntent decode(ObjectNode json, CodecContext context) {
    HostToHostIntent.Builder builder = HostToHostIntent.builder();

    IntentCodec.intentAttributes(json, context, builder);
    ConnectivityIntentCodec.intentAttributes(json, context, builder);

    String one = nullIsIllegal(json.get(ONE),
            ONE + IntentCodec.MISSING_MEMBER_MESSAGE).asText();
    builder.one(HostId.hostId(one));

    String two = nullIsIllegal(json.get(TWO),
            TWO + IntentCodec.MISSING_MEMBER_MESSAGE).asText();
    builder.two(HostId.hostId(two));

    return builder.build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:HostToHostIntentCodec.java

示例8: matchHostToHostIntent

import org.onosproject.net.intent.HostToHostIntent; //导入依赖的package包/类
/**
 * Matches the JSON representation of a host to host intent.
 *
 * @param jsonIntent JSON representation of the intent
 * @param description Description object used for recording errors
 * @return true if the JSON matches the intent, false otherwise
 */
private boolean matchHostToHostIntent(JsonNode jsonIntent, Description description) {
    final HostToHostIntent hostToHostIntent = (HostToHostIntent) intent;

    // check host one
    final String host1 = hostToHostIntent.one().toString();
    final String jsonHost1 = jsonIntent.get("one").asText();
    if (!host1.equals(jsonHost1)) {
        description.appendText("host one was " + jsonHost1);
        return false;
    }

    // check host 2
    final String host2 = hostToHostIntent.two().toString();
    final String jsonHost2 = jsonIntent.get("two").asText();
    if (!host2.equals(jsonHost2)) {
        description.appendText("host two was " + jsonHost2);
        return false;
    }
    return true;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:IntentJsonMatcher.java

示例9: hostToHostIntent

import org.onosproject.net.intent.HostToHostIntent; //导入依赖的package包/类
/**
 * Tests the encoding of a host to host intent.
 */
@Test
public void hostToHostIntent() {
    final HostToHostIntent intent =
            HostToHostIntent.builder()
                    .appId(appId)
                    .one(id1)
                    .two(id2)
                    .build();

    final JsonCodec<HostToHostIntent> intentCodec =
            context.codec(HostToHostIntent.class);
    assertThat(intentCodec, notNullValue());

    final ObjectNode intentJson = intentCodec.encode(intent, context);
    assertThat(intentJson, matchesIntent(intent));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:IntentCodecTest.java

示例10: getIntentById

import org.onosproject.net.intent.HostToHostIntent; //导入依赖的package包/类
/**
 * Gets a single intent by Id.
 *
 * @param appId the Application ID
 * @param key the Intent key value to look up
 * @return intent data
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{appId}/{key}")
public Response getIntentById(@PathParam("appId") Short appId,
                              @PathParam("key") String key) {
    final ApplicationId app = get(CoreService.class).getAppId(appId);

    Intent intent = get(IntentService.class).getIntent(Key.of(key, app));
    if (intent == null) {
        intent = get(IntentService.class)
                .getIntent(Key.of(Long.parseLong(key), app));
    }
    nullIsNotFound(intent, INTENT_NOT_FOUND);

    final ObjectNode root;
    if (intent instanceof HostToHostIntent) {
        root = codec(HostToHostIntent.class).encode((HostToHostIntent) intent, this);
    } else if (intent instanceof PointToPointIntent) {
        root = codec(PointToPointIntent.class).encode((PointToPointIntent) intent, this);
    } else {
        root = codec(Intent.class).encode(intent, this);
    }
    return ok(root).build();
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:32,代码来源:IntentsWebResource.java

示例11: createHostIntent

import org.onosproject.net.intent.HostToHostIntent; //导入依赖的package包/类
private void createHostIntent(ObjectNode event) {
    ObjectNode payload = payload(event);
    long id = number(event, "sid");
    // TODO: add protection against device ids and non-existent hosts.
    HostId one = hostId(string(payload, "one"));
    HostId two = hostId(string(payload, "two"));

    HostToHostIntent intent =
            HostToHostIntent.builder()
                    .appId(appId)
                    .one(one)
                    .two(two)
                    .build();


    intentService.submit(intent);
    startMonitoringIntent(event, intent);
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:19,代码来源:TopologyViewWebSocket.java

示例12: createHostIntent

import org.onosproject.net.intent.HostToHostIntent; //导入依赖的package包/类
private void createHostIntent(ObjectNode event) {
    ObjectNode payload = payload(event);
    long id = number(event, "sid");
    // TODO: add protection against device ids and non-existent hosts.
    HostId one = hostId(string(payload, "one"));
    HostId two = hostId(string(payload, "two"));

    HostToHostIntent intent =
            HostToHostIntent.builder()
                    .appId(appId)
                    .one(one)
                    .two(two)
                    .build();

    intentService.submit(intent);
    startMonitoringIntent(event, intent);
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:18,代码来源:TopologyViewMessageHandler.java

示例13: execute

import org.onosproject.net.intent.HostToHostIntent; //导入依赖的package包/类
@Override
protected void execute() {
    IntentService service = get(IntentService.class);

    HostId oneId = HostId.hostId(one);
    HostId twoId = HostId.hostId(two);

    List<Constraint> constraints = buildConstraints();

    HostToHostIntent intent = HostToHostIntent.builder()
            .appId(appId())
            .key(key())
            .one(oneId)
            .two(twoId)
            .constraints(constraints)
            .priority(priority())
            .build();
    service.submit(intent);
    print("Host to Host intent submitted:\n%s", intent.toString());
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:21,代码来源:AddHostToHostIntentCommand.java

示例14: testMatches

import org.onosproject.net.intent.HostToHostIntent; //导入依赖的package包/类
@Test
public void testMatches() {
    Intent intent = HostToHostIntent.builder()
            .key(manager.generateKey(NETWORK, HOST_1, HOST_2))
            .appId(manager.appId)
            .one(HOST_1)
            .two(HOST_2)
            .build();

    assertTrue(manager.matches(NETWORK, Optional.of(HOST_1), intent));
    assertTrue(manager.matches(NETWORK, Optional.of(HOST_2), intent));
    assertTrue(manager.matches(NETWORK, Optional.empty(), intent));

    assertFalse(manager.matches(NETWORK, Optional.of(HOST_3), intent));
    assertFalse(manager.matches(NETWORK_2, Optional.of(HOST_1), intent));
    assertFalse(manager.matches(NETWORK_2, Optional.of(HOST_3), intent));
}
 
开发者ID:bocon13,项目名称:onos-byon,代码行数:18,代码来源:NetworkManagerTest.java

示例15: process

import org.onosproject.net.intent.HostToHostIntent; //导入依赖的package包/类
@Override
public void process(ObjectNode payload) {
    // TODO: add protection against device ids and non-existent hosts.
    HostId one = hostId(string(payload, ONE));
    HostId two = hostId(string(payload, TWO));

    HostToHostIntent intent = HostToHostIntent.builder()
            .appId(appId)
            .one(one)
            .two(two)
            .build();

    services.intent().submit(intent);
    if (overlayCache.isActive(TrafficOverlay.TRAFFIC_ID)) {
        traffic.monitor(intent);
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:18,代码来源:TopologyViewMessageHandler.java


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