Package org.fressian

Examples of org.fressian.FressianReader


     */
    public static List<Object> unpack(byte[] data) {
        List<Object> lst = new ArrayList<Object>();
        try {
            ByteArrayInputStream is = new ByteArrayInputStream(data);
            FressianReader r = new FressianReader(is, FressianTraceFormat.READ_LOOKUP);
            while (is.available() > 0) {
                lst.add(r.readObject());
            }
        } catch (IOException e) {
            log.error(ZorkaLogger.ZAG_ERRORS, "Should not happen.", e);
        }
        return lst;
View Full Code Here


     *
     * @param is input stream representing trace file content.
     * @throws IOException if connection breaks or server-side data processing error occurs;
     */
    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++;
            }
View Full Code Here

    private void load(File file) {
        InputStream is = null;

        try {
            is = open(file);
            FressianReader r = new FressianReader(is, FressianTraceFormat.READ_LOOKUP);
            for (Object obj = r.readObject(); obj != null; obj = r.readObject()) {
                if (obj instanceof Symbol) {
                    Symbol sym = (Symbol) obj;
                    symbols.put(sym.getId(), sym.getName());
                } else if (obj instanceof ViewerTraceRecord) {
                    ((ViewerTraceRecord) obj).fixup();
View Full Code Here

            }
        };
    }

    private FressianReader reader() {
        return new FressianReader(new ByteArrayInputStream(output.toByteArray()), READ_LOOKUP);
    }
View Full Code Here

        m.setTemplate(mt);
        m.setTemplateId(mt.getId());

        writer.checkMetric(m.getId());

        FressianReader reader = reader();

        MetricTemplate mt2 = (MetricTemplate) reader.readObject();
        Metric m2 = (Metric) reader.readObject();

        assertThat(m2).isInstanceOfAny(RawDataMetric.class);

        assertThat(m2.getId()).isEqualTo(m.getId());
        assertThat(m2.getName()).isEqualTo(m.getName());
View Full Code Here

        tr.setAttr(sid("ATTR2"), "bork");
        tr.setAttr(sid("ATTR3"), 1.23);

        writer.write(tr);

        FressianReader reader = reader();

        Object obj = reader.readObject();

        while (obj instanceof Symbol) {
            Symbol s = (Symbol) obj;
            assertThat(s.getId()).isEqualTo(sid(s.getName()));
            obj = reader.readObject();
        }

        TraceRecord tr2 = (TraceRecord) obj;
        assertThat(tr2.getFlags()).isEqualTo(TraceRecord.EXCEPTION_PASS);
        assertThat(tr2.getCalls()).isEqualTo(tr.getCalls());
View Full Code Here

        tm.setFlags(TraceMarker.OVERFLOW_FLAG);
        tr.setMarker(tm);

        writer.write(tr);

        FressianReader reader = reader();

        Object obj = reader.readObject();

        Set<Integer> ids = new HashSet<Integer>();

        while (obj instanceof Symbol) {
            Symbol s = (Symbol) obj;
            assertThat(s.getId()).isEqualTo(sid(s.getName()));
            obj = reader.readObject();
            ids.add(s.getId());
        }

        TraceRecord tr2 = (TraceRecord) obj;
        assertThat(tr2.getFlags()).isEqualTo(TraceRecord.TRACE_BEGIN);
View Full Code Here

                tr("some.Class", "someMethod", "()V", 2, 0, 0, 100,
                        tr("other.Class", "otherMethod", "()V", 1, 0, 0, 50));

        writer.write(tr);

        FressianReader reader = reader();

        Object obj = reader.readObject();

        while (obj instanceof Symbol) {
            Symbol s = (Symbol) obj;
            assertThat(s.getId()).isEqualTo(sid(s.getName()));
            obj = reader.readObject();
        }

        TraceRecord tr2 = (TraceRecord) obj;
        assertThat(tr2.numChildren()).isEqualTo(1);
        assertThat(tr2.getChild(0).getTime()).isEqualTo(50L);
View Full Code Here

        tr.setException(new Exception("oja!"));
        tr.fixup(symbols);

        writer.write(tr);

        FressianReader reader = reader();

        Object obj = reader.readObject();

        while (obj instanceof Symbol) {
            Symbol s = (Symbol) obj;
            assertThat(s.getId()).isEqualTo(sid(s.getName()));
            obj = reader.readObject();
        }

        TraceRecord tr2 = (TraceRecord) obj;

        SymbolicException se = (SymbolicException) tr2.getException();
View Full Code Here

        PerfRecord pr = new PerfRecord(100L, sid("PERF"), Arrays.asList(ps(m, 100L, 100L), ps(m, 200L, 200L)));

        writer.write(pr);

        FressianReader reader = reader();

        Object obj = reader.readObject();

        while (obj != null && !(obj instanceof PerfRecord)) {
            if (obj instanceof Symbol) {
                Symbol s = (Symbol) obj;
                assertThat(s.getId()).isEqualTo(sid(s.getName()));
            }
            obj = reader.readObject();
        }

        PerfRecord pr2 = (PerfRecord) obj;
        assertThat(pr2).isNotNull();
        assertThat(pr2.getClock()).isEqualTo(100L);
View Full Code Here

TOP

Related Classes of org.fressian.FressianReader

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.