Search in sources :

Example 26 with ExtendedDataInputStream

use of herddb.utils.ExtendedDataInputStream in project herddb by diennea.

the class BookKeeperDataStorageManager method readIndexStatusFromFile.

public IndexStatus readIndexStatusFromFile(byte[] fileContent, String checkpointsFile) throws DataStorageManagerException {
    try {
        if (fileContent == null) {
            throw new DataStorageManagerException("Missing znode for " + checkpointsFile + " IndexStatusFile");
        }
        XXHash64Utils.verifyBlockWithFooter(fileContent, 0, fileContent.length);
        try (InputStream input = new SimpleByteArrayInputStream(fileContent);
            ExtendedDataInputStream dataIn = new ExtendedDataInputStream(input)) {
            // version
            long version = dataIn.readVLong();
            // flags for future implementations
            long flags = dataIn.readVLong();
            if (version != 1 || flags != 0) {
                throw new DataStorageManagerException("corrupted index status file " + checkpointsFile);
            }
            return IndexStatus.deserialize(dataIn);
        }
    } catch (IOException err) {
        throw new DataStorageManagerException(err);
    }
}
Also used : DataStorageManagerException(herddb.storage.DataStorageManagerException) ExtendedDataInputStream(herddb.utils.ExtendedDataInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ExtendedDataInputStream(herddb.utils.ExtendedDataInputStream) SimpleByteArrayInputStream(herddb.utils.SimpleByteArrayInputStream) InputStream(java.io.InputStream) SimpleByteArrayInputStream(herddb.utils.SimpleByteArrayInputStream) IOException(java.io.IOException)

Example 27 with ExtendedDataInputStream

use of herddb.utils.ExtendedDataInputStream in project herddb by diennea.

the class BookKeeperDataStorageManager method readLogSequenceNumberFromTablesMetadataFile.

private static LogSequenceNumber readLogSequenceNumberFromTablesMetadataFile(String tableSpace, byte[] data, String znode) throws DataStorageManagerException {
    try (InputStream input = new ByteArrayInputStream(data);
        ExtendedDataInputStream din = new ExtendedDataInputStream(input)) {
        // version
        long version = din.readVLong();
        // flags for future implementations
        long flags = din.readVLong();
        if (version != 1 || flags != 0) {
            throw new DataStorageManagerException("corrupted table list znode" + znode);
        }
        String readname = din.readUTF();
        if (!readname.equals(tableSpace)) {
            throw new DataStorageManagerException("znode " + znode + " is not for spablespace " + tableSpace);
        }
        long ledgerId = din.readZLong();
        long offset = din.readZLong();
        return new LogSequenceNumber(ledgerId, offset);
    } catch (IOException err) {
        throw new DataStorageManagerException(err);
    }
}
Also used : ExtendedDataInputStream(herddb.utils.ExtendedDataInputStream) DataStorageManagerException(herddb.storage.DataStorageManagerException) ByteArrayInputStream(java.io.ByteArrayInputStream) SimpleByteArrayInputStream(herddb.utils.SimpleByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ExtendedDataInputStream(herddb.utils.ExtendedDataInputStream) SimpleByteArrayInputStream(herddb.utils.SimpleByteArrayInputStream) InputStream(java.io.InputStream) LogSequenceNumber(herddb.log.LogSequenceNumber) IOException(java.io.IOException)

Example 28 with ExtendedDataInputStream

use of herddb.utils.ExtendedDataInputStream in project herddb by diennea.

the class BookKeeperDataStorageManager method readLogSequenceNumberFromCheckpointInfoFile.

private static LogSequenceNumber readLogSequenceNumberFromCheckpointInfoFile(String tableSpace, byte[] data, String checkPointFile) throws DataStorageManagerException, IOException {
    try (InputStream input = new ByteArrayInputStream(data);
        ExtendedDataInputStream din = new ExtendedDataInputStream(input)) {
        // version
        long version = din.readVLong();
        // flags for future implementations
        long flags = din.readVLong();
        if (version != 1 || flags != 0) {
            throw new IOException("corrupted checkpoint file");
        }
        String readname = din.readUTF();
        if (!readname.equals(tableSpace)) {
            throw new DataStorageManagerException("zonde " + checkPointFile + " is not for spablespace " + tableSpace + " but for " + readname);
        }
        long ledgerId = din.readZLong();
        long offset = din.readZLong();
        return new LogSequenceNumber(ledgerId, offset);
    }
}
Also used : ExtendedDataInputStream(herddb.utils.ExtendedDataInputStream) DataStorageManagerException(herddb.storage.DataStorageManagerException) ByteArrayInputStream(java.io.ByteArrayInputStream) SimpleByteArrayInputStream(herddb.utils.SimpleByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ExtendedDataInputStream(herddb.utils.ExtendedDataInputStream) SimpleByteArrayInputStream(herddb.utils.SimpleByteArrayInputStream) InputStream(java.io.InputStream) LogSequenceNumber(herddb.log.LogSequenceNumber) IOException(java.io.IOException)

Aggregations

ExtendedDataInputStream (herddb.utils.ExtendedDataInputStream)28 SimpleByteArrayInputStream (herddb.utils.SimpleByteArrayInputStream)27 IOException (java.io.IOException)23 DataStorageManagerException (herddb.storage.DataStorageManagerException)22 InputStream (java.io.InputStream)22 ODirectFileInputStream (herddb.utils.ODirectFileInputStream)10 ByteArrayInputStream (java.io.ByteArrayInputStream)10 LogSequenceNumber (herddb.log.LogSequenceNumber)9 BufferedInputStream (java.io.BufferedInputStream)9 ArrayList (java.util.ArrayList)4 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)3 KeyToPageIndex (herddb.index.KeyToPageIndex)2 BLinkKeyToPageIndex (herddb.index.blink.BLinkKeyToPageIndex)2 Index (herddb.model.Index)2 Table (herddb.model.Table)2 Transaction (herddb.model.Transaction)2 Bytes (herddb.utils.Bytes)2 RawString (herddb.utils.RawString)2 Path (java.nio.file.Path)2 Stat (org.apache.zookeeper.data.Stat)2