Package org.voltcore.messaging

Examples of org.voltcore.messaging.TransactionInfoBaseMessage


    @Test
    public void testCompleteWithoutFirstFrag()
    {
        ReplaySequencer dut = new ReplaySequencer();

        TransactionInfoBaseMessage sntl = makeSentinel(1L);
        TransactionInfoBaseMessage frag = makeFragment(1L);
        TransactionInfoBaseMessage cmpl = makeCompleteTxn(1L);

        Assert.assertTrue(dut.offer(1L, sntl));
        // a restart complete arrives before the first fragment
        Assert.assertFalse(dut.offer(1L, cmpl));
        Assert.assertTrue(dut.offer(1L, frag));
View Full Code Here


        if (!m_hsIds.contains(message.m_sourceHSId)) {
            m_recoveryLog.info("Dropping message " + message + " because it is not from a known up site");
            return;
        }
        if (message instanceof TransactionInfoBaseMessage) {
            TransactionInfoBaseMessage info = (TransactionInfoBaseMessage)message;

            // Special case heartbeats which only update RPQ
            if (info instanceof HeartbeatMessage) {
                // use the heartbeat to unclog the priority queue if clogged
                long lastSeenTxnFromInitiator = m_txnQueue.noteTransactionRecievedAndReturnLastSeen(
                        info.getInitiatorHSId(), info.getTxnId(),
                        ((HeartbeatMessage) info).getLastSafeTxnId());

                // respond to the initiator with the last seen transaction
                HeartbeatResponseMessage response = new HeartbeatResponseMessage(
                        m_hsId, lastSeenTxnFromInitiator,
                        m_txnQueue.getQueueState() == RestrictedPriorityQueue.QueueState.BLOCKED_SAFETY);
                m_mailbox.send(info.getInitiatorHSId(), response);
                // we're done here (in the case of heartbeats)
                return;
            }
            assert(false);
        } else if (message instanceof HeartbeatResponseMessage) {
View Full Code Here

        }
        for (int i = 0; i < 4000; i++) {
            // get next message, update the sphandle according to SpScheduler rules,
            // but only submit messages that would have been forwarded by the master
            // to the repair log.
            TransactionInfoBaseMessage msg = msgGen.generateRandomMessageInStream();
            msg.setSpHandle(sphandle.getTxnId());
            sphandle = sphandle.makeNext();
            if (!msg.isReadOnly() || msg instanceof CompleteTransactionMessage) {
                if (!stops[0]) {
                    logs[0].deliver(msg);
                }
                if (!stops[1]) {
                    logs[1].deliver(msg);
                }
                logs[2].deliver(msg);
                // Putting this inside this loop
                // guarantees at least one message in everyone's repair log,
                // which avoids having to check for the special case where a node
                // has an empty repair log on account of rejoin and shouldn't
                // be fed any transactions
                for (int j = 0; j < 2; j++) {
                    // Hacky way to get spaced failures
                    if (rand.nextDouble() < (.01 / ((j + 1) * 5))) {
                        stops[j] = true;
                    }
                }
            }
        }

        List<Long> survivors = new ArrayList<Long>();
        survivors.add(0l);
        survivors.add(1l);
        survivors.add(2l);
        MpPromoteAlgo dut = new MpPromoteAlgo(survivors, mbox, "bleh ");
        Future<Long> result = dut.start();
        for (int i = 0; i < 3; i++) {
            List<Iv2RepairLogResponseMessage> stuff = logs[i].contents(dut.getRequestId(), true);
            System.out.println("Repair log size from: " + i + ": " + stuff.size());
            for (Iv2RepairLogResponseMessage msg : stuff) {
                msg.m_sourceHSId = (long)i;
                dut.deliver(msg);
            }
        }
        result.get();
        assertFalse(result.isCancelled());
        assertTrue(result.isDone());
        // Unfortunately, it's painful to try to stub things to make repairSurvivors() work, so we'll
        // go and inspect the guts of SpPromoteAlgo instead.  This iteration is largely a copy of the inner loop
        // of repairSurvivors()
        List<TransactionInfoBaseMessage> finalStream = new ArrayList<TransactionInfoBaseMessage>();
        for (Iv2RepairLogResponseMessage li : dut.m_repairLogUnion) {
            VoltMessage msg = dut.createRepairMessage(li);
            finalStream.add((TransactionInfoBaseMessage)msg);
        }
        // Check the sanity of the repair stream generated by the MPI.
        long lastTxnId = Long.MIN_VALUE;
        boolean seenFrag = false;
        for (TransactionInfoBaseMessage msg : finalStream) {
            if (lastTxnId == Long.MIN_VALUE) {
                lastTxnId = msg.getTxnId();
            }
            else {
                assertTrue(msg.getTxnId() > lastTxnId);
                lastTxnId = msg.getTxnId();
            }
            if (msg instanceof FragmentTaskMessage) {
                assertFalse(seenFrag);
                seenFrag = true;
            }
View Full Code Here

        }
        for (int i = 0; i < 4000; i++) {
            // get next message, update the sphandle according to SpScheduler rules,
            // but only submit messages that would have been forwarded by the master
            // to the repair log.
            TransactionInfoBaseMessage msg = msgGen.generateRandomMessageInStream();
            msg.setSpHandle(sphandle.getTxnId());
            sphandle = sphandle.makeNext();
            if (!msg.isReadOnly() || msg instanceof CompleteTransactionMessage) {
                if (!stops[0]) {
                    logs[0].deliver(msg);
                }
                if (!stops[1]) {
                    logs[1].deliver(msg);
                }
                logs[2].deliver(msg);
                // Putting this inside this loop
                // guarantees at least one message in everyone's repair log,
                // which avoids having to check for the special case where a node
                // has an empty repair log on account of rejoin and shouldn't
                // be fed any transactions
                for (int j = 0; j < 2; j++) {
                    // Hacky way to get spaced failures
                    if (rand.nextDouble() < (.01 / ((j + 1) * 5))) {
                        stops[j] = true;
                    }
                }
            }
        }

        List<Long> survivors = new ArrayList<Long>();
        survivors.add(0l);
        survivors.add(1l);
        survivors.add(2l);
        SpPromoteAlgo dut = new SpPromoteAlgo(survivors, mbox, "bleh ", 0);
        Future<Long> result = dut.start();
        for (int i = 0; i < 3; i++) {
            List<Iv2RepairLogResponseMessage> stuff = logs[i].contents(dut.getRequestId(), false);
            System.out.println("Repair log size from: " + i + ": " + stuff.size());
            for (Iv2RepairLogResponseMessage msg : stuff) {
                msg.m_sourceHSId = i;
                dut.deliver(msg);
                // First message is metadata only, skip it in validation stream
                if (msg.getSequence() > 0) {
                    //System.out.println("finalstreams: " + finalStreams);
                    //System.out.println("get(i): " + i + ": " + finalStreams.get((long)i));
                    //System.out.println("msg: " + msg);
                    finalStreams.get((long)i).add((TransactionInfoBaseMessage)msg.getPayload());
                }
            }
        }
        result.get();
        assertFalse(result.isCancelled());
        assertTrue(result.isDone());
        // Unfortunately, it's painful to try to stub things to make repairSurvivors() work, so we'll
        // go and inspect the guts of SpPromoteAlgo instead.  This iteration is largely a copy of the inner loop
        // of repairSurvivors()
        for (Iv2RepairLogResponseMessage li : dut.m_repairLogUnion) {
            for (Entry<Long, SpPromoteAlgo.ReplicaRepairStruct> entry : dut.m_replicaRepairStructs.entrySet()) {
                if (entry.getValue().needs(li.getHandle())) {
                    // append the missing message for this 'node' to the list of messages that node has seen
                    finalStreams.get(entry.getKey()).add((TransactionInfoBaseMessage)li.getPayload());
                }
            }
        }
        // check that all the lists for all the nodes are identical after repair
        int longest = Integer.MIN_VALUE;
        for (Entry<Long, List<TransactionInfoBaseMessage>> entry : finalStreams.entrySet()) {
            System.out.println("SIZE: " + entry.getValue().size());
            if (entry.getValue().size() > longest) {
                if (longest == Integer.MIN_VALUE) {
                    longest = entry.getValue().size();
                }
                else {
                    fail("Mismatch in repair stream size!");
                }
            }
        }
        for (int i = 0; i < longest; i++) {
            TransactionInfoBaseMessage current = null;
            for (Entry<Long, List<TransactionInfoBaseMessage>> entry : finalStreams.entrySet()) {
                TransactionInfoBaseMessage msg = entry.getValue().get(i);
                if (current == null) {
                    current = msg;
                }
                else {
                    assertEquals(current.getSpHandle(), msg.getSpHandle());
                    assertEquals(current.getClass(), msg.getClass());
                }
            }
        }
    }
