public Integer getCurrentDataFileId() { synchronized (currentDataFile) { return currentDataFile.get().getDataFileId(); } }
synchronized DataFileAccessor openDataFileAccessor(DataFile dataFile) throws IOException { if (closed) { throw new IOException("Closed."); } Pool pool = pools.get(dataFile.getDataFileId()); if (pool == null) { pool = new Pool(dataFile); pools.put(dataFile.getDataFileId(), pool); } return pool.openDataFileReader(); }
synchronized void disposeDataFileAccessors(DataFile dataFile) { if (closed) { throw new IllegalStateException("Closed."); } Pool pool = pools.get(dataFile.getDataFileId()); if (pool != null) { if (pool.getOpenCounter() == 0) { pool.dispose(); pools.remove(dataFile.getDataFileId()); } else { throw new IllegalStateException("The data file is still in use: " + dataFile + ", use count: " + pool.getOpenCounter()); } } }
private void rotateWriteFile() throws IOException { synchronized (dataFileIdLock) { DataFile dataFile = nextDataFile; if (dataFile == null) { dataFile = newDataFile(); } synchronized (currentDataFile) { fileMap.put(dataFile.getDataFileId(), dataFile); fileByFileMap.put(dataFile.getFile(), dataFile); dataFiles.addLast(dataFile); currentDataFile.set(dataFile); } nextDataFile = null; } if (PreallocationScope.ENTIRE_JOURNAL_ASYNC == preallocationScope) { preAllocateNextDataFileFuture = scheduler.submit(preAllocateNextDataFileTask); } }
synchronized void closeDataFileAccessor(DataFileAccessor reader) { Pool pool = pools.get(reader.getDataFile().getDataFileId()); if (pool == null || closed) { reader.dispose(); } else { pool.closeDataFileReader(reader); } }
int num = Integer.parseInt(numStr); DataFile dataFile = new ReadOnlyDataFile(file, num); fileMap.put(dataFile.getDataFileId(), dataFile); totalLength.addAndGet(dataFile.getLength()); } catch (NumberFormatException e) {
public DataFile reserveDataFile() { synchronized (dataFileIdLock) { int nextNum = nextDataFileId++; File file = getFile(nextNum); DataFile reservedDataFile = new DataFile(file, nextNum); synchronized (currentDataFile) { fileMap.put(reservedDataFile.getDataFileId(), reservedDataFile); fileByFileMap.put(file, reservedDataFile); if (dataFiles.isEmpty()) { dataFiles.addLast(reservedDataFile); } else { dataFiles.getTail().linkBefore(reservedDataFile); } } return reservedDataFile; } }
public void append(Journal.WriteCommand write) throws IOException { this.writes.addLast(write); write.location.setDataFileId(dataFile.getDataFileId()); write.location.setOffset(offset+size); int s = write.location.getSize(); size += s; dataFile.incrementLength(s); journal.addToTotalLength(s); } }
int num = Integer.parseInt(numStr); DataFile dataFile = new DataFile(file, num); fileMap.put(dataFile.getDataFileId(), dataFile); totalLength.addAndGet(dataFile.getLength()); } catch (NumberFormatException e) {
public void append(Journal.WriteCommand write) throws IOException { this.writes.addLast(write); write.location.setDataFileId(dataFile.getDataFileId()); write.location.setOffset(offset + size); int s = write.location.getSize(); size += s; dataFile.incrementLength(s); journal.addToTotalLength(s); } }
Collection<DataFile> dataFiles = journal.getFileMap().values(); for (DataFile dataFile : dataFiles) { int id = dataFile.getDataFileId(); for (long offset : dataFile.getCorruptedBlocks()) { corruptedLocations.add(new Location(id, (int) offset));
Collection<DataFile> dataFiles = journal.getFileMap().values(); for (DataFile dataFile : dataFiles) { int id = dataFile.getDataFileId();
public Location getFirstLocation() throws IllegalStateException, IOException { if( dataFiles.isEmpty() ) { return null; } DataFile first = dataFiles.getHead(); Location cur = new Location(); cur.setDataFileId(first.getDataFileId()); cur.setOffset(0); cur.setSize(0); return getNextLocation(cur); }
protected Location recoveryCheck(DataFile dataFile) throws IOException { Location location = new Location(); location.setDataFileId(dataFile.getDataFileId()); location.setOffset(0);
logger.warn("Journal failed while writing at: " + wb.dataFile.getDataFileId() + ":" + wb.offset, error); synchronized (enqueueMutex) { shutdown = true;
cur.setDataFileId(head.getDataFileId()); cur.setOffset(0); } else { return null; } else { cur.setDataFileId(dataFile.getDataFileId().intValue()); cur.setOffset(0); if (limit != null && cur.compareTo(limit) >= 0) {
public Integer getCurrentDataFileId() { synchronized (currentDataFile) { return currentDataFile.get().getDataFileId(); } }
public Integer getCurrentDataFileId() { synchronized (currentDataFile) { return currentDataFile.get().getDataFileId(); } }
synchronized DataFileAccessor openDataFileAccessor(DataFile dataFile) throws IOException { if (closed) { throw new IOException("Closed."); } Pool pool = pools.get(dataFile.getDataFileId()); if (pool == null) { pool = new Pool(dataFile); pools.put(dataFile.getDataFileId(), pool); } return pool.openDataFileReader(); }
public void append(Journal.WriteCommand write) throws IOException { this.writes.addLast(write); write.location.setDataFileId(dataFile.getDataFileId()); write.location.setOffset(offset+size); int s = write.location.getSize(); size += s; dataFile.incrementLength(s); journal.addToTotalLength(s); } }