public void basicClose(DiskRegion dr) { ArrayList<Oplog> oplogsToClose = new ArrayList<Oplog>(); synchronized (this.oplogIdToOplog) { oplogsToClose.addAll(this.oplogIdToOplog.values()); oplogsToClose.addAll(this.inactiveOplogs.values()); oplogsToClose.addAll(this.drfOnlyOplogs.values()); { Oplog child = getChild(); if (child != null) { oplogsToClose.add(child); } } } for (Oplog oplog : oplogsToClose) { oplog.close(dr); } }
public void basicClose(DiskRegion dr) { ArrayList<Oplog> oplogsToClose = new ArrayList<Oplog>(); synchronized (this.oplogIdToOplog) { oplogsToClose.addAll(this.oplogIdToOplog.values()); oplogsToClose.addAll(this.inactiveOplogs.values()); oplogsToClose.addAll(this.drfOnlyOplogs.values()); { Oplog child = getChild(); if (child != null) { oplogsToClose.add(child); } } } for (Oplog oplog : oplogsToClose) { oplog.close(dr); } }
public RuntimeException close() { RuntimeException rte = null; try { closeOtherOplogs(); } catch (RuntimeException e) { if (rte != null) { rte = e; } } if (this.child != null) { try { this.child.finishKrf(); } catch (RuntimeException e) { if (rte != null) { rte = e; } } try { this.child.close(); } catch (RuntimeException e) { if (rte != null) { rte = e; } } } return rte; }
public RuntimeException close() { RuntimeException rte = null; try { closeOtherOplogs(); } catch (RuntimeException e) { if (rte != null) { rte = e; } } if (this.child != null) { try { this.child.finishKrf(); } catch (RuntimeException e) { if (rte != null) { rte = e; } } try { this.child.close(); } catch (RuntimeException e) { if (rte != null) { rte = e; } } } return rte; }
/** closes all the oplogs except the current one * */ private void closeOtherOplogs() { // get a snapshot to prevent CME Oplog[] oplogs = getAllOplogs(); // if there are oplogs which are to be compacted, destroy them // do not do oplogs[0] for (int i = 1; i < oplogs.length; i++) { oplogs[i].finishKrf(); oplogs[i].close(); removeOplog(oplogs[i].getOplogId()); } }
/** closes all the oplogs except the current one * */ private void closeOtherOplogs() { // get a snapshot to prevent CME Oplog[] oplogs = getAllOplogs(); // if there are oplogs which are to be compacted, destroy them // do not do oplogs[0] for (int i = 1; i < oplogs.length; i++) { oplogs[i].finishKrf(); oplogs[i].close(); removeOplog(oplogs[i].getOplogId()); } }
private void basicAddToBeCompacted(Oplog oplog) { if (!oplog.isRecovering() && oplog.hasNoLiveValues()) { oplog.cancelKrf(); oplog.close(); // fix for bug 41687 oplog.deleteFiles(oplog.getHasDeletes()); } else { int inactivePromotedCount = 0; parent.getStats().incCompactableOplogs(1); Long key = Long.valueOf(oplog.getOplogId()); synchronized (this.oplogIdToOplog) { if (this.inactiveOplogs.remove(key) != null) { if (oplog.isRAFOpen()) { inactiveOpenCount.decrementAndGet(); } inactivePromotedCount++; } this.oplogIdToOplog.put(key, oplog); } if (inactivePromotedCount > 0) { parent.getStats().incInactiveOplogs(-inactivePromotedCount); } } }
private void basicAddToBeCompacted(Oplog oplog) { if (!oplog.isRecovering() && oplog.hasNoLiveValues()) { oplog.cancelKrf(); oplog.close(); // fix for bug 41687 oplog.deleteFiles(oplog.getHasDeletes()); } else { int inactivePromotedCount = 0; parent.getStats().incCompactableOplogs(1); Long key = Long.valueOf(oplog.getOplogId()); synchronized (this.oplogIdToOplog) { if (this.inactiveOplogs.remove(key) != null) { if (oplog.isRAFOpen()) { inactiveOpenCount.decrementAndGet(); } inactivePromotedCount++; } // logger.info(LocalizedStrings.DEBUG, "DEBUG addToBeCompacted #" + oplog.getOplogId()); this.oplogIdToOplog.put(key, oplog); } if (inactivePromotedCount > 0) { parent.getStats().incInactiveOplogs(-inactivePromotedCount); } } }
private void handleEmpty(boolean calledByCompactor) { lockCompactor(); try { if (!calledByCompactor) { logger.info(LocalizedMessage.create(LocalizedStrings.Oplog_CLOSING_EMPTY_OPLOG_0_1, new Object[] { getParent().getName(), toString() })); } cancelKrf(); close(); deleteFiles(getHasDeletes()); } finally { unlockCompactor(); } }
private void handleEmpty(boolean calledByCompactor) { lockCompactor(); try { if (!calledByCompactor) { if (logger.infoEnabled()) { logger.info(LocalizedStrings.Oplog_CLOSING_EMPTY_OPLOG_0_1, new Object[] {getParent().getName(), toString()}); } } cancelKrf(); close(); deleteFiles(getHasDeletes()); } finally { unlockCompactor(); } }
private void offlineCompact(OplogEntryIdSet deletedIds, boolean latestOplog) { // If we only do this if "(getRecordsSkipped() > 0)" then it will only compact // an oplog that has some garbage in it. // Instead if we do every oplog in case they set maxOplogSize // then all oplogs will be converted to obey maxOplogSize. // 45777: for normal offline compaction, we only do it when getRecordsSkipped() > 0 // but for upgrade disk store, we have to do it for pure creates oplog if (getRecordsSkipped() > 0 || getHasDeletes() || getParent().isUpgradeVersionOnly()) { this.offlineCompactPhase2 = true; if(getOplogSet().getChild() == null) { getOplogSet().initChild(); } readCrf(deletedIds, true, latestOplog); this.deleted.set(false); destroyCrfOnly(); } else { // For every live entry in this oplog add it to the deleted set // so that we will skip it when we recovery the next oplogs. for (OplogEntryIdMap.Iterator it = getRecoveryMap().iterator(); it.hasNext();) { it.advance(); deletedIds.add(it.key()); } close(); } }
private void offlineCompact(OplogEntryIdSet deletedIds, boolean latestOplog) { // If we only do this if "(getRecordsSkipped() > 0)" then it will only // compact // an oplog that has some garbage in it. // Instead if we do every oplog in case they set maxOplogSize // then all oplogs will be converted to obey maxOplogSize. // 45777: for normal offline compaction, we only do it when // getRecordsSkipped() > 0 // but for upgrade disk store, we have to do it for pure creates oplog if (getRecordsSkipped() > 0 || getHasDeletes() || getParent().isUpgradeVersionOnly()) { this.offlineCompactPhase2 = true; if (getOplogSet().getChild() == null) { getOplogSet().initChild(); } readCrf(deletedIds, true, latestOplog); this.deleted.set(false); destroyCrfOnly(); } else { // For every live entry in this oplog add it to the deleted set // so that we will skip it when we recovery the next oplogs. for (OplogEntryIdMap.Iterator it = getRecoveryMap().iterator(); it.hasNext();) { it.advance(); deletedIds.add(it.key()); } close(); } }
public void testGetChild() { deleteFiles(); region = DiskRegionHelperFactory .getAsyncPersistOnlyRegion(cache, diskProps); DiskRegion dr = ((LocalRegion)region).getDiskRegion(); Oplog oplog = dr.testHook_getChild(); long id = oplog.getOplogId(); StatisticsFactory factory = region.getCache().getDistributedSystem(); Oplog newOplog = new Oplog(id, dr.getOplogSet(), new DirectoryHolder(factory, dirs[0], 1000000, 0)); dr.getDiskStore().persistentOplogs.setChild(newOplog); assertEquals(newOplog, dr.testHook_getChild()); dr.setChild(oplog); assertEquals(oplog, dr.testHook_getChild()); newOplog.close(); newOplog = null; closeDown(); }