@Override public Object call() throws Exception { return affinity.backupPartitions(n); } }, IgniteException.class, EXPECTED_MSG);
/** {@inheritDoc} */ @Override public int[] backupPartitions(ClusterNode n) { CacheOperationContext old = gate.enter(null); try { return delegate.backupPartitions(n); } finally { gate.leave(old); } }
/** {@inheritDoc} */ @Override public int[] call() throws Exception { if (primary && backup) return affinity().allPartitions(n); else if (primary) return affinity().primaryPartitions(n); else if (backup) return affinity().backupPartitions(n); else throw new IllegalStateException("primary or backup or both flags should be switched on"); } }
/** * Check allPartitions, backupPartitions and primaryPartitions methods. * * @param testAff Affinity1. * @param aff Affinity2. */ private void checkPartitions(Affinity testAff, Affinity aff) { for (ClusterNode n : nodes()) { checkEqualIntArray(testAff.allPartitions(n), aff.allPartitions(n)); checkEqualIntArray(testAff.backupPartitions(n), aff.backupPartitions(n)); checkEqualIntArray(testAff.primaryPartitions(n), aff.primaryPartitions(n)); } }
/** * JUnit. * * @throws Exception If failed. */ @Test public void testBackupPartitions() throws Exception { // Pick 2 nodes and create a projection over them. ClusterNode n0 = grid(0).localNode(); // Get backup partitions without explicitly specified levels. int[] parts = grid(0).affinity(DEFAULT_CACHE_NAME).backupPartitions(n0); 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 = new ArrayList<>(nodes(assignment, p)); assert !F.isEmpty(owners); // Remove primary. Iterator<ClusterNode> iter = owners.iterator(); iter.next(); iter.remove(); assert owners.contains(n0); } }
int[] parts = node != null ? aff.backupPartitions(node) : U.EMPTY_INTS;
assertEquals(0, aff.backupPartitions(((IgniteKernal)node).localNode()).length);
/** {@inheritDoc} */ @Override public int[] backupPartitions(ClusterNode n) { CacheOperationContext old = gate.enter(null); try { return delegate.backupPartitions(n); } finally { gate.leave(old); } }
int[] parts = node != null ? aff.backupPartitions(node) : U.EMPTY_INTS;