• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java NodeId类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: sendAndReceive

import org.onosproject.cluster.NodeId; //导入依赖的package包/类
@Override
public <M, R> CompletableFuture<R> sendAndReceive(M message,
                                                  MessageSubject subject,
                                                  Function<M, byte[]> encoder,
                                                  Function<byte[], R> decoder,
                                                  NodeId toNodeId) {
    checkPermission(CLUSTER_WRITE);
    try {
        ClusterMessage envelope = new ClusterMessage(
                clusterService.getLocalNode().id(),
                subject,
                timeFunction(encoder, subjectMeteringAgent, SERIALIZING).
                        apply(message));
        return sendAndReceive(subject, envelope.getBytes(), toNodeId).
                thenApply(bytes -> timeFunction(decoder, subjectMeteringAgent, DESERIALIZING).apply(bytes));
    } catch (Exception e) {
        return Tools.exceptionalFuture(e);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:ClusterCommunicationManager.java


示例2: decode

import org.onosproject.cluster.NodeId; //导入依赖的package包/类
@Override
public RoleInfo decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }

    // parse node identifier of master
    NodeId nodeId = json.get(MASTER) == null ?
            null : NodeId.nodeId(json.get(MASTER).asText());

    // parse node identifier of backups
    List<NodeId> backups = new ArrayList<>();

    ArrayNode backupsJson = (ArrayNode) nullIsIllegal(json.get(BACKUPS),
            BACKUPS + MISSING_MEMBER_MESSAGE);

    IntStream.range(0, backupsJson.size()).forEach(i -> {
        JsonNode backupJson = nullIsIllegal(backupsJson.get(i),
                "Backup node id cannot be null");
        backups.add(NodeId.nodeId(backupJson.asText()));
    });

    return new RoleInfo(nodeId, backups);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:RoleInfoCodec.java


示例3: 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


示例4: execute

import org.onosproject.cluster.NodeId; //导入依赖的package包/类
@Override
protected void execute() {
    RegionService regionService = get(RegionService.class);
    RegionAdminService regionAdminService = get(RegionAdminService.class);
    RegionId regionId = RegionId.regionId(id);

    if (regionService.getRegion(regionId) == null) {
        print("The region with id %s does not exist.", regionId);
        return;
    }

    List<Set<NodeId>> masters = Lists.newArrayList();
    Set<NodeId> nodeIds = Sets.newHashSet();
    for (String masterArg : masterArgs) {
        if (masterArg.equals("/")) {
            masters.add(nodeIds);
            nodeIds = Sets.newHashSet();
        } else {
            nodeIds.add(NodeId.nodeId(masterArg));
        }
    }
    masters.add(nodeIds);

    regionAdminService.updateRegion(regionId, name, REGION_TYPE_MAP.get(type), masters);
    print("Region with id %s is successfully updated.", regionId);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:RegionUpdateCommand.java


示例5: checkDeviceMasters

import org.onosproject.cluster.NodeId; //导入依赖的package包/类
private void checkDeviceMasters(Set<DeviceId> deviceIds, Set<NodeId> expectedMasters,
                                 Consumer<DeviceId> checkRole) {
    // each device's master must be contained in the list of expectedMasters
    deviceIds.stream().forEach(deviceId -> {
        assertTrue("wrong master:", expectedMasters.contains(mgr.getMasterFor(deviceId)));
        if (checkRole != null) {
            checkRole.accept(deviceId);
        }
    });
    // each node in expectedMasters must have approximately the same number of devices
    if (expectedMasters.size() > 1) {
        int minValue = Integer.MAX_VALUE;
        int maxDevices = -1;
        for (NodeId nodeId: expectedMasters) {
            int numDevicesManagedByNode = mgr.getDevicesOf(nodeId).size();
            if (numDevicesManagedByNode < minValue) {
                minValue = numDevicesManagedByNode;
            }
            if (numDevicesManagedByNode > maxDevices) {
                maxDevices = numDevicesManagedByNode;
            }
            assertTrue("not balanced:", maxDevices - minValue <= 1);
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:MastershipManagerTest.java


示例6: sendAdvertisementToPeer

import org.onosproject.cluster.NodeId; //导入依赖的package包/类
private void sendAdvertisementToPeer(NodeId peer) {
    long adCreationTime = System.currentTimeMillis();
    AntiEntropyAdvertisement<K> ad = createAdvertisement();
    clusterCommunicator.sendAndReceive(ad,
            antiEntropyAdvertisementSubject,
            serializer::encode,
            serializer::decode,
            peer)
            .whenComplete((result, error) -> {
                if (error != null) {
                    log.debug("Failed to send anti-entropy advertisement to {}", peer, error);
                } else if (result == AntiEntropyResponse.PROCESSED) {
                    antiEntropyTimes.put(peer, adCreationTime);
                }
            });
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:EventuallyConsistentMapImpl.java


示例7: setUpTest

import org.onosproject.cluster.NodeId; //导入依赖的package包/类
/**
 * Sets up the global values for all the tests.
 */
@Before
public void setUpTest() {
    final CodecManager codecService = new CodecManager();
    codecService.activate();
    codecService.registerCodec(ControlLoadSnapshot.class, new ControlLoadSnapshotCodec());
    ServiceDirectory testDirectory =
            new TestServiceDirectory()
                    .add(ControlPlaneMonitorService.class,
                            mockControlPlaneMonitorService)
                    .add(ClusterService.class, mockClusterService)
                    .add(CodecService.class, codecService);
    BaseResource.setServiceDirectory(testDirectory);

    nodeId = new NodeId("1");
    mockControlLoad = new MockControlLoad();
    ControllerNode mockControllerNode = new MockControllerNode(nodeId);

    expect(mockClusterService.getLocalNode()).andReturn(mockControllerNode).anyTimes();
    replay(mockClusterService);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:ControlMetricsResourceTest.java


示例8: decode

import org.onosproject.cluster.NodeId; //导入依赖的package包/类
@Override
public MastershipTerm decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }

    // node identifier of master
    NodeId nodeId = NodeId.nodeId(nullIsIllegal(json.get(MASTER),
            MASTER + MISSING_MEMBER_MESSAGE).asText());

    // term number
    long termNumber = nullIsIllegal(json.get(TERM_NUMBER),
            TERM_NUMBER + MISSING_MEMBER_MESSAGE).asLong();

    return MastershipTerm.of(nodeId, termNumber);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:MastershipTermCodec.java


示例9: promote

import org.onosproject.cluster.NodeId; //导入依赖的package包/类
public ElectionState promote(NodeId nodeId) {
    Registration registration = registrations.stream()
                                          .filter(r -> r.nodeId().equals(nodeId))
                                          .findFirst()
                                          .orElse(null);
    List<Registration> updatedRegistrations = Lists.newArrayList();
    updatedRegistrations.add(registration);
    registrations.stream()
                 .filter(r -> !r.nodeId().equals(nodeId))
                 .forEach(updatedRegistrations::add);
    return new ElectionState(updatedRegistrations,
                            leader,
                            term,
                            termStartTime);

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


示例10: assertInternalDeviceEvent

import org.onosproject.cluster.NodeId; //导入依赖的package包/类
private void assertInternalDeviceEvent(NodeId sender,
        DeviceId deviceId,
        ProviderId providerId,
        DeviceDescription expectedDesc,
        Capture<InternalDeviceEvent> actualEvent,
        Capture<MessageSubject> actualSubject,
        Capture<Function<InternalDeviceEvent, byte[]>> actualEncoder) {
    assertTrue(actualEvent.hasCaptured());
    assertTrue(actualSubject.hasCaptured());
    assertTrue(actualEncoder.hasCaptured());

    assertEquals(GossipDeviceStoreMessageSubjects.DEVICE_UPDATE,
            actualSubject.getValue());
    assertEquals(deviceId, actualEvent.getValue().deviceId());
    assertEquals(providerId, actualEvent.getValue().providerId());
    assertDeviceDescriptionEquals(expectedDesc, actualEvent.getValue().deviceDescription().value());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:GossipDeviceStoreTest.java


示例11: evict

import org.onosproject.cluster.NodeId; //导入依赖的package包/类
public ElectionState evict(NodeId nodeId, Supplier<Long> termCounter) {
    Optional<Registration> registration =
            registrations.stream().filter(r -> r.nodeId.equals(nodeId)).findFirst();
    if (registration.isPresent()) {
        List<Registration> updatedRegistrations =
                registrations.stream()
                .filter(r -> !r.nodeId().equals(nodeId))
                .collect(Collectors.toList());
        if (leader.nodeId().equals(nodeId)) {
            if (updatedRegistrations.size() > 0) {
                return new ElectionState(updatedRegistrations,
                        updatedRegistrations.get(0),
                        termCounter.get(),
                        System.currentTimeMillis());
            } else {
                return new ElectionState(updatedRegistrations, null, term, termStartTime);
            }
        } else {
            return new ElectionState(updatedRegistrations, leader, term, termStartTime);
        }
    } else {
        return this;
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:AtomixLeaderElectorState.java


示例12: createRegion

import org.onosproject.cluster.NodeId; //导入依赖的package包/类
@Override
public Region createRegion(RegionId regionId, String name, Region.Type type,
                           List<Set<NodeId>> masterNodeIds) {
    checkNotNull(regionId, REGION_ID_NULL);
    checkNotNull(name, NAME_NULL);
    checkNotNull(name, REGION_TYPE_NULL);
    return store.createRegion(regionId, name, type, masterNodeIds == null ? of() : masterNodeIds);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:RegionManager.java


示例13: DeviceAntiEntropyAdvertisement

import org.onosproject.cluster.NodeId; //导入依赖的package包/类
public DeviceAntiEntropyAdvertisement(NodeId sender,
            Map<DeviceFragmentId, Timestamp> devices,
            Map<PortFragmentId, Timestamp> ports,
            Map<DeviceId, Timestamp> offline) {
    this.sender = checkNotNull(sender);
    this.deviceFingerPrints = checkNotNull(devices);
    this.portFingerPrints = checkNotNull(ports);
    this.offline = checkNotNull(offline);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:DeviceAntiEntropyAdvertisement.java


示例14: addOrUpdateFlowRule

import org.onosproject.cluster.NodeId; //导入依赖的package包/类
@Override
public FlowRuleEvent addOrUpdateFlowRule(FlowEntry rule) {
    NodeId master = mastershipService.getMasterFor(rule.deviceId());
    if (Objects.equals(local, master)) {
        return addOrUpdateFlowRuleInternal(rule);
    }

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


示例15: testRegionDecode

import org.onosproject.cluster.NodeId; //导入依赖的package包/类
/**
 * Tests decoding of a json object.
 */
@Test
public void testRegionDecode() throws IOException {
    Region region = getRegion("Region.json");
    checkCommonData(region);

    assertThat(region.masters().size(), is(2));

    NodeId nodeId1 = NodeId.nodeId("1");
    NodeId nodeId2 = NodeId.nodeId("2");
    Set<NodeId> nodeIds1 = region.masters().get(0);
    Set<NodeId> nodeIds2 = region.masters().get(1);
    assertThat(nodeIds1.containsAll(ImmutableSet.of(nodeId1)), is(true));
    assertThat(nodeIds2.containsAll(ImmutableSet.of(nodeId1, nodeId2)), is(true));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:RegionCodecTest.java


示例16: getMasterFor

import org.onosproject.cluster.NodeId; //导入依赖的package包/类
@Override
public NodeId getMasterFor(DeviceId deviceId) {
    if (DEVS_TRUNK.contains(deviceId)) {
        return CNID_1;
    }
    if (DEVS_LEFT.contains(deviceId)) {
        return CNID_2;
    }
    if (DEVS_RIGHT.contains(deviceId)) {
        return CNID_3;
    }
    return null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:14,代码来源:AbstractTopoModelTest.java


示例17: basics

import org.onosproject.cluster.NodeId; //导入依赖的package包/类
@Test
public void basics() {
    ImmutableList<Set<NodeId>> masters = ImmutableList
            .of(ImmutableSet.of(nodeId("n1"), nodeId("n2")),
                ImmutableSet.of(nodeId("n3"), nodeId("n4")));
    Region r = new DefaultRegion(ID1, "R1", METRO, masters);
    assertEquals("incorrect id", ID1, r.id());
    assertEquals("incorrect name", "R1", r.name());
    assertEquals("incorrect type", METRO, r.type());
    assertEquals("incorrect masters", masters, r.masters());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:12,代码来源:DefaultRegionTest.java


示例18: jsonToSet

import org.onosproject.cluster.NodeId; //导入依赖的package包/类
private Set<NodeId> jsonToSet(JsonNode nodes) {
    final Set<NodeId> nodeIds = Sets.newHashSet();
    nodes.forEach(node -> nodeIds.add(NodeId.nodeId(node.asText())));
    return nodeIds;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:6,代码来源:RegionJsonMatcher.java


示例19: addSample

import org.onosproject.cluster.NodeId; //导入依赖的package包/类
private synchronized void addSample(long time, NodeId nodeId,
                                    double overallRate, double currentRate) {
    Sample fullSample = createCurrentSampleIfNeeded(time);
    setSampleData(current, nodeId, currentRate);
    setSampleData(overall, nodeId, overallRate);
    pruneSamplesIfNeeded();

    if (fullSample != null && ui != null) {
        ui.reportSample(fullSample);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:12,代码来源:IntentPerfCollector.java


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GenericTypeInfo类代码示例发布时间:2022-05-22
下一篇:
Java BlobstoreInputStream类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap