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


Java PcepFactories.getGenericReader方法代码示例

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


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

示例1: decode

import org.onosproject.pcepio.protocol.PcepFactories; //导入方法依赖的package包/类
@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel,
        ChannelBuffer buffer) throws Exception {
    log.debug("Message received.");
    if (!channel.isConnected()) {
        log.info("Channel is not connected.");
        // In testing, I see decode being called AFTER decode last.
        // This check avoids that from reading corrupted frames
        return null;
    }

    HexDump.pcepHexDump(buffer);

    // Buffer can contain multiple messages, also may contain out of bound message.
    // Read the message one by one from buffer and parse it. If it encountered out of bound message,
    // then mark the reader index and again take the next chunk of messages from the channel
    // and parse again from the marked reader index.
    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    List<PcepMessage> msgList = (List<PcepMessage>) ctx.getAttachment();

    if (msgList == null) {
        msgList = new LinkedList<>();
    }

    try {
        while (buffer.readableBytes() > 0) {
            buffer.markReaderIndex();
            PcepMessage message = reader.readFrom(buffer);
            msgList.add(message);
        }
        ctx.setAttachment(null);
        return msgList;
    } catch (PcepOutOfBoundMessageException e) {
        log.debug("PCEP message decode error");
        buffer.resetReaderIndex();
        buffer.discardReadBytes();
        ctx.setAttachment(msgList);
    }
    return null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:41,代码来源:PcepMessageDecoder.java

示例2: tunnelProviderAddedTest2

import org.onosproject.pcepio.protocol.PcepFactories; //导入方法依赖的package包/类
@Test
public void tunnelProviderAddedTest2() throws PcepParseException, PcepOutOfBoundMessageException {
    PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1"));

    byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x50, 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
                                    0x00, 0x00, 0x00, 0x01, // SRP object
                                    0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
                                    0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x00, 0x24, 0x00, // LSP object
                                    0x00, 0x10, (byte) 0xAB,
                                    0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, // symbolic path tlv
                                    0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
                                    0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05,
                                    0x05, 0x05, 0x05,

                                    0x07, 0x10, 0x00, 0x14, // ERO object
                                    0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects
                                    0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, };

    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(reportMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = reader.readFrom(buffer);

    PcepClientImpl pc = new PcepClientImpl();
    PcepPacketStats pktStats = new PcepPacketStatsImpl();

    pc.init(pccId, PcepVersion.PCEP_1, pktStats);
    pc.setChannel(channel);
    pc.setAgent(controllerImpl.agent());
    pc.setConnected(true);
    pc.setCapability(new ClientCapability(true, true, true, true, true));

    controllerImpl.agent().addConnectedClient(pccId, pc);
    controllerImpl.processClientMessage(pccId, message);

    pc.setLspDbSyncStatus(PcepSyncStatus.SYNCED);
    pc.setLabelDbSyncStatus(PcepSyncStatus.IN_SYNC);
    pc.setLabelDbSyncStatus(PcepSyncStatus.SYNCED);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:41,代码来源:PcepClientControllerImplTest.java

示例3: tunnelProviderAddedTest1

import org.onosproject.pcepio.protocol.PcepFactories; //导入方法依赖的package包/类
/**
 * Tests PCRpt msg with sync flag set.
 */
@Test
public void tunnelProviderAddedTest1() throws PcepParseException, PcepOutOfBoundMessageException {
    byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84,
            0x21, 0x10, 0x00, 0x14,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x01, //SRP object
            0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
            0x00, 0x00, 0x00, 0x02,
            0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
            0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
            0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
            0x01, 0x01, 0x01, 0x01,
            0x00, 0x01, 0x00, 0x01,
            0x01, 0x01, 0x01, 0x01,
            0x05, 0x05, 0x05, 0x05,

            0x07, 0x10, 0x00, 0x14, //ERO object
            0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects
            0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,

            0x08, 0x10, 0x00, 0x34, //RRO object
            0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects
            0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00,
            0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00,
            0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00,
            0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00,
            0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00
            };

    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(reportMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = reader.readFrom(buffer);

    DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
    newBuilder.set(PcepTunnelProvider.LSRID, "1.1.1.1");
    newBuilder.set(AnnotationKeys.TYPE, "L3");
    Device device = new DefaultDevice(ProviderId.NONE, DeviceId.deviceId("1.1.1.1"), ROUTER,
            UNKOWN, UNKOWN, UNKOWN,
            UNKOWN, new ChassisId(),
            newBuilder.build());

    deviceService.addDevice(device);
    controller.getClient(PccId.pccId(IpAddress.valueOf("1.1.1.1"))).setCapability(
            new ClientCapability(true, true, true, true, true));
    masterShipService.setMaster(true);
    Link link = DefaultLink.builder()
            .src(new ConnectPoint(device.id(), PortNumber.portNumber(16843009)))
            .dst(new ConnectPoint(device.id(), PortNumber.portNumber(84215045)))
            .state(ACTIVE)
            .type(Link.Type.DIRECT)
            .providerId(ProviderId.NONE)
            .build();
    linkService.addLink(link);
    controller.processClientMessage(PccId.pccId(IpAddress.valueOf("1.1.1.1")), message);

    assertThat(registry.tunnelIdCounter, is((long) 1));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:61,代码来源:PcepTunnelAddedTest.java

示例4: tunnelProviderAddedTest2

import org.onosproject.pcepio.protocol.PcepFactories; //导入方法依赖的package包/类
/**
 * Tests updating an existing tunnel on receiving asynchronous PCRpt msg,
 * i.e. without any SRP id.
 */
@Test
public void tunnelProviderAddedTest2() throws PcepParseException, PcepOutOfBoundMessageException {
    byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x50,
                                   0x21, 0x10, 0x00, 0x14, //SRP object
                                   0x00, 0x00, 0x00, 0x00,
                                   0x00, 0x00, 0x00, 0x00,
                                   0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
                                   0x00, 0x00, 0x00, 0x02,
                                   0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x19, //LSP object
                                   0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path TLV
                                   0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
                                   0x4e, 0x1f, 0x04, 0x00,
                                   0x00, 0x01, 0x00, 0x01,
                                   0x4e, 0x1f, 0x04, 0x00,
                                   0x4e, 0x20, 0x04, 0x00,
                                   0x07, 0x10, 0x00, 0x14, //ERO object
                                   0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, // ERO IPv4 sub objects
                                   0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
                                   };

    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(reportMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = reader.readFrom(buffer);

    // create an existing tunnel.
    IpTunnelEndPoint tunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(0x4e1f0400));
    IpTunnelEndPoint tunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(0x4e200400));

    SparseAnnotations annotations = DefaultAnnotations.builder()
            .set(BANDWIDTH, (new Integer(1)).toString())
            .set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name())
            .set(PCC_TUNNEL_ID, String.valueOf(1))
            .set(PLSP_ID, String.valueOf(1))
            .set(LOCAL_LSP_ID, String.valueOf(1))
            .set(DELEGATE, String.valueOf("true"))
            .build();

    Tunnel tunnel = new DefaultTunnel(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, INIT, null, null,
                                      TunnelName.tunnelName("T123"), null, annotations);
    tunnelService.setupTunnel(null, null, tunnel, null);

    PccId pccId = PccId.pccId(IpAddress.valueOf(0x4e1f0400));
    PcepClientAdapter pc = new PcepClientAdapter();
    pc.init(pccId, PcepVersion.PCEP_1);
    masterShipService.setMaster(true);
    controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true);
    controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));
    controller.getClient(pccId).setLspDbSyncStatus(SYNCED);

    // Process update message.
    controller.processClientMessage(pccId, message);
    assertThat(tunnelService.queryAllTunnels().size(), is(1));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:60,代码来源:PcepTunnelAddedTest.java

