use of org.apache.ignite.internal.processors.timeout.GridTimeoutObject in project ignite by apache.
the class StartNodeCallableImpl method initTimer.
/**
* Initialize timer to wait for command execution.
*
* @param cmd Command to log.
*/
private GridTimeoutObject initTimer(String cmd) {
GridTimeoutObject to = new GridTimeoutObjectAdapter(EXECUTE_WAIT_TIME) {
private final Thread thread = Thread.currentThread();
@Override
public void onTimeout() {
thread.interrupt();
}
@Override
public String toString() {
return S.toString("GridTimeoutObject", "cmd", cmd, "thread", thread);
}
};
boolean wasAdded = proc.addTimeoutObject(to);
assert wasAdded : "Timeout object was not added: " + to;
return to;
}
use of org.apache.ignite.internal.processors.timeout.GridTimeoutObject in project ignite by apache.
the class IgniteTxRemoveTimeoutObjectsTest method logTimeoutObjectsFrequency.
/**
* Print the number of each timeout object type on each grid to the log.
*/
private void logTimeoutObjectsFrequency() {
StringBuilder sb = new StringBuilder("Timeout objects frequency [");
for (Ignite ignite : G.allGrids()) {
IgniteEx igniteEx = (IgniteEx) ignite;
Map<String, Integer> objFreqMap = new HashMap<>();
Set<GridTimeoutObject> objs = getTimeoutObjects(igniteEx);
for (GridTimeoutObject obj : objs) {
String clsName = obj.getClass().getSimpleName();
Integer cnt = objFreqMap.get(clsName);
if (cnt == null)
objFreqMap.put(clsName, 1);
else
objFreqMap.put(clsName, cnt + 1);
}
sb.append("[").append(igniteEx.name()).append(": size=").append(objs.size()).append(", ");
for (Map.Entry<String, Integer> entry : objFreqMap.entrySet()) {
sb.append(entry.getKey()).append("=").append(entry.getValue()).append(", ");
}
sb.delete(sb.length() - 2, sb.length()).append("]; ");
}
sb.delete(sb.length() - 2, sb.length()).append("]");
info(sb.toString().replaceAll("distributed.IgniteTxRemoveTimeoutObjectsTest", "Grid"));
}
use of org.apache.ignite.internal.processors.timeout.GridTimeoutObject in project ignite by apache.
the class WriteAheadLogManagerSelfTest method testNoRaceAutoArchiveAndDeactivation.
/**
* Checking the absence of a race between the deactivation of the VAL and
* automatic archiving, which may lead to a fail of the node.
*
* @throws Exception If failed.
*/
@Test
public void testNoRaceAutoArchiveAndDeactivation() throws Exception {
for (int i = 0; i < 10; i++) {
if (log.isInfoEnabled())
log.info(">>> Test iteration:" + i);
IgniteEx n = startGrid(0, cfg -> {
cfg.getDataStorageConfiguration().setWalAutoArchiveAfterInactivity(10);
});
n.cluster().state(ACTIVE);
awaitPartitionMapExchange();
GridTimeoutObject timeoutObj = timeoutRollover(n);
assertNotNull(timeoutObj);
n.cache(DEFAULT_CACHE_NAME).put(current().nextInt(), new byte[16]);
CountDownLatch l = new CountDownLatch(1);
AtomicBoolean stop = new AtomicBoolean();
IgniteInternalFuture<Object> fut = runAsync(() -> {
l.countDown();
while (!stop.get()) lastRecordLoggedMs(n).set(1);
});
assertTrue(l.await(getTestTimeout(), MILLISECONDS));
walMgr(n).onDeActivate(n.context());
stop.set(true);
fut.get(getTestTimeout());
assertEquals(1, G.allGrids().size());
stopAllGrids();
cleanPersistenceDir();
}
}
use of org.apache.ignite.internal.processors.timeout.GridTimeoutObject in project ignite by apache.
the class WriteAheadLogManagerSelfTest method testAutoArchiveWithoutNullPointerException.
/**
* Check that auto archive will execute without {@link NullPointerException}.
*
* @throws Exception If failed.
*/
@Test
public void testAutoArchiveWithoutNullPointerException() throws Exception {
setRootLoggerDebugLevel();
LogListener logLsnr0 = LogListener.matches("Checking if WAL rollover required").build();
LogListener logLsnr1 = LogListener.matches(Pattern.compile("Rollover segment \\[\\d+ to \\d+\\], recordType=null")).build();
IgniteEx n = startGrid(0, cfg -> {
cfg.setGridLogger(new ListeningTestLogger(log, logLsnr0, logLsnr1)).getDataStorageConfiguration().setWalAutoArchiveAfterInactivity(100_000);
});
n.cluster().state(ACTIVE);
awaitPartitionMapExchange();
GridTimeoutObject timeoutObj = timeoutRollover(n);
assertNotNull(timeoutObj);
n.cache(DEFAULT_CACHE_NAME).put(current().nextInt(), new byte[16]);
disableWal(n);
lastRecordLoggedMs(n).set(1);
timeoutObj.onTimeout();
assertTrue(logLsnr0.check());
assertTrue(logLsnr1.check());
}
use of org.apache.ignite.internal.processors.timeout.GridTimeoutObject in project ignite by apache.
the class FileWriteAheadLogManager method stop0.
/**
* {@inheritDoc}
*/
@Override
protected void stop0(boolean cancel) {
final GridTimeoutProcessor.CancelableTask schedule = backgroundFlushSchedule;
if (schedule != null)
schedule.close();
final GridTimeoutObject timeoutObj = nextAutoArchiveTimeoutObj;
if (timeoutObj != null)
cctx.time().removeTimeoutObject(timeoutObj);
final FileWriteHandle currHnd = currentHandle();
try {
if (mode == WALMode.BACKGROUND) {
if (currHnd != null)
currHnd.flush(null);
}
if (currHnd != null)
currHnd.close(false);
if (walWriter != null)
walWriter.shutdown();
if (archiver != null)
archiver.shutdown();
if (compressor != null)
compressor.shutdown();
if (decompressor != null)
decompressor.shutdown();
} catch (Exception e) {
U.error(log, "Failed to gracefully close WAL segment: " + this.currHnd.fileIO, e);
}
}
Aggregations