Search in sources :

Example 11 with IgniteProductVersion

use of org.apache.ignite.lang.IgniteProductVersion in project ignite by apache.

the class GridProductVersionSelfTest method testFromString.

/**
 * @throws Exception If failed.
 */
@Test
public void testFromString() throws Exception {
    IgniteProductVersion ver = IgniteProductVersion.fromString("1.2.3");
    assertEquals(1, ver.major());
    assertEquals(2, ver.minor());
    assertEquals(3, ver.maintenance());
    assertEquals("", ver.stage());
    assertEquals(0, ver.revisionTimestamp());
    assertArrayEquals(new byte[20], ver.revisionHash());
    ver = IgniteProductVersion.fromString("1.2.3-0-DEV");
    assertEquals(1, ver.major());
    assertEquals(2, ver.minor());
    assertEquals(3, ver.maintenance());
    assertEquals(0, ver.revisionTimestamp());
    assertArrayEquals(new byte[20], ver.revisionHash());
    ver = IgniteProductVersion.fromString("1.2.3.b1-4-DEV");
    assertEquals(1, ver.major());
    assertEquals(2, ver.minor());
    assertEquals(3, ver.maintenance());
    assertEquals("b1", ver.stage());
    assertEquals(4, ver.revisionTimestamp());
    assertArrayEquals(new byte[20], ver.revisionHash());
    ver = IgniteProductVersion.fromString("1.2.3.final-4-DEV");
    assertEquals(1, ver.major());
    assertEquals(2, ver.minor());
    assertEquals(3, ver.maintenance());
    assertEquals("final", ver.stage());
    assertEquals(4, ver.revisionTimestamp());
    assertArrayEquals(new byte[20], ver.revisionHash());
    ver = IgniteProductVersion.fromString("1.2.3");
    assertEquals(1, ver.major());
    assertEquals(2, ver.minor());
    assertEquals(3, ver.maintenance());
    assertEquals("", ver.stage());
    assertEquals(0, ver.revisionTimestamp());
    assertArrayEquals(new byte[20], ver.revisionHash());
    ver = IgniteProductVersion.fromString("1.2.3-4");
    assertEquals(1, ver.major());
    assertEquals(2, ver.minor());
    assertEquals(3, ver.maintenance());
    assertEquals("", ver.stage());
    assertEquals(4, ver.revisionTimestamp());
    assertArrayEquals(new byte[20], ver.revisionHash());
    ver = IgniteProductVersion.fromString("1.2.3-4-18e5a7ec9e3202126a69bc231a6b965bc1d73dee");
    assertEquals(1, ver.major());
    assertEquals(2, ver.minor());
    assertEquals(3, ver.maintenance());
    assertEquals("", ver.stage());
    assertEquals(4, ver.revisionTimestamp());
    assertArrayEquals(new byte[] { 24, -27, -89, -20, -98, 50, 2, 18, 106, 105, -68, 35, 26, 107, -106, 91, -63, -41, 61, -18 }, ver.revisionHash());
    ver = IgniteProductVersion.fromString("1.2.3.b1-4-18e5a7ec9e3202126a69bc231a6b965bc1d73dee");
    assertEquals(1, ver.major());
    assertEquals(2, ver.minor());
    assertEquals(3, ver.maintenance());
    assertEquals("b1", ver.stage());
    assertEquals(4, ver.revisionTimestamp());
    assertArrayEquals(new byte[] { 24, -27, -89, -20, -98, 50, 2, 18, 106, 105, -68, 35, 26, 107, -106, 91, -63, -41, 61, -18 }, ver.revisionHash());
    ver = IgniteProductVersion.fromString("1.2.3-rc1-4-18e5a7ec9e3202126a69bc231a6b965bc1d73dee");
    assertEquals(1, ver.major());
    assertEquals(2, ver.minor());
    assertEquals(3, ver.maintenance());
    assertEquals("rc1", ver.stage());
    assertEquals(4, ver.revisionTimestamp());
    assertArrayEquals(new byte[] { 24, -27, -89, -20, -98, 50, 2, 18, 106, 105, -68, 35, 26, 107, -106, 91, -63, -41, 61, -18 }, ver.revisionHash());
    ver = IgniteProductVersion.fromString("1.2.3-SNAPSHOT-4-18e5a7ec9e3202126a69bc231a6b965bc1d73dee");
    assertEquals(1, ver.major());
    assertEquals(2, ver.minor());
    assertEquals(3, ver.maintenance());
    assertEquals("SNAPSHOT", ver.stage());
    assertEquals(4, ver.revisionTimestamp());
    assertArrayEquals(new byte[] { 24, -27, -89, -20, -98, 50, 2, 18, 106, 105, -68, 35, 26, 107, -106, 91, -63, -41, 61, -18 }, ver.revisionHash());
    ver = IgniteProductVersion.fromString("1.2.3.b1-SNAPSHOT-4-18e5a7ec9e3202126a69bc231a6b965bc1d73dee");
    assertEquals(1, ver.major());
    assertEquals(2, ver.minor());
    assertEquals(3, ver.maintenance());
    assertEquals("b1-SNAPSHOT", ver.stage());
    assertEquals(4, ver.revisionTimestamp());
    assertArrayEquals(new byte[] { 24, -27, -89, -20, -98, 50, 2, 18, 106, 105, -68, 35, 26, 107, -106, 91, -63, -41, 61, -18 }, ver.revisionHash());
    IgniteProductVersion.fromString(VER_STR + '-' + BUILD_TSTAMP + '-' + REV_HASH_STR);
}
Also used : IgniteProductVersion(org.apache.ignite.lang.IgniteProductVersion) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 12 with IgniteProductVersion

