Package org.voltdb.messaging

Examples of org.voltdb.messaging.FragmentResponseMessage


        System.out.println("REMOTE TASK: " + plan.remoteWork.toString());

        if (!single_frag) {
            // generate a remote fragment response for each remote message
            for (int i = 0; i < remoteHSIds.length; i++) {
                FragmentResponseMessage resp =
                    new FragmentResponseMessage(plan.remoteWork, remoteHSIds[i]);
                if (rollback && i == (remoteHSIds.length - 1)) {
                    resp.setStatus(FragmentResponseMessage.UNEXPECTED_ERROR,
                                   new EEException(1234));
                }
                else {
                    resp.setStatus(FragmentResponseMessage.SUCCESS, null);
                    for (int j = 0; j < distributedOutputDepIds.size(); j++) {
                        resp.addDependency(distributedOutputDepIds.get(j),
                                           new VoltTable(new VoltTable.ColumnInfo("BOGO",
                                                                                  VoltType.BIGINT)));
                    }
                }
                System.out.println("RESPONSE: " + resp);
                plan.generatedResponses.add(resp);
            }
        }

        // generate local task with new output IDs, use above outputs as inputs, if any
        plan.localWork = new FragmentTaskMessage(Long.MIN_VALUE, // try not to care
                Long.MIN_VALUE,
                Long.MIN_VALUE,
                1234l,
                readOnly,
                false,
                false);

        for (int i = 0; i < batchSize; i++) {
            plan.localWork.addFragment(VoltSystemProcedure.fragIdToHash(0L),
                    depsToResumeList.get(i), createDummyParameterSet());
        }

       for (int i = 0; i < depsForLocalTask.size(); i++) {
           if (depsForLocalTask.get(i) < 0) continue;
           plan.localWork.addInputDepId(i, depsForLocalTask.get(i));
       }
       // create the FragmentResponse for the BorrowTask
       FragmentResponseMessage resp =
           new FragmentResponseMessage(plan.remoteWork, remoteHSIds[0]);
       resp.setStatus(FragmentResponseMessage.SUCCESS, null);
       for (int j = 0; j < batchSize ; j++) {
           resp.addDependency(depsToResumeList.get(j),
                              new VoltTable(new VoltTable.ColumnInfo("BOGO",
                                                                     VoltType.BIGINT)));
       }
       System.out.println("BORROW RESPONSE: " + resp);
       plan.generatedResponses.add(resp);
View Full Code Here


                        m_runner.executeSysProcPlanFragment(
                                m_runner.getTxnState(),
                                null,
                                hashToFragId(ftm.getPlanHash(0)),
                                ftm.getParameterSetForFragment(0));
                FragmentResponseMessage frm = new FragmentResponseMessage(ftm, m.getHSId());
                frm.addDependency(dp.depId, dp.dependency);
                m.send(ftm.getCoordinatorHSId(), frm);

                if (!m_unexpectedDependencies.isEmpty()) {
                    for (Integer dependencyId : dependencyIds) {
                        if (m_unexpectedDependencies.containsKey(dependencyId)) {
                            receivedDependencyIds.put(dependencyId, m_unexpectedDependencies.remove(dependencyId));
                        }
                    }

                    /*
                     * This predicate exists below in FRM handling, they have to match
                     */
                    if (receivedDependencyIds.size() == dependencyIds.size() &&
                            receivedDependencyIds.keySet().equals(dependencyIds)) {
                        break;
                    }
                }
            } else if (vm instanceof FragmentResponseMessage) {
                FragmentResponseMessage frm = (FragmentResponseMessage)vm;
                final int dependencyId = frm.getTableDependencyIdAtIndex(0);
                if (dependencyIds.contains(dependencyId)) {
                    receivedDependencyIds.put(
                            dependencyId,
                            Arrays.asList(new VoltTable[] {frm.getTableAtIndex(0)}));
                    log.trace("Received dependency at " + CoreUtils.hsIdToString(m.getHSId()) +
                            "-" + CoreUtils.hsIdToString(m_site.getCorrespondingSiteId()) +
                            " from " + CoreUtils.hsIdToString(frm.m_sourceHSId) +
                            " have " + receivedDependencyIds.size() + " " + receivedDependencyIds.keySet() +
                            " and need " + dependencyIds.size() + " " + dependencyIds);
                    /*
                     * This predicate exists above in FTM handling, they have to match
                     */
                    if (receivedDependencyIds.size() == dependencyIds.size() &&
                            receivedDependencyIds.keySet().equals(dependencyIds)) {
                        break;
                    }
                } else {
                    /*
                     * Stash the dependency intended for a different fragment
                     */
                    if (m_unexpectedDependencies.put(
                            dependencyId,
                            Arrays.asList(new VoltTable[] {frm.getTableAtIndex(0)})) != null) {
                        VoltDB.crashGlobalVoltDB("Received a duplicate dependency", true, null);
                    }
                }
            }
        }
