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


Java MastershipService.getMasterFor方法代码示例

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


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

示例1: getTableStatistics

import org.onosproject.mastership.MastershipService; //导入方法依赖的package包/类
@Override
public Iterable<TableStatisticsEntry> getTableStatistics(NetworkId networkId, DeviceId deviceId) {
    MastershipService mastershipService =
            vnaService.get(networkId, MastershipService.class);
    NodeId master = mastershipService.getMasterFor(deviceId);

    if (master == null) {
        log.debug("Failed to getTableStats: No master for {}", deviceId);
        return Collections.emptyList();
    }

    if (deviceTableStats.get(networkId) == null) {
        deviceTableStats.put(networkId, Maps.newConcurrentMap());
    }

    List<TableStatisticsEntry> tableStats = deviceTableStats.get(networkId).get(deviceId);
    if (tableStats == null) {
        return Collections.emptyList();
    }
    return ImmutableList.copyOf(tableStats);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:22,代码来源:DistributedVirtualFlowRuleStore.java

示例2: process

import org.onosproject.mastership.MastershipService; //导入方法依赖的package包/类
@Override
public void process(long sid, ObjectNode payload) {
    String id = string(payload, ID, ZERO_URI);

    DeviceId deviceId = deviceId(id);
    DeviceService service = get(DeviceService.class);
    MastershipService ms = get(MastershipService.class);
    Device device = service.getDevice(deviceId);
    ObjectNode data = objectNode();
    NodeId masterFor = ms.getMasterFor(deviceId);

    data.put(ID, deviceId.toString());
    data.put(NAME, deviceName(device));
    data.put(TYPE, capitalizeFully(device.type().toString()));
    data.put(TYPE_IID, getTypeIconId(device));
    data.put(MFR, device.manufacturer());
    data.put(HW, device.hwVersion());
    data.put(SW, device.swVersion());
    data.put(SERIAL, device.serialNumber());
    data.put(CHASSIS_ID, device.chassisId().toString());
    data.put(MASTER_ID, masterFor != null ? masterFor.toString() : NONE);
    data.put(PROTOCOL, deviceProtocol(device));

    ArrayNode ports = arrayNode();

    List<Port> portList = new ArrayList<>(service.getPorts(deviceId));
    Collections.sort(portList, (p1, p2) -> {
        long delta = p1.number().toLong() - p2.number().toLong();
        return delta == 0 ? 0 : (delta < 0 ? -1 : +1);
    });

    for (Port p : portList) {
        ports.add(portData(p, deviceId));
    }
    data.set(PORTS, ports);

    ObjectNode rootNode = objectNode();
    rootNode.set(DETAILS, data);
    sendMessage(DEV_DETAILS_RESP, 0, rootNode);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:41,代码来源:DeviceViewMessageHandler.java

示例3: json

import org.onosproject.mastership.MastershipService; //导入方法依赖的package包/类
private JsonNode json(MastershipService service, ObjectMapper mapper,
                      Device device) {
    NodeId master = service.getMasterFor(device.id());
    ObjectNode result = mapper.createObjectNode()
            .put("id", device.id().toString())
            .put("master", master != null ? master.toString() : "none");
    RoleInfo nodes = service.getNodesFor(device.id());
    ArrayNode standbys = mapper.createArrayNode();
    for (NodeId nid : nodes.backups()) {
        standbys.add(nid.toString());
    }
    result.set("standbys", standbys);
    return result;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:15,代码来源:RolesCommand.java

示例4: getFlowEntry

import org.onosproject.mastership.MastershipService; //导入方法依赖的package包/类
@Override
public FlowEntry getFlowEntry(NetworkId networkId, FlowRule rule) {
    MastershipService mastershipService =
            vnaService.get(networkId, MastershipService.class);
    NodeId master = mastershipService.getMasterFor(rule.deviceId());

    if (master == null) {
        log.debug("Failed to getFlowEntry: No master for {}, vnet {}",
                  rule.deviceId(), networkId);
        return null;
    }

    if (Objects.equals(local, master)) {
        return flowTable.getFlowEntry(networkId, rule);
    }

    log.trace("Forwarding getFlowEntry to {}, which is the primary (master) " +
                      "for device {}, vnet {}",
              master, rule.deviceId(), networkId);

    VirtualFlowRule vRule = new VirtualFlowRule(networkId, rule);

    return Tools.futureGetOrElse(clusterCommunicator.sendAndReceive(vRule,
                                                                    GET_FLOW_ENTRY,
                                                                    serializer::encode,
                                                                    serializer::decode,
                                                                    master),
                                 FLOW_RULE_STORE_TIMEOUT_MILLIS,
                                 TimeUnit.MILLISECONDS,
                                 null);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:32,代码来源:DistributedVirtualFlowRuleStore.java

示例5: getFlowEntries

import org.onosproject.mastership.MastershipService; //导入方法依赖的package包/类
@Override
public Iterable<FlowEntry> getFlowEntries(NetworkId networkId, DeviceId deviceId) {
    MastershipService mastershipService =
            vnaService.get(networkId, MastershipService.class);
    NodeId master = mastershipService.getMasterFor(deviceId);

    if (master == null) {
        log.debug("Failed to getFlowEntries: No master for {}, vnet {}", deviceId, networkId);
        return Collections.emptyList();
    }

    if (Objects.equals(local, master)) {
        return flowTable.getFlowEntries(networkId, deviceId);
    }

    log.trace("Forwarding getFlowEntries to {}, which is the primary (master) for device {}",
              master, deviceId);

    return Tools.futureGetOrElse(
            clusterCommunicator.sendAndReceive(deviceId,
                                               GET_DEVICE_FLOW_ENTRIES,
                                               serializer::encode,
                                               serializer::decode,
                                               master),
            FLOW_RULE_STORE_TIMEOUT_MILLIS,
            TimeUnit.MILLISECONDS,
            Collections.emptyList());
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:29,代码来源:DistributedVirtualFlowRuleStore.java

示例6: addOrUpdateFlowRule

import org.onosproject.mastership.MastershipService; //导入方法依赖的package包/类
@Override
public FlowRuleEvent addOrUpdateFlowRule(NetworkId networkId, FlowEntry rule) {
    MastershipService mastershipService =
            vnaService.get(networkId, MastershipService.class);
    NodeId master = mastershipService.getMasterFor(rule.deviceId());
    if (Objects.equals(local, master)) {
        return addOrUpdateFlowRuleInternal(networkId, rule);
    }

    log.warn("Tried to update FlowRule {} state,"
                     + " while the Node was not the master.", rule);
    return null;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:14,代码来源:DistributedVirtualFlowRuleStore.java

示例7: removeFlowRule

import org.onosproject.mastership.MastershipService; //导入方法依赖的package包/类
@Override
public FlowRuleEvent removeFlowRule(NetworkId networkId, FlowEntry rule) {
    final DeviceId deviceId = rule.deviceId();

    MastershipService mastershipService =
            vnaService.get(networkId, MastershipService.class);
    NodeId master = mastershipService.getMasterFor(deviceId);

    if (Objects.equals(local, master)) {
        // bypass and handle it locally
        return removeFlowRuleInternal(new VirtualFlowEntry(networkId, rule));
    }

    if (master == null) {
        log.warn("Failed to removeFlowRule: No master for {}", deviceId);
        // TODO: revisit if this should be null (="no-op") or Exception
        return null;
    }

    log.trace("Forwarding removeFlowRule to {}, which is the master for device {}",
              master, deviceId);

    return Futures.getUnchecked(clusterCommunicator.sendAndReceive(
            new VirtualFlowEntry(networkId, rule),
            REMOVE_FLOW_ENTRY,
            serializer::encode,
            serializer::decode,
            master));
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:30,代码来源:DistributedVirtualFlowRuleStore.java

示例8: handle

import org.onosproject.mastership.MastershipService; //导入方法依赖的package包/类
@Override
public void handle(final ClusterMessage message) {
    VirtualFlowRuleBatchOperation vOperation = serializer.decode(message.payload());
    log.debug("received batch request {}", vOperation);

    FlowRuleBatchOperation operation = vOperation.operation();

    final DeviceId deviceId = operation.deviceId();
    MastershipService mastershipService =
            vnaService.get(vOperation.networkId(), MastershipService.class);
    NodeId master = mastershipService.getMasterFor(deviceId);
    if (!Objects.equals(local, master)) {
        Set<FlowRule> failures = new HashSet<>(operation.size());
        for (FlowRuleBatchEntry op : operation.getOperations()) {
            failures.add(op.target());
        }
        CompletedBatchOperation allFailed = new CompletedBatchOperation(false, failures, deviceId);
        // This node is no longer the master, respond as all failed.
        // TODO: we might want to wrap response in envelope
        // to distinguish sw programming failure and hand over
        // it make sense in the latter case to retry immediately.
        message.respond(serializer.encode(allFailed));
        return;
    }

    pendingResponses.put(operation.id(), message.sender());
    storeBatchInternal(vOperation.networkId(), operation);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:29,代码来源:DistributedVirtualFlowRuleStore.java

示例9: process

import org.onosproject.mastership.MastershipService; //导入方法依赖的package包/类
@Override
public void process(ObjectNode payload) {
    String id = string(payload, ID, ZERO_URI);

    DeviceId deviceId = deviceId(id);
    DeviceService service = get(DeviceService.class);
    MastershipService ms = get(MastershipService.class);
    Device device = service.getDevice(deviceId);
    ObjectNode data = objectNode();
    NodeId masterFor = ms.getMasterFor(deviceId);

    data.put(ID, deviceId.toString());
    data.put(NAME, deviceName(device));
    data.put(TYPE, capitalizeFully(device.type().toString()));
    data.put(TYPE_IID, getTypeIconId(device));
    data.put(MFR, device.manufacturer());
    data.put(HW, device.hwVersion());
    data.put(SW, device.swVersion());
    data.put(SERIAL, device.serialNumber());
    data.put(CHASSIS_ID, device.chassisId().toString());
    data.put(MASTER_ID, masterFor != null ? masterFor.toString() : NONE);
    data.put(PROTOCOL, deviceProtocol(device));
    data.put(PIPECONF, devicePipeconf(device));

    ArrayNode ports = arrayNode();

    List<Port> portList = new ArrayList<>(service.getPorts(deviceId));
    portList.sort((p1, p2) -> {
        long delta = p1.number().toLong() - p2.number().toLong();
        return delta == 0 ? 0 : (delta < 0 ? -1 : +1);
    });

    for (Port p : portList) {
        ports.add(portData(p, deviceId));
    }
    data.set(PORTS, ports);

    ObjectNode rootNode = objectNode();
    rootNode.set(DETAILS, data);

    // NOTE: ... an alternate way of getting all the details of an item:
    // Use the codec context to get a JSON of the device. See ONOS-5976.
    rootNode.set(DEVICE, getJsonCodecContext().encode(device, Device.class));

    sendMessage(DEV_DETAILS_RESP, rootNode);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:47,代码来源:DeviceViewMessageHandler.java


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