/** {@inheritDoc} */ @Override public boolean equals(Object obj) { // NOTE! // Do not call super. As IDs will differ, but we can ignore this. if (!(obj instanceof TcpDiscoveryJoinRequestMessage)) return false; TcpDiscoveryJoinRequestMessage other = (TcpDiscoveryJoinRequestMessage)obj; return F.eqNodes(other.node, node); }
/** {@inheritDoc} */ @Override public boolean equals(Object obj) { return F.eqNodes(this, obj); }
/** {@inheritDoc} */ @Override public boolean equals(Object o) { return F.eqNodes(this, o); }
/** {@inheritDoc} */ @Override public boolean equals(Object o) { return F.eqNodes(this, o); }
/** {@inheritDoc} */ @Override public boolean equals(Object obj) { // NOTE! // Do not call super. As IDs will differ, but we can ignore this. if (!(obj instanceof TcpDiscoveryStatusCheckMessage)) return false; TcpDiscoveryStatusCheckMessage other = (TcpDiscoveryStatusCheckMessage)obj; return F.eqNodes(other.creatorNode, creatorNode) && F.eq(other.failedNodeId, failedNodeId) && status == other.status; }
/** {@inheritDoc} */ @Override public boolean equals(Object o) { return F.eqNodes(this, o); }
/** * @param disc Discovery. * @return Second node in the topology. * @throws InterruptedException If interrupted. */ @SuppressWarnings("BusyWait") private ClusterNode awaitOther(final GridDiscoveryManager disc) throws InterruptedException { while (disc.allNodes().size() < 2) Thread.sleep(1000); for (ClusterNode node : disc.allNodes()) if (!F.eqNodes(node, disc.localNode())) return node; assert false; return null; } }
/** * JUnit. * * @throws Exception If failed. */ @Test public void testMapPartitionsToNodeCollection() throws Exception { Collection<Integer> parts = new LinkedList<>(); for (int p = 0; p < affinity().partitions(); p++) parts.add(p); Map<Integer, ClusterNode> map = grid(0).affinity(DEFAULT_CACHE_NAME).mapPartitionsToNodes(parts); AffinityFunctionContext ctx = new GridAffinityFunctionContextImpl(new ArrayList<>(grid(0).cluster().nodes()), null, null, new AffinityTopologyVersion(1), 1); AffinityFunction aff = affinity(); List<List<ClusterNode>> assignment = aff.assignPartitions(ctx); for (Map.Entry<Integer, ClusterNode> e : map.entrySet()) assert F.eqNodes(F.first(nodes(assignment, aff, e.getKey())), e.getValue()); }
/** * JUnit. * * @throws Exception If failed. */ @Test public void testMapPartitionsToNode() throws Exception { Map<Integer, ClusterNode> map = grid(0).affinity(DEFAULT_CACHE_NAME).mapPartitionsToNodes(F.asList(0, 1, 5, 19, 12)); AffinityFunctionContext ctx = new GridAffinityFunctionContextImpl(new ArrayList<>(grid(0).cluster().nodes()), null, null, new AffinityTopologyVersion(1), 1); AffinityFunction aff = affinity(); List<List<ClusterNode>> assignment = aff.assignPartitions(ctx); for (Map.Entry<Integer, ClusterNode> e : map.entrySet()) assert F.eqNodes(F.first(nodes(assignment, aff, e.getKey())), e.getValue()); }
/** * JUnit. * * @throws Exception If failed. */ @Test public void testMapPartitionsToNodeArray() throws Exception { Map<Integer, ClusterNode> map = grid(0).affinity(DEFAULT_CACHE_NAME).mapPartitionsToNodes(F.asList(0, 1, 5, 19, 12)); AffinityFunctionContext ctx = new GridAffinityFunctionContextImpl(new ArrayList<>(grid(0).cluster().nodes()), null, null, new AffinityTopologyVersion(1), 1); AffinityFunction aff = affinity(); List<List<ClusterNode>> assignment = aff.assignPartitions(ctx); for (Map.Entry<Integer, ClusterNode> e : map.entrySet()) assert F.eqNodes(F.first(nodes(assignment, aff, e.getKey())), e.getValue()); }
/** * @param key Key. * @return For the given key pair {primary node, some other node}. */ private IgniteBiTuple<ClusterNode, ClusterNode> getNodes(Integer key) { Affinity<Integer> aff = grid(0).affinity(DEFAULT_CACHE_NAME); int part = aff.partition(key); ClusterNode primary = aff.mapPartitionToNode(part); assert primary != null; Collection<ClusterNode> nodes = new ArrayList<>(grid(0).cluster().nodes()); nodes.remove(primary); ClusterNode other = F.first(nodes); assert other != null; assert !F.eqNodes(primary, other); return F.t(primary, other); } }
/** * JUnit. * * @throws Exception If failed. */ @Test public void testPrimaryPartitions() throws Exception { // Pick 2 nodes and create a projection over them. ClusterNode n0 = grid(0).localNode(); int[] parts = grid(0).affinity(DEFAULT_CACHE_NAME).primaryPartitions(n0); info("Primary partitions count: " + parts.length); assert parts.length > 1 : "Invalid partitions: " + Arrays.toString(parts); for (int part : parts) assert part >= 0; assert !F.isEmpty(parts); AffinityFunctionContext ctx = new GridAffinityFunctionContextImpl(new ArrayList<>(grid(0).cluster().nodes()), null, null, new AffinityTopologyVersion(1), 1); List<List<ClusterNode>> assignment = affinity().assignPartitions(ctx); for (int p : parts) { Collection<ClusterNode> owners = nodes(assignment, p); assert !F.isEmpty(owners); ClusterNode primary = F.first(owners); assert F.eqNodes(n0, primary); } }
/** * JUnit. * * @throws Exception If failed. */ @Test public void testPrimaryPartitionsOneNode() throws Exception { AffinityFunctionContext ctx = new GridAffinityFunctionContextImpl(new ArrayList<>(grid(0).cluster().nodes()), null, null, new AffinityTopologyVersion(1), 1); List<List<ClusterNode>> assignment = affinity().assignPartitions(ctx); for (ClusterNode node : grid(0).cluster().nodes()) { int[] parts = grid(0).affinity(DEFAULT_CACHE_NAME).primaryPartitions(node); assert !F.isEmpty(parts); for (int p : parts) { Collection<ClusterNode> owners = nodes(assignment, p); assert !F.isEmpty(owners); ClusterNode primary = F.first(owners); assert F.eqNodes(node, primary); } } }
assert F.eqNodes(localNode(), node);
/** {@inheritDoc} */ @Override public boolean equals(Object o) { return F.eqNodes(this, o); }
/** {@inheritDoc} */ @Override public boolean equals(Object obj) { // NOTE! // Do not call super. As IDs will differ, but we can ignore this. if (!(obj instanceof TcpDiscoveryJoinRequestMessage)) return false; TcpDiscoveryJoinRequestMessage other = (TcpDiscoveryJoinRequestMessage)obj; return F.eqNodes(other.node, node); }
/** {@inheritDoc} */ @Override public boolean equals(Object obj) { // NOTE! // Do not call super. As IDs will differ, but we can ignore this. if (!(obj instanceof TcpDiscoveryStatusCheckMessage)) return false; TcpDiscoveryStatusCheckMessage other = (TcpDiscoveryStatusCheckMessage)obj; return F.eqNodes(other.creatorNode, creatorNode) && F.eq(other.failedNodeId, failedNodeId) && status == other.status; }
assert F.eqNodes(localNode(), node);