當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultPartition類代碼示例

本文整理匯總了Java中org.onosproject.cluster.DefaultPartition的典型用法代碼示例。如果您正苦於以下問題:Java DefaultPartition類的具體用法?Java DefaultPartition怎麽用?Java DefaultPartition使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DefaultPartition類屬於org.onosproject.cluster包,在下文中一共展示了DefaultPartition類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildDefaultPartitions

import org.onosproject.cluster.DefaultPartition; //導入依賴的package包/類
private static Set<Partition> buildDefaultPartitions(Collection<ControllerNode> nodes) {
    List<ControllerNode> sorted = new ArrayList<>(nodes);
    Collections.sort(sorted, (o1, o2) -> o1.id().toString().compareTo(o2.id().toString()));
    Set<Partition> partitions = Sets.newHashSet();
    // add partitions
    int length = nodes.size();
    int count = Math.min(3, length);
    for (int i = 0; i < length; i++) {
        int index = i;
        Set<NodeId> set = new HashSet<>(count);
        for (int j = 0; j < count; j++) {
            set.add(sorted.get((i + j) % length).id());
        }
        partitions.add(new DefaultPartition(PartitionId.from((index + 1)), set));
    }
    return partitions;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:18,代碼來源:ClusterManager.java

示例2: activate

import org.onosproject.cluster.DefaultPartition; //導入依賴的package包/類
@Activate
public void activate() {
    String localIp = getSiteLocalAddress();
    ControllerNode localNode =
            new DefaultControllerNode(new NodeId(localIp), IpAddress.valueOf(localIp), DEFAULT_ONOS_PORT);
    // partition 1
    Partition partition = new DefaultPartition(PartitionId.from(1), ImmutableSet.of(localNode.id()));
    ClusterMetadata metadata = new ClusterMetadata(PROVIDER_ID,
                                    "default",
                                    ImmutableSet.of(localNode),
                                    ImmutableSet.of(partition));
    long version = System.currentTimeMillis();
    cachedMetadata.set(new Versioned<>(metadata, version));
    providerRegistry.register(this);
    log.info("Started");
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:17,代碼來源:DefaultClusterMetadataProvider.java

示例3: buildDefaultPartitions

import org.onosproject.cluster.DefaultPartition; //導入依賴的package包/類
private Set<Partition> buildDefaultPartitions(Collection<ControllerNode> nodes, int partitionSize) {
    List<ControllerNode> sorted = new ArrayList<>(nodes);
    Collections.sort(sorted, (o1, o2) -> o1.id().toString().compareTo(o2.id().toString()));
    Set<Partition> partitions = Sets.newHashSet();
    // add partitions
    int length = nodes.size();
    int count = Math.min(partitionSize, length);
    for (int i = 0; i < length; i++) {
        int index = i;
        Set<NodeId> set = new HashSet<>(count);
        for (int j = 0; j < count; j++) {
            set.add(sorted.get((i + j) % length).id());
        }
        partitions.add(new DefaultPartition(PartitionId.from((index + 1)), versionService.version(), set));
    }
    return partitions;
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:18,代碼來源:ClusterManager.java

示例4: activate

import org.onosproject.cluster.DefaultPartition; //導入依賴的package包/類
@Activate
public void activate() {
    partition = new ActiveStoragePartition(
            new DefaultPartition(
                    PartitionId.SHARED,
                    null,
                    clusterService.getNodes()
                            .stream()
                            .map(ControllerNode::id)
                            .collect(Collectors.toSet())),
            clusterCommunicator,
            clusterService);
    partition.open().join();
    primitiveCreator = partition.client();
    log.info("Started");
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:17,代碼來源:CoordinationManager.java

示例5: testComputeInitialIncompletePartition

import org.onosproject.cluster.DefaultPartition; //導入依賴的package包/類
@Test
public void testComputeInitialIncompletePartition() throws Exception {
    Partition sourcePartition = new DefaultPartition(
            PartitionId.from(1),
            Version.version("1.0.0"),
            Arrays.asList(
                    NodeId.nodeId("1"),
                    NodeId.nodeId("2"),
                    NodeId.nodeId("3")));
    Version targetVersion = Version.version("1.0.1");
    List<NodeId> members = Arrays.asList(
            NodeId.nodeId("1"),
            NodeId.nodeId("2"));
    Partition forkedPartition = PartitionManager.computeInitialPartition(sourcePartition, targetVersion, members);
    assertTrue(forkedPartition.getMembers().size() == 2);
    assertTrue(forkedPartition.getMembers().contains(NodeId.nodeId("1")));
    assertTrue(forkedPartition.getMembers().contains(NodeId.nodeId("2")));
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:19,代碼來源:PartitionManagerTest.java

示例6: testComputeInitialCompletePartition

import org.onosproject.cluster.DefaultPartition; //導入依賴的package包/類
@Test
public void testComputeInitialCompletePartition() throws Exception {
    Partition sourcePartition = new DefaultPartition(
            PartitionId.from(1),
            Version.version("1.0.0"),
            Arrays.asList(
                    NodeId.nodeId("3"),
                    NodeId.nodeId("4"),
                    NodeId.nodeId("5")));
    Version targetVersion = Version.version("1.0.1");
    List<NodeId> members = Arrays.asList(
            NodeId.nodeId("1"),
            NodeId.nodeId("2"),
            NodeId.nodeId("3"),
            NodeId.nodeId("4"),
            NodeId.nodeId("5"));
    Partition forkedPartition = PartitionManager.computeInitialPartition(sourcePartition, targetVersion, members);
    assertTrue(forkedPartition.getMembers().size() == 4);
    assertTrue(forkedPartition.getMembers().contains(NodeId.nodeId("1")));
    assertTrue(forkedPartition.getMembers().contains(NodeId.nodeId("3")));
    assertTrue(forkedPartition.getMembers().contains(NodeId.nodeId("4")));
    assertTrue(forkedPartition.getMembers().contains(NodeId.nodeId("5")));
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:24,代碼來源:PartitionManagerTest.java

示例7: testComputeFinalIncompletePartition

import org.onosproject.cluster.DefaultPartition; //導入依賴的package包/類
@Test
public void testComputeFinalIncompletePartition() throws Exception {
    Partition sourcePartition = new DefaultPartition(
            PartitionId.from(1),
            Version.version("1.0.0"),
            Arrays.asList(
                    NodeId.nodeId("1"),
                    NodeId.nodeId("2"),
                    NodeId.nodeId("3")));
    Version targetVersion = Version.version("1.0.1");
    List<NodeId> members = Arrays.asList(
            NodeId.nodeId("1"),
            NodeId.nodeId("2"));
    Partition forkedPartition = PartitionManager.computeFinalPartition(sourcePartition, targetVersion, members);
    assertTrue(forkedPartition.getMembers().size() == 2);
    assertTrue(forkedPartition.getMembers().contains(NodeId.nodeId("1")));
    assertTrue(forkedPartition.getMembers().contains(NodeId.nodeId("2")));
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:19,代碼來源:PartitionManagerTest.java

示例8: testComputeFinalCompletePartition

import org.onosproject.cluster.DefaultPartition; //導入依賴的package包/類
@Test
public void testComputeFinalCompletePartition() throws Exception {
    Partition sourcePartition = new DefaultPartition(
            PartitionId.from(1),
            Version.version("1.0.0"),
            Arrays.asList(
                    NodeId.nodeId("3"),
                    NodeId.nodeId("4"),
                    NodeId.nodeId("5")));
    Version targetVersion = Version.version("1.0.1");
    List<NodeId> members = Arrays.asList(
            NodeId.nodeId("1"),
            NodeId.nodeId("2"),
            NodeId.nodeId("3"),
            NodeId.nodeId("4"),
            NodeId.nodeId("5"));
    Partition forkedPartition = PartitionManager.computeFinalPartition(sourcePartition, targetVersion, members);
    assertTrue(forkedPartition.getMembers().size() == 3);
    assertTrue(forkedPartition.getMembers().contains(NodeId.nodeId("3")));
    assertTrue(forkedPartition.getMembers().contains(NodeId.nodeId("4")));
    assertTrue(forkedPartition.getMembers().contains(NodeId.nodeId("5")));
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:23,代碼來源:PartitionManagerTest.java

示例9: computePartition

import org.onosproject.cluster.DefaultPartition; //導入依賴的package包/類
/**
 * Computes a forked partition from the given source partition.
 *
 * @param sourcePartition the source partition from which to compute the partition
 * @param targetVersion the target partition version
 * @param members the set of members available to the partition
 * @param delta the number of additional members to preserve outside the partition
 * @return the computed forked partition
 */
private static Partition computePartition(
        Partition sourcePartition,
        Version targetVersion,
        List<NodeId> members,
        int delta) {
    // Create a collection of members of the forked/isolated partition. Initial membership
    // will include up to n upgraded nodes until all n nodes in the partition have been upgraded.
    List<NodeId> sortedMembers = members.stream()
            .sorted()
            .collect(Collectors.toList());

    // Create a list of members of the partition that have been upgraded according to the
    // version isolated cluster membership.
    List<NodeId> partitionMembers = sortedMembers.stream()
            .filter(nodeId -> sourcePartition.getMembers().contains(nodeId))
            .collect(Collectors.toList());

    // If additional members need to be added to the partition to make up a full member list,
    // add members in sorted order to create deterministic rebalancing of nodes.
    int totalMembers = sourcePartition.getMembers().size() + delta;
    if (partitionMembers.size() < totalMembers) {
        for (int i = partitionMembers.size(); i < totalMembers; i++) {
            Optional<NodeId> nextMember = sortedMembers.stream()
                    .filter(nodeId -> !partitionMembers.contains(nodeId))
                    .findFirst();
            if (nextMember.isPresent()) {
                partitionMembers.add(nextMember.get());
            } else {
                break;
            }
        }
    }

    return new DefaultPartition(
            sourcePartition.getId(),
            targetVersion,
            partitionMembers);
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:48,代碼來源:PartitionManager.java

示例10: deserialize

import org.onosproject.cluster.DefaultPartition; //導入依賴的package包/類
@Override
public Partition deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    return jp.readValueAs(DefaultPartition.class);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:6,代碼來源:ConfigFileBasedClusterMetadataProvider.java


注:本文中的org.onosproject.cluster.DefaultPartition類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。