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


Java Validation.validateType方法代码示例

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


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

示例1: checkMandatoryAttr

import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
 * Checks mandatory attributes are presents, if not present throws exception.
 *
 * @param isOrigin say whether origin attribute is present
 * @param isAsPath say whether aspath attribute is present
 * @param isNextHop say whether nexthop attribute is present
 * @param isMpReach say whether mpreach attribute is present
 * @param isMpUnReach say whether mpunreach attribute is present
 * @throws BgpParseException if mandatory path attribute is not present
 */
public static void checkMandatoryAttr(boolean isOrigin, boolean isAsPath,
        boolean isNextHop, boolean isMpReach, boolean isMpUnReach)
        throws BgpParseException {
    // Mandatory attributes validation not required for MP_UNREACH
    if (isMpUnReach) {
        return;
    }

    if (!isOrigin) {
        log.debug("Mandatory Attributes not Present");
        Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
                BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
                Origin.ORIGIN_TYPE);
    }
    if (!isAsPath) {
        log.debug("Mandatory Attributes not Present");
        Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
                BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
                AsPath.ASPATH_TYPE);
    }
    if (!isMpUnReach && !isMpReach && !isNextHop) {
        log.debug("Mandatory Attributes not Present");
        Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
                BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
                NextHop.NEXTHOP_TYPE);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:38,代码来源:BgpPathAttributes.java

示例2: checkMandatoryAttr

import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
/**
 * Checks mandatory attributes are presents, if not present throws exception.
 *
 * @param isOrigin say whether origin attribute is present
 * @param isAsPath say whether aspath attribute is present
 * @param isNextHop say whether nexthop attribute is present
 * @param isMpReach say whether mpreach attribute is present
 * @param isMpUnReach say whether mpunreach attribute is present
 * @throws BgpParseException if mandatory path attribute is not present
 */
public static void checkMandatoryAttr(boolean isOrigin, boolean isAsPath,
        boolean isNextHop, boolean isMpReach, boolean isMpUnReach)
        throws BgpParseException {
    // Mandatory attributes validation not required for MP_UNREACH
    if (isMpUnReach) {
        return;
    }

    if (!isOrigin) {
        log.debug("Mandatory attributes not Present");
        Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
                BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
                Origin.ORIGIN_TYPE);
    }
    if (!isAsPath) {
        log.debug("Mandatory attributes not Present");
        Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
                BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
                AsPath.ASPATH_TYPE);
    }
    if (!isMpReach && !isNextHop) {
        log.debug("Mandatory attributes not Present");
        Validation.validateType(BgpErrorType.UPDATE_MESSAGE_ERROR,
                BgpErrorType.MISSING_WELLKNOWN_ATTRIBUTE,
                NextHop.NEXTHOP_TYPE);
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:38,代码来源:BgpPathAttributes.java

示例3: readFrom

import org.onosproject.bgpio.util.Validation; //导入方法依赖的package包/类
@Override
public BgpMessage readFrom(ChannelBuffer cb, BgpHeader bgpHeader)
        throws BgpParseException {

    if (cb.readableBytes() < MINIMUM_COMMON_HEADER_LENGTH) {
        log.error("Packet should have minimum length.");
        Validation.validateLen(BgpErrorType.MESSAGE_HEADER_ERROR, BgpErrorType.BAD_MESSAGE_LENGTH,
                               cb.readableBytes());
    }
    if (cb.readableBytes() > MAXIMUM_PACKET_LENGTH) {
        log.error("Packet length should not exceed {}.", MAXIMUM_PACKET_LENGTH);
        Validation.validateLen(BgpErrorType.MESSAGE_HEADER_ERROR, BgpErrorType.BAD_MESSAGE_LENGTH,
                               cb.readableBytes());
    }
    try {
        // fixed value property version == 4
        byte[] marker = new byte[BgpHeader.MARKER_LENGTH];
        cb.readBytes(marker, 0, BgpHeader.MARKER_LENGTH);
        bgpHeader.setMarker(marker);
        for (int i = 0; i < BgpHeader.MARKER_LENGTH; i++) {
            if (marker[i] != (byte) 0xff) {
                throw new BgpParseException(BgpErrorType.MESSAGE_HEADER_ERROR,
                                            BgpErrorType.CONNECTION_NOT_SYNCHRONIZED, null);
            }
        }
        short length = cb.readShort();
        if (length > cb.readableBytes() + HEADER_AND_MSG_LEN) {
            Validation.validateLen(BgpErrorType.MESSAGE_HEADER_ERROR,
                                   BgpErrorType.BAD_MESSAGE_LENGTH, length);
        }
        bgpHeader.setLength(length);
        byte type = cb.readByte();
        bgpHeader.setType(type);
        log.debug("Reading update message of type " + type);

        int len = length - MINIMUM_COMMON_HEADER_LENGTH;
        switch (type) {
        case OPEN_MSG_TYPE:
            log.debug("OPEN MESSAGE is received");
            return BgpOpenMsgVer4.READER.readFrom(cb.readBytes(len), bgpHeader);
        case KEEPALIVE_MSG_TYPE:
            log.debug("KEEPALIVE MESSAGE is received");
            return BgpKeepaliveMsgVer4.READER.readFrom(cb.readBytes(len), bgpHeader);
        case UPDATE_MSG_TYPE:
            log.debug("UPDATE MESSAGE is received");
            return BgpUpdateMsgVer4.READER.readFrom(cb.readBytes(len), bgpHeader);
        case NOTIFICATION_MSG_TYPE:
            log.debug("NOTIFICATION MESSAGE is received");
            return BgpNotificationMsgVer4.READER.readFrom(cb.readBytes(len), bgpHeader);
        default:
            Validation.validateType(BgpErrorType.MESSAGE_HEADER_ERROR, BgpErrorType.BAD_MESSAGE_TYPE, type);
            return null;
        }
    } catch (IndexOutOfBoundsException e) {
        throw new BgpParseException(BgpErrorType.MESSAGE_HEADER_ERROR,
                                    BgpErrorType.BAD_MESSAGE_LENGTH, null);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:59,代码来源:BgpMessageVer4.java


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