use of org.apache.ignite.internal.IgniteFutureTimeoutCheckedException in project ignite by apache.
the class IgniteCheckpointDirtyPagesForLowLoadTest method testManyCachesAndNotManyPuts.
/**
* @throws Exception if failed.
*/
@Test
public void testManyCachesAndNotManyPuts() throws Exception {
try {
IgniteEx ignite = startGrid(0);
ignite.active(true);
log.info("Saving initial data to caches");
for (int g = 0; g < GROUPS; g++) {
for (int c = 0; c < CACHES_IN_GRP; c++) {
TreeMap<Long, Long> data = new TreeMap<>();
for (int j = 0; j < PARTS; j++) {
// to fill each partition cache with at least 1 element
data.put((long) j, (long) j);
}
ignite.cache("dummyCache" + c + "." + g).putAll(data);
}
}
GridCacheDatabaseSharedManager db = (GridCacheDatabaseSharedManager) (ignite.context().cache().context().database());
Collection<Integer> pageCntObserved = new ArrayList<>();
boolean checkpointWithLowNumOfPagesFound = false;
for (int i = 0; i < 20; i++) {
Random random = new Random();
// touch some entry
int d = random.nextInt(PARTS) + PARTS;
int cIdx = random.nextInt(CACHES_IN_GRP);
int gIdx = random.nextInt(GROUPS);
String fullname = "dummyCache" + cIdx + "." + gIdx;
ignite.cache(fullname).put(d, d);
if (log.isInfoEnabled())
log.info("Put to cache [" + fullname + "] value " + d);
long start = System.nanoTime();
try {
final int cpTimeout = 25000;
db.wakeupForCheckpoint("").get(cpTimeout, TimeUnit.MILLISECONDS);
} catch (IgniteFutureTimeoutCheckedException ignored) {
long msPassed = U.millisSinceNanos(start);
log.error("Timeout during waiting for checkpoint to start:" + " [" + msPassed + "] but checkpoint is not running");
continue;
}
final int timeout = 5000;
int currCpPages = waitForCurrentCheckpointPagesCounterUpdated(db, timeout);
if (currCpPages < 0) {
log.error("Timeout during waiting for checkpoint counter to be updated");
continue;
}
pageCntObserved.add(currCpPages);
log.info("Current CP pages: " + currCpPages);
if (currCpPages < PARTS * GROUPS) {
// reasonable number of pages in CP
checkpointWithLowNumOfPagesFound = true;
break;
}
}
stopGrid(0);
assertTrue("All checkpoints mark too much pages: " + pageCntObserved, checkpointWithLowNumOfPagesFound);
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.internal.IgniteFutureTimeoutCheckedException in project ignite by apache.
the class TxPartitionCounterStateConsistencyTest method testPartitionConsistencyCancelledRebalanceCoordinatorIsDemander.
/**
* Tests reproduces the problem: if coordinator is a demander after activation and supplier has left, new
* rebalance will finish and cause no partition inconsistencies.
*
* @throws Exception If failed.
*/
@Test
public void testPartitionConsistencyCancelledRebalanceCoordinatorIsDemander() throws Exception {
backups = 2;
Ignite crd = startGrids(SERVER_NODES);
crd.cluster().active(true);
int[] primaryParts = crd.affinity(DEFAULT_CACHE_NAME).primaryPartitions(crd.cluster().localNode());
IgniteCache<Object, Object> cache = crd.cache(DEFAULT_CACHE_NAME);
List<Integer> p1Keys = partitionKeys(cache, primaryParts[0], 2, 0);
assertTrue(crd.affinity(DEFAULT_CACHE_NAME).isPrimary(crd.cluster().localNode(), p1Keys.get(0)));
final String primName = crd.name();
cache.put(p1Keys.get(0), 0);
cache.put(p1Keys.get(1), 1);
forceCheckpoint();
List<Ignite> backups = Arrays.asList(grid(1), grid(2));
assertFalse(backups.contains(crd));
final String demanderName = backups.get(0).name();
stopGrid(true, demanderName);
// Create counters delta.
cache.remove(p1Keys.get(1));
stopAllGrids();
crd = startNodeWithBlockingSupplying(0);
startGrid(1);
startNodeWithBlockingSupplying(2);
crd.cluster().active(true);
TestRecordingCommunicationSpi spi0 = TestRecordingCommunicationSpi.spi(crd);
TestRecordingCommunicationSpi spi2 = TestRecordingCommunicationSpi.spi(ignite(2));
IgniteInternalFuture fut = GridTestUtils.runAsync(() -> {
try {
GridTestUtils.waitForCondition(() -> spi0.hasBlockedMessages() || spi2.hasBlockedMessages(), 10_000);
// Stop before supplying rebalance. New rebalance must start with second backup as supplier
// doing full rebalance.
stopGrid(primName);
spi2.stopBlock();
} catch (Exception e) {
fail();
}
});
try {
fut.get(10_000);
} catch (IgniteFutureTimeoutCheckedException e) {
for (Ignite ignite : G.allGrids()) {
final PartitionUpdateCounter cntr = counter(primaryParts[0], ignite.name());
log.info("Node: " + ignite.name() + ", cntr=" + cntr);
}
assertPartitionsSame(idleVerify(crd, DEFAULT_CACHE_NAME));
fail("Rebalancing is expected");
}
awaitPartitionMapExchange();
assertPartitionsSame(idleVerify(grid(demanderName), DEFAULT_CACHE_NAME));
}
use of org.apache.ignite.internal.IgniteFutureTimeoutCheckedException in project ignite by apache.
the class GridServiceDeploymentCompoundFutureSelfTest method testWaitForCompletionOnFailingFuture.
/**
* @throws Exception If failed.
*/
@Test
public void testWaitForCompletionOnFailingFuture() throws Exception {
GridServiceDeploymentCompoundFuture<IgniteUuid> compFut = new GridServiceDeploymentCompoundFuture<>();
int failingFutsNum = 2;
int completingFutsNum = 5;
Collection<GridServiceDeploymentFuture> failingFuts = new ArrayList<>(completingFutsNum);
for (int i = 0; i < failingFutsNum; i++) {
ServiceConfiguration failingCfg = config("Failed-" + i);
GridServiceDeploymentFuture<IgniteUuid> failingFut = new GridServiceDeploymentFuture<>(failingCfg, IgniteUuid.randomUuid());
failingFuts.add(failingFut);
compFut.add(failingFut);
}
List<GridFutureAdapter<Object>> futs = new ArrayList<>(completingFutsNum);
for (int i = 0; i < completingFutsNum; i++) {
GridServiceDeploymentFuture<IgniteUuid> fut = new GridServiceDeploymentFuture<>(config(String.valueOf(i)), IgniteUuid.randomUuid());
futs.add(fut);
compFut.add(fut);
}
compFut.markInitialized();
List<Exception> causes = new ArrayList<>();
for (GridServiceDeploymentFuture fut : failingFuts) {
Exception cause = new Exception("Test error");
causes.add(cause);
fut.onDone(cause);
}
try {
compFut.get(100);
fail("Should never reach here.");
} catch (IgniteFutureTimeoutCheckedException e) {
log.info("Expected exception: " + e.getMessage());
}
for (GridFutureAdapter<Object> fut : futs) fut.onDone();
try {
compFut.get();
fail("Should never reach here.");
} catch (IgniteCheckedException ce) {
log.info("Expected exception: " + ce.getMessage());
IgniteException e = U.convertException(ce);
assertTrue(e instanceof ServiceDeploymentException);
Throwable[] supErrs = e.getSuppressed();
assertEquals(failingFutsNum, supErrs.length);
for (int i = 0; i < failingFutsNum; i++) assertEquals(causes.get(i), supErrs[i].getCause());
}
}
use of org.apache.ignite.internal.IgniteFutureTimeoutCheckedException in project ignite by apache.
the class GridFutureAdapterSelfTest method checkChaining.
/**
* @param exec Executor for chain callback.
* @throws Exception If failed.
*/
@SuppressWarnings("ErrorNotRethrown")
private void checkChaining(ExecutorService exec) throws Exception {
final CX1<IgniteInternalFuture<Object>, Object> passThrough = new CX1<IgniteInternalFuture<Object>, Object>() {
@Override
public Object applyx(IgniteInternalFuture<Object> f) throws IgniteCheckedException {
return f.get();
}
};
GridFutureAdapter<Object> fut = new GridFutureAdapter<>();
IgniteInternalFuture<Object> chain = exec != null ? fut.chain(passThrough, exec) : fut.chain(passThrough);
assertFalse(fut.isDone());
assertFalse(chain.isDone());
try {
chain.get(20);
fail("Expects timeout exception.");
} catch (IgniteFutureTimeoutCheckedException e) {
info("Expected timeout exception: " + e.getMessage());
}
fut.onDone("result");
assertEquals("result", exec == null ? chain.get(1) : chain.get());
// Test exception re-thrown.
fut = new GridFutureAdapter<>();
chain = exec != null ? fut.chain(passThrough, exec) : fut.chain(passThrough);
fut.onDone(new ClusterGroupEmptyCheckedException("test exception"));
try {
chain.get();
fail("Expects failed with exception.");
} catch (ClusterGroupEmptyCheckedException e) {
info("Expected exception: " + e.getMessage());
}
// Test error re-thrown.
fut = new GridFutureAdapter<>();
chain = exec != null ? fut.chain(passThrough, exec) : fut.chain(passThrough);
try {
fut.onDone(new StackOverflowError("test error"));
if (exec == null)
fail("Expects failed with error.");
} catch (StackOverflowError e) {
info("Expected error: " + e.getMessage());
}
try {
chain.get();
fail("Expects failed with error.");
} catch (StackOverflowError e) {
info("Expected error: " + e.getMessage());
}
}
use of org.apache.ignite.internal.IgniteFutureTimeoutCheckedException in project ignite by apache.
the class CacheObjectBinaryProcessorImpl method metadata.
/**
* {@inheritDoc}
*/
@Nullable
@Override
public BinaryType metadata(final int typeId, final int schemaId) {
BinaryMetadataHolder holder = metadataLocCache.get(typeId);
if (ctx.clientNode()) {
if (holder == null || !holder.metadata().hasSchema(schemaId)) {
if (log.isDebugEnabled())
log.debug("Waiting for client metadata update" + " [typeId=" + typeId + ", schemaId=" + schemaId + ", pendingVer=" + (holder == null ? "NA" : holder.pendingVersion()) + ", acceptedVer=" + (holder == null ? "NA" : holder.acceptedVersion()) + ']');
try {
transport.requestUpToDateMetadata(typeId).get();
} catch (IgniteCheckedException ignored) {
// No-op.
}
holder = metadataLocCache.get(typeId);
IgniteFuture<?> reconnectFut0 = reconnectFut;
if (holder == null && reconnectFut0 != null)
throw new IgniteClientDisconnectedException(reconnectFut0, "Client node disconnected.");
if (log.isDebugEnabled())
log.debug("Finished waiting for client metadata update" + " [typeId=" + typeId + ", schemaId=" + schemaId + ", pendingVer=" + (holder == null ? "NA" : holder.pendingVersion()) + ", acceptedVer=" + (holder == null ? "NA" : holder.acceptedVersion()) + ']');
}
} else {
if (holder != null && IgniteThread.current() instanceof IgniteDiscoveryThread)
return holder.metadata().wrap(binaryCtx);
else if (holder != null && (holder.pendingVersion() - holder.acceptedVersion() > 0)) {
if (log.isDebugEnabled())
log.debug("Waiting for metadata update" + " [typeId=" + typeId + ", schemaId=" + schemaId + ", pendingVer=" + holder.pendingVersion() + ", acceptedVer=" + holder.acceptedVersion() + ']');
long t0 = System.nanoTime();
GridFutureAdapter<MetadataUpdateResult> fut = transport.awaitMetadataUpdate(typeId, holder.pendingVersion());
try {
fut.get();
} catch (IgniteCheckedException e) {
log.error("Failed to wait for metadata update [typeId=" + typeId + ", schemaId=" + schemaId + ']', e);
}
if (log.isDebugEnabled())
log.debug("Finished waiting for metadata update" + " [typeId=" + typeId + ", waitTime=" + NANOSECONDS.convert(System.nanoTime() - t0, MILLISECONDS) + "ms" + ", schemaId=" + schemaId + ", pendingVer=" + holder.pendingVersion() + ", acceptedVer=" + holder.acceptedVersion() + ']');
holder = metadataLocCache.get(typeId);
} else if (holder == null || !holder.metadata().hasSchema(schemaId)) {
// Last resort waiting.
U.warn(log, "Schema is missing while no metadata updates are in progress " + "(will wait for schema update within timeout defined by " + IGNITE_WAIT_SCHEMA_UPDATE + " system property)" + " [typeId=" + typeId + ", missingSchemaId=" + schemaId + ", pendingVer=" + (holder == null ? "NA" : holder.pendingVersion()) + ", acceptedVer=" + (holder == null ? "NA" : holder.acceptedVersion()) + ", binMetaUpdateTimeout=" + waitSchemaTimeout + ']');
long t0 = System.nanoTime();
GridFutureAdapter<?> fut = transport.awaitSchemaUpdate(typeId, schemaId);
try {
fut.get(waitSchemaTimeout);
} catch (IgniteFutureTimeoutCheckedException e) {
log.error("Timed out while waiting for schema update [typeId=" + typeId + ", schemaId=" + schemaId + ']');
} catch (IgniteCheckedException ignored) {
// No-op.
}
holder = metadataLocCache.get(typeId);
if (log.isDebugEnabled() && holder != null && holder.metadata().hasSchema(schemaId))
log.debug("Found the schema after wait" + " [typeId=" + typeId + ", waitTime=" + NANOSECONDS.convert(System.nanoTime() - t0, MILLISECONDS) + "ms" + ", schemaId=" + schemaId + ", pendingVer=" + holder.pendingVersion() + ", acceptedVer=" + holder.acceptedVersion() + ']');
}
}
if (holder != null && metadataFileStore != null) {
try {
metadataFileStore.waitForWriteCompletion(typeId, holder.pendingVersion());
} catch (IgniteCheckedException e) {
log.warning("Failed to wait for metadata write operation for [typeId=" + typeId + ", typeVer=" + holder.acceptedVersion() + ']', e);
return null;
}
}
return holder != null ? holder.metadata().wrap(binaryCtx) : null;
}
Aggregations