protected static boolean commitBuffer(final OMMapBufferEntry iEntry) { final long timer = OProfiler.getInstance().startChrono(); // FORCE THE WRITE OF THE BUFFER boolean forceSucceed = false; for (int i = 0; i < FORCE_RETRY; ++i) { try { iEntry.buffer.force(); forceSucceed = true; break; } catch (Exception e) { OLogManager.instance() .debug( iEntry, "Can't write memory buffer to disk. Retrying (" + (i + 1) + "/" + FORCE_RETRY + ")..."); OMemoryWatchDog.freeMemory(FORCE_DELAY); } } if (!forceSucceed) OLogManager.instance() .debug(iEntry, "Can't commit memory buffer to disk after %d retries", FORCE_RETRY); else OProfiler.getInstance().updateCounter("OMMapManager.pagesCommitted", 1); OProfiler.getInstance().stopChrono("OMMapManager.commitPages", timer); return forceSucceed; }
public void renameFile(long fileId, String oldFileName, String newFileName) throws IOException { synchronized (syncObject) { if (!files.containsKey(fileId)) return; final OFileClassic file = files.get(fileId); final String osFileName = file.getName(); if (osFileName.startsWith(oldFileName)) { final File newFile = new File( storageLocal.getStoragePath() + File.separator + newFileName + osFileName.substring( osFileName.lastIndexOf(oldFileName) + oldFileName.length())); boolean renamed = file.renameTo(newFile); while (!renamed) { OMemoryWatchDog.freeMemoryForResourceCleanup(100); renamed = file.renameTo(newFile); } } writeNameIdEntry(new NameFileIdEntry(oldFileName, -1), false); writeNameIdEntry(new NameFileIdEntry(newFileName, fileId), true); nameIdMap.remove(oldFileName); nameIdMap.put(newFileName, fileId); } }
public void rename(String iOldName, String iNewName) { for (OFile file : files) { final String osFileName = file.getName(); if (osFileName.startsWith(name)) { final File newFile = new File( storage.getStoragePath() + "/" + iNewName + osFileName.substring(osFileName.lastIndexOf(name) + name.length())); for (OStorageFileConfiguration conf : config.infoFiles) { if (conf.parent.name.equals(name)) conf.parent.name = iNewName; if (conf.path.endsWith(osFileName)) conf.path = new String(conf.path.replace(osFileName, newFile.getName())); } boolean renamed = file.renameTo(newFile); while (!renamed) { OMemoryWatchDog.freeMemoryForResourceCleanup(100); renamed = file.renameTo(newFile); } } } }