/** * @param node Node. * @param discoveryDataClusterState Discovery data cluster state. * @return {@code True} if node is included in BaselineTopology. */ public static boolean baselineNode(ClusterNode node, DiscoveryDataClusterState discoveryDataClusterState) { return discoveryDataClusterState.baselineTopology().consistentIds().contains(node.consistentId()); }
/** * Checks whether all conditions to meet BaselineTopology are satisfied. */ private boolean isBaselineSatisfied(BaselineTopology blt, List<ClusterNode> serverNodes) { if (blt == null) return false; if (blt.consistentIds() == null) return false; if (//only node participating in BaselineTopology is allowed to send activation command... blt.consistentIds().contains(ctx.discovery().localNode().consistentId()) //...and with this node BaselineTopology is reached && blt.isSatisfied(serverNodes)) return true; return false; }
@Override public void verify(BaselineTopology blt) { assertNotNull(blt); assertEquals(3, blt.consistentIds().size()); } };
/** {@inheritDoc} */ @Override public long getRowCount() { BaselineTopology blt = ctx.state().clusterState().baselineTopology(); return blt == null ? 0 : blt.consistentIds().size(); } }
/** * @param blt Baseline Topology. */ public static BaselineTopologyHistoryItem fromBaseline(BaselineTopology blt) { if (blt == null) return null; List<Long> fullActivationHistory = new ArrayList<>(blt.branchingHistory().size()); fullActivationHistory.addAll(blt.branchingHistory()); return new BaselineTopologyHistoryItem(blt.id(), U.arrayList(blt.consistentIds()), fullActivationHistory); }
@Override public void verify(BaselineTopology blt) { assertNotNull(blt); assertEquals(4, blt.consistentIds().size()); long activationHash = U.field(blt, "branchingPntHash"); assertEquals(expectedActivationHash, activationHash); } };
@Override public void verify(BaselineTopology blt) { assertNotNull(blt); assertEquals(3, blt.consistentIds().size()); long activationHash = U.field(blt, "branchingPntHash"); assertEquals(expectedHash2, activationHash); } };
@Override public void verify(BaselineTopology blt) { assertNotNull(blt); assertEquals(3, blt.consistentIds().size()); long activationHash = U.field(blt, "branchingPntHash"); assertEquals(expectedHash1, activationHash); } };
/** {@inheritDoc} */ @Override public Iterator<Row> getRows(Session ses, SearchRow first, SearchRow last) { List<Row> rows = new ArrayList<>(); BaselineTopology blt = ctx.state().clusterState().baselineTopology(); if (blt == null) return rows.iterator(); Set<Object> consistentIds = blt.consistentIds(); Collection<ClusterNode> srvNodes = ctx.discovery().aliveServerNodes(); Set<Object> aliveNodeIds = new HashSet<>(F.nodeConsistentIds(srvNodes)); for (Object consistentId : consistentIds) { rows.add( createRow( ses, consistentId, aliveNodeIds.contains(consistentId) ) ); } return rows.iterator(); }
/** */ @Nullable private Collection<Object> onlineBaselineNodesRequestedForRemoval( Collection<? extends BaselineNode> newBlt) { BaselineTopology blt = ctx.state().clusterState().baselineTopology(); Set<Object> bltConsIds; if (blt == null) return null; else bltConsIds = blt.consistentIds(); ArrayList<Object> onlineNodesRequestedForRemoval = new ArrayList<>(); Collection<Object> aliveNodesConsIds = getConsistentIds(ctx.discovery().aliveServerNodes()); Collection<Object> newBltConsIds = getConsistentIds(newBlt); for (Object oldBltConsId : bltConsIds) { if (aliveNodesConsIds.contains(oldBltConsId)) { if (!newBltConsIds.contains(oldBltConsId)) onlineNodesRequestedForRemoval.add(oldBltConsId); } } return onlineNodesRequestedForRemoval; }
/** * Checks whether local node participating in Baseline Topology and warn if not. */ private void checkLocalNodeInBaseline(BaselineTopology blt) { if (blt == null || blt.consistentIds() == null || ctx.clientNode() || ctx.isDaemon()) return; if (!CU.isPersistenceEnabled(ctx.config())) return; if (!blt.consistentIds().contains(ctx.discovery().localNode().consistentId())) { U.quietAndInfo(log, "Local node is not included in Baseline Topology and will not be used " + "for persistent data storage. Use control.(sh|bat) script or IgniteCluster interface to include " + "the node to Baseline Topology."); } }
/** * @return {@code true} if local node is in baseline and {@code false} otherwise. */ private boolean isLocalNodeInBaseline() { BaselineTopology topology = cctx.discovery().discoCache().state().baselineTopology(); return topology != null && topology.consistentIds().contains(cctx.localNode().consistentId()); }
for (Object consId : blt.consistentIds()) { ClusterNode srvNode = aliveNodesByConsId.get(consId);
/** * Logs Tx state to WAL if needed. * * @param tx Transaction. * @return WALPointer or {@code null} if nothing was logged. */ @Nullable WALPointer logTxRecord(IgniteTxAdapter tx) { BaselineTopology baselineTop; // Log tx state change to WAL. if (cctx.wal() == null || (!logTxRecords && !tx.txState().mvccEnabled()) || (baselineTop = cctx.kernalContext().state().clusterState().baselineTopology()) == null || !baselineTop.consistentIds().contains(cctx.localNode().consistentId())) return null; Map<Short, Collection<Short>> nodes = tx.consistentIdMapper.mapToCompactIds(tx.topVer, tx.txNodes, baselineTop); TxRecord record; if (tx.txState().mvccEnabled()) record = new MvccTxRecord(tx.state(), tx.nearXidVersion(), tx.writeVersion(), nodes, tx.mvccSnapshot()); else record = new TxRecord(tx.state(), tx.nearXidVersion(), tx.writeVersion(), nodes); try { return cctx.wal().log(record); } catch (IgniteCheckedException e) { U.error(log, "Failed to log TxRecord: " + record, e); throw new IgniteException("Failed to log TxRecord: " + record, e); } }
/** * Verifies that neither BaselineTopology nor BaselineTopologyHistory are changed when cluster is deactivated. */ @Test public void testBaselineTopologyRemainsTheSameOnClusterDeactivation() throws Exception { startGrids(2); IgniteEx srv = grid(0); srv.cluster().active(true); awaitPartitionMapExchange(); assertTrue(srv.cluster().active()); srv.cluster().active(false); BaselineTopology blt = getBaselineTopology(srv); BaselineTopologyHistory bltHist = getBaselineTopologyHistory(srv); assertEquals(0, blt.id()); assertEquals(2, blt.consistentIds().size()); assertEquals(1, blt.branchingHistory().size()); assertEquals(0, bltHist.history().size()); }
/** * @param node Node. * @param discoveryDataClusterState Discovery data cluster state. * @return {@code True} if node is included in BaselineTopology. */ public static boolean baselineNode(ClusterNode node, DiscoveryDataClusterState discoveryDataClusterState) { return discoveryDataClusterState.baselineTopology().consistentIds().contains(node.consistentId()); }
/** * Checks whether all conditions to meet BaselineTopology are satisfied. */ private boolean isBaselineSatisfied(BaselineTopology blt, List<ClusterNode> serverNodes) { if (blt == null) return false; if (blt.consistentIds() == null) return false; if (//only node participating in BaselineTopology is allowed to send activation command... blt.consistentIds().contains(ctx.discovery().localNode().consistentId()) //...and with this node BaselineTopology is reached && blt.isSatisfied(serverNodes)) return true; return false; }
/** {@inheritDoc} */ @Override public long getRowCount() { BaselineTopology blt = ctx.state().clusterState().baselineTopology(); return blt == null ? 0 : blt.consistentIds().size(); } }
/** * @param blt Baseline Topology. */ public static BaselineTopologyHistoryItem fromBaseline(BaselineTopology blt) { if (blt == null) return null; List<Long> fullActivationHistory = new ArrayList<>(blt.branchingHistory().size()); fullActivationHistory.addAll(blt.branchingHistory()); return new BaselineTopologyHistoryItem(blt.id(), U.arrayList(blt.consistentIds()), fullActivationHistory); }
/** * @return {@code true} if local node is not in baseline and {@code false} otherwise. */ private boolean isLocalNodeNotInBaseline() { BaselineTopology topology = cctx.discovery().discoCache().state().baselineTopology(); return topology!= null && !topology.consistentIds().contains(cctx.localNode().consistentId()); }