View Full Code Here

        RepairLog dut = new RepairLog();
        for (int i = 0; i < 4000; i++) {
            // get next message, update the sphandle according to SpScheduler rules,
            // but only submit messages that would have been forwarded by the master
            // to the repair log.
            TransactionInfoBaseMessage msg = msgGen.generateRandomMessageInStream();
            msg.setSpHandle(sphandle.getTxnId());
            sphandle = sphandle.makeNext();
            if (!msg.isReadOnly() || msg instanceof CompleteTransactionMessage) {
                dut.deliver(msg);
            }
        }
        List<Iv2RepairLogResponseMessage> stuff = dut.contents(1l, false);
        validateRepairLog(stuff);
View Full Code Here

            hostLog.warn("Dropping message " + message + " because it is from a unknown site id " +
                    CoreUtils.hsIdToString(message.m_sourceHSId));
            return;
        }
        if (message instanceof TransactionInfoBaseMessage) {
            TransactionInfoBaseMessage info = (TransactionInfoBaseMessage)message;
            assertTxnIdOrdering(info);

            // Special case heartbeats which only update RPQ
            if (info instanceof HeartbeatMessage) {
                return;
            }
            else if (info instanceof InitiateTaskMessage) {
            }
            //Participant notices are sent enmasse from the initiator to multiple partitions
            // and don't communicate any information about safe replication, hence DUMMY_LAST_SEEN_TXN_ID
            // it can be used for global ordering since it is a valid txnid from an initiator
            else if (info instanceof MultiPartitionParticipantMessage) {
            }

            // Every non-heartbeat notice requires a transaction state.
            TransactionState ts = m_transactionsById.get(info.getTxnId());

            if (ts != null)
            {
                if (message instanceof FragmentTaskMessage) {
                    ts.createLocalFragmentWork((FragmentTaskMessage)message, false);
View Full Code Here

                m_lastSpHandle = m.getSpHandle();
                truncate(m.getTruncationHandle(), IS_SP);
                m_logSP.add(new Item(IS_SP, m, m.getSpHandle(), m.getTxnId()));
            }
        } else if (msg instanceof FragmentTaskMessage) {
            final TransactionInfoBaseMessage m = (TransactionInfoBaseMessage)msg;
            if (!m.isReadOnly()) {
                truncate(m.getTruncationHandle(), IS_MP);
                // only log the first fragment of a procedure (and handle 1st case)
                if (m.getTxnId() > m_lastMpHandle || m_lastMpHandle == Long.MAX_VALUE) {
                    m_logMP.add(new Item(IS_MP, m, m.getSpHandle(), m.getTxnId()));
                    m_lastMpHandle = m.getTxnId();
                    m_lastSpHandle = m.getSpHandle();
                }
            }
        }
        else if (msg instanceof CompleteTransactionMessage) {
            // a CompleteTransactionMessage which indicates restart is not the end of the
View Full Code Here

        // not yet time to catch-up.
        if (m_rejoinState != kStateReplayingRejoin) {
            return false;
        }

        TransactionInfoBaseMessage tibm = m_rejoinTaskLog.getNextMessage();
        if (tibm != null) {
            mrm.didUnrestricted();
            if (tibm instanceof Iv2InitiateTaskMessage) {
                Iv2InitiateTaskMessage m = (Iv2InitiateTaskMessage)tibm;
                SpProcedureTask t = new SpProcedureTask(
View Full Code Here

TOP

Related Classes of org.voltcore.messaging.TransactionInfoBaseMessage

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.