inflightWrites.put(new Journal.WriteKey(write.location), write);
inflightWrites.put(new Journal.WriteKey(write.location), write);
inflightWrites.put(new Journal.WriteKey(write.location), write);
inflightWrites.put(new Journal.WriteKey(write.location), write);
public ByteSequence readRecord(Location location) throws IOException { if (!location.isValid()) { throw new IOException("Invalid location: " + location); } Journal.WriteCommand asyncWrite = inflightWrites.get(new Journal.WriteKey(location)); if (asyncWrite != null) { return asyncWrite.data; } try { if (location.getSize() == Location.NOT_SET) { file.seek(location.getOffset()); location.setSize(file.readInt()); location.setType(file.readByte()); } else { file.seek(location.getOffset() + Journal.RECORD_HEAD_SPACE); } if ((long)location.getOffset() + location.getSize() > dataFile.length) { throw new IOException("Invalid location size: " + location + ", size: " + location.getSize()); } byte[] data = new byte[location.getSize() - Journal.RECORD_HEAD_SPACE]; file.readFully(data); return new ByteSequence(data, 0, data.length); } catch (RuntimeException e) { throw new IOException("Invalid location: " + location + " : " + e, e); } }
public ByteSequence readRecord(Location location) throws IOException { if (!location.isValid()) { throw new IOException("Invalid location: " + location); } Journal.WriteCommand asyncWrite = inflightWrites.get(new Journal.WriteKey(location)); if (asyncWrite != null) { return asyncWrite.data; } try { if (location.getSize() == Location.NOT_SET) { file.seek(location.getOffset()); location.setSize(file.readInt()); location.setType(file.readByte()); } else { file.seek(location.getOffset() + Journal.RECORD_HEAD_SPACE); } if ((long)location.getOffset() + location.getSize() > dataFile.length) { throw new IOException("Invalid location size: " + location + ", size: " + location.getSize()); } byte[] data = new byte[location.getSize() - Journal.RECORD_HEAD_SPACE]; file.readFully(data); return new ByteSequence(data, 0, data.length); } catch (RuntimeException e) { throw new IOException("Invalid location: " + location + " : " + e, e); } }
public ByteSequence readRecord(Location location) throws IOException { if (!location.isValid()) { throw new IOException("Invalid location: " + location); } Journal.WriteCommand asyncWrite = inflightWrites.get(new Journal.WriteKey(location)); if (asyncWrite != null) { return asyncWrite.data; } try { if (location.getSize() == Location.NOT_SET) { file.seek(location.getOffset()); location.setSize(file.readInt()); location.setType(file.readByte()); } else { file.seek(location.getOffset() + Journal.RECORD_HEAD_SPACE); } if ((long)location.getOffset() + location.getSize() > dataFile.length) { throw new IOException("Invalid location size: " + location + ", size: " + location.getSize()); } byte[] data = new byte[location.getSize() - Journal.RECORD_HEAD_SPACE]; file.readFully(data); return new ByteSequence(data, 0, data.length); } catch (RuntimeException e) { throw new IOException("Invalid location: " + location + " : " + e, e); } }
private WriteBatch enqueueWrite(Journal.WriteCommand write) throws IOException { while (true) { if (nextWriteBatch == null) { nextWriteBatch = new WriteBatch(target, target.getLength(), write); break; } else { // Append to current batch if possible.. if (nextWriteBatch.canAppend(write)) { nextWriteBatch.append(write); break; } else { // Flush current batch and start a new one. writePendingBatch(); nextWriteBatch = null; } } } if (!write.sync) { inflightWrites.put(new Journal.WriteKey(write.location), write); } return nextWriteBatch; }
private WriteBatch enqueueWrite(Journal.WriteCommand write) throws IOException { while (true) { if (nextWriteBatch == null) { nextWriteBatch = new WriteBatch(target, target.getLength(), write); break; } else { // Append to current batch if possible.. if (nextWriteBatch.canAppend(write)) { nextWriteBatch.append(write); break; } else { // Flush current batch and start a new one. writePendingBatch(); nextWriteBatch = null; } } } if (!write.sync) { inflightWrites.put(new Journal.WriteKey(write.location), write); } return nextWriteBatch; }
private WriteBatch enqueueWrite(Journal.WriteCommand write) throws IOException { while (true) { if (nextWriteBatch == null) { nextWriteBatch = new WriteBatch(target, target.getLength(), write); break; } else { // Append to current batch if possible.. if (nextWriteBatch.canAppend(write)) { nextWriteBatch.append(write); break; } else { // Flush current batch and start a new one. writePendingBatch(); nextWriteBatch = null; } } } if (!write.sync) { inflightWrites.put(new Journal.WriteKey(write.location), write); } return nextWriteBatch; }
protected void signalDone(WriteBatch wb) { // Now that the data is on disk, remove the writes from the in // flight // cache. Journal.WriteCommand write = wb.writes.getHead(); while (write != null) { if (!write.sync) { inflightWrites.remove(new Journal.WriteKey(write.location)); } if (write.onComplete != null && wb.exception.get() == null) { try { write.onComplete.run(); } catch (Throwable e) { logger.info("Add exception was raised while executing the run command for onComplete", e); } } write = write.getNext(); } // Signal any waiting threads that the write is on disk. wb.latch.countDown(); }
protected void signalDone(WriteBatch wb) { // Now that the data is on disk, remove the writes from the in // flight // cache. Journal.WriteCommand write = wb.writes.getHead(); while (write != null) { if (!write.sync) { inflightWrites.remove(new Journal.WriteKey(write.location)); } if (write.onComplete != null && wb.exception.get() == null) { try { write.onComplete.run(); } catch (Throwable e) { logger.info("Add exception was raised while executing the run command for onComplete", e); } } write = write.getNext(); } // Signal any waiting threads that the write is on disk. wb.latch.countDown(); }
protected void signalDone(WriteBatch wb) { // Now that the data is on disk, remove the writes from the in // flight // cache. Journal.WriteCommand write = wb.writes.getHead(); while (write != null) { if (!write.sync) { inflightWrites.remove(new Journal.WriteKey(write.location)); } if (write.onComplete != null && wb.exception.get() == null) { try { write.onComplete.run(); } catch (Throwable e) { logger.info("Add exception was raised while executing the run command for onComplete", e); } } write = write.getNext(); } // Signal any waiting threads that the write is on disk. wb.latch.countDown(); }
private void signalDone(WriteBatch writeBatch) { // Now that the data is on disk, remove the writes from the in // flight cache and signal any onComplete requests. Journal.WriteCommand write = writeBatch.writes.getHead(); while (write != null) { if (!write.sync) { inflightWrites.remove(new Journal.WriteKey(write.location)); } if (write.onComplete != null) { try { write.onComplete.run(); } catch (Throwable e) { LOG.info("Add exception was raised while executing the run command for onComplete", e); } } write = write.getNext(); } } }
private void signalDone(WriteBatch writeBatch) { // Now that the data is on disk, remove the writes from the in // flight cache and signal any onComplete requests. Journal.WriteCommand write = writeBatch.writes.getHead(); while (write != null) { if (!write.sync) { inflightWrites.remove(new Journal.WriteKey(write.location)); } if (write.onComplete != null) { try { write.onComplete.run(); } catch (Throwable e) { LOG.info("Add exception was raised while executing the run command for onComplete", e); } } write = write.getNext(); } } }
private void signalDone(WriteBatch writeBatch) { // Now that the data is on disk, remove the writes from the in // flight cache and signal any onComplete requests. Journal.WriteCommand write = writeBatch.writes.getHead(); while (write != null) { if (!write.sync) { inflightWrites.remove(new Journal.WriteKey(write.location)); } if (write.onComplete != null) { try { write.onComplete.run(); } catch (Throwable e) { LOG.info("Add exception was raised while executing the run command for onComplete", e); } } write = write.getNext(); } } }
public void readLocationDetails(Location location) throws IOException { Journal.WriteCommand asyncWrite = inflightWrites.get(new Journal.WriteKey(location)); if (asyncWrite != null) { location.setSize(asyncWrite.location.getSize()); location.setType(asyncWrite.location.getType()); } else { file.seek(location.getOffset()); location.setSize(file.readInt()); location.setType(file.readByte()); } }
public void readLocationDetails(Location location) throws IOException { Journal.WriteCommand asyncWrite = inflightWrites.get(new Journal.WriteKey(location)); if (asyncWrite != null) { location.setSize(asyncWrite.location.getSize()); location.setType(asyncWrite.location.getType()); } else { file.seek(location.getOffset()); location.setSize(file.readInt()); location.setType(file.readByte()); } }
public void readLocationDetails(Location location) throws IOException { Journal.WriteCommand asyncWrite = inflightWrites.get(new Journal.WriteKey(location)); if (asyncWrite != null) { location.setSize(asyncWrite.location.getSize()); location.setType(asyncWrite.location.getType()); } else { file.seek(location.getOffset()); location.setSize(file.readInt()); location.setType(file.readByte()); } }
public ByteSequence readRecord(Location location) throws IOException { if (!location.isValid()) { throw new IOException("Invalid location: " + location); } Journal.WriteCommand asyncWrite = inflightWrites.get(new Journal.WriteKey(location)); if (asyncWrite != null) { return asyncWrite.data; } try { if (location.getSize() == Location.NOT_SET) { file.seek(location.getOffset()); location.setSize(file.readInt()); location.setType(file.readByte()); } else { file.seek(location.getOffset() + Journal.RECORD_HEAD_SPACE); } if ((long)location.getOffset() + location.getSize() > dataFile.length) { throw new IOException("Invalid location size: " + location + ", size: " + location.getSize()); } byte[] data = new byte[location.getSize() - Journal.RECORD_HEAD_SPACE]; file.readFully(data); return new ByteSequence(data, 0, data.length); } catch (RuntimeException e) { throw new IOException("Invalid location: " + location + " : " + e, e); } }