public void removeData(StoreTxLogPosition txLogPosition, long fromIndex, int length) { // 减少存活数就可以了, 物理删除滞后 fileHeader.getAliveNum().decrementAndGet(); synchronized (this) { this.lastTxLogPosition = txLogPosition; } }
public void removeData(StoreTxLogPosition txLogPosition, long fromIndex, int length) { // 减少存活数就可以了, 物理删除滞后 fileHeader.getAliveNum().decrementAndGet(); synchronized (this) { this.lastTxLogPosition = txLogPosition; } }
public void flushDisk() throws IOException { if (totalNum == fileHeader.getTotalNum().get() && aliveNum == fileHeader.getAliveNum().get()) { return; } totalNum = fileHeader.getTotalNum().get(); aliveNum = fileHeader.getAliveNum().get(); if (DataBlock.LOGGER.isDebugEnabled()) { DataBlock.LOGGER.debug("flush Data start"); } synchronized (this) { fileHeader.setStoreTxLogRecordId(lastTxLogPosition.getRecordId()); // 先把data数据刷到磁盘 fileChannel.force(true); } // 再写文件头部汇总信息 fileHeader.write(fileChannel); if (DataBlock.LOGGER.isDebugEnabled()) { DataBlock.LOGGER.debug("flush Data end:" + JSON.toJSONString(fileHeader)); } }
public void flushDisk() throws IOException { if (totalNum == fileHeader.getTotalNum().get() && aliveNum == fileHeader.getAliveNum().get()) { return; } totalNum = fileHeader.getTotalNum().get(); aliveNum = fileHeader.getAliveNum().get(); if (DataBlock.LOGGER.isDebugEnabled()) { DataBlock.LOGGER.debug("flush Data start"); } synchronized (this) { fileHeader.setStoreTxLogRecordId(lastTxLogPosition.getRecordId()); // 先把data数据刷到磁盘 fileChannel.force(true); } // 再写文件头部汇总信息 fileHeader.write(fileChannel); if (DataBlock.LOGGER.isDebugEnabled()) { DataBlock.LOGGER.debug("flush Data end:" + JSON.toJSONString(fileHeader)); } }
/** * 写data */ public DataAppendResult append(StoreTxLogPosition txLog, byte[] dataBytes) throws IOException { int length = dataBytes.length; DataAppendResult result = new DataAppendResult(); synchronized (this) { if (length > maxDataEntrySize) { throw new DBException("Value size can not great than " + maxDataEntrySize); } if (fileHeader.getFileLength() + length >= fileSize) { fileHeader.markFull(); throw new CapacityNotEnoughException(); } ReadableByteChannel src = Channels.newChannel(new UnsafeByteArrayInputStream(dataBytes)); long position = fileHeader.getFileLength(); fileChannel.transferFrom(src, position, length); result.setFileId(fileId); result.setFromIndex(position); result.setLength(length); fileHeader.setFileLength(fileHeader.getFileLength() + length); fileHeader.getTotalNum().incrementAndGet(); fileHeader.getAliveNum().incrementAndGet(); this.lastTxLogPosition = txLog; } return result; }
/** * 写data */ public DataAppendResult append(StoreTxLogPosition txLog, byte[] dataBytes) throws IOException { int length = dataBytes.length; DataAppendResult result = new DataAppendResult(); synchronized (this) { if (length > maxDataEntrySize) { throw new DBException("Value size can not great than " + maxDataEntrySize); } if (fileHeader.getFileLength() + length >= fileSize) { fileHeader.markFull(); throw new CapacityNotEnoughException(); } ReadableByteChannel src = Channels.newChannel(new UnsafeByteArrayInputStream(dataBytes)); long position = fileHeader.getFileLength(); fileChannel.transferFrom(src, position, length); result.setFileId(fileId); result.setFromIndex(position); result.setLength(length); fileHeader.setFileLength(fileHeader.getFileLength() + length); fileHeader.getTotalNum().incrementAndGet(); fileHeader.getAliveNum().incrementAndGet(); this.lastTxLogPosition = txLog; } return result; }
public void removeData(StoreTxLogPosition txLogPosition, long fromIndex, int length) { // 减少存活数就可以了, 物理删除滞后 fileHeader.getAliveNum().decrementAndGet(); synchronized (this) { this.lastTxLogPosition = txLogPosition; } }
public void flushDisk() throws IOException { if (totalNum == fileHeader.getTotalNum().get() && aliveNum == fileHeader.getAliveNum().get()) { return; } totalNum = fileHeader.getTotalNum().get(); aliveNum = fileHeader.getAliveNum().get(); if (DataBlock.LOGGER.isDebugEnabled()) { DataBlock.LOGGER.debug("flush Data start"); } synchronized (this) { fileHeader.setStoreTxLogRecordId(lastTxLogPosition.getRecordId()); // 先把data数据刷到磁盘 fileChannel.force(true); } // 再写文件头部汇总信息 fileHeader.write(fileChannel); if (DataBlock.LOGGER.isDebugEnabled()) { DataBlock.LOGGER.debug("flush Data end:" + JSON.toJSONString(fileHeader)); } }
/** * 写data */ public DataAppendResult append(StoreTxLogPosition txLog, byte[] dataBytes) throws IOException { int length = dataBytes.length; DataAppendResult result = new DataAppendResult(); synchronized (this) { if (length > maxDataEntrySize) { throw new DBException("Value size can not great than " + maxDataEntrySize); } if (fileHeader.getFileLength() + length >= fileSize) { fileHeader.markFull(); throw new CapacityNotEnoughException(); } ReadableByteChannel src = Channels.newChannel(new UnsafeByteArrayInputStream(dataBytes)); long position = fileHeader.getFileLength(); fileChannel.transferFrom(src, position, length); result.setFileId(fileId); result.setFromIndex(position); result.setLength(length); fileHeader.setFileLength(fileHeader.getFileLength() + length); fileHeader.getTotalNum().incrementAndGet(); fileHeader.getAliveNum().incrementAndGet(); this.lastTxLogPosition = txLog; } return result; }