use of org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology in project ignite by apache.
the class ZkCommunicationFailureContext method cachePartitionOwners.
/**
* {@inheritDoc}
*/
@Override
public List<List<ClusterNode>> cachePartitionOwners(String cacheName) {
if (cacheName == null)
throw new NullPointerException("Null cache name.");
DynamicCacheDescriptor cacheDesc = ctx.affinity().caches().get(CU.cacheId(cacheName));
if (cacheDesc == null)
throw new IllegalArgumentException("Invalid cache name: " + cacheName);
if (cacheDesc.cacheConfiguration().getCacheMode() == CacheMode.LOCAL)
return Collections.emptyList();
CacheGroupContext grp = ctx.cache().cacheGroup(cacheDesc.groupId());
GridDhtPartitionTopology top;
if (grp == null) {
top = ctx.exchange().clientTopologyIfExists(cacheDesc.groupId());
assert top != null : cacheName;
} else
top = grp.topology();
return top.allOwners();
}
use of org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology in project ignite by apache.
the class IgniteWalRecoveryTest method testRandomCrash.
/**
* @throws Exception if failed.
*/
@Test
public void testRandomCrash() throws Exception {
checkpointFrequency = 2_000 + new Random().nextInt(4_000);
IgniteEx ctrlGrid = startGrid(0);
fork = true;
IgniteEx cacheGrid = startGrid(1);
ctrlGrid.cluster().active(true);
IgniteCompute rmt = ctrlGrid.compute(ctrlGrid.cluster().forRemotes());
rmt.run(new LoadRunnable(false));
info(">>> Finished cache population.");
rmt.run(new AsyncLoadRunnable());
Thread.sleep(5_000);
info(">>> Killing remote process...");
((IgniteProcessProxy) cacheGrid).kill();
startGrid(1);
final GridDhtPartitionTopology top = ctrlGrid.cachex(CACHE_NAME).context().topology();
waitForReadyTopology(top, new AffinityTopologyVersion(3, 0));
assertFalse(top.lostPartitions().isEmpty());
int res = rmt.call(new VerifyCallable());
assertEquals(0, res);
}
use of org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology in project ignite by apache.
the class IgniteWalRecoveryTest method testLargeRandomCrash.
/**
* @throws Exception if failed.
*/
@Test
public void testLargeRandomCrash() throws Exception {
checkpointFrequency = 2_000 + new Random().nextInt(4_000);
IgniteEx ctrlGrid = startGrid(0);
fork = true;
IgniteEx cacheGrid = startGrid(1);
ctrlGrid.cluster().active(true);
IgniteCompute rmt = ctrlGrid.compute(ctrlGrid.cluster().forRemotes());
rmt.run(new LargeLoadRunnable(false));
info(">>> Finished cache population.");
rmt.run(new AsyncLargeLoadRunnable());
Thread.sleep(5_000);
info(">>> Killing remote process...");
((IgniteProcessProxy) cacheGrid).kill();
startGrid(1);
final GridDhtPartitionTopology top = ctrlGrid.cachex(CACHE_NAME).context().topology();
waitForReadyTopology(top, new AffinityTopologyVersion(3, 0));
assertFalse(top.lostPartitions().isEmpty());
int res = rmt.call(new VerifyLargeCallable());
assertEquals(0, res);
}
use of org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology in project ignite by apache.
the class WaitMapExchangeFinishCallable method call.
/**
* {@inheritDoc}
*/
@Override
public Void call() throws Exception {
Collection<IgniteInternalCache<?, ?>> cachesx = ((IgniteKernal) ignite).cachesx(null);
for (IgniteInternalCache<?, ?> cache : cachesx) {
try {
GridDhtPartitionTopology top = cache.context().isNear() ? cache.context().near().dht().topology() : cache.context().dht().topology();
BenchmarkUtils.println("Validating cache: " + cache.name());
for (; ; ) {
boolean success = true;
if (top.readyTopologyVersion().topologyVersion() == ignite.cluster().topologyVersion()) {
for (Map.Entry<UUID, GridDhtPartitionMap> e : top.partitionMap(true).entrySet()) {
for (Map.Entry<Integer, GridDhtPartitionState> p : e.getValue().entrySet()) {
if (p.getValue() != GridDhtPartitionState.OWNING) {
BenchmarkUtils.println("Not owning partition [part=" + p.getKey() + ", state=" + p.getValue() + ']');
success = false;
break;
}
}
if (!success)
break;
}
} else {
BenchmarkUtils.println("Topology version is different [cache=" + top.readyTopologyVersion() + ", cluster=" + ignite.cluster().topologyVersion() + ']');
success = false;
}
if (!success)
Thread.sleep(1000);
else {
BenchmarkUtils.println("Cache state is fine: " + cache.name());
break;
}
}
} catch (RuntimeException e1) {
BenchmarkUtils.println("Ignored exception: " + e1);
}
}
return null;
}
use of org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology in project ignite by apache.
the class CachePartitionLossWithRestartsTest method testPartitionLossDetectionOnClientTopology.
/**
*/
@Test
public void testPartitionLossDetectionOnClientTopology() throws Exception {
final IgniteEx crd = startGrids(3);
crd.cluster().baselineAutoAdjustEnabled(false);
crd.cluster().active(true);
assertTrue(grid(1).cache(DEFAULT_CACHE_NAME).lostPartitions().isEmpty());
assertTrue(grid(2).cache(DEFAULT_CACHE_NAME).lostPartitions().isEmpty());
final IgniteEx g3 = startGrid(3);
awaitPartitionMapExchange();
stopGrid(1);
// Loss detection is done just before exchange future completion.
// Will wait for it's finishing.
AffinityTopologyVersion topVer = new AffinityTopologyVersion(5, 0);
GridDhtPartitionTopology top0 = waitForDetection(crd, topVer);
GridDhtPartitionTopology top1 = waitForDetection(grid(2), topVer);
GridDhtPartitionTopology top2 = waitForDetection(g3, topVer);
final Set<Integer> lost1 = new HashSet<>(top0.lostPartitions());
final Set<Integer> lost2 = new HashSet<>(top1.lostPartitions());
final Set<Integer> lost3 = new HashSet<>(top2.lostPartitions());
assertFalse(lost1.isEmpty());
assertEquals(lost1, lost2);
assertEquals(lost1, lost3);
GridDhtPartitionTopology top = startGrid(1).cachex(DEFAULT_CACHE_NAME).context().topology();
assertEquals(lost1, top.lostPartitions());
// TODO https://issues.apache.org/jira/browse/IGNITE-13053
grid(1).resetLostPartitions(Collections.singleton(DEFAULT_CACHE_NAME));
awaitPartitionMapExchange();
}
Aggregations