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


Java NodeId.equals方法代码示例

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


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

示例1: create

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
private boolean create(LabelResourcePool pool) {
    Device device = deviceService.getDevice(pool.deviceId());
    if (device == null) {
        return false;
    }

    NodeId master = mastershipService.getMasterFor(pool.deviceId());

    if (master == null) {
        log.warn("Failed to create label resource pool: No master for {}", pool);
        return false;
    }

    if (master.equals(clusterService.getLocalNode().id())) {
        return internalCreate(pool);
    }

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

    return complete(clusterCommunicator
            .sendAndReceive(pool,
                            LabelResourceMessageSubjects.LABEL_POOL_CREATED,
                            SERIALIZER::encode, SERIALIZER::decode,
                            master));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:DistributedLabelResourceStore.java

示例2: getRole

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
@Override
public MastershipRole getRole(NodeId nodeId, DeviceId deviceId) {
    //just query
    NodeId current = masterMap.get(deviceId);
    MastershipRole role;

    if (current != null && current.equals(nodeId)) {
        return MastershipRole.MASTER;
    }

    if (backups.getOrDefault(deviceId, Collections.emptyList()).contains(nodeId)) {
        role = MastershipRole.STANDBY;
    } else {
        role = MastershipRole.NONE;
    }
    return role;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:SimpleMastershipStore.java

示例3: setStandby

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
@Override
public CompletableFuture<MastershipEvent> setStandby(NodeId nodeId, DeviceId deviceId) {
    checkArgument(nodeId != null, NODE_ID_NULL);
    checkArgument(deviceId != null, DEVICE_ID_NULL);

    NodeId currentMaster = getMaster(deviceId);
    if (!nodeId.equals(currentMaster)) {
        return CompletableFuture.completedFuture(null);
    }

    String leadershipTopic = createDeviceMastershipTopic(deviceId);
    List<NodeId> candidates = leadershipService.getCandidates(leadershipTopic);

    NodeId newMaster = candidates.stream()
                                 .filter(candidate -> !Objects.equal(nodeId, candidate))
                                 .findFirst()
                                 .orElse(null);
    log.info("Transitioning to role {} for {}. Next master: {}",
            newMaster != null ? MastershipRole.STANDBY : MastershipRole.NONE, deviceId, newMaster);

    if (newMaster != null) {
        return setMaster(newMaster, deviceId);
    }
    return relinquishRole(nodeId, deviceId);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:ConsistentDeviceMastershipStore.java

示例4: relinquishRole

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
@Override
public CompletableFuture<MastershipEvent> relinquishRole(NodeId nodeId, DeviceId deviceId) {
    checkArgument(nodeId != null, NODE_ID_NULL);
    checkArgument(deviceId != null, DEVICE_ID_NULL);

    if (nodeId.equals(localNodeId)) {
        return relinquishLocalRole(deviceId);
    }

    log.debug("Forwarding request to relinquish "
            + "role for device {} to {}", deviceId, nodeId);
    return clusterCommunicator.sendAndReceive(
            deviceId,
            ROLE_RELINQUISH_SUBJECT,
            SERIALIZER::encode,
            SERIALIZER::decode,
            nodeId);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:ConsistentDeviceMastershipStore.java

示例5: getCurrentStatistic

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
@Override
public Set<FlowEntry> getCurrentStatistic(ConnectPoint connectPoint) {
    final DeviceId deviceId = connectPoint.deviceId();
    NodeId master = mastershipService.getMasterFor(deviceId);
    if (master == null) {
        log.warn("No master for {}", deviceId);
        return Collections.emptySet();
    }
    if (master.equals(clusterService.getLocalNode().id())) {
        return getCurrentStatisticInternal(connectPoint);
    } else {
        return Tools.futureGetOrElse(clusterCommunicator.sendAndReceive(
                                    connectPoint,
                                    GET_CURRENT,
                                    SERIALIZER::encode,
                                    SERIALIZER::decode,
                                    master),
                               STATISTIC_STORE_TIMEOUT_MILLIS,
                               TimeUnit.MILLISECONDS,
                               Collections.emptySet());
    }

}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:DistributedStatisticStore.java

示例6: getPreviousStatistic

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
@Override
public Set<FlowEntry> getPreviousStatistic(ConnectPoint connectPoint) {
    final DeviceId deviceId = connectPoint.deviceId();
    NodeId master = mastershipService.getMasterFor(deviceId);
    if (master == null) {
        log.warn("No master for {}", deviceId);
        return Collections.emptySet();
    }
    if (master.equals(clusterService.getLocalNode().id())) {
        return getPreviousStatisticInternal(connectPoint);
    } else {
        return Tools.futureGetOrElse(clusterCommunicator.sendAndReceive(
                                    connectPoint,
                                    GET_PREVIOUS,
                                    SERIALIZER::encode,
                                    SERIALIZER::decode,
                                    master),
                               STATISTIC_STORE_TIMEOUT_MILLIS,
                               TimeUnit.MILLISECONDS,
                               Collections.emptySet());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:DistributedStatisticStore.java

示例7: emit

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
@Override
public void emit(OutboundPacket packet) {
    NodeId myId = clusterService.getLocalNode().id();
    NodeId master = mastershipService.getMasterFor(packet.sendThrough());

    if (master == null) {
        return;
    }

    if (myId.equals(master)) {
        notifyDelegate(new PacketEvent(Type.EMIT, packet));
        return;
    }

    communicationService.unicast(packet, PACKET_OUT_SUBJECT, SERIALIZER::encode, master)
                        .whenComplete((r, error) -> {
                            if (error != null) {
                                log.warn("Failed to send packet-out to {}", master, error);
                            }
                        });
}
 
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:DistributedPacketStore.java

示例8: destroyDevicePool

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
@Override
public boolean destroyDevicePool(DeviceId deviceId) {
    Device device = deviceService.getDevice(deviceId);
    if (device == null) {
        return false;
    }

    NodeId master = mastershipService.getMasterFor(deviceId);

    if (master == null) {
        log.warn("Failed to destroyDevicePool. No master for {}", deviceId);
        return false;
    }

    if (master.equals(clusterService.getLocalNode().id())) {
        return internalDestroy(deviceId);
    }

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

    return complete(clusterCommunicator
            .sendAndReceive(deviceId,
                            LabelResourceMessageSubjects.LABEL_POOL_DESTROYED,
                            SERIALIZER::encode, SERIALIZER::decode,
                            master));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:DistributedLabelResourceStore.java

示例9: applyFromDevicePool

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
@Override
public Collection<LabelResource> applyFromDevicePool(DeviceId deviceId,
                                                     long applyNum) {
    Device device = deviceService.getDevice(deviceId);
    if (device == null) {
        return Collections.emptyList();
    }
    LabelResourceRequest request = new LabelResourceRequest(deviceId,
                                                            LabelResourceRequest.Type.APPLY,
                                                            applyNum, null);
    NodeId master = mastershipService.getMasterFor(deviceId);

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

    if (master.equals(clusterService.getLocalNode().id())) {
        return internalApply(request);
    }

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

    return complete(clusterCommunicator
            .sendAndReceive(request,
                            LabelResourceMessageSubjects.LABEL_POOL_APPLY,
                            SERIALIZER::encode, SERIALIZER::decode,
                            master));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:31,代码来源:DistributedLabelResourceStore.java

示例10: updatePortBandwidth

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
/**
 * Updates bandwidth resource of given connect point.
 * @param cp Connect point
 * @param bandwidth New bandwidth
 */
private void updatePortBandwidth(ConnectPoint cp, Bandwidth bandwidth) {
    NodeId localNode = clusterService.getLocalNode().id();
    NodeId sourceMaster = mastershipService.getMasterFor(cp.deviceId());
    if (localNode.equals(sourceMaster)) {
        log.debug("update Port {} Bandwidth {}", cp, bandwidth);
        BandwidthCapacity bwCapacity = networkConfigService.addConfig(cp, BandwidthCapacity.class);
        bwCapacity.capacity(bandwidth).apply();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:15,代码来源:OpticalPathProvisioner.java

示例11: processLeaderChange

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
private synchronized void processLeaderChange(NodeId newLeader) {
    boolean currLeader = newLeader.equals(localId);
    if (isLeader.getAndSet(currLeader) != currLeader) {
        if (currLeader) {
            scheduleBalance();
        } else {
            cancelBalance();
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:11,代码来源:MastershipLoadBalancer.java

示例12: reelect

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
private synchronized NodeId reelect(DeviceId did, NodeId nodeId) {
    List<NodeId> stbys = backups.getOrDefault(did, Collections.emptyList());
    NodeId backup = null;
    for (NodeId n : stbys) {
        if (!n.equals(nodeId)) {
            backup = n;
            break;
        }
    }
    stbys.remove(backup);
    return backup;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:13,代码来源:SimpleMastershipStore.java

示例13: setupLightpath

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
private void setupLightpath(Intent intent) {
    checkNotNull(intent);

    // TODO change the coordination approach between packet intents and optical intents
    // Low speed LLDP may cause multiple calls which are not expected

    if (intentService.getIntentState(intent.key()) != IntentState.FAILED) {
        return;
    }

    // Get source and destination based on intent type
    ConnectPoint src;
    ConnectPoint dst;
    if (intent instanceof HostToHostIntent) {
        HostToHostIntent hostToHostIntent = (HostToHostIntent) intent;

        Host one = hostService.getHost(hostToHostIntent.one());
        Host two = hostService.getHost(hostToHostIntent.two());

        checkNotNull(one);
        checkNotNull(two);

        src = one.location();
        dst = two.location();
    } else if (intent instanceof PointToPointIntent) {
        PointToPointIntent p2pIntent = (PointToPointIntent) intent;

        src = p2pIntent.ingressPoint();
        dst = p2pIntent.egressPoint();
    } else {
        return;
    }

    if (src == null || dst == null) {
        return;
    }

    // Ignore if we're not the master for the intent's origin device
    NodeId localNode = clusterService.getLocalNode().id();
    NodeId sourceMaster = mastershipService.getMasterFor(src.deviceId());
    if (!localNode.equals(sourceMaster)) {
        return;
    }

    // Generate optical connectivity intents
    List<Intent> intents = getOpticalIntents(src, dst);

    // Submit the intents
    for (Intent i : intents) {
        intentService.submit(i);
        log.debug("Submitted an intent: {}", i);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:54,代码来源:OpticalPathProvisioner.java

示例14: createOrUpdateDevice

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
@Override
public synchronized DeviceEvent createOrUpdateDevice(ProviderId providerId,
                                                     DeviceId deviceId,
                                                     DeviceDescription deviceDescription) {
    NodeId localNode = clusterService.getLocalNode().id();
    NodeId deviceNode = mastershipService.getMasterFor(deviceId);

    // Process device update only if we're the master,
    // otherwise signal the actual master.
    DeviceEvent deviceEvent = null;
    if (localNode.equals(deviceNode)) {

        final Timestamp newTimestamp = deviceClockService.getTimestamp(deviceId);
        final Timestamped<DeviceDescription> deltaDesc = new Timestamped<>(deviceDescription, newTimestamp);
        final Timestamped<DeviceDescription> mergedDesc;
        final Map<ProviderId, DeviceDescriptions> device = getOrCreateDeviceDescriptionsMap(deviceId);

        synchronized (device) {
            deviceEvent = createOrUpdateDeviceInternal(providerId, deviceId, deltaDesc);
            mergedDesc = device.get(providerId).getDeviceDesc();
        }

        if (deviceEvent != null) {
            log.debug("Notifying peers of a device update topology event for providerId: {} and deviceId: {}",
                     providerId, deviceId);
            notifyPeers(new InternalDeviceEvent(providerId, deviceId, mergedDesc));
        }

    } else {
        // Only forward for ConfigProvider
        // Forwarding was added as a workaround for ONOS-490
        if (!providerId.scheme().equals("cfg")) {
            return null;
        }
        // FIXME Temporary hack for NPE (ONOS-1171).
        // Proper fix is to implement forwarding to master on ConfigProvider
        // redo ONOS-490
        if (deviceNode == null) {
            // silently ignore
            return null;
        }


        DeviceInjectedEvent deviceInjectedEvent = new DeviceInjectedEvent(
                providerId, deviceId, deviceDescription);

        // TODO check unicast return value
        clusterCommunicator.unicast(deviceInjectedEvent, DEVICE_INJECTED, SERIALIZER::encode, deviceNode);
        /* error log:
        log.warn("Failed to process injected device id: {} desc: {} " +
                        "(cluster messaging failed: {})",
                deviceId, deviceDescription, e);
        */
    }

    return deviceEvent;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:58,代码来源:GossipDeviceStore.java

示例15: removeDevice

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
@Override
public synchronized DeviceEvent removeDevice(DeviceId deviceId) {
    final NodeId myId = clusterService.getLocalNode().id();
    NodeId master = mastershipService.getMasterFor(deviceId);

    // if there exist a master, forward
    // if there is no master, try to become one and process

    boolean relinquishAtEnd = false;
    if (master == null) {
        final MastershipRole myRole = mastershipService.getLocalRole(deviceId);
        if (myRole != MastershipRole.NONE) {
            relinquishAtEnd = true;
        }
        log.debug("Temporarily requesting role for {} to remove", deviceId);
        mastershipService.requestRoleFor(deviceId);
        MastershipTerm term = termService.getMastershipTerm(deviceId);
        if (term != null && myId.equals(term.master())) {
            master = myId;
        }
    }

    if (!myId.equals(master)) {
        log.debug("{} has control of {}, forwarding remove request",
                  master, deviceId);

        // TODO check unicast return value
        clusterCommunicator.unicast(deviceId, DEVICE_REMOVE_REQ, SERIALIZER::encode, master);
         /* error log:
         log.error("Failed to forward {} remove request to {}", deviceId, master, e);
         */

        // event will be triggered after master processes it.
        return null;
    }

    // I have control..

    Timestamp timestamp = deviceClockService.getTimestamp(deviceId);
    DeviceEvent event = removeDeviceInternal(deviceId, timestamp);
    if (event != null) {
        log.debug("Notifying peers of a device removed topology event for deviceId: {}",
                  deviceId);
        notifyPeers(new InternalDeviceRemovedEvent(deviceId, timestamp));
    }
    if (relinquishAtEnd) {
        log.debug("Relinquishing temporary role acquired for {}", deviceId);
        mastershipService.relinquishMastership(deviceId);
    }
    return event;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:52,代码来源:GossipDeviceStore.java


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