View Full Code Here

        FragmentTaskMessage sptask = createFrag(txnid, true, primary_hsid);
        dut.deliver(sptask);
        // verify no response sent yet
        verify(mbox, times(0)).send(anyLong(), (VoltMessage)anyObject());
        verify(mbox, times(0)).send(new long[] {anyLong()}, (VoltMessage)anyObject());
        FragmentResponseMessage resp = new FragmentResponseMessage(sptask, 0l);
        dut.deliver(resp);
        verify(mbox, times(1)).send(eq(primary_hsid), eq(resp));
    }
View Full Code Here

        FragmentTaskMessage sptask = createFrag(txnid, true, primary_hsid);
        dut.deliver(sptask);
        // verify no response sent yet
        verify(mbox, times(0)).send(anyLong(), (VoltMessage)anyObject());
        verify(mbox, times(0)).send(new long[] {anyLong()}, (VoltMessage)anyObject());
        FragmentResponseMessage resp = new FragmentResponseMessage(sptask, 0l);
        dut.deliver(resp);
        verify(mbox, times(1)).send(eq(primary_hsid), eq(resp));
    }
View Full Code Here

        // verify no response sent yet
        verify(mbox, times(0)).send(anyLong(), (VoltMessage)anyObject());
        ArgumentCaptor<FragmentTaskMessage> replmsg = ArgumentCaptor.forClass(FragmentTaskMessage.class);
        verify(mbox, times(1)).send(eq(new long[] {2}), replmsg.capture());
        assertEquals(dut_hsid, replmsg.getValue().getCoordinatorHSId());
        FragmentResponseMessage resp = new FragmentResponseMessage(sptask, 0l);
        dut.deliver(resp);
        FragmentResponseMessage replresp = new FragmentResponseMessage(replmsg.getValue(), 0l);
        dut.deliver(replresp);
        verify(mbox, times(1)).send(eq(primary_hsid), eq(resp));
    }
