當前位置: 首頁>>代碼示例>>Java>>正文


Java PcepParseException類代碼示例

本文整理匯總了Java中org.onosproject.pcepio.exceptions.PcepParseException的典型用法代碼示例。如果您正苦於以下問題:Java PcepParseException類的具體用法?Java PcepParseException怎麽用?Java PcepParseException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PcepParseException類屬於org.onosproject.pcepio.exceptions包,在下文中一共展示了PcepParseException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: closeMessageTest1

import org.onosproject.pcepio.exceptions.PcepParseException; //導入依賴的package包/類
/**
 * Common header, reason to close.
 */
@Test
public void closeMessageTest1() throws PcepParseException, PcepOutOfBoundMessageException {

    byte[] closeMsg = new byte[] {0x20, 0x07, 0x00, 0x0C, 0x0f, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02 };

    byte[] testCloseMsg = {0 };
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(closeMsg);

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

    message = reader.readFrom(buffer);
    assertThat(message, instanceOf(PcepCloseMsg.class));

    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);
    testCloseMsg = buf.array();

    int readLen = buf.writerIndex();
    testCloseMsg = new byte[readLen];
    buf.readBytes(testCloseMsg, 0, readLen);
    assertThat(testCloseMsg, is(closeMsg));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:28,代碼來源:PcepCloseMsgTest.java

示例2: read

import org.onosproject.pcepio.exceptions.PcepParseException; //導入依賴的package包/類
/**
 * Reads from channel buffer and returns object of PcepEndPointsObject.
 *
 * @param cb of channel buffer
 * @return object of PcepEndPointsObject
 * @throws PcepParseException while parsing channel buffer
 */
