/** * This method is slow and should be optimized if used for anything important. * At this time it was added to do some internal assertions that have since * been removed. */ public DiskRegion getByName(String name) { for (DiskRegion dr : getDiskRegions()) { if (dr.getName().equals(name)) { return dr; } } return null; }
/** * This method is slow and should be optimized if used for anything important. * At this time it was added to do some internal assertions that have since * been removed. */ DiskRegion getByName(String name) { for (DiskRegion dr : getDiskRegions()) { if (dr.getName().equals(name)) { return dr; } } return null; }
/** * Removes the key/value pair with the given id on disk. * * @param entry * DiskEntry object on which remove operation is called */ public final void remove(DiskRegion dr, DiskEntry entry) { try { basicRemove(dr, entry); } catch (IOException ex) { throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_WRITING_KEY_TO_0.toLocalizedString(this.diskFile.getPath()), ex, dr.getName()); } catch (InterruptedException ie) { Thread.currentThread().interrupt(); dr.getCancelCriterion().checkCancelInProgress(ie); throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_WRITING_KEY_TO_0_DUE_TO_FAILURE_IN_ACQUIRING_READ_LOCK_FOR_ASYNCH_WRITING.toLocalizedString(this.diskFile.getPath()), ie, dr.getName()); } }
/** * Removes the key/value pair with the given id on disk. * * @param entry * DiskEntry object on which remove operation is called */ public final void remove(DiskRegion dr, DiskEntry entry) { try { basicRemove(dr, entry); } catch (IOException ex) { throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_WRITING_KEY_TO_0.toLocalizedString(this.diskFile.getPath()), ex, dr.getName()); } catch (InterruptedException ie) { Thread.currentThread().interrupt(); dr.getCancelCriterion().checkCancelInProgress(ie); throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_WRITING_KEY_TO_0_DUE_TO_FAILURE_IN_ACQUIRING_READ_LOCK_FOR_ASYNCH_WRITING.toLocalizedString(this.diskFile.getPath()), ie, dr.getName()); } }
/** * All callers must have {@link #releaseReadLock(DiskRegion)} in a matching * finally block. Note that this is no longer implemented by getting a read * lock but instead locks the same lock that acquireWriteLock does. * * @since 5.1 */ void acquireReadLock(DiskRegion dr) { dr.basicAcquireReadLock(); synchronized (this.closeRegionGuard) { entryOpsCount.incrementAndGet(); if (dr.isRegionClosed()) { dr.releaseReadLock(); throw new RegionDestroyedException( "The DiskRegion has been closed or destroyed", dr.getName()); } } }
/** * All callers must have {@link #releaseReadLock(DiskRegion)} in a matching * finally block. Note that this is no longer implemented by getting a read * lock but instead locks the same lock that acquireWriteLock does. * * @since 5.1 */ void acquireReadLock(DiskRegion dr) { dr.basicAcquireReadLock(); synchronized (this.closeRegionGuard) { entryOpsCount.incrementAndGet(); if (dr.isRegionClosed()) { dr.releaseReadLock(); throw new RegionDestroyedException( "The DiskRegion has been closed or destroyed", dr.getName()); } } }
return basicModify(entry, value, userBits, async); } catch (IOException ex) { throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_WRITING_KEY_TO_0.toLocalizedString(this.diskFile.getPath()), ex, dr.getName()); } catch (InterruptedException ie) { Thread.currentThread().interrupt(); dr.getCancelCriterion().checkCancelInProgress(ie); throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_WRITING_KEY_TO_0_DUE_TO_FAILURE_IN_ACQUIRING_READ_LOCK_FOR_ASYNCH_WRITING.toLocalizedString(this.diskFile.getPath()), ie, dr.getName());
return basicModify(entry, value, userBits, async); } catch (IOException ex) { throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_WRITING_KEY_TO_0.toLocalizedString(this.diskFile.getPath()), ex, dr.getName()); } catch (InterruptedException ie) { Thread.currentThread().interrupt(); dr.getCancelCriterion().checkCancelInProgress(ie); throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_WRITING_KEY_TO_0_DUE_TO_FAILURE_IN_ACQUIRING_READ_LOCK_FOR_ASYNCH_WRITING.toLocalizedString(this.diskFile.getPath()), ie, dr.getName());
void addDiskRegion(DiskRegion dr) { if (dr.isBackup()) { PersistentOplogSet oplogSet = getPersistentOplogSet(dr); if(!isOffline()) { oplogSet.initChild(); } DiskRegion old = this.drMap.putIfAbsent(dr.getId(), dr); if (old != null) { throw new IllegalStateException("DiskRegion already exists with id " + dr.getId() + " and name " + old.getName()); } getDiskInitFile().createRegion(dr); } else { this.overflowMap.add(dr); } if (getOwnedByRegion()) { this.ownCount.incrementAndGet(); } }
void addDiskRegion(DiskRegion dr) { if (dr.isBackup()) { PersistentOplogSet oplogSet = getPersistentOplogSet(dr); if(!isOffline()) { oplogSet.initChild(); } DiskRegion old = this.drMap.putIfAbsent(dr.getId(), dr); if (old != null) { throw new IllegalStateException("DiskRegion already exists with id " + dr.getId() + " and name " + old.getName()); } getDiskInitFile().createRegion(dr); } else { this.overflowMap.add(dr); } if (getOwnedByRegion()) { this.ownCount.incrementAndGet(); // logger.info(LocalizedStrings.DEBUG, "DEBUG: ds=" + getName() // + "addDiskRegion ownCount=" + getOwnCount(), new // RuntimeException("STACK")); } }
final BytesAndBits getBytesAndBits(DiskRegion dr, DiskId id, boolean faultingIn) { acquireReadLock(dr); try { if (dr.isRegionClosed()) { throw new RegionDestroyedException( LocalizedStrings.DiskRegion_THE_DISKREGION_HAS_BEEN_CLOSED_OR_DESTROYED .toLocalizedString(), dr.getName()); } if (dr.didClearCountChange()) { throw new DiskAccessException( LocalizedStrings.DiskRegion_ENTRY_HAS_BEEN_CLEARED_AND_IS_NOT_PRESENT_ON_DISK .toLocalizedString(), dr.getName()); } BytesAndBits bb = getBytesAndBitsWithoutLock(dr, id, faultingIn, false /* * Get * only * user * bit */); if (bb == CLEAR_BB) { throw new DiskAccessException( LocalizedStrings.DiskRegion_ENTRY_HAS_BEEN_CLEARED_AND_IS_NOT_PRESENT_ON_DISK .toLocalizedString(), dr.getName()); } return bb; } finally { releaseReadLock(dr); } }
final BytesAndBits getBytesAndBits(DiskRegion dr, DiskId id, boolean faultingIn) { acquireReadLock(dr); try { BytesAndBits bb = getBytesAndBitsWithoutLock(dr, id, faultingIn, false /* * Get * only * user * bit */); if (bb == CLEAR_BB) { throw new DiskAccessException( LocalizedStrings.DiskRegion_ENTRY_HAS_BEEN_CLEARED_AND_IS_NOT_PRESENT_ON_DISK .toLocalizedString(), dr.getName()); } return bb; } finally { releaseReadLock(dr); } }
/** * Write the GC RVV for a single region to disk */ public final void writeGCRVV(DiskRegion dr) { boolean useNextOplog = false; synchronized (this.lock) { if (getOplogSet().getChild() != this) { useNextOplog = true; } else { try { writeRVVRecord(this.drf, Collections.<Long, AbstractDiskRegion> singletonMap(dr.getId(), dr), true); } catch (IOException ex) { dr.getCancelCriterion().checkCancelInProgress(ex); throw new DiskAccessException(LocalizedStrings.Oplog_FAILED_RECORDING_RVV_BECAUSE_OF_0.toLocalizedString(this.diskFile .getPath()), ex, dr.getName()); } } } if (useNextOplog) { getOplogSet().getChild().writeGCRVV(dr); } else { DiskStoreObserver.endWriteGCRVV(dr); } }
/** * Write the GC RVV for a single region to disk */ public final void writeGCRVV(DiskRegion dr) { boolean useNextOplog = false; synchronized (this.lock) { if (getOplogSet().getChild() != this) { useNextOplog = true; } else { try { writeRVVRecord( this.drf, Collections.<Long, AbstractDiskRegion> singletonMap(dr.getId(), dr), true); } catch (IOException ex) { dr.getCancelCriterion().checkCancelInProgress(ex); throw new DiskAccessException( LocalizedStrings.Oplog_FAILED_RECORDING_RVV_BECAUSE_OF_0.toLocalizedString(this.diskFile .getPath()), ex, dr.getName()); } } } if(useNextOplog) { getOplogSet().getChild().writeGCRVV(dr); } else { DiskStoreObserver.endWriteGCRVV(dr); } }
public void writeRVV(DiskRegion dr, LocalRegion region, Boolean isRVVTrusted) { acquireReadLock(dr); try { if (dr.isRegionClosed()) { dr.getCancelCriterion().checkCancelInProgress(null); throw new RegionDestroyedException( LocalizedStrings.DiskRegion_THE_DISKREGION_HAS_BEEN_CLOSED_OR_DESTROYED .toLocalizedString(), dr.getName()); } RegionVersionVector inMemoryRVV = (region==null)?null:region.getVersionVector(); // persist the new GC RVV information for this region to the CRF PersistentOplogSet oplogSet = getPersistentOplogSet(dr); // use current dr.rvvTrust oplogSet.getChild().writeRVV(dr, inMemoryRVV, isRVVTrusted); } finally { releaseReadLock(dr); } }
throw new RegionDestroyedException( LocalizedStrings.DiskRegion_THE_DISKREGION_HAS_BEEN_CLOSED_OR_DESTROYED .toLocalizedString(), dr.getName());
public void writeRVV(DiskRegion dr, LocalRegion region, Boolean isRVVTrusted) { if (region != null && !region.getConcurrencyChecksEnabled()) { return; } acquireReadLock(dr); try { if (dr.isRegionClosed()) { dr.getCancelCriterion().checkCancelInProgress(null); throw new RegionDestroyedException( LocalizedStrings.DiskRegion_THE_DISKREGION_HAS_BEEN_CLOSED_OR_DESTROYED .toLocalizedString(), dr.getName()); } RegionVersionVector inMemoryRVV = (region==null)?null:region.getVersionVector(); // persist the new GC RVV information for this region to the CRF PersistentOplogSet oplogSet = getPersistentOplogSet(dr); // use current dr.rvvTrust oplogSet.getChild().writeRVV(dr, inMemoryRVV, isRVVTrusted); } finally { releaseReadLock(dr); } }
throw new RegionDestroyedException( LocalizedStrings.DiskRegion_THE_DISKREGION_HAS_BEEN_CLOSED_OR_DESTROYED .toLocalizedString(), dr.getName());
final void putVersionTagOnly(LocalRegion region, VersionTag tag, boolean async) { DiskRegion dr = region.getDiskRegion(); // this method will only be called by backup oplog assert dr.isBackup(); if (!async) { acquireReadLock(dr); } try { if (dr.isRegionClosed()) { region.getCancelCriterion().checkCancelInProgress(null); throw new RegionDestroyedException( LocalizedStrings.DiskRegion_THE_DISKREGION_HAS_BEEN_CLOSED_OR_DESTROYED .toLocalizedString(), dr.getName()); } if (dr.getRegionVersionVector().contains(tag.getMemberID(), tag.getRegionVersion())) { // No need to write the conflicting tag to disk if the disk RVV already // contains this tag. return; } PersistentOplogSet oplogSet = getPersistentOplogSet(dr); oplogSet.getChild().saveConflictVersionTag(region, tag, async); } finally { if (!async) { releaseReadLock(dr); } } }
final void putVersionTagOnly(LocalRegion region, VersionTag tag, boolean async) { DiskRegion dr = region.getDiskRegion(); // this method will only be called by backup oplog assert dr.isBackup(); if (!async) { acquireReadLock(dr); } try { if (dr.isRegionClosed()) { region.getCancelCriterion().checkCancelInProgress(null); throw new RegionDestroyedException( LocalizedStrings.DiskRegion_THE_DISKREGION_HAS_BEEN_CLOSED_OR_DESTROYED .toLocalizedString(), dr.getName()); } if (dr.getRegionVersionVector().contains(tag.getMemberID(), tag.getRegionVersion())) { // No need to write the conflicting tag to disk if the disk RVV already // contains this tag. return; } PersistentOplogSet oplogSet = getPersistentOplogSet(dr); oplogSet.getChild().saveConflictVersionTag(region, tag, async); } finally { if (!async) { releaseReadLock(dr); } } }