use of org.apache.ignite.lang.IgniteProductVersion in project ignite by apache.
the class AbstractClientCompatibilityTest method testClient.
/**
* @param serverVer Server version.
*/
private void testClient(String serverVer) {
try {
IgniteProductVersion clientVer = IgniteVersionUtils.VER;
X.println(">>> Started client test [clientVer=" + clientVer + ", serverVer=" + serverVer + ']');
testClient(clientVer, IgniteProductVersion.fromString(serverVer));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.apache.ignite.lang.IgniteProductVersion in project ignite by apache.
the class JavaThinCompatibilityTest method testClient.
/**
* {@inheritDoc}
*/
@Override
protected void testClient(IgniteProductVersion clientVer, IgniteProductVersion serverVer) throws Exception {
IgniteProductVersion minVer = clientVer.compareTo(serverVer) < 0 ? clientVer : serverVer;
testCacheConfiguration(minVer.compareTo(VER_2_7_0) >= 0, minVer.compareTo(VER_2_8_0) >= 0);
testCacheApi();
testBinary();
testQueries();
if (minVer.compareTo(VER_2_5_0) >= 0)
testAuthentication();
if (minVer.compareTo(VER_2_8_0) >= 0) {
testTransactions();
testExpiryPolicy();
}
if (clientVer.compareTo(VER_2_9_0) >= 0 && serverVer.compareTo(VER_2_8_0) >= 0)
testClusterAPI();
if (minVer.compareTo(VER_2_9_0) >= 0) {
testUserAttributes();
testClusterGroups();
testCompute();
testServices();
}
if (clientVer.compareTo(VER_2_11_0) >= 0 && serverVer.compareTo(VER_2_10_0) >= 0)
testContinuousQueries();
if (clientVer.compareTo(VER_2_13_0) >= 0) {
if (serverVer.compareTo(VER_2_13_0) >= 0) {
testServiceDescriptors();
testServicesWithCallerContext();
} else {
testServiceDescriptorsThrows();
testServicesWithCallerContextThrows();
}
}
}
use of org.apache.ignite.lang.IgniteProductVersion in project ignite by apache.
the class IgniteCompatibilityNodeRunner method main.
/**
* Starts {@link Ignite} with test's default configuration.
*
* Command-line arguments specification:
* <pre>
* args[0] - required - path to closure for tuning IgniteConfiguration before node startup;
* args[1] - required - name of the starting node;
* args[2] - required - id of the starting node;
* args[3] - required - sync-id of a node for synchronization of startup. Must be equals
* to arg[2] in case of starting the first node in the Ignite cluster;
* args[4] - required - expected Ignite's version to check at startup;
* args[5] - optional - path to closure for actions after node startup.
* </pre>
*
* @param args Command-line arguments.
* @throws Exception In case of an error.
*/
public static void main(String[] args) throws Exception {
try {
X.println(GridJavaProcess.PID_MSG_PREFIX + U.jvmPid());
X.println("Starting Ignite Node... Args=" + Arrays.toString(args));
if (args.length < 5) {
throw new IllegalArgumentException("At least five arguments expected:" + " [path/to/closure/file] [ignite-instance-name] [node-id] [sync-node-id] [node-ver]" + " [optional/path/to/closure/file]");
}
final Thread watchdog = delayedDumpClasspath();
IgniteConfiguration cfg = CompatibilityTestsFacade.getConfiguration();
IgniteInClosure<IgniteConfiguration> cfgClo = readClosureFromFileAndDelete(args[0]);
cfgClo.apply(cfg);
final UUID nodeId = UUID.fromString(args[2]);
final UUID syncNodeId = UUID.fromString(args[3]);
final IgniteProductVersion expNodeVer = IgniteProductVersion.fromString(args[4]);
// Ignite instance name and id must be set according to arguments
// it's used for nodes managing: start, stop etc.
cfg.setIgniteInstanceName(args[1]);
cfg.setNodeId(nodeId);
final Ignite ignite = Ignition.start(cfg);
assert ignite.cluster().node(syncNodeId) != null : "Node has not joined [id=" + nodeId + "]";
assert ignite.cluster().localNode().version().compareToIgnoreTimestamp(expNodeVer) == 0 : "Node is of unexpected " + "version: [act=" + ignite.cluster().localNode().version() + ", exp=" + expNodeVer + ']';
// It needs to set private static field 'ignite' of the IgniteNodeRunner class via reflection
GridTestUtils.setFieldValue(new IgniteNodeRunner(), "ignite", ignite);
if (args.length == 6) {
IgniteInClosure<Ignite> clo = readClosureFromFileAndDelete(args[5]);
clo.apply(ignite);
}
X.println(IgniteCompatibilityAbstractTest.SYNCHRONIZATION_LOG_MESSAGE + nodeId);
watchdog.interrupt();
} catch (Throwable e) {
e.printStackTrace();
X.println("Dumping classpath, error occurred: " + e);
dumpClasspath();
throw e;
}
}
use of org.apache.ignite.lang.IgniteProductVersion in project ignite by apache.
the class GridDhtPartitionsExchangeFuture method finishExchangeOnCoordinator.
/**
* @param sndResNodes Additional nodes to send finish message to.
*/
private void finishExchangeOnCoordinator(@Nullable Collection<ClusterNode> sndResNodes) {
if (isDone() || !enterBusy())
return;
try {
if (!F.isEmpty(exchangeGlobalExceptions) && dynamicCacheStartExchange() && isRollbackSupported()) {
sendExchangeFailureMessage();
return;
}
AffinityTopologyVersion resTopVer = exchCtx.events().topologyVersion();
if (log.isInfoEnabled()) {
log.info("finishExchangeOnCoordinator [topVer=" + initialVersion() + ", resVer=" + resTopVer + ']');
}
Map<Integer, CacheGroupAffinityMessage> idealAffDiff = null;
// Reserve at least 2 threads for system operations.
int parallelismLvl = U.availableThreadCount(cctx.kernalContext(), GridIoPolicy.SYSTEM_POOL, 2);
if (exchCtx.mergeExchanges()) {
synchronized (mux) {
if (mergedJoinExchMsgs != null) {
for (Map.Entry<UUID, GridDhtPartitionsSingleMessage> e : mergedJoinExchMsgs.entrySet()) {
msgs.put(e.getKey(), e.getValue());
updatePartitionSingleMap(e.getKey(), e.getValue());
}
}
}
assert exchCtx.events().hasServerJoin() || exchCtx.events().hasServerLeft();
exchCtx.events().processEvents(this);
if (exchCtx.events().hasServerLeft())
idealAffDiff = cctx.affinity().onServerLeftWithExchangeMergeProtocol(this);
else
cctx.affinity().onServerJoinWithExchangeMergeProtocol(this, true);
doInParallel(parallelismLvl, cctx.kernalContext().pools().getSystemExecutorService(), cctx.affinity().cacheGroups().values(), desc -> {
if (desc.config().getCacheMode() == CacheMode.LOCAL)
return null;
CacheGroupContext grp = cctx.cache().cacheGroup(desc.groupId());
GridDhtPartitionTopology top = grp != null ? grp.topology() : cctx.exchange().clientTopology(desc.groupId(), events().discoveryCache());
top.beforeExchange(this, true, true);
return null;
});
}
span.addLog(() -> "Affinity recalculation (crd)");
timeBag.finishGlobalStage("Affinity recalculation (crd)");
Map<Integer, CacheGroupAffinityMessage> joinedNodeAff = new ConcurrentHashMap<>(cctx.cache().cacheGroups().size());
doInParallel(parallelismLvl, cctx.kernalContext().pools().getSystemExecutorService(), msgs.values(), msg -> {
processSingleMessageOnCrdFinish(msg, joinedNodeAff);
return null;
});
timeBag.finishGlobalStage("Collect update counters and create affinity messages");
if (firstDiscoEvt.type() == EVT_DISCOVERY_CUSTOM_EVT) {
assert firstDiscoEvt instanceof DiscoveryCustomEvent;
if (activateCluster() || changedBaseline())
assignPartitionsStates(null);
DiscoveryCustomMessage discoveryCustomMessage = ((DiscoveryCustomEvent) firstDiscoEvt).customMessage();
if (discoveryCustomMessage instanceof DynamicCacheChangeBatch) {
if (exchActions != null) {
Set<String> caches = exchActions.cachesToResetLostPartitions();
if (!F.isEmpty(caches))
resetLostPartitions(caches);
Set<Integer> cacheGroupsToResetOwners = concat(exchActions.cacheGroupsToStart().stream().map(grp -> grp.descriptor().groupId()), exchActions.cachesToResetLostPartitions().stream().map(CU::cacheId)).collect(Collectors.toSet());
assignPartitionsStates(cacheGroupsToResetOwners);
}
} else if (discoveryCustomMessage instanceof SnapshotDiscoveryMessage && ((SnapshotDiscoveryMessage) discoveryCustomMessage).needAssignPartitions()) {
markAffinityReassign();
assignPartitionsStates(null);
}
} else if (exchCtx.events().hasServerJoin())
assignPartitionsStates(null);
else if (exchCtx.events().hasServerLeft())
assignPartitionsStates(emptySet());
// Validation should happen after resetting owners to avoid false desync reporting.
validatePartitionsState();
// Recalculate new affinity based on partitions availability.
if (!exchCtx.mergeExchanges() && forceAffReassignment) {
idealAffDiff = cctx.affinity().onCustomEventWithEnforcedAffinityReassignment(this);
timeBag.finishGlobalStage("Ideal affinity diff calculation (enforced)");
}
for (CacheGroupContext grpCtx : cctx.cache().cacheGroups()) {
if (!grpCtx.isLocal())
grpCtx.topology().applyUpdateCounters();
}
timeBag.finishGlobalStage("Apply update counters");
updateLastVersion(cctx.versions().last());
cctx.versions().onExchange(lastVer.get().order());
IgniteProductVersion minVer = exchCtx.events().discoveryCache().minimumNodeVersion();
GridDhtPartitionsFullMessage msg = createPartitionsMessage(true, minVer.compareToIgnoreTimestamp(PARTIAL_COUNTERS_MAP_SINCE) >= 0);
if (!cctx.affinity().rebalanceRequired() && !deactivateCluster())
msg.rebalanced(true);
if (exchCtx.mergeExchanges()) {
assert !centralizedAff;
msg.resultTopologyVersion(resTopVer);
if (exchCtx.events().hasServerLeft())
msg.idealAffinityDiff(idealAffDiff);
} else if (forceAffReassignment)
msg.idealAffinityDiff(idealAffDiff);
msg.prepareMarshal(cctx);
timeBag.finishGlobalStage("Full message preparing");
synchronized (mux) {
finishState = new FinishState(crd.id(), resTopVer, msg);
state = ExchangeLocalState.DONE;
}
if (centralizedAff) {
assert !exchCtx.mergeExchanges();
IgniteInternalFuture<Map<Integer, Map<Integer, List<UUID>>>> fut = cctx.affinity().initAffinityOnNodeLeft(this);
if (!fut.isDone())
fut.listen(this::onAffinityInitialized);
else
onAffinityInitialized(fut);
} else {
Set<ClusterNode> nodes;
Map<UUID, GridDhtPartitionsSingleMessage> mergedJoinExchMsgs0;
synchronized (mux) {
srvNodes.remove(cctx.localNode());
nodes = new LinkedHashSet<>(srvNodes);
mergedJoinExchMsgs0 = mergedJoinExchMsgs;
if (mergedJoinExchMsgs != null) {
for (Map.Entry<UUID, GridDhtPartitionsSingleMessage> e : mergedJoinExchMsgs.entrySet()) {
if (e.getValue() != null) {
ClusterNode node = cctx.discovery().node(e.getKey());
if (node != null)
nodes.add(node);
}
}
} else
mergedJoinExchMsgs0 = Collections.emptyMap();
if (!F.isEmpty(sndResNodes))
nodes.addAll(sndResNodes);
}
if (msg.rebalanced())
markRebalanced();
if (!nodes.isEmpty())
sendAllPartitions(msg, nodes, mergedJoinExchMsgs0, joinedNodeAff);
timeBag.finishGlobalStage("Full message sending");
discoveryLag = calculateDiscoveryLag(msgs, mergedJoinExchMsgs0);
if (!stateChangeExchange())
onDone(exchCtx.events().topologyVersion(), null);
for (Map.Entry<UUID, GridDhtPartitionsSingleMessage> e : pendingSingleMsgs.entrySet()) {
if (log.isInfoEnabled()) {
log.info("Process pending message on coordinator [node=" + e.getKey() + ", ver=" + initialVersion() + ", resVer=" + resTopVer + ']');
}
processSingleMessage(e.getKey(), e.getValue());
}
}
if (stateChangeExchange()) {
StateChangeRequest req = exchActions.stateChangeRequest();
assert req != null : exchActions;
boolean stateChangeErr = false;
if (!F.isEmpty(exchangeGlobalExceptions)) {
stateChangeErr = true;
cctx.kernalContext().state().onStateChangeError(exchangeGlobalExceptions, req);
} else {
boolean hasMoving = !partsToReload.isEmpty();
Set<Integer> waitGrps = cctx.affinity().waitGroups();
if (!hasMoving) {
for (CacheGroupContext grpCtx : cctx.cache().cacheGroups()) {
if (waitGrps.contains(grpCtx.groupId()) && grpCtx.topology().hasMovingPartitions()) {
hasMoving = true;
break;
}
}
}
cctx.kernalContext().state().onExchangeFinishedOnCoordinator(this, hasMoving);
}
if (!cctx.kernalContext().state().clusterState().localBaselineAutoAdjustment()) {
ClusterState state = stateChangeErr ? ClusterState.INACTIVE : req.state();
ChangeGlobalStateFinishMessage stateFinishMsg = new ChangeGlobalStateFinishMessage(req.requestId(), state, !stateChangeErr);
cctx.discovery().sendCustomEvent(stateFinishMsg);
}
timeBag.finishGlobalStage("State finish message sending");
if (!centralizedAff)
onDone(exchCtx.events().topologyVersion(), null);
}
// Try switch late affinity right now if an exchange has been completed normally.
if (!centralizedAff && isDone() && error() == null && !cctx.kernalContext().isStopping())
cctx.exchange().checkRebalanceState();
} catch (IgniteCheckedException e) {
if (reconnectOnError(e))
onDone(new IgniteNeedReconnectException(cctx.localNode(), e));
else
onDone(e);
} finally {
leaveBusy();
}
}
use of org.apache.ignite.lang.IgniteProductVersion in project ignite by apache.
the class AffinityFunctionExcludeNeighborsAbstractSelfTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(final String igniteInstanceName) throws Exception {
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
// Override node attributes in discovery spi.
TcpDiscoverySpi spi = new TcpDiscoverySpi() {
@Override
public void setNodeAttributes(Map<String, Object> attrs, IgniteProductVersion ver) {
super.setNodeAttributes(attrs, ver);
// Set unique mac addresses for every group of three nodes.
String macAddrs = "MOCK_MACS_" + (gridInstanceNum / 3);
attrs.put(IgniteNodeAttributes.ATTR_MACS, macAddrs);
gridInstanceNum++;
}
};
spi.setIpFinder(sharedStaticIpFinder);
c.setDiscoverySpi(spi);
CacheConfiguration cc = defaultCacheConfiguration();
cc.setCacheMode(PARTITIONED);
cc.setBackups(backups);
cc.setAffinity(affinityFunction());
cc.setRebalanceMode(NONE);
c.setCacheConfiguration(cc);
return c;
}
Aggregations