Package org.fressian

Examples of org.fressian.FressianWriter


     * @param data object to be submitted
     * @throws IOException if connection breaks or server error occurs when processing submitted data;
     */
    public void submit(Object data) throws IOException {
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        FressianWriter writer = new FressianWriter(os, FressianTraceFormat.WRITE_LOOKUP);
        writer.writeObject(data);
        writer.close();
        send(ZICO_DATA, ZicoCommonUtil.pack(data));
        ZicoPacket pkt = recv();
        if (pkt.getStatus() != ZICO_OK) {
            throw new ZicoException(pkt.getStatus(), "ZICO submission error: status=" + pkt.getStatus());
        }
View Full Code Here


     * @return bytes with encoded data
     */
    public static byte[] pack(Object... data) {
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        try {
            FressianWriter writer = new FressianWriter(os, FressianTraceFormat.WRITE_LOOKUP);
            for (Object d : data) {
                writer.writeObject(d);
            }
        } catch (IOException e) {
            log.error(ZorkaLogger.ZAG_ERRORS, "Should not happen.", e);
        }
        return os.toByteArray();
View Full Code Here

        this.output = output;
    }


    public void softReset() {
        writer = new FressianWriter(os, FressianTraceFormat.WRITE_LOOKUP);
    }
View Full Code Here

    public void reset() {
        os = output.getOutputStream();
        symbolsSent.reset();
        metricsSent.reset();
        templatesSent.reset();
        this.writer = new FressianWriter(os, FressianTraceFormat.WRITE_LOOKUP);
    }
View Full Code Here

     */
    public void load(InputStream is) throws IOException {
        FressianReader reader = new FressianReader(is, FressianTraceFormat.READ_LOOKUP);

        ByteArrayOutputStream os = new ByteArrayOutputStream();
        FressianWriter writer = new FressianWriter(os, FressianTraceFormat.WRITE_LOOKUP);

        Object obj;

        while (null != (obj = reader.readObject())) {
            writer.writeObject(obj);

            if (obj instanceof TraceRecord) {
                records++;
            }

            if (obj instanceof TraceRecord && os.size() > packetSize) {
                conn.send(ZicoPacket.ZICO_DATA, os.toByteArray());
                ZicoPacket rslt = conn.recv();
                if (rslt.getStatus() != ZicoPacket.ZICO_OK) {
                    throw new ZicoException(rslt.getStatus(), "Error submitting data.");
                }
                bytes += os.size();
                os = new ByteArrayOutputStream();
                writer = new FressianWriter(os, FressianTraceFormat.WRITE_LOOKUP);
                //System.out.print(".");
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.fressian.FressianWriter

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.