예제 #1
0
void ClearClusterSingletons()
{
	ClusterCache.clear();
}
예제 #2
0
    bool GetActive(IClusterVector * clusters)
    {
        CComInitialize com;
        ServerT server;
        CString url = GetIConfig(QUERYBUILDER_CFG)->Get(GLOBAL_SERVER_SMC);
        server.SetUrl(url);

        CStructArrayOut<ActiveWorkunit> running;
#if _COMMS_VER < 499
        bool thorQueueManagement;
        if (server.Index(exceptions.GetArrayAddress(), exceptions.GetCountAddress(), &build, thorClusters.GetArrayAddress(), thorClusters.GetCountAddress(), holeClusters.GetArrayAddress() , holeClusters.GetCountAddress(), dfuJobs.GetArrayAddress(), dfuJobs.GetCountAddress(), &thorQueueManagement) == S_OK)
#elif _COMMS_VER < 505
        bool thorQueueManagement;
        CStructArrayOut<ActiveWorkunit> running;
        if (server.Index(exceptions.GetArrayAddress(), exceptions.GetCountAddress(), &build, thorClusters.GetArrayAddress(), thorClusters.GetCountAddress(), holeClusters.GetArrayAddress() , holeClusters.GetCountAddress(), dfuJobs.GetArrayAddress(), dfuJobs.GetCountAddress(), running.GetArrayAddress(), running.GetCountAddress(), &thorQueueManagement) == S_OK)
#elif _COMMS_VER < 50509
        CStructArrayOut<ActiveWorkunit> running;
        if (server.Index(exceptions.GetArrayAddress(), exceptions.GetCountAddress(), &build, thorClusters.GetArrayAddress(), thorClusters.GetCountAddress(), holeClusters.GetArrayAddress() , holeClusters.GetCountAddress(), dfuJobs.GetArrayAddress(), dfuJobs.GetCountAddress(), running.GetArrayAddress(), running.GetCountAddress()) == S_OK)
#elif _COMMS_VER < 51100
        CStructArrayOut<ActiveWorkunit> running;
        if (server.Activity(false, exceptions.GetArrayAddress(), exceptions.GetCountAddress(), &build, thorClusters.GetArrayAddress(), thorClusters.GetCountAddress(), holeClusters.GetArrayAddress() , holeClusters.GetCountAddress(), dfuJobs.GetArrayAddress(), dfuJobs.GetCountAddress(), running.GetArrayAddress(), running.GetCountAddress()) == S_OK)
#elif _COMMS_VER < 67205
        CComBSTR build;
        CStructArrayOut<ThorCluster> thorClusters;
        CStructArrayOut<HoleCluster> holeClusters;
        CStructArrayOut<DFUJob> dfuJobs;
        ESP_EXCEPTION_LOG(EspException);
        if (server.Activity(exceptions.GetArrayAddress(), exceptions.GetCountAddress(), &build, thorClusters.GetArrayAddress(), thorClusters.GetCountAddress(), holeClusters.GetArrayAddress() , holeClusters.GetCountAddress(), dfuJobs.GetArrayAddress(), dfuJobs.GetCountAddress(), running.GetArrayAddress(), running.GetCountAddress()) == S_OK)
        {
            if (build)
                m_version = CreateVersion(url, CString(build));

            //  Multi thor support - there could be some jobs running on a multi thor!
            for(int i = 0; i < running.GetCount(); ++i)
            {
                CComBSTR thorClusterName = running.GetItem(i)->Instance;
#elif _COMMS_VER < 700000
        CComBSTR build;
        CStructArrayOut<ThorCluster> thorClusters;
        CStructArrayOut<HoleCluster> holeClusters;
        CStructArrayOut<DFUJob> dfuJobs;
        ESP_EXCEPTION_LOG2(EspException);
        if (server.Activity(exceptions, &build, thorClusters.GetArrayAddress(), thorClusters.GetCountAddress(), holeClusters.GetArrayAddress() , holeClusters.GetCountAddress(), dfuJobs.GetArrayAddress(), dfuJobs.GetCountAddress(), running.GetArrayAddress(), running.GetCountAddress()) == S_OK)
        {
            if (build)
                m_version = CreateVersion(url, CString(build));

            //  Multi thor support - there could be some jobs running on a multi thor!
            for(int i = 0; i < running.GetCount(); ++i)
            {
                CComBSTR thorClusterName = running.GetItem(i)->Instance;
#else
        ESP_STATUS_LOG;
        if (server.ListActiveOrQueuedWorkunits(running.GetArrayAddress(), running.GetCountAddress(), &status.m_statusCode, &status.m_statusMessage) == S_OK)
        {
            //  Multi thor support - there could be some jobs running on a multi thor!
            for(int i = 0; i < running.GetCount(); ++i)
            {
                CComBSTR thorClusterName = running.GetItem(i)->ServerInstance;
#endif
                CComBSTR thorClusterStatus = running.GetItem(i)->State;
                ThorCluster thorCluster;
                thorCluster.ClusterName = thorClusterName;
                thorCluster.QueueStatus = thorClusterStatus;
                StlLinked<ICluster> cluster = CreateCluster(m_url, &thorCluster, running);
                if (std::find(clusters->begin(), clusters->end(), cluster) == clusters->end())
                {
                    clusters->push_back(cluster.get());
                }
            }
            return true;
        }
        else
            _DBGLOG(m_url, LEVEL_WARNING, server.GetClientError());

        return false;
    }

    IVersion * GetBuild()
    {
        if (m_version)
            return m_version;
        IClusterVector results;
        if (GetActive(&results))
            return m_version;
        return m_unknown;
    }

    bool SetPriority(const std::_tstring &cluster, const std::_tstring &wuid, PRIORITY priority)
    {
        CComInitialize com;
        ServerT server;
        server.SetUrl(CString(GetIConfig(QUERYBUILDER_CFG)->Get(GLOBAL_SERVER_SMC)));

        CComBSTR inCluster = CT2W(cluster.c_str(), CP_UTF8);
        CComBSTR inWuid = CT2W(wuid.c_str(), CP_UTF8);

        HRESULT result;
#if _COMMS_VER < 67205 
        ESP_EXCEPTION_LOG(EspException);
#elif _COMMS_VER < 700000 
        ESP_EXCEPTION_LOG2(EspException);
#else
        ESP_STATUS_LOG;
#endif
        switch (priority)
        {
        case PRIORITY_UP:
            {
#if _COMMS_VER < 51100 
                result = server.MoveJobUp(inCluster, inWuid);
#elif _COMMS_VER < 67205
                result = server.MoveJobUp(inCluster, inWuid, exceptions.GetArrayAddress(), exceptions.GetCountAddress());
#elif _COMMS_VER < 700000 
                result = server.MoveJobUp(inCluster, inWuid, exceptions);
#else
                CComBSTR position = _T("up");
                result = server.SetWorkunitPositionInSamePriority(inCluster, inWuid, position, &status.m_statusCode, &status.m_statusMessage);
#endif
            }
            break;
        case PRIORITY_DOWN:
            {
#if _COMMS_VER < 51100 
                result = server.MoveJobDown(inCluster, inWuid);
#elif _COMMS_VER < 67205
                result = server.MoveJobDown(inCluster, inWuid, exceptions.GetArrayAddress(), exceptions.GetCountAddress());
#elif _COMMS_VER < 700000 
                result = server.MoveJobDown(inCluster, inWuid, exceptions);
#else
                CComBSTR position = _T("down");
                result = server.SetWorkunitPositionInSamePriority(inCluster, inWuid, position, &status.m_statusCode, &status.m_statusMessage);
#endif
            }
            break;
        case PRIORITY_TOP:
            {
#if _COMMS_VER < 51100 
                result = server.MoveJobFront(inCluster, inWuid);
#elif _COMMS_VER < 67205
                result = server.MoveJobFront(inCluster, inWuid, exceptions.GetArrayAddress(), exceptions.GetCountAddress());
#elif _COMMS_VER < 700000 
                result = server.MoveJobFront(inCluster, inWuid, exceptions);
#else
                CComBSTR position = _T("front");
                result = server.SetWorkunitPositionInSamePriority(inCluster, inWuid, position, &status.m_statusCode, &status.m_statusMessage);
#endif
            }
            break;
        case PRIORITY_BOTTOM:
            {
#if _COMMS_VER < 51100 
                result = server.MoveJobBack(inCluster, inWuid);
#elif _COMMS_VER < 67205
                result = server.MoveJobBack(inCluster, inWuid, exceptions.GetArrayAddress(), exceptions.GetCountAddress());
#elif _COMMS_VER < 700000 
                result = server.MoveJobBack(inCluster, inWuid, exceptions);
#else
                CComBSTR position = _T("end");
                result = server.SetWorkunitPositionInSamePriority(inCluster, inWuid, position, &status.m_statusCode, &status.m_statusMessage);
#endif
            }
            break;
        default:
            _DBGLOG(m_url, LEVEL_WARNING, server.GetClientError());
            return false;
        }
        if(result == S_OK)
        {
            return true;
        }
        else
            _DBGLOG(m_url, LEVEL_WARNING, server.GetClientError());
        return false;
    }

    bool SetPriority(Dali::IWorkunitVector *workunits, PRIORITY priority)
    {
        switch (priority)
        {
        case PRIORITY_UP:
        case PRIORITY_TOP:
            {
                for(Dali::IWorkunitVector::iterator itr = workunits->begin(); itr != workunits->end(); ++itr)
                {
                    Dali::IWorkunitAdapt& workunit = *itr;
                    SetPriority(workunit->GetCluster(), workunit->GetWuid(), priority);
                }
            }
            break;
        case PRIORITY_DOWN:
        case PRIORITY_BOTTOM:
            {
                for (Dali::IWorkunitVector::reverse_iterator itr = workunits->rbegin(); itr != workunits->rend(); ++itr)
                {
                    Dali::IWorkunitAdapt& workunit = *itr;
                    SetPriority(workunit->GetCluster(), workunit->GetWuid(), priority);
                }
            }
            break;
        }
        return true;
    }
};
#endif

CacheT<std::_tstring, CSMC> SMCCache;
ISMC * AttachSMC(const std::_tstring & url, const std::_tstring & label)
{
    return SMCCache.Get(new CSMC(url.c_str(), label.c_str()));
}
COMMS_API ISMC * AttachSMC(const _variant_t & url, const std::_tstring & label)
{
    return SMCCache.Get(new CSMC(url, label.c_str()));
}
void ClearSingletons()
{
    ClearVersionCache();
    ClearClusterCache();
    SMCCache.clear();
}
}
예제 #3
0
void ClearDropZoneSingletons()
{
    DropZoneCache.clear();
}