use of org.apache.ignite.lang.IgniteProductVersion in project ignite by apache.

the class IgniteUtilsSelfTest method testIsOldestNodeVersionAtLeast.

/**
 */
@Test
public void testIsOldestNodeVersionAtLeast() {
    IgniteProductVersion v240 = IgniteProductVersion.fromString("2.4.0");
    IgniteProductVersion v241 = IgniteProductVersion.fromString("2.4.1");
    IgniteProductVersion v250 = IgniteProductVersion.fromString("2.5.0");
    IgniteProductVersion v250ts = IgniteProductVersion.fromString("2.5.0-b1-3");
    TcpDiscoveryNode node240 = new TcpDiscoveryNode();
    node240.version(v240);
    TcpDiscoveryNode node241 = new TcpDiscoveryNode();
    node241.version(v241);
    TcpDiscoveryNode node250 = new TcpDiscoveryNode();
    node250.version(v250);
    TcpDiscoveryNode node250ts = new TcpDiscoveryNode();
    node250ts.version(v250ts);
    assertTrue(U.isOldestNodeVersionAtLeast(v240, asList(node240, node241, node250, node250ts)));
    assertFalse(U.isOldestNodeVersionAtLeast(v241, asList(node240, node241, node250, node250ts)));
    assertTrue(U.isOldestNodeVersionAtLeast(v250, asList(node250, node250ts)));
    assertTrue(U.isOldestNodeVersionAtLeast(v250ts, asList(node250, node250ts)));
}
Also used : IgniteProductVersion(org.apache.ignite.lang.IgniteProductVersion) TcpDiscoveryNode(org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode) GridCommonTest(org.apache.ignite.testframework.junits.common.GridCommonTest) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 13 with IgniteProductVersion

use of org.apache.ignite.lang.IgniteProductVersion in project ignite by apache.

the class GridCachePartitionExchangeManager method onExchangeDone.

/**
     * @param exchFut Exchange.
     * @param err Error.
     */
public void onExchangeDone(GridDhtPartitionsExchangeFuture exchFut, @Nullable Throwable err) {
    AffinityTopologyVersion topVer = exchFut.topologyVersion();
    if (log.isDebugEnabled())
        log.debug("Exchange done [topVer=" + topVer + ", fut=" + exchFut + ", err=" + err + ']');
    IgniteProductVersion minVer = cctx.localNode().version();
    IgniteProductVersion maxVer = cctx.localNode().version();
    if (err == null) {
        if (!F.isEmpty(exchFut.discoveryEvent().topologyNodes())) {
            for (ClusterNode node : exchFut.discoveryEvent().topologyNodes()) {
                IgniteProductVersion ver = node.version();
                if (ver.compareTo(minVer) < 0)
                    minVer = ver;
                if (ver.compareTo(maxVer) > 0)
                    maxVer = ver;
            }
        }
    }
    nodeVers.put(topVer, new IgnitePair<>(minVer, maxVer));
    AffinityTopologyVersion histVer = new AffinityTopologyVersion(topVer.topologyVersion() - 10, 0);
    for (AffinityTopologyVersion oldVer : nodeVers.headMap(histVer).keySet()) nodeVers.remove(oldVer);
    if (err == null) {
        while (true) {
            AffinityTopologyVersion readyVer = readyTopVer.get();
            if (readyVer.compareTo(topVer) >= 0)
                break;
            if (readyTopVer.compareAndSet(readyVer, topVer))
                break;
        }
        for (Map.Entry<AffinityTopologyVersion, AffinityReadyFuture> entry : readyFuts.entrySet()) {
            if (entry.getKey().compareTo(topVer) <= 0) {
                if (log.isDebugEnabled())
                    log.debug("Completing created topology ready future " + "[ver=" + topVer + ", fut=" + entry.getValue() + ']');
                entry.getValue().onDone(topVer);
            }
        }
    } else {
        for (Map.Entry<AffinityTopologyVersion, AffinityReadyFuture> entry : readyFuts.entrySet()) {
            if (entry.getKey().compareTo(topVer) <= 0) {
                if (log.isDebugEnabled())
                    log.debug("Completing created topology ready future with error " + "[ver=" + topVer + ", fut=" + entry.getValue() + ']');
                entry.getValue().onDone(err);
            }
        }
    }
    ExchangeFutureSet exchFuts0 = exchFuts;
    if (exchFuts0 != null) {
        int skipped = 0;
        for (GridDhtPartitionsExchangeFuture fut : exchFuts0.values()) {
            if (exchFut.exchangeId().topologyVersion().compareTo(fut.exchangeId().topologyVersion()) < 0)
                continue;
            skipped++;
            if (skipped > 10)
                fut.cleanUp();
        }
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) IgniteProductVersion(org.apache.ignite.lang.IgniteProductVersion) Map(java.util.Map) NavigableMap(java.util.NavigableMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) GridDhtPartitionFullMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap) GridDhtPartitionMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) TreeMap(java.util.TreeMap)

