public String toString() { StringBuffer sb = new StringBuffer(); sb.append("dir=").append(getDir()) .append(" maxSpace=").append(getCapacity()) .append(" usedSpace=").append(getUsedSpace()) .append(" availableSpace=").append(getAvailableSpace()); return sb.toString(); }
public long getTotalBytesOnDisk() { long diskSpace = 0; for (DirectoryHolder dr : this.directoryHolders) { diskSpace += dr.getDiskDirectoryStats().getDiskSpace(); } return diskSpace; }
/** * The diskStats are at PR level.Hence if the region is a bucket region, the * stats should not be closed, but the figures of entriesInVM and * overflowToDisk contributed by that bucket need to be removed from the stats * . */ private void statsClose() { this.stats.close(); if (this.directories != null) { for (int i = 0; i < this.directories.length; i++) { this.directories[i].close(); } } }
public long getAvailableSpace() { return getCapacity() - getUsedSpace(); }
private int getArrayIndexOfDirectory(File searchDir) { for(DirectoryHolder holder : directories) { if(holder.getDir().equals(searchDir)) { return holder.getArrayIndex(); } } return 0; }
maxOplogSizeParam = minSize; long availableSpace = this.dirHolder.getAvailableSpace(); if (availableSpace < minSize this.diskFile = new File(this.dirHolder.getDir(), "OVERFLOW" + n + "_" + oplogId); try {
if (dirHolder.getAvailableSpace() >= minAvailableSpace) { selectedHolder = dirHolder; break; if (selectedHolder.getAvailableSpace() < minAvailableSpace) { LocalizedStrings.DiskRegion_COMPLEXDISKREGIONGETNEXTDIR_MAX_DIRECTORY_SIZE_WILL_GET_VIOLATED__GOING_AHEAD_WITH_THE_SWITCHING_OF_OPLOG_ANY_WAYS_CURRENTLY_AVAILABLE_SPACE_IN_THE_DIRECTORY_IS__0__THE_CAPACITY_OF_DIRECTORY_IS___1, new Object[] { Long.valueOf(selectedHolder.getUsedSpace()), Long.valueOf(selectedHolder.getCapacity()) });
@Override protected File dir() { return dir.getDir(); }
private void preblow() { this.dirHolder.incrementTotalOplogSize(this.maxOplogSize); final OplogFile olf = getOLF(); try { olf.raf.setLength(this.maxOplogSize); olf.raf.seek(0); } catch (IOException ioe) { // @todo need a warning since this can impact perf. // I don't think I need any of this. If setLength throws then // the file is still ok. // raf.close(); // if (!this.opLogFile.delete() && this.opLogFile.exists()) { // throw new DiskAccessException(LocalizedStrings.NewLBHTreeDiskRegion_COULD_NOT_DELETE__0_.toLocalizedString(this.opLogFile.getAbsolutePath()), this.owner); // } // f = new File(this.diskFile.getPath() + OPLOG_FILE_EXT); // this.opLogFile = f; // raf = new RandomAccessFile(f, "rw"); } } /**
DiskRegion dr = ((LocalRegion)region).getDiskRegion(); StatisticsFactory factory = region.getCache().getDistributedSystem(); Oplog oplog1 = new Oplog(11, dr.getOplogSet(), new DirectoryHolder(factory,dirs[1], 1000, 0)); Oplog oplog2 = new Oplog(12, dr.getOplogSet(), new DirectoryHolder(factory,dirs[2], 1000, 1)); Oplog oplog3 = new Oplog(13, dr.getOplogSet(), new DirectoryHolder(factory,dirs[3], 1000, 2));
private void preblow(OplogFile olf, long maxSize) throws IOException { long availableSpace = this.dirHolder.getAvailableSpace(); if (availableSpace >= maxSize) { try {
private void setFirstChild(TreeSet<Oplog> oplogSet, boolean force) { if (parent.isOffline() && !parent.isOfflineCompacting()) return; if (!oplogSet.isEmpty()) { Oplog first = oplogSet.first(); DirectoryHolder dh = first.getDirectoryHolder(); dirCounter = dh.getArrayIndex(); dirCounter = (++dirCounter) % parent.dirLength; // we want the first child to go in the directory after the directory // used by the existing oplog with the max id. // This fixes bug 41822. } if (force || maxRecoveredOplogId > 0) { setChild(new Oplog(maxRecoveredOplogId + 1, this, getNextDir())); } }
private void deleteFile() { final OplogFile olf = getOLF(); if (this.maxOplogSize != 0) { this.dirHolder.decrementTotalOplogSize(this.maxOplogSize); this.maxOplogSize = 0; olf.currSize = 0; } if (olf.f == null) return; if (!olf.f.exists()) return; if (!olf.f.delete() && olf.f.exists()) { throw new DiskAccessException(LocalizedStrings.Oplog_COULD_NOT_DELETE__0_.toLocalizedString(olf.f.getAbsolutePath()), this.parent); } logger.info(LocalizedMessage.create(LocalizedStrings.Oplog_DELETE_0_1_2, new Object[] {toString(), "crf", this.parent.getName()})); }
maxOplogSizeParam = minSize; long availableSpace = this.dirHolder.getAvailableSpace(); if (availableSpace < minSize this.diskFile = new File(this.dirHolder.getDir(), "OVERFLOW" + n + "_" + oplogId); try {
if (dirHolder.getAvailableSpace() >= minAvailableSpace) { if (checkForWarning && !parent.isDirectoryUsageNormal(dirHolder)) { if (logger.isDebugEnabled()) { if (selectedHolder.getAvailableSpace() < minAvailableSpace) { new Object[] { Long.valueOf(selectedHolder.getUsedSpace()), Long.valueOf(selectedHolder.getCapacity()) }));
private void deleteFiles(FilenameFilter overflowFileFilter) { for (int i = 0; i < this.directories.length; i++) { File dir = this.directories[i].getDir(); File[] files = FileUtil.listFiles(dir, overflowFileFilter); for (File file : files) { boolean deleted = file.delete(); if (!deleted && file.exists() && logger.isDebugEnabled()) { logger.debug("Could not delete file {}", file); } } } }
private void preblow() { this.dirHolder.incrementTotalOplogSize(this.maxOplogSize); final OplogFile olf = getOLF(); try { olf.raf.setLength(this.maxOplogSize); olf.raf.seek(0); } catch (IOException ioe) { // @todo need a warning since this can impact perf. // if (this.logger.warningEnabled()) { // this.logger.warning( // LocalizedStrings.Oplog_OPLOGCREATEOPLOGEXCEPTION_IN_PREBLOWING_THE_FILE_A_NEW_RAF_OBJECT_FOR_THE_OPLOG_FILE_WILL_BE_CREATED_WILL_NOT_BE_PREBLOWNEXCEPTION_STRING_IS_0, // ioe, null); // } // I don't think I need any of this. If setLength throws then // the file is still ok. // raf.close(); // if (!this.opLogFile.delete() && this.opLogFile.exists()) { // throw new DiskAccessException(LocalizedStrings.NewLBHTreeDiskRegion_COULD_NOT_DELETE__0_.toLocalizedString(this.opLogFile.getAbsolutePath()), this.owner); // } // f = new File(this.diskFile.getPath() + OPLOG_FILE_EXT); // if (logger.fineEnabled()) // logger.fine("Creating operation log file " + f); // this.opLogFile = f; // raf = new RandomAccessFile(f, "rw"); } } /**
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(); }
private int getArrayIndexOfDirectory(File searchDir) { for(DirectoryHolder holder : directories) { if(holder.getDir().equals(searchDir)) { return holder.getArrayIndex(); } } return 0; }
public long getAvailableSpace() { return getCapacity() - getUsedSpace(); }