Package com.yahoo.omid.tso

Examples of com.yahoo.omid.tso.TSOMessage


        // because the whole frame might not be in the buffer yet.
        // We will reset the buffer position to the marked position if
        // there's not enough bytes in the buffer.
        buf.markReaderIndex();

        TSOMessage msg;
        try {
            if (zipper != null) {
               msg = zipper.decodeMessage(buf);
               LOG.debug("Zipper returned " + msg);
               if (msg != null) {
                  return msg;
               }
               buf.resetReaderIndex();
            }
            byte type = buf.readByte();
            if (LOG.isTraceEnabled()) {
                LOG.trace("Decoding message : " + type);
            }
            switch (type) {
            case TSOMessage.TimestampRequest:
                msg = new TimestampRequest();
                break;
            case TSOMessage.TimestampResponse:
                msg = new TimestampResponse();
                break;
            case TSOMessage.CommitRequest:
                msg = new CommitRequest();
                break;
            case TSOMessage.CommitResponse:
                msg = new CommitResponse();
                break;
            case TSOMessage.CommitQueryRequest:
                msg = new CommitQueryRequest();
                break;
            case TSOMessage.CommitQueryResponse:
                msg = new CommitQueryResponse();
                break;
            case TSOMessage.CommittedTransactionReport:
                msg = new CommittedTransactionReport();
                break;
            case TSOMessage.LargestDeletedTimestampReport:
                msg = new LargestDeletedTimestampReport();
                break;
            case TSOMessage.AbortRequest:
                msg = new AbortRequest();
                break;
            case TSOMessage.FullAbortReport:
                msg = new FullAbortRequest();
                break;
            default:
                throw new Exception("Wrong type " + type + " (" + Integer.toHexString(type) +") " + buf.toString().length());
            }
            msg.readObject(buf);
        } catch (IndexOutOfBoundsException e) {
            // Not enough byte in the buffer, reset to the start for the next try
            buf.resetReaderIndex();
            return null;
        } catch (EOFException e) {
View Full Code Here


    }

    private int checkExpectedMessage(DecoderEmbedder<TSOMessage> decoder, Deque<TSOMessage> expectedMessages) {
        int checked = 0;
        while (!expectedMessages.isEmpty()) {
            TSOMessage expected = expectedMessages.poll();
            TSOMessage actual = decoder.poll();
            assertEquals("Read message didn't correspond to written message", expected, actual);
            checked++;
        }
        return checked;
    }
View Full Code Here

            for (int commitDiff = -512; commitDiff < 512; commitDiff++) {
                long st = zipper.lastStartTimestamp + startDiff;
                long ct = zipper.lastCommitTimestamp + commitDiff;
                buffer.clear();
                zipper.encodeCommit(buffer, st, ct);
                TSOMessage msg = dezipper.decodeMessage(buffer);
                assertThat(msg, is(CommittedTransactionReport.class));
                CommittedTransactionReport ctr = (CommittedTransactionReport) msg;
                assertThat("startDiff: " + startDiff + " commitDiff: " + commitDiff, ctr.commitTimestamp, is(ct));
                assertThat("startDiff: " + startDiff + " commitDiff: " + commitDiff, ctr.startTimestamp, is(st));
            }
View Full Code Here

        for (int tsDiff = -1024 * 1024; tsDiff < 1024 * 1024; tsDiff++) {
            long st = zipper.lastStartTimestamp + tsDiff;
            buffer.clear();
            zipper.encodeHalfAbort(buffer, st);
            zipper.encodeFullAbort(buffer, st);
            TSOMessage msg = dezipper.decodeMessage(buffer);
            assertThat(msg, is(AbortedTransactionReport.class));
            AbortedTransactionReport atr = (AbortedTransactionReport) msg;
            assertThat("startDiff: " + tsDiff, atr.startTimestamp, is(st));
            msg = dezipper.decodeMessage(buffer);
            assertThat(msg, is(CleanedTransactionReport.class));
View Full Code Here

        // because the whole frame might not be in the buffer yet.
        // We will reset the buffer position to the marked position if
        // there's not enough bytes in the buffer.
        buf.markReaderIndex();

        TSOMessage msg;
        try {
            if (zipper != null) {
                msg = zipper.decodeMessage(buf);
                LOG.debug("Zipper returned " + msg);
                if (msg != null) {
                    return msg;
                }
                buf.resetReaderIndex();
            }
            byte type = buf.readByte();
            if (LOG.isTraceEnabled()) {
                LOG.trace("Decoding message : " + type);
            }
            switch (type) {
            case TSOMessage.TimestampRequest:
                msg = new TimestampRequest();
                break;
            case TSOMessage.TimestampResponse:
                msg = new TimestampResponse();
                break;
            case TSOMessage.CommitRequest:
                msg = new CommitRequest();
                break;
            case TSOMessage.CommitResponse:
                msg = new CommitResponse();
                break;
            case TSOMessage.CommitQueryRequest:
                msg = new CommitQueryRequest();
                break;
            case TSOMessage.CommitQueryResponse:
                msg = new CommitQueryResponse();
                break;
            case TSOMessage.CommittedTransactionReport:
                msg = new CommittedTransactionReport();
                break;
            case TSOMessage.LargestDeletedTimestampReport:
                msg = new LargestDeletedTimestampReport();
                break;
            case TSOMessage.AbortRequest:
                msg = new AbortRequest();
                break;
            case TSOMessage.FullAbortReport:
                msg = new FullAbortRequest();
                break;
            default:
                throw new Exception("Wrong type " + type + " (" + Integer.toHexString(type) + ") " + buf.toString().length());
            }
            msg.readObject(buf);
        } catch (IndexOutOfBoundsException e) {
            // Not enough byte in the buffer, reset to the start for the next try
            buf.resetReaderIndex();
            return null;
        } catch (EOFException e) {
View Full Code Here

TOP

Related Classes of com.yahoo.omid.tso.TSOMessage

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.