コード例 #1
0
  private void processFragmentResponseDependencies(FragmentResponseMessage response) {
    int depCount = response.getTableCount();
    for (int i = 0; i < depCount; i++) {
      int dependencyId = response.getTableDependencyIdAtIndex(i);
      VoltTable payload = response.getTableAtIndex(i);
      assert (payload != null);

      // if we're getting a dependency, i hope we know about it
      assert (m_missingDependencies != null);

      WorkUnit w = m_missingDependencies.get(dependencyId);
      if (w == null) {
        String msg =
            "Unable to find WorkUnit for dependency: "
                + dependencyId
                + " as part of TXN: "
                + txnId
                + " received from execution site: "
                + response.getExecutorSiteId();
        hostLog.warn(msg);
        // throw new FragmentFailureException();
        return;
      }

      // if the node is recovering, it doesn't matter if the payload matches
      if (response.isRecovering()) {
        w.putDummyDependency(dependencyId, response.getExecutorSiteId());
      } else {
        w.putDependency(
            dependencyId, response.getExecutorSiteId(), payload, m_site.getSiteTracker());
      }
      if (w.allDependenciesSatisfied()) {
        handleWorkUnitComplete(w);
      }
    }
  }
コード例 #2
0
  void processFragmentWork(
      FragmentTaskMessage ftask, HashMap<Integer, List<VoltTable>> dependencies) {
    assert (ftask.getFragmentCount() > 0);

    FragmentResponseMessage response = m_site.processFragmentTask(this, dependencies, ftask);
    if (response.getStatusCode() != FragmentResponseMessage.SUCCESS) {
      if (m_missingDependencies != null) m_missingDependencies.clear();
      m_readyWorkUnits.clear();

      if (m_isCoordinator) {
        // throw an exception which will back the runtime all the way
        // to the stored procedure invocation call, triggering undo
        // at that point
        if (response.getException() != null) {
          throw response.getException();
        } else {
          throw new FragmentFailureException();
        }
      } else {
        m_needsRollback = true;
        m_done = true;
      }
    }

    if (m_isCoordinator && (response.getDestinationSiteId() == response.getExecutorSiteId())) {
      processFragmentResponseDependencies(response);
    } else {
      m_mbox.send(response.getDestinationSiteId(), response);
      // If we're not the coordinator, the transaction is read-only,
      // and this was the final task, then we can try to move on after
      // we've finished this work.
      if (!isCoordinator() && isReadOnly() && ftask.isFinalTask()) {
        m_done = true;
      }
    }
  }