public static PcepEndPointsObject read(ChannelBuffer cb) throws PcepParseException {

    PcepObjectHeader endPointsObjHeader;
    int sourceIpAddress;
    int destIpAddress;

    endPointsObjHeader = PcepObjectHeader.read(cb);
    if (endPointsObjHeader.getObjType() == END_POINTS_OBJ_TYPE
            && endPointsObjHeader.getObjClass() == END_POINTS_OBJ_CLASS) {
        sourceIpAddress = cb.readInt();
        destIpAddress = cb.readInt();
    } else {
        throw new PcepParseException("Expected PcepEndPointsObject.");
    }
    return new PcepEndPointsObjectVer1(endPointsObjHeader, sourceIpAddress, destIpAddress);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:24,代碼來源:PcepEndPointsObjectVer1.java

示例3: build

import org.onosproject.pcepio.exceptions.PcepParseException; //導入依賴的package包/類
@Override
public PcepLabelObject build() throws PcepParseException {
    PcepObjectHeader labelObjHeader = this.bIsHeaderSet ? this.labelObjHeader : DEFAULT_LABEL_OBJECT_HEADER;
    boolean oBit = this.bIsOFlagSet ? this.oBit : DEFAULT_OFLAG;

    if (!this.bIsLabelSet) {
        throw new PcepParseException(" Label NOT Set while building PcepLabelObject.");
    }
    if (bIsPFlagSet) {
        labelObjHeader.setPFlag(bPFlag);
    }
    if (bIsIFlagSet) {
        labelObjHeader.setIFlag(bIFlag);
    }
    return new PcepLabelObjectVer1(labelObjHeader, oBit, this.label, this.optionalTlv);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:17,代碼來源:PcepLabelObjectVer1.java

示例4: read

import org.onosproject.pcepio.exceptions.PcepParseException; //導入依賴的package包/類
@Override
public void read(ChannelBuffer cb) throws PcepParseException {
    PcepObjectHeader tempObjHeader;

    while (0 < cb.readableBytes()) {
        cb.markReaderIndex();
        tempObjHeader = PcepObjectHeader.read(cb);
        cb.resetReaderIndex();
        byte yObjClass = tempObjHeader.getObjClass();
        if ((yObjClass != PcepRPObjectVer1.RP_OBJ_CLASS) && (yObjClass != PcepLSObjectVer1.LS_OBJ_CLASS)
                && (yObjClass != PcepErrorObjectVer1.ERROR_OBJ_CLASS)) {
            throw new PcepParseException("Unknown Object is present in PCEP-ERROR. Object Class: " + yObjClass);
        }

        this.errList.add(PcepErrorVer1.read(cb));
    }
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:18,代碼來源:PcepErrorInfoVer1.java

示例5: parseErrorObjectList

import org.onosproject.pcepio.exceptions.PcepParseException; //導入依賴的package包/類
/**
 * Parse error-obj-list.
 *
 * @param llErrObjList error object list output
 * @param cb channel buffer input
 * @throws PcepParseException if mandatory fields are missing
 * @return error object header
 */
public PcepObjectHeader parseErrorObjectList(List<PcepErrorObject> llErrObjList, ChannelBuffer cb)
        throws PcepParseException {
    PcepObjectHeader tempObjHeader = null;

    while (0 < cb.readableBytes()) {
        cb.markReaderIndex();
        tempObjHeader = PcepObjectHeader.read(cb);
        cb.resetReaderIndex();
        if (tempObjHeader.getObjClass() == PcepErrorObjectVer1.ERROR_OBJ_CLASS) {
            llErrObjList.add(PcepErrorObjectVer1.read(cb));
        } else {
            break;
        }
    }
    return tempObjHeader;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:25,代碼來源:PcepErrorMsgVer1.java

示例6: build

import org.onosproject.pcepio.exceptions.PcepParseException; //導入依賴的package包/類
@Override
public PcepEndPointsObject build() throws PcepParseException {

    PcepObjectHeader endpointsObjHeader = this.bIsHeaderSet ? this.endpointsObjHeader
            : DEFAULT_END_POINTS_OBJECT_HEADER;

    if (bIsPFlagSet) {
        endpointsObjHeader.setPFlag(bPFlag);
    }

    if (bIsIFlagSet) {
        endpointsObjHeader.setIFlag(bIFlag);
    }

    if (!this.bIsSourceIpAddressset) {
        throw new PcepParseException("SourceIpAddress not set while building EndPoints object");
    }

    if (!this.bIsDestIpAddressset) {
        throw new PcepParseException("DestIpAddress not set while building EndPoints object");
    }

    return new PcepEndPointsObjectVer1(endpointsObjHeader, this.sourceIpAddress, this.destIpAddress);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:25,代碼來源:PcepEndPointsObjectVer1.java

示例7: write

import org.onosproject.pcepio.exceptions.PcepParseException; //導入依賴的package包/類
@Override
public int write(ChannelBuffer cb) throws PcepParseException {

    int objStartIndex = cb.writerIndex();

    //Write common header
    int objLenIndex = fecObjHeader.write(cb);
    cb.writeInt(localNodeID);
    cb.writeInt(localInterfaceID);
    cb.writeInt(remoteNodeID);
    cb.writeInt(remoteInterfaceID);

    //Now write FEC IPv4 Unnumbered Adjacency Object Length
    cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));

    return cb.writerIndex();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:18,代碼來源:PcepFecObjectIPv4UnnumberedAdjacencyVer1.java

示例8: initiateMessageTest17

import org.onosproject.pcepio.exceptions.PcepParseException; //導入依賴的package包/類
/**
 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT
 * objects in PcInitiate message.
 */
@Test
public void initiateMessageTest17() throws PcepParseException, PcepOutOfBoundMessageException {

    // SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT.
    //
    byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60,
            0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
            0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
            0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
            (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
            (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
            0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
            0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object
            0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
            0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00};

    byte[] testInitiateCreationMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(initiateCreationMsg);

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

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepInitiateMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();

    message.writeTo(buf);

    testInitiateCreationMsg = buf.array();

    int iReadLen = buf.writerIndex();
    testInitiateCreationMsg = new byte[iReadLen];
    buf.readBytes(testInitiateCreationMsg, 0, iReadLen);

    assertThat(testInitiateCreationMsg, is(initiateCreationMsg));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:44,代碼來源:PcepInitiateMsgExtTest.java

示例9: processPcepMessage

import org.onosproject.pcepio.exceptions.PcepParseException; //導入依賴的package包/類
@Override
void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException {

    //h.channel.getPipeline().remove("waittimeout");
    log.debug("Message received in established state " + m.getType());
    //dispatch the message
    h.dispatchMessage(m);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:9,代碼來源:PcepChannelHandler.java

示例10: read

import org.onosproject.pcepio.exceptions.PcepParseException; //導入依賴的package包/類
/**
 * Reads channel buffer and returns object of PcepLabelRange.
 *
 * @param cb of type channel buffer.
 * @return object of PcepLabelRange
 * @throws PcepParseException when fails to read from channel buffer
 */
public static PcepLabelRange read(ChannelBuffer cb) throws PcepParseException {

    //parse and store SRP mandatory object
    PcepSrpObject srpObj = null;
    srpObj = PcepSrpObjectVer1.read(cb);
    if (srpObj == null) {
        throw new PcepParseException("Exception while parsing srp object");
    }

    LinkedList<PcepLabelRangeObject> llLabelRangeList = new LinkedList<>();
    boolean bFoundLabelRangeObj = false;
    while (0 < cb.readableBytes()) {
        //parse and store <labelrange-list>
        PcepLabelRangeObject lrObj;
        lrObj = PcepLabelRangeObjectVer1.read(cb);
        if (lrObj == null) {
            throw new PcepParseException("Exception while parsing label range object");
        } else {
            llLabelRangeList.add(lrObj);
            bFoundLabelRangeObj = true;
        }
    }

    if (!bFoundLabelRangeObj) {
        throw new PcepParseException("At least one LABEL-RANGE MUST be present.");
    }
    return new PcepLabelRangeVer1(srpObj, llLabelRangeList);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:36,代碼來源:PcepLabelRangeVer1.java

示例11: sendHandshakeOpenMessage

import org.onosproject.pcepio.exceptions.PcepParseException; //導入依賴的package包/類
/**
 * Send handshake open message.
 *
 * @throws IOException,PcepParseException
 */
private void sendHandshakeOpenMessage() throws IOException, PcepParseException {
    PcepOpenObject pcepOpenobj = factory1.buildOpenObject()
            .setSessionId(sessionId)
            .setKeepAliveTime(keepAliveTime)
            .setDeadTime(deadTime)
            .build();
    PcepMessage msg = factory1.buildOpenMsg()
            .setPcepOpenObj(pcepOpenobj)
            .build();
    log.debug("Sending OPEN message to {}", channel.getRemoteAddress());
    channel.write(Collections.singletonList(msg));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:18,代碼來源:PcepChannelHandler.java

示例12: reportMessageTest20

import org.onosproject.pcepio.exceptions.PcepParseException; //導入依賴的package包/類
/**
 * This test case checks for SRP Object,LSP Object,ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object
 * in PcRpt message.
 */
@Test
public void reportMessageTest20() throws PcepParseException, PcepOutOfBoundMessageException {

    byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x88,
            0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object
            0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object
            0x07, 0x10, 0x00, 0x14, //ERO Object
            0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
            0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
            0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
            0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object
            0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object
            0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object
            0x01, 0x01, 0x04, 0x00, 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};

    byte[] testReportMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(reportMsg);

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

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepReportMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);

    int readLen = buf.writerIndex();
    testReportMsg = new byte[readLen];
    buf.readBytes(testReportMsg, 0, readLen);

    assertThat(testReportMsg, is(reportMsg));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:44,代碼來源:PcepReportMsgTest.java

示例13: errorMessageTest9

import org.onosproject.pcepio.exceptions.PcepParseException; //導入依賴的package包/類
/**
 * This test case checks for
 * PCEP-ERROR Object, PCEP-ERROR Object
 * in PcepErrorMsg message.
 */
@Test
public void errorMessageTest9() throws PcepParseException, PcepOutOfBoundMessageException {

    byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x14, // common header
            0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
            0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
            0x00, 0x00, 0x01, 0x01};

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

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

    message = reader.readFrom(buffer);

    byte[] testErrorMsg = {0};
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    assertThat(message, instanceOf(PcepErrorMsg.class));
    message.writeTo(buf);
    int iReadLen = buf.writerIndex();
    testErrorMsg = new byte[iReadLen];
    buf.readBytes(testErrorMsg, 0, iReadLen);

    assertThat(testErrorMsg, is(errorMsg));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:32,代碼來源:PcepErrorMsgTest.java

示例14: pcepUpdateMsgTest11

import org.onosproject.pcepio.exceptions.PcepParseException; //導入依賴的package包/類
/**
 * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
 * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, Metric objects in PcUpd message.
 */
@Test
public void pcepUpdateMsgTest11() throws PcepParseException, PcepOutOfBoundMessageException {

    byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
            0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
            0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
            0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
            0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
            (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
            (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
            0x00, 0x11, 0x00, 0x02,  0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
            0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
            0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
            0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
            0x01, 0x01, 0x04, 0x00,
            0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
            0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object

    byte[] testupdateMsg = {0};
    ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
    buffer.writeBytes(updateMsg);

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

    message = reader.readFrom(buffer);

    assertThat(message, instanceOf(PcepUpdateMsg.class));
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    message.writeTo(buf);
    testupdateMsg = buf.array();

    int readLen = buf.writerIndex() - 0;
    testupdateMsg = new byte[readLen];
    buf.readBytes(testupdateMsg, 0, readLen);

    assertThat(testupdateMsg, is(updateMsg));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:44,代碼來源:PcepUpdateMsgTest.java

示例15: errorMessageTest12

import org.onosproject.pcepio.exceptions.PcepParseException; //導入依賴的package包/類
/**
 * This test case checks for
 * RP Object, PCEP-ERROR Object
 * in PcepErrorMsg message.
 */
@Test
public void errorMessageTest12() throws PcepParseException, PcepOutOfBoundMessageException {

    //RP Object, PCEP-ERROR Object
    byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x18, // common header
            0x02, 0x10, 0x00, 0x0C, // RP Object Header
            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header
            0x00, 0x00, 0x01, 0x01};

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

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

    message = reader.readFrom(buffer);

    byte[] testErrorMsg = {0};
    ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
    assertThat(message, instanceOf(PcepErrorMsg.class));
    message.writeTo(buf);
    int iReadLen = buf.writerIndex();
    testErrorMsg = new byte[iReadLen];
    buf.readBytes(testErrorMsg, 0, iReadLen);

    assertThat(testErrorMsg, is(errorMsg));
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:33,代碼來源:PcepErrorMsgTest.java


注:本文中的org.onosproject.pcepio.exceptions.PcepParseException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。