use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.
the class WalRolloverTypesTest method checkNextSegmentTypeWithCacheActivity.
/**
* Under load, ensures the record gets into very beginning of the segment in {@code NEXT_SEGMENT} log mode.
*/
private void checkNextSegmentTypeWithCacheActivity(WALMode mode, boolean disableArch) throws Exception {
walMode = mode;
disableWALArchiving = disableArch;
IgniteEx ig = startGrid(0);
ig.cluster().active(true);
IgniteCache<Integer, Integer> cache = ig.getOrCreateCache(DEFAULT_CACHE_NAME);
final long testDuration = 30_000;
long startTime = U.currentTimeMillis();
IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(() -> {
ThreadLocalRandom random = ThreadLocalRandom.current();
while (U.currentTimeMillis() - startTime < testDuration) cache.put(random.nextInt(100), random.nextInt(100_000));
}, 8, "cache-put-thread");
IgniteWriteAheadLogManager walMgr = ig.context().cache().context().wal();
IgniteCacheDatabaseSharedManager dbMgr = ig.context().cache().context().database();
AdHocWALRecord markerRecord = new AdHocWALRecord();
WALPointer ptr0;
WALPointer ptr1;
do {
try {
U.sleep(1000);
ptr0 = walMgr.log(markerRecord);
dbMgr.checkpointReadLock();
try {
ptr1 = walMgr.log(markerRecord, NEXT_SEGMENT);
} finally {
dbMgr.checkpointReadUnlock();
}
assertTrue(ptr0.index() < ptr1.index());
assertEquals(HEADER_RECORD_SIZE, ptr1.fileOffset());
} catch (IgniteCheckedException e) {
log.error(e.getMessage(), e);
}
} while (U.currentTimeMillis() - startTime < testDuration);
fut.get();
}
use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.
the class WalRolloverRecordLoggingTest method testAvoidInfinityWaitingOnRolloverOfSegment.
/**
*/
@Test
public void testAvoidInfinityWaitingOnRolloverOfSegment() throws Exception {
IgniteEx ig = startGrid(0);
ig.cluster().active(true);
IgniteCache<Integer, Integer> cache = ig.getOrCreateCache(DEFAULT_CACHE_NAME);
long startTime = U.currentTimeMillis();
long duration = 5_000;
IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(() -> {
ThreadLocalRandom random = ThreadLocalRandom.current();
while (U.currentTimeMillis() - startTime < duration) cache.put(random.nextInt(100_000), random.nextInt(100_000));
}, 8, "cache-put-thread");
Thread t = new Thread(() -> {
do {
try {
U.sleep(100);
} catch (IgniteInterruptedCheckedException e) {
// No-op.
}
ig.context().cache().context().database().wakeupForCheckpoint("test");
} while (U.currentTimeMillis() - startTime < duration);
});
t.start();
IgniteWriteAheadLogManager walMgr = ig.context().cache().context().wal();
IgniteCacheDatabaseSharedManager dbMgr = ig.context().cache().context().database();
RolloverRecord rec = new RolloverRecord();
do {
try {
dbMgr.checkpointReadLock();
try {
walMgr.log(rec, RolloverType.NEXT_SEGMENT);
} finally {
dbMgr.checkpointReadUnlock();
}
} catch (IgniteCheckedException e) {
log.error(e.getMessage(), e);
}
} while (U.currentTimeMillis() - startTime < duration);
fut.get();
t.join();
}
use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.
the class DurableBackgroundTasksProcessor method metaStorageOperation.
/**
* Performing an operation on a {@link MetaStorage}.
* Guarded by {@link #metaStorageMux}.
*
* @param consumer MetaStorage operation, argument can be {@code null}.
* @throws IgniteException If an exception is thrown from the {@code consumer}.
*/
private void metaStorageOperation(IgniteThrowableConsumer<MetaStorage> consumer) throws IgniteException {
synchronized (metaStorageMux) {
IgniteCacheDatabaseSharedManager dbMgr = ctx.cache().context().database();
dbMgr.checkpointReadLock();
try {
MetaStorage metaStorage = dbMgr.metaStorage();
consumer.accept(metaStorage);
} catch (IgniteCheckedException e) {
throw new IgniteException(e);
} finally {
dbMgr.checkpointReadUnlock();
}
}
}
use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.
the class IgniteDefragmentationImpl method getStatus.
/**
* Get defragmentation status.
* @return Defragmentation status or {@code null} if there is no ongoing defragmentation.
*/
private Status getStatus() {
final MaintenanceRegistry maintenanceRegistry = ctx.maintenanceRegistry();
if (!maintenanceRegistry.isMaintenanceMode())
return null;
IgniteCacheDatabaseSharedManager dbMgr = ctx.cache().context().database();
assert dbMgr instanceof GridCacheDatabaseSharedManager;
CachePartitionDefragmentationManager defrgMgr = ((GridCacheDatabaseSharedManager) dbMgr).defragmentationManager();
if (defrgMgr == null)
return null;
return defrgMgr.status();
}
use of org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager in project ignite by apache.
the class IndexBuildStatusStorage method metaStorageOperation.
/**
* Performing an operation on a {@link MetaStorage}.
* Guarded by {@link #metaStorageMux}.
*
* @param consumer MetaStorage operation, argument can be {@code null}.
* @throws IgniteException If an exception is thrown from the {@code consumer}.
*/
private void metaStorageOperation(IgniteThrowableConsumer<MetaStorage> consumer) {
synchronized (metaStorageMux) {
IgniteCacheDatabaseSharedManager db = ctx.cache().context().database();
db.checkpointReadLock();
try {
consumer.accept(db.metaStorage());
} catch (IgniteCheckedException e) {
throw new IgniteException(e);
} finally {
db.checkpointReadUnlock();
}
}
}
Aggregations