View Full Code Here

            VoltMessage resp = counter.getLastResponse();
            if (resp != null) {
                // MPI is tracking deps per partition HSID.  We need to make
                // sure we write ours into the message getting sent to the MPI
                if (resp instanceof FragmentResponseMessage) {
                    FragmentResponseMessage fresp = (FragmentResponseMessage)resp;
                    fresp.setExecutorSiteId(m_mailbox.getHSId());
                }
                m_mailbox.send(counter.m_destinationId, resp);
            }
            else {
                hostLog.warn("TXN " + counter.getTxnId() + " lost all replicas and " +
View Full Code Here

        if (counter != null) {
            int result = counter.offer(message);
            if (result == DuplicateCounter.DONE) {
                m_duplicateCounters.remove(new DuplicateCounterKey(message.getTxnId(), message.getSpHandle()));
                m_repairLogTruncationHandle = message.getSpHandle();
                FragmentResponseMessage resp = (FragmentResponseMessage)counter.getLastResponse();
                // MPI is tracking deps per partition HSID.  We need to make
                // sure we write ours into the message getting sent to the MPI
                resp.setExecutorSiteId(m_mailbox.getHSId());
                m_mailbox.send(counter.m_destinationId, resp);
            }
            else if (result == DuplicateCounter.MISMATCH) {
                VoltDB.crashGlobalVoltDB("HASH MISMATCH running multi-part procedure.", true, null);
            }
View Full Code Here

    /**
     * Respond with a dummy fragment response.
     */
    private void respondWithDummy()
    {
        final FragmentResponseMessage response =
            new FragmentResponseMessage(m_fragmentMsg, m_initiator.getHSId());
        response.m_sourceHSId = m_initiator.getHSId();
        response.setRecovering(true);
        response.setStatus(FragmentResponseMessage.SUCCESS, null);

        // Set the dependencies even if this is a dummy response. This site could be the master
        // on elastic join, so the fragment response message is actually going to the MPI.
        VoltTable depTable = new VoltTable(new VoltTable.ColumnInfo("STATUS", VoltType.TINYINT));
        depTable.setStatusCode(VoltTableUtil.NULL_DEPENDENCY_STATUS);
        for (int frag = 0; frag < m_fragmentMsg.getFragmentCount(); frag++) {
            final int outputDepId = m_fragmentMsg.getOutputDepId(frag);
            response.addDependency(outputDepId, depTable);
        }

        m_initiator.deliver(response);
    }
View Full Code Here

            !VoltDB.instance().isMpSysprocSafeToExecute(m_txnState.txnId)) {
            respondWithDummy();
            return;
        }

        final FragmentResponseMessage response = processFragmentTask(siteConnection);
        response.m_sourceHSId = m_initiator.getHSId();
        m_initiator.deliver(response);
    }
View Full Code Here

    // Extracted the sysproc portion of ExecutionSite processFragmentTask(), then
    // modifed to work in the new world
    public FragmentResponseMessage processFragmentTask(SiteProcedureConnection siteConnection)
    {
        final FragmentResponseMessage currentFragResponse =
            new FragmentResponseMessage(m_fragmentMsg, m_initiator.getHSId());
        currentFragResponse.setStatus(FragmentResponseMessage.SUCCESS, null);

        for (int frag = 0; frag < m_fragmentMsg.getFragmentCount(); frag++)
        {
            final long fragmentId = VoltSystemProcedure.hashToFragId(m_fragmentMsg.getPlanHash(frag));
            // equivalent to dep.depId:
            // final int outputDepId = m_fragmentMsg.getOutputDepId(frag);

            ParameterSet params = m_fragmentMsg.getParameterSetForFragment(frag);

            try {
                // run the overloaded sysproc planfragment. pass an empty dependency
                // set since remote (non-aggregator) fragments don't receive dependencies.
                final DependencyPair dep
                    = siteConnection.executeSysProcPlanFragment(m_txnState,
                                                         m_inputDeps,
                                                         fragmentId,
                                                         params);
                // @Shutdown returns null, handle it here
                if (dep != null) {
                    currentFragResponse.addDependency(dep.depId, dep.dependency);
                }
            } catch (final EEException e) {
                hostLog.l7dlog(Level.TRACE, LogKeys.host_ExecutionSite_ExceptionExecutingPF.name(),
                        new Object[] { Encoder.hexEncode(m_fragmentMsg.getFragmentPlan(frag)) }, e);
                currentFragResponse.setStatus(FragmentResponseMessage.UNEXPECTED_ERROR, e);
                break;
            } catch (final SQLException e) {
                hostLog.l7dlog(Level.TRACE, LogKeys.host_ExecutionSite_ExceptionExecutingPF.name(),
                        new Object[] { Encoder.hexEncode(m_fragmentMsg.getFragmentPlan(frag)) }, e);
                currentFragResponse.setStatus(FragmentResponseMessage.UNEXPECTED_ERROR, e);
                break;
            }
            catch (final SpecifiedException e) {
                // Note that with SpecifiedException, the error code here might get changed before
                // the client/user sees it. It really just needs to indicate failure.
                //
                // Key point here vs the next catch block for VAE is to not wrap the subclass of
                // SerializableException here to preserve it during the serialization.
                //
                currentFragResponse.setStatus(
                        FragmentResponseMessage.USER_ERROR,
                        e);
            }
            catch (final VoltAbortException e) {
                currentFragResponse.setStatus(
                        FragmentResponseMessage.USER_ERROR,
                        new SerializableException(CoreUtils.throwableToString(e)));
                break;
            }
        }
View Full Code Here

TOP

Related Classes of org.voltdb.messaging.FragmentResponseMessage

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.