Package org.apache.jute

Examples of org.apache.jute.BinaryInputArchive


            }
        }
    }

    private void readConnectRequest() throws IOException, InterruptedException {
        BinaryInputArchive bia = BinaryInputArchive
                .getArchive(new ByteBufferInputStream(incomingBuffer));
        ConnectRequest connReq = new ConnectRequest();
        connReq.deserialize(bia, "connect");
        if (LOG.isDebugEnabled()) {
            LOG.debug("Session establishment request from client "
View Full Code Here


              System.currentTimeMillis(), OpCode.create);
        Record txn = new CreateTxn("/Test", new byte[0], null, false, 1);
        txnLog.append(txnHeader, txn);
        FileInputStream in = new FileInputStream(tmpDir.getPath() + "/log." +
              Long.toHexString(txnHeader.getZxid()));
        BinaryInputArchive ia  = BinaryInputArchive.getArchive(in);
        FileHeader header = new FileHeader();
        header.deserialize(ia, "fileheader");
        LOG.info("Received magic : " + header.getMagic() +
              " Expected : " + FileTxnLog.TXNLOG_MAGIC);
        Assert.assertTrue("Missing magic number ",
View Full Code Here

    public long getEndTime() { return endtime; }
    public LogSkipList getSkipList() { return skiplist; }

    public static boolean isTransactionFile(String file) throws IOException {
        RandomAccessFileReader reader = new RandomAccessFileReader(new File(file));
        BinaryInputArchive logStream = new BinaryInputArchive(reader);
        FileHeader fhdr = new FileHeader();
        fhdr.deserialize(logStream, "fileheader");
  reader.close();

        return fhdr.getMagic() == FileTxnLog.TXNLOG_MAGIC;
View Full Code Here

  skiplist = new LogSkipList();

  RandomAccessFileReader reader = new RandomAccessFileReader(new File(file));
  try {
      BinaryInputArchive logStream = new BinaryInputArchive(reader);
      FileHeader fhdr = new FileHeader();
      fhdr.deserialize(logStream, "fileheader");
     
      byte[] bytes = null;
      while (true) {
    long lastFp = reader.getPosition();

    long crcValue;

    try {
        crcValue = logStream.readLong("crcvalue");
        bytes = logStream.readBuffer("txnEntry");
    } catch (EOFException e) {
        break;
    }
   
    if (bytes.length == 0) {
        break;
    }
    Checksum crc = new Adler32();
    crc.update(bytes, 0, bytes.length);
    if (crcValue != crc.getValue()) {
        throw new IOException("CRC doesn't match " + crcValue +
            " vs " + crc.getValue());
    }
    if (logStream.readByte("EOR") != 'B') {
        throw new EOFException("Last transaction was partial.");
    }
    TxnHeader hdr = new TxnHeader();
    Record r = SerializeUtils.deserializeTxn(bytes, hdr);
   
View Full Code Here

      try {
    this.src = src;
    this.starttime = starttime;
    this.endtime = endtime;
    reader = new RandomAccessFileReader(new File(src.file));
    logStream = new BinaryInputArchive(reader);
    FileHeader fhdr = new FileHeader();
    fhdr.deserialize(logStream, "fileheader");
      } catch (Exception e) {
    throw new IllegalArgumentException("Cannot open transaction log ("+src.file+") :" + e);
      }
View Full Code Here

        BinaryOutputArchive oa = BinaryOutputArchive.getArchive(baos);
        tree.serialize(oa, "test");
        baos.flush();

        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        BinaryInputArchive ia = BinaryInputArchive.getArchive(bais);
        dserTree.deserialize(ia, "test");

        Field pfield = DataTree.class.getDeclaredField("pTrie");
        pfield.setAccessible(true);
        PathTrie pTrie = (PathTrie)pfield.get(dserTree);
View Full Code Here

public class DeserializationPerfTest extends ZKTestCase {
    protected static final Logger LOG = LoggerFactory.getLogger(DeserializationPerfTest.class);

    private static void deserializeTree(int depth, int width, int len)
            throws InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
        BinaryInputArchive ia;
        int count;
        {
            DataTree tree = new DataTree();
            SerializationPerfTest.createNodes(tree, "/", depth, tree.getNode("/").stat.getCversion(), width, new byte[len]);
            count = tree.getNodeCount();
View Full Code Here

        request.serialize(boa, "request");
        baos.close();
        ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());
        bb.rewind();

        BinaryInputArchive bia = BinaryInputArchive.getArchive(new ByteBufferInputStream(bb));
        MultiTransactionRecord decodedRequest = new MultiTransactionRecord();
        decodedRequest.deserialize(bia, "request");
        return decodedRequest;
    }
View Full Code Here

        request.serialize(boa, "result");
        baos.close();
        ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());
        bb.rewind();

        BinaryInputArchive bia = BinaryInputArchive.getArchive(new ByteBufferInputStream(bb));
        MultiResponse decodedRequest = new MultiResponse();
        decodedRequest.deserialize(bia, "result");
        return decodedRequest;
    }
View Full Code Here

              System.currentTimeMillis(), OpCode.create);
        Record txn = new CreateTxn("/Test", new byte[0], null, false, 1);
        txnLog.append(txnHeader, txn);
        FileInputStream in = new FileInputStream(tmpDir.getPath() + "/log." +
              Long.toHexString(txnHeader.getZxid()));
        BinaryInputArchive ia  = BinaryInputArchive.getArchive(in);
        FileHeader header = new FileHeader();
        header.deserialize(ia, "fileheader");
        LOG.info("Received magic : " + header.getMagic() +
              " Expected : " + FileTxnLog.TXNLOG_MAGIC);
        Assert.assertTrue("Missing magic number ",
View Full Code Here

TOP

Related Classes of org.apache.jute.BinaryInputArchive

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.