Example 14 with IgniteProductVersion

use of org.apache.ignite.lang.IgniteProductVersion in project ignite by apache.

the class IdleVerify method execute.

/**
 * {@inheritDoc}
 */
@Override
public Object execute(GridClientConfiguration clientCfg, Logger logger) throws Exception {
    try (GridClient client = Command.startClient(clientCfg)) {
        Collection<GridClientNode> nodes = client.compute().nodes(GridClientNode::connectable);
        boolean idleVerifyV2 = true;
        for (GridClientNode node : nodes) {
            String nodeVerStr = node.attribute(IgniteNodeAttributes.ATTR_BUILD_VER);
            IgniteProductVersion nodeVer = IgniteProductVersion.fromString(nodeVerStr);
            if (nodeVer.compareTo(VerifyBackupPartitionsTaskV2.V2_SINCE_VER) < 0) {
                idleVerifyV2 = false;
                break;
            }
        }
        if (args.dump())
            cacheIdleVerifyDump(client, clientCfg, logger);
        else if (idleVerifyV2)
            cacheIdleVerifyV2(client, clientCfg);
        else
            legacyCacheIdleVerify(client, clientCfg, logger);
    }
    return null;
}
Also used : GridClientNode(org.apache.ignite.internal.client.GridClientNode) IgniteProductVersion(org.apache.ignite.lang.IgniteProductVersion) GridClient(org.apache.ignite.internal.client.GridClient)

Example 15 with IgniteProductVersion

use of org.apache.ignite.lang.IgniteProductVersion in project ignite by apache.

the class GridDiscoveryManager method createDiscoCache.

/**
 * Called from discovery thread.
 *
 * @param topVer Topology version.
 * @param state Current state.
 * @param loc Local node.
 * @param topSnapshot Topology snapshot.
 * @return Newly created discovery cache.
 */
