Search in sources :

Example 1 with BinaryDecoder

use of org.apache.tephra.snapshot.BinaryDecoder in project cdap by caskdata.

the class AbstractSnapshotCodec method decode.

@Override
public TransactionSnapshot decode(InputStream in) {
    BinaryDecoder decoder = new BinaryDecoder(in);
    try {
        long timestamp = decoder.readLong();
        long readPointer = decoder.readLong();
        long writePointer = decoder.readLong();
        // some attributes where removed during format change, luckily those stored at the end, so we just give a chance
        // to skip them
        decodeObsoleteAttributes(decoder);
        Collection<Long> invalid = decodeInvalid(decoder);
        NavigableMap<Long, TransactionManager.InProgressTx> inProgress = decodeInProgress(decoder);
        NavigableMap<Long, Set<ChangeId>> committing = decodeChangeSets(decoder);
        NavigableMap<Long, Set<ChangeId>> committed = decodeChangeSets(decoder);
        return new TransactionSnapshot(timestamp, readPointer, writePointer, invalid, inProgress, committing, committed);
    } catch (IOException e) {
        LOG.error("Unable to deserialize transaction state: ", e);
        throw Throwables.propagate(e);
    }
}
Also used : TransactionSnapshot(org.apache.tephra.persist.TransactionSnapshot) Set(java.util.Set) HashSet(java.util.HashSet) IOException(java.io.IOException) BinaryDecoder(org.apache.tephra.snapshot.BinaryDecoder)

Example 2 with BinaryDecoder

use of org.apache.tephra.snapshot.BinaryDecoder in project cdap by caskdata.

the class AbstractSnapshotCodec method decodeTransactionVisibilityState.

@Override
public TransactionVisibilityState decodeTransactionVisibilityState(InputStream in) {
    BinaryDecoder decoder = new BinaryDecoder(in);
    try {
        long timestamp = decoder.readLong();
        long readPointer = decoder.readLong();
        long writePointer = decoder.readLong();
        // some attributes where removed during format change, luckily those stored at the end, so we just give a chance
        // to skip them
        decodeObsoleteAttributes(decoder);
        Collection<Long> invalid = decodeInvalid(decoder);
        NavigableMap<Long, TransactionManager.InProgressTx> inProgress = decodeInProgress(decoder);
        return new TransactionSnapshot(timestamp, readPointer, writePointer, invalid, inProgress);
    } catch (IOException e) {
        LOG.error("Unable to deserialize transaction state: ", e);
        throw Throwables.propagate(e);
    }
}
Also used : TransactionSnapshot(org.apache.tephra.persist.TransactionSnapshot) IOException(java.io.IOException) BinaryDecoder(org.apache.tephra.snapshot.BinaryDecoder)

Aggregations

IOException (java.io.IOException)2 TransactionSnapshot (org.apache.tephra.persist.TransactionSnapshot)2 BinaryDecoder (org.apache.tephra.snapshot.BinaryDecoder)2 HashSet (java.util.HashSet)1 Set (java.util.Set)1