List<String> entries = getSubdirEntries(); if (entries != null) { state.curEntry = nextSorted(entries, state.curEntry); File blkFile = getBlockFile(bpid, block); File metaFile = FsDatasetUtil.findMetaFile(blkFile); block.setGenerationStamp( state.curFinalizedSubDir = getNextFinalizedSubDir(); if (state.curFinalizedSubDir == null) { state.curFinalizedDir = getNextFinalizedDir(); if (state.curFinalizedDir == null) { state.atEnd = true;
private String getNextFinalizedDir() throws IOException { File dir = Paths.get( bpidDir.getAbsolutePath(), "current", "finalized").toFile(); return getNextSubDir(state.curFinalizedDir, dir); }
@Override public void save() throws IOException { state.lastSavedMs = Time.now(); boolean success = false; try (BufferedWriter writer = new BufferedWriter( new OutputStreamWriter(fileIoProvider.getFileOutputStream( FsVolumeImpl.this, getTempSaveFile()), "UTF-8"))) { WRITER.writeValue(writer, state); success = true; } finally { if (!success) { fileIoProvider.delete(FsVolumeImpl.this, getTempSaveFile()); } } fileIoProvider.move(FsVolumeImpl.this, getTempSaveFile().toPath(), getSaveFile().toPath(), StandardCopyOption.ATOMIC_MOVE); if (LOG.isTraceEnabled()) { LOG.trace("save({}, {}): saved {}", storageID, bpid, WRITER.writeValueAsString(state)); } }
List<String> entries = getSubdirEntries(); if (entries != null) { state.curEntry = nextSorted(entries, state.curEntry); state.curFinalizedSubDir = getNextFinalizedSubDir(); if (state.curFinalizedSubDir == null) { state.curFinalizedDir = getNextFinalizedDir(); if (state.curFinalizedDir == null) { state.atEnd = true;
List<String> entries = getSubdirEntries(); if (entries != null) { state.curEntry = nextSorted(entries, state.curEntry); state.curFinalizedSubDir = getNextFinalizedSubDir(); if (state.curFinalizedSubDir == null) { state.curFinalizedDir = getNextFinalizedDir(); if (state.curFinalizedDir == null) { state.atEnd = true;
@Override public void save() throws IOException { state.lastSavedMs = Time.now(); boolean success = false; ObjectMapper mapper = new ObjectMapper(); try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(getTempSaveFile(), false), "UTF-8"))) { mapper.writerWithDefaultPrettyPrinter().writeValue(writer, state); success = true; } finally { if (!success) { if (getTempSaveFile().delete()) { LOG.debug("save({}, {}): error deleting temporary file.", storageID, bpid); } } } Files.move(getTempSaveFile().toPath(), getSaveFile().toPath(), StandardCopyOption.ATOMIC_MOVE); if (LOG.isTraceEnabled()) { LOG.trace("save({}, {}): saved {}", storageID, bpid, mapper.writerWithDefaultPrettyPrinter().writeValueAsString(state)); } }
@Override public void save() throws IOException { state.lastSavedMs = Time.now(); boolean success = false; ObjectMapper mapper = new ObjectMapper(); try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(getTempSaveFile(), false), "UTF-8"))) { mapper.writerWithDefaultPrettyPrinter().writeValue(writer, state); success = true; } finally { if (!success) { if (getTempSaveFile().delete()) { LOG.debug("save({}, {}): error deleting temporary file.", storageID, bpid); } } } Files.move(getTempSaveFile().toPath(), getSaveFile().toPath(), StandardCopyOption.ATOMIC_MOVE); if (LOG.isTraceEnabled()) { LOG.trace("save({}, {}): saved {}", storageID, bpid, mapper.writerWithDefaultPrettyPrinter().writeValueAsString(state)); } }
@Override public BlockIterator newBlockIterator(String bpid, String name) { return new BlockIteratorImpl(bpid, name); }
@Override public BlockIterator newBlockIterator(String bpid, String name) { return new BlockIteratorImpl(bpid, name); }
private String getNextFinalizedDir() throws IOException { File dir = Paths.get( bpidDir.getAbsolutePath(), "current", "finalized").toFile(); return getNextSubDir(state.curFinalizedDir, dir); }
@Override public BlockIterator loadBlockIterator(String bpid, String name) throws IOException { BlockIteratorImpl iter = new BlockIteratorImpl(bpid, name); iter.load(); return iter; }
private String getNextFinalizedSubDir() throws IOException { if (state.curFinalizedDir == null) { return null; } File dir = Paths.get( bpidDir.getAbsolutePath(), "current", "finalized", state.curFinalizedDir).toFile(); return getNextSubDir(state.curFinalizedSubDir, dir); }
private String getNextFinalizedSubDir() throws IOException { if (state.curFinalizedDir == null) { return null; } File dir = Paths.get( bpidDir.getAbsolutePath(), "current", "finalized", state.curFinalizedDir).toFile(); return getNextSubDir(state.curFinalizedSubDir, dir); }
BlockIteratorImpl(String bpid, String name) { this.bpidDir = new File(currentDir, bpid); this.name = name; this.bpid = bpid; rewind(); }
BlockIteratorImpl(String bpid, String name) { this.bpidDir = new File(currentDir, bpid); this.name = name; this.bpid = bpid; rewind(); }
@Override public BlockIterator loadBlockIterator(String bpid, String name) throws IOException { BlockIteratorImpl iter = new BlockIteratorImpl(bpid, name); iter.load(); return iter; }
private String getNextFinalizedDir() throws IOException { File dir = Paths.get( bpidDir.getAbsolutePath(), "current", "finalized").toFile(); return getNextSubDir(state.curFinalizedDir, dir); }
public void load() throws IOException { ObjectMapper mapper = new ObjectMapper(); File file = getSaveFile(); this.state = mapper.reader(BlockIteratorState.class).readValue(file); LOG.trace("load({}, {}): loaded iterator {} from {}: {}", storageID, bpid, name, file.getAbsoluteFile(), mapper.writerWithDefaultPrettyPrinter().writeValueAsString(state)); }
public void load() throws IOException { ObjectMapper mapper = new ObjectMapper(); File file = getSaveFile(); this.state = mapper.reader(BlockIteratorState.class).readValue(file); LOG.trace("load({}, {}): loaded iterator {} from {}: {}", storageID, bpid, name, file.getAbsoluteFile(), mapper.writerWithDefaultPrettyPrinter().writeValueAsString(state)); }
@Override public BlockIterator loadBlockIterator(String bpid, String name) throws IOException { BlockIteratorImpl iter = new BlockIteratorImpl(bpid, name); iter.load(); return iter; }