@NotNull
private DiscoCache createDiscoCache(AffinityTopologyVersion topVer, DiscoveryDataClusterState state, ClusterNode loc, Collection<ClusterNode> topSnapshot) {
    assert topSnapshot.contains(loc);
    HashSet<UUID> alives = U.newHashSet(topSnapshot.size());
    HashMap<UUID, ClusterNode> nodeMap = U.newHashMap(topSnapshot.size());
    ArrayList<ClusterNode> daemonNodes = new ArrayList<>(topSnapshot.size());
    ArrayList<ClusterNode> srvNodes = new ArrayList<>(topSnapshot.size());
    ArrayList<ClusterNode> rmtNodes = new ArrayList<>(topSnapshot.size());
    ArrayList<ClusterNode> allNodes = new ArrayList<>(topSnapshot.size());
    Map<UUID, Short> nodeIdToConsIdx;
    Map<Short, UUID> consIdxToNodeId;
    List<? extends BaselineNode> baselineNodes;
    IgniteProductVersion minVer = null;
    IgniteProductVersion minSrvVer = null;
    for (ClusterNode node : topSnapshot) {
        if (alive(node))
            alives.add(node.id());
        if (node.isDaemon())
            daemonNodes.add(node);
        else {
            allNodes.add(node);
            if (!node.isLocal())
                rmtNodes.add(node);
            if (!node.isClient()) {
                srvNodes.add(node);
                if (minSrvVer == null)
                    minSrvVer = node.version();
                else if (node.version().compareTo(minSrvVer) < 0)
                    minSrvVer = node.version();
            }
        }
        nodeMap.put(node.id(), node);
        if (minVer == null)
            minVer = node.version();
        else if (node.version().compareTo(minVer) < 0)
            minVer = node.version();
    }
    assert !rmtNodes.contains(loc) : "Remote nodes collection shouldn't contain local node" + " [rmtNodes=" + rmtNodes + ", loc=" + loc + ']';
    BaselineTopology blt = state.baselineTopology();
    if (blt != null) {
        nodeIdToConsIdx = U.newHashMap(srvNodes.size());
        consIdxToNodeId = U.newHashMap(srvNodes.size());
        Map<Object, Short> m = blt.consistentIdMapping();
        Map<Object, ClusterNode> aliveNodesByConsId = U.newHashMap(srvNodes.size());
        for (ClusterNode node : srvNodes) {
            Short compactedId = m.get(node.consistentId());
            if (compactedId != null) {
                nodeIdToConsIdx.put(node.id(), compactedId);
                consIdxToNodeId.put(compactedId, node.id());
            }
            aliveNodesByConsId.put(node.consistentId(), node);
        }
        List<BaselineNode> baselineNodes0 = new ArrayList<>(blt.size());
        for (Object consId : blt.consistentIds()) {
            ClusterNode srvNode = aliveNodesByConsId.get(consId);
            if (srvNode != null)
                baselineNodes0.add(srvNode);
            else
                baselineNodes0.add(blt.baselineNode(consId));
        }
        baselineNodes = baselineNodes0;
    } else {
        nodeIdToConsIdx = null;
        consIdxToNodeId = null;
        baselineNodes = null;
    }
    Map<Integer, List<ClusterNode>> allCacheNodes = U.newHashMap(allNodes.size());
    Map<Integer, List<ClusterNode>> cacheGrpAffNodes = U.newHashMap(allNodes.size());
    Set<ClusterNode> rmtNodesWithCaches = new TreeSet<>(NodeOrderComparator.getInstance());
    fillAffinityNodeCaches(allNodes, allCacheNodes, cacheGrpAffNodes, rmtNodesWithCaches, nodeIdToConsIdx == null ? null : nodeIdToConsIdx.keySet());
    return new DiscoCache(topVer, state, loc, Collections.unmodifiableList(rmtNodes), Collections.unmodifiableList(allNodes), Collections.unmodifiableList(srvNodes), Collections.unmodifiableList(daemonNodes), U.sealList(rmtNodesWithCaches), baselineNodes == null ? null : Collections.unmodifiableList(baselineNodes), Collections.unmodifiableMap(allCacheNodes), Collections.unmodifiableMap(cacheGrpAffNodes), Collections.unmodifiableMap(nodeMap), alives, nodeIdToConsIdx == null ? null : Collections.unmodifiableMap(nodeIdToConsIdx), consIdxToNodeId == null ? null : Collections.unmodifiableMap(consIdxToNodeId), minVer, minSrvVer);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) IgniteProductVersion(org.apache.ignite.lang.IgniteProductVersion) BaselineNode(org.apache.ignite.cluster.BaselineNode) IgniteSystemProperties.getInteger(org.apache.ignite.IgniteSystemProperties.getInteger) TreeSet(java.util.TreeSet) BaselineTopology(org.apache.ignite.internal.processors.cluster.BaselineTopology) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) List(java.util.List) UUID(java.util.UUID) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

IgniteProductVersion (org.apache.ignite.lang.IgniteProductVersion)18 Map (java.util.Map)6 UUID (java.util.UUID)5 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 ClusterNode (org.apache.ignite.cluster.ClusterNode)3 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)3 Test (org.junit.Test)3 SQLException (java.sql.SQLException)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 BinaryReaderExImpl (org.apache.ignite.internal.binary.BinaryReaderExImpl)2 BinaryWriterExImpl (org.apache.ignite.internal.binary.BinaryWriterExImpl)2 BinaryHeapInputStream (org.apache.ignite.internal.binary.streams.BinaryHeapInputStream)2 BinaryHeapOutputStream (org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream)2 GroupKeyEncrypted (org.apache.ignite.internal.managers.encryption.GroupKeyEncrypted)2 CheckpointRecord (org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord)2 DataRecord (org.apache.ignite.internal.pagemem.wal.record.DataRecord)2 IndexRenameRootPageRecord (org.apache.ignite.internal.pagemem.wal.record.IndexRenameRootPageRecord)2 MasterKeyChangeRecordV2 (org.apache.ignite.internal.pagemem.wal.record.MasterKeyChangeRecordV2)2