Package org.apache.jute

Examples of org.apache.jute.InputArchive


            return -1L;
        }
        LOG.info("Reading snapshot " + snap);
        InputStream snapIS = new BufferedInputStream(new FileInputStream(snap));
        CheckedInputStream crcIn = new CheckedInputStream(snapIS, new Adler32());
        InputArchive ia=BinaryInputArchive.getArchive(crcIn);
        deserialize(dt,sessions, ia);
        long checkSum = crcIn.getChecksum().getValue();
        long val = ia.readLong("val");
        if (val != checkSum) {
            throw new IOException("CRC corruption in snapshot :  " + snap);
        }
        snapIS.close();
        crcIn.close();
View Full Code Here


     */
    private static FileHeader readHeader(File file) throws IOException {
        InputStream is =null;
        try{
            is = new BufferedInputStream(new FileInputStream(file));
            InputArchive ia=BinaryInputArchive.getArchive(is);
            FileHeader hdr = new FileHeader();
            hdr.deserialize(ia, "fileheader");
            return hdr;
         }finally{
             try{
View Full Code Here

                crc.update(bytes, 0, bytes.length);
                if (crcValue != crc.getValue())
                    throw new IOException(CRC_ERROR);
                if (bytes == null || bytes.length == 0)
                    return false;
                InputArchive iab = BinaryInputArchive
                                    .getArchive(new ByteArrayInputStream(bytes));
                hdr = new TxnHeader();
                record = SerializeUtils.deserializeTxn(iab, hdr);
            } catch (EOFException e) {
                LOG.debug("EOF excepton " + e);
View Full Code Here

           
            LearnerHandler lh = new LearnerHandler(leaderSocket, leader);
            lh.start();
            leaderSocket.setSoTimeout(4000);

            InputArchive ia = BinaryInputArchive.getArchive(followerSocket
                    .getInputStream());
            OutputArchive oa = BinaryOutputArchive.getArchive(followerSocket
                    .getOutputStream());

            conversation.converseWithLeader(ia, oa, leader);
View Full Code Here

                }
            };
            followerThread.start();
            Socket leaderSocket = ss.accept();
           
            InputArchive ia = BinaryInputArchive.getArchive(leaderSocket
                    .getInputStream());
            OutputArchive oa = BinaryOutputArchive.getArchive(leaderSocket
                    .getOutputStream());

            conversation.converseWithFollower(ia, oa, follower);
View Full Code Here

        DataTree dt = new DataTree();
        Map<Long, Integer> sessions = new ConcurrentHashMap<Long, Integer>();
        InputStream snapIS = new BufferedInputStream(new FileInputStream(
                snapFile));
        CheckedInputStream crcIn = new CheckedInputStream(snapIS, new Adler32());
        InputArchive ia = BinaryInputArchive.getArchive(crcIn);
        try {
            snap.deserialize(dt, sessions, ia);
        } catch (IOException ie) {
            // we failed on the most recent snapshot
            // must be incomplete
            // try reading the next one
            // after corrupting
            snapIS.close();
            crcIn.close();
            throw ie;
        }

        long checksum = crcIn.getChecksum().getValue();
        long val = ia.readLong("val");
        snapIS.close();
        crcIn.close();
        return (val != checksum);
    }
View Full Code Here

      if (crcValue != crc.getValue())
      {
        throw new IOException("CRC doesn't match " + crcValue + " vs "
            + crc.getValue());
      }
      InputArchive iab = BinaryInputArchive
          .getArchive(new ByteArrayInputStream(bytes));
      TxnHeader hdr = new TxnHeader();
      Record txn = SerializeUtils.deserializeTxn(iab, hdr);
      if (bw != null)
      {
View Full Code Here

     */
    private static FileHeader readHeader(File file) throws IOException {
        InputStream is =null;
        try {
            is = new BufferedInputStream(new FileInputStream(file));
            InputArchive ia=BinaryInputArchive.getArchive(is);
            FileHeader hdr = new FileHeader();
            hdr.deserialize(ia, "fileheader");
            return hdr;
         } finally {
             try {
View Full Code Here

                crc.update(bytes, 0, bytes.length);
                if (crcValue != crc.getValue())
                    throw new IOException(CRC_ERROR);
                if (bytes == null || bytes.length == 0)
                    return false;
                InputArchive iab = BinaryInputArchive
                                    .getArchive(new ByteArrayInputStream(bytes));
                hdr = new TxnHeader();
                record = SerializeUtils.deserializeTxn(iab, hdr);
            } catch (EOFException e) {
                LOG.debug("EOF excepton " + e);
View Full Code Here

            if ( crcValue != crc.getValue() )
            {
                throw new IOException("CRC doesn't match " + crcValue + " vs " + crc.getValue());
            }

            InputArchive    iab = BinaryInputArchive.getArchive(new ByteArrayInputStream(bytes));
            TxnHeader       hdr = new TxnHeader();

            Record          record = useOldDeserializeMethod ? (Record)deserializeTxnMethod.invoke(null, iab, hdr) : (Record)deserializeTxnMethod.invoke(null, bytes, hdr);

            if ( logStream.readByte("EOR") != 'B' )
View Full Code Here

TOP

Related Classes of org.apache.jute.InputArchive

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.