示例5: tunnelProviderAddedTest3

import org.onosproject.pcepio.protocol.PcepFactories; //导入方法依赖的package包/类
/**
 * Tests adding a new tunnel on receiving asynchronous PCRpt msg,
 * i.e. without any SRP id.
 */
@Test
public void tunnelProviderAddedTest3() throws PcepParseException, PcepOutOfBoundMessageException {
    byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84,
                                   0x21, 0x10, 0x00, 0x14, //SRP object
                                   0x00, 0x00, 0x00, 0x00,
                                   0x00, 0x00, 0x00, 0x00,
                                   0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
                                   0x00, 0x00, 0x00, 0x02,
                                   0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x1B, // LSP object
                                   0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV
                                   0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
                                   0x01, 0x01, 0x01, 0x01,
                                   0x00, 0x01, 0x00, 0x01,
                                   0x01, 0x01, 0x01, 0x01,
                                   0x05, 0x05, 0x05, 0x05,

                                   0x07, 0x10, 0x00, 0x14, //ERO object
                                   0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects
                                   0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,

                                   0x08, 0x10, 0x00, 0x34, //RRO object
                                   0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects
                                   0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00,
                                   0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00,
                                   0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00,
                                   0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00,
                                   0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00
                                   };

    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(reportMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = reader.readFrom(buffer);

    DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
    newBuilder.set(PcepTunnelProvider.LSRID, "1.1.1.1");
    newBuilder.set(AnnotationKeys.TYPE, "L3");
    Device device = new DefaultDevice(ProviderId.NONE, DeviceId.deviceId("1.1.1.1"), ROUTER,
            UNKOWN, UNKOWN, UNKOWN,
            UNKOWN, new ChassisId(),
            newBuilder.build());

    deviceService.addDevice(device);

    PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1"));
    controller.getClient(pccId).setLspDbSyncStatus(SYNCED);
    controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));

    Link link = DefaultLink.builder()
            .src(new ConnectPoint(device.id(), PortNumber.portNumber(16843009)))
            .dst(new ConnectPoint(device.id(), PortNumber.portNumber(84215045)))
            .state(ACTIVE)
            .type(Link.Type.DIRECT)
            .providerId(ProviderId.NONE)
            .build();
    linkService.addLink(link);
    PcepClientAdapter pc = new PcepClientAdapter();
    pc.init(pccId, PcepVersion.PCEP_1);
    controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true);
    masterShipService.setMaster(true);
    controller.processClientMessage(pccId, message);

    assertThat(registry.tunnelIdCounter, is((long) 1));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:70,代码来源:PcepTunnelAddedTest.java

