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);
}
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)));
}
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();
}
}
}
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;
}
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);
}
Aggregations