コード例 #1
0
ファイル: DrError.cpp プロジェクト: KarthikTunga/Dryad
DrString DrError::ToShortText()
{
    DrString s;
    if (m_explanation.GetString() == DrNull)
    {
        s.SetF("%s:%x:%s", m_component.GetChars(), m_code, DRERRORSTRING(m_code));
    }
    else
    {
        s.SetF("%s:%x:%s. %s", m_component.GetChars(), m_code, DRERRORSTRING(m_code), m_explanation.GetChars());
    }
    return s;
}
コード例 #2
0
ファイル: DrFileSystem.cpp プロジェクト: CodEnFisH/Dryad
void DrInputStreamManager::SetName(DrString name)
{
    m_name = name;

    DrString nameBase;
    if (m_name.GetString() == DrNull)
    {
        nameBase = "In";
    }
    else
    {
        nameBase = m_name;
    }

    int i;
    for (i=0; i<m_vertices->Size(); ++i)
    {
        DrString vertexName;
        vertexName.SetF("%s[%d]", nameBase.GetChars(), i);
        m_vertices[i]->SetName(vertexName);
    }
}
コード例 #3
0
ファイル: DrVertexCommand.cpp プロジェクト: CodEnFisH/Dryad
DrString DrVertexCommandBlock::GetPropertyLabel(int vertexId, int vertexVersion)
{
    DrString s;
    s.SetF("%s-%d.%d", s_CommandPropertyLabel, vertexId, vertexVersion);
    return s;
}
コード例 #4
0
ファイル: DrVertexCommand.cpp プロジェクト: CodEnFisH/Dryad
DrString DrVertexStatus::GetPropertyLabel(int vertexId, int vertexVersion)
{
    DrString s;
    s.SetF("%s-%d.%d", s_StatusPropertyLabel, vertexId, vertexVersion);
    return s;
}
コード例 #5
0
ファイル: DrCohort.cpp プロジェクト: Applied-Duality/Dryad
void DrCohortProcess::ReceiveMessage(DrProcessInfoRef message)
{
    if (m_receivedProcess == false)
    {
        /* when the CohortStarter helper below actually scheduled the process, it
           wasn't holding our lock. So the first thing it does is send us a
           message containing our DrProcess. Because of the ordering guarantees
           of the message queue, that is the first message we will receive. There
           are two cases: either it sent the process to be scheduled, in which
           case we will hear from a subsequent message whether it succeeded or not,
           or there was an unsatisfiable hard constraint in which case we hear with
           an error right now. */

        m_receivedProcess = true;

        /* this can only be the fake message from the Cohort Starter */
        DrAssert(message->m_state->m_state == DPS_NotStarted);
        
        if (message->m_process.IsNull())
        {
            /* there was an error scheduling */
            DrAssert(message->m_state->m_status != DrNull);

            DrString msg = DrError::ToShortText(message->m_state->m_status);
            DrLogI("Cohort %s v.%d got scheduling error message on cohort startup %s",
                   m_parent->GetDescription().GetChars(), m_version, msg.GetChars());

			m_parent->GetGang()->CancelVersion(m_version, message->m_state->m_status);
        }
        else
        {
            DrAssert(message->m_state->m_status == DrNull);
            m_process = message->m_process;
            DrLogI("Cohort %s v.%d got startup message",
                   m_parent->GetDescription().GetChars(), m_version);
        }

        return;
    }

    if (m_process.IsNull())
    {
        /* we have already finished so do nothing */
        return;
    }

    DrLogI("Cohort %s v.%d got message state %d",
           m_parent->GetDescription().GetChars(), m_version,
           message->m_state->m_state);

    DrProcessStateRecordPtr state = message->m_state;
    if (state->m_state > DPS_Running)
    {
        /* in the normal course of affairs, we should have already seen the process
           start running, in which case the vertices have all initiated their own
           message sends to the process which will also return informing them that
           it has finished, at which point we will be notified cleanly via NotifyVertexCompletion.
           The DrProcess machinery is supposed to have delayed the message we are now
           receiving in order to give the vertex messages a chance to arrive. So if we
           ever get here, something has gone wrong: either the process never started or
           the vertex messages didn't get sent.

           We are going to call Cancel below on the gang, which will result in all our vertices
           calling NotifyVertexCompletion and eventually us cleaning up once they all report.
        */

        DrErrorRef error;

        if (state->m_state == DPS_Completed)
        {
            DrString reason;
            if (m_processHandle == DrNull)
            {
                if (state->m_status == DrNull)
                {
                    reason.SetF("Process completed with no error without starting");
                    error = DrNew DrError(DrError_VertexError, "DrCohortProcess", reason);
                }
                else
                {
                    reason.SetF("Process completed with code %s without starting",
                                DRERRORSTRING(state->m_status->m_code));
                    error = DrNew DrError(state->m_status->m_code, "DrCohortProcess", reason);
                    error->AddProvenance(state->m_status);
                }
            }
            else
            {
                if (state->m_status == DrNull)
                {
                    reason.SetF("Process completed with no error but vertex message was never delivered");
                    error = DrNew DrError(DrError_VertexError, "DrCohortProcess", reason);
                }
                else
                {
                    reason.SetF("Process completed with code %s but vertex message was never delivered",
                                DRERRORSTRING(state->m_status->m_code));
                    error = DrNew DrError(state->m_status->m_code, "DrCohortProcess", reason);
                    error->AddProvenance(state->m_status);
                }
            }
        }
        else
        {
            if (state->m_status == DrNull)
            {
                DrLogW("Empty status delivered with process info state %u", state->m_state);
                DrString reason;
                reason.SetF("Empty status with failed process state %u", state->m_state);
                error = DrNew DrError(DrError_Unexpected, "DrCohortProcess", reason);
            }
            else
            {
                DrString reason;
                reason.SetF("%s process code %s",
                            (state->m_state == DPS_Failed) ? "Failed" : "Zombie",
                            DRERRORSTRING(state->m_status->m_code));
                error = DrNew DrError(state->m_status->m_code, "DrCohortProcess", reason);
                error->AddProvenance(state->m_status);
            }
        }

        DrString eString = DrError::ToShortText(error);
        DrLogI("Cohort %s v.%d cancelling gang %s %s",
               m_parent->GetDescription().GetChars(), m_version, eString.GetChars(),
               error->m_explanation.GetChars());

		m_parent->GetGang()->CancelVersion(m_version, error);
    }
    else if (m_processHandle == DrNull && state->m_state == DPS_Running)
    {
        /* the process has started so tell everyone about it */
        m_processHandle = state->m_process;
        DrAssert(m_processHandle != DrNull);

        DrLogI("Cohort %s v.%d starting process",
               m_parent->GetDescription().GetChars(), m_version);

        m_parent->NotifyProcessHasStarted(m_version);
    }
}