Package org.apache.jute

Examples of org.apache.jute.BinaryOutputArchive


        assertEquals(request.hashCode(), decodedRequest.hashCode());
    }

    private MultiTransactionRecord codeDecode(MultiTransactionRecord request) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        BinaryOutputArchive boa = BinaryOutputArchive.getArchive(baos);
        request.serialize(boa, "request");
        baos.close();
        ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());
        bb.rewind();
View Full Code Here


        assertEquals(result.hashCode(), decodedResult.hashCode());
    }

    private MultiResponse codeDecode(MultiResponse request) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        BinaryOutputArchive boa = BinaryOutputArchive.getArchive(baos);
        request.serialize(boa, "result");
        baos.close();
        ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());
        bb.rewind();
View Full Code Here

            throws InterruptedException, IOException, KeeperException.NodeExistsException, KeeperException.NoNodeException {
        DataTree tree = new DataTree();
        createNodes(tree, "/", depth, width, tree.getNode("/").stat.getCversion(), new byte[len]);
        int count = tree.getNodeCount();

        BinaryOutputArchive oa =
            BinaryOutputArchive.getArchive(new NullOutputStream());
        System.gc();
        long start = System.nanoTime();
        tree.serialize(oa, "test");
        long end = System.nanoTime();
View Full Code Here

      SimpleLearner sl = new SimpleLearner(ftsl);
      long startZxid = sl.zk.getLastProcessedZxid();
     
      // Set up bogus streams
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      BinaryOutputArchive oa = BinaryOutputArchive.getArchive(baos);
      sl.leaderOs = BinaryOutputArchive.getArchive(new ByteArrayOutputStream());
     
      // make streams and socket do something innocuous
      sl.bufferedOutput = new BufferedOutputStream(System.out);
      sl.sock = new Socket();
     
      // fake messages from the server
      QuorumPacket qp = new QuorumPacket(Leader.SNAP, 0, null, null);
      oa.writeRecord(qp, null);
      sl.zk.getZKDatabase().serializeSnapshot(oa);
      oa.writeString("BenWasHere", "signature");
      TxnHeader hdr = new TxnHeader(0, 0, 0, 0, ZooDefs.OpCode.create);
      CreateTxn txn = new CreateTxn("/foo", new byte[0], new ArrayList<ACL>(), false, sl.zk.getZKDatabase().getNode("/").stat.getCversion());
          ByteArrayOutputStream tbaos = new ByteArrayOutputStream();
          BinaryOutputArchive boa = BinaryOutputArchive.getArchive(tbaos);
          hdr.serialize(boa, "hdr");
          txn.serialize(boa, "txn");
          tbaos.close();
      qp = new QuorumPacket(Leader.PROPOSAL, 1, tbaos.toByteArray(), null);
      oa.writeRecord(qp, null);
View Full Code Here

            txnHeader = new TxnHeader(0xabcd, 0x123, prevPzxid + 1,
                    System.currentTimeMillis(), OpCode.create);
            txn = new CreateTxn(path, new byte[0], null, false, cversion);                      
            ArrayList txnList = new ArrayList();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            BinaryOutputArchive boa = BinaryOutputArchive.getArchive(baos);
            txn.serialize(boa, "request") ;
            ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());
            Txn txact = new Txn(OpCode.create,  bb.array());
            txnList.add(txact);
            txn = new MultiTxn(txnList);
View Full Code Here

                sChannel.connect(new InetSocketAddress(host,port));
                // Construct a connection request
                ConnectRequest conReq = new ConnectRequest(0, 0,
                        10000, 0, "password".getBytes());
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                BinaryOutputArchive boa = BinaryOutputArchive.getArchive(baos);
                boa.writeInt(-1, "len");
                conReq.serialize(boa, "connect");
                baos.close();
                ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());
                bb.putInt(bb.capacity() - 4);
                bb.rewind();
View Full Code Here

        /*
         * Add sid to payload
         */
        LearnerInfo li = new LearnerInfo(self.getId(), 0x10000);
        ByteArrayOutputStream bsid = new ByteArrayOutputStream();
        BinaryOutputArchive boa = BinaryOutputArchive.getArchive(bsid);
        boa.writeRecord(li, "LearnerInfo");
        qp.setData(bsid.toByteArray());
       
        writePacket(qp, true);
        readPacket(qp);       
        final long newEpoch = ZxidUtils.getEpochFromZxid(qp.getZxid());
View Full Code Here

    public void write(byte[] b, int off, int len) throws IOException {
        bb.put(b, off, len);
    }
    static public void record2ByteBuffer(Record record, ByteBuffer bb)
    throws IOException {
        BinaryOutputArchive oa;
        oa = BinaryOutputArchive.getArchive(new ByteBufferOutputStream(bb));
        record.serialize(oa, "request");
    }
View Full Code Here

        if (!channel.isOpen()) {
            return;
        }
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        // Make space for length
        BinaryOutputArchive bos = BinaryOutputArchive.getArchive(baos);
        try {
            baos.write(fourBytes);
            bos.writeRecord(h, "header");
            if (r != null) {
                bos.writeRecord(r, tag);
            }
            baos.close();
        } catch (IOException e) {
            LOG.error("Error serializing response");
        }
View Full Code Here

                minCommittedLog = request.zxid;
                maxCommittedLog = request.zxid;
            }

            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            BinaryOutputArchive boa = BinaryOutputArchive.getArchive(baos);
            try {
                request.hdr.serialize(boa, "hdr");
                if (request.txn != null) {
                    request.txn.serialize(boa, "txn");
                }
View Full Code Here

TOP

Related Classes of org.apache.jute.BinaryOutputArchive

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.