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


Java Policy.type方法代码示例

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


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

示例1: createPolicy

import org.onosproject.segmentrouting.Policy; //导入方法依赖的package包/类
/**
 * Create a new segment routing policy.
 *
 * @param input JSON stream for policy to create
 * @return status of the request - OK if the policy is created,
 * @throws IOException if JSON processing fails
 */
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response createPolicy(InputStream input) throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    ObjectNode policyJson = (ObjectNode) mapper.readTree(input);
    SegmentRoutingService srService = get(SegmentRoutingService.class);
    Policy policyInfo = POLICY_CODEC.decode(policyJson, this);

    if (policyInfo.type() == Policy.Type.TUNNEL_FLOW) {
        srService.createPolicy(policyInfo);
        return Response.ok().build();
    } else {
        return Response.serverError().build();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:PolicyWebResource.java

示例2: encode

import org.onosproject.segmentrouting.Policy; //导入方法依赖的package包/类
@Override
public ObjectNode encode(Policy policy, CodecContext context) {
    final ObjectNode result = context.mapper().createObjectNode()
            .put(POLICY_ID, policy.id());

    result.put(PRIORITY, policy.priority());
    result.put(TYPE, policy.type().toString());

    if (policy.dstIp() != null) {
        result.put(DST_IP, policy.dstIp());
    }
    if (policy.srcIp() != null) {
        result.put(SRC_IP, policy.srcIp());
    }
    if (policy.ipProto() != null) {
        result.put(PROTO_TYPE, policy.ipProto());
    }

    int srcPort = policy.srcPort() & 0xffff;
    if (policy.srcPort() != 0) {
        result.put(SRC_PORT, srcPort);
    }
    int dstPort = policy.dstPort() & 0xffff;
    if (policy.dstPort() != 0) {
        result.put(DST_PORT, dstPort);
    }
    if (policy.type() == Policy.Type.TUNNEL_FLOW) {
        result.put(TUNNEL_ID, ((TunnelPolicy) policy).tunnelId());
    }

    return result;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:33,代码来源:PolicyCodec.java

示例3: printPolicy

import org.onosproject.segmentrouting.Policy; //导入方法依赖的package包/类
private void printPolicy(Policy policy) {
    if (policy.type() == Policy.Type.TUNNEL_FLOW) {
        print(FORMAT_MAPPING_TUNNEL, policy.id(), policy.type(), policy.priority(),
                policy.srcIp(), policy.srcPort(), policy.dstIp(), policy.dstPort(),
                (policy.ipProto() == null) ? "" : policy.ipProto(),
                ((TunnelPolicy) policy).tunnelId());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:PolicyListCommand.java


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