示例6: tunnelProviderAddedTest5

import org.onosproject.pcepio.protocol.PcepFactories; //导入方法依赖的package包/类
/**
 * Tests adding PCC Init LSP after LSP DB sync is over.
 */
@Test
public void tunnelProviderAddedTest5() throws PcepParseException, PcepOutOfBoundMessageException {
    byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84,
                                   0x21, 0x10, 0x00, 0x14, //SRP object
                                   0x00, 0x00, 0x00, 0x00,
                                   0x00, 0x00, 0x00, 0x00,
                                   0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
                                   0x00, 0x00, 0x00, 0x02,
                                   0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x19, // LSP object
                                   0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV
                                   0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
                                   0x01, 0x01, 0x01, 0x01,
                                   0x00, 0x01, 0x00, 0x01,
                                   0x01, 0x01, 0x01, 0x01,
                                   0x05, 0x05, 0x05, 0x05,

                                   0x07, 0x10, 0x00, 0x14, //ERO object
                                   0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects
                                   0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00,

                                   0x08, 0x10, 0x00, 0x34, //RRO object
                                   0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects
                                   0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00,
                                   0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00,
                                   0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00,
                                   0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00,
                                   0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00
                                   };

    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(reportMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = reader.readFrom(buffer);

    DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
    newBuilder.set(PcepTunnelProvider.LSRID, "1.1.1.1");
    newBuilder.set(AnnotationKeys.TYPE, "L3");
    Device device = new DefaultDevice(ProviderId.NONE, DeviceId.deviceId("1.1.1.1"), ROUTER,
            UNKOWN, UNKOWN, UNKOWN,
            UNKOWN, new ChassisId(),
            newBuilder.build());

    deviceService.addDevice(device);

    PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1"));
    controller.getClient(pccId).setLspDbSyncStatus(SYNCED);
    controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));

    PcepClientAdapter pc = new PcepClientAdapter();
    pc.init(pccId, PcepVersion.PCEP_1);
    controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true);
    masterShipService.setMaster(true);
    controller.processClientMessage(pccId, message);

    assertThat(registry.tunnelIdCounter, is((long) 0));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:61,代码来源:PcepTunnelAddedTest.java

示例7: tunnelProviderAddedTest1

import org.onosproject.pcepio.protocol.PcepFactories; //导入方法依赖的package包/类
@Test
public void tunnelProviderAddedTest1() throws PcepParseException, PcepOutOfBoundMessageException {
    PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1"));

    byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x50, 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
                                    0x00, 0x00, 0x00, 0x01, // SRP object
                                    0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
                                    0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x00, 0x24, // LSP object
                                    0x00, 0x00, 0x10, (byte) 0xAB,
                                    0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, // symbolic path tlv
                                    0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV
                                    0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05,
                                    0x05, 0x05, 0x05,

                                    0x07, 0x10, 0x00, 0x14, // ERO object
                                    0x01, 0x08, (byte) 0x01, 0x01, // ERO IPv4 sub objects
                                    0x01, 0x01, 0x04, 0x00,
                                    0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, };

    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(reportMsg);

    PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
    PcepMessage message = reader.readFrom(buffer);

    PcepClientImpl pc = new PcepClientImpl();
    PcepPacketStats pktStats = new PcepPacketStatsImpl();

    pc.init(pccId, PcepVersion.PCEP_1, pktStats);
    pc.setChannel(channel);
    pc.setAgent(controllerImpl.agent());
    pc.setConnected(true);
    pc.setCapability(new ClientCapability(true, true, true, true, true));

    controllerImpl.agent().addConnectedClient(pccId, pc);
    controllerImpl.processClientMessage(pccId, message);

    pc.setLspDbSyncStatus(PcepSyncStatus.SYNCED);
    pc.setLabelDbSyncStatus(PcepSyncStatus.IN_SYNC);
    pc.setLabelDbSyncStatus(PcepSyncStatus.SYNCED);

    List<PcepMessage> deleteMsgs = ((MockChannel) channel).msgsWritten();
    assertThat(deleteMsgs.size(), is(1));

    for (PcepMessage msg : deleteMsgs) {
        assertThat(((PcepInitiateMsg) msg).getPcInitiatedLspRequestList().getFirst().getSrpObject().getRFlag(),
                   is(true));
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:50,代码来源:PcepClientControllerImplTest.java


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