Пример #1
0
void testAbort(const char *wuid)
{
    getDFUWorkUnitFactory();

    Owned<IDFUWorkUnitFactory> factory = getDFUWorkUnitFactory();
    Owned<IConstDFUWorkUnit> wu = factory->openWorkUnit(wuid,false);
    if (wu) {
        wu->requestAbort();
    }
    else
        ERRLOG("WUID %s not found", wuid);
}
Пример #2
0
void testProgressMonitor(const char *wuid)
{
    getDFUWorkUnitFactory();

    Owned<IDFUWorkUnitFactory> factory = getDFUWorkUnitFactory();
    Owned<IConstDFUWorkUnit> wu = factory->openWorkUnit(wuid,false);
    class cProgressMon: public CInterface, implements IDFUprogressSubscriber
    {
    public:
        IMPLEMENT_IINTERFACE;

        void notify(IConstDFUprogress *progress)
        {
            StringBuffer s;
            progress->formatProgressMessage(s);
            PROGLOG(" %s",s.str());
        }
Пример #3
0
IPropertyTree* CFileSpraySoapBindingEx::createPTreeForXslt(const char* method, const char* dfuwuid)
{
    Owned<IEnvironmentFactory> factory = getEnvironmentFactory();
    Owned<IConstEnvironment> m_constEnv = factory->openEnvironment();
    Owned<IPropertyTree> pEnvRoot = &m_constEnv->getPTree();
    IPropertyTree* pEnvSoftware = pEnvRoot->queryPropTree("Software");

    Owned<IPropertyTree> pRoot = createPTreeFromXMLString("<Environment/>");
    IPropertyTree* pSoftware = pRoot->addPropTree("Software", createPTree("Software"));

    if (pEnvSoftware)
    {
        StringBuffer dfuwuidSourcePartIP, wuxml;
        if(dfuwuid && *dfuwuid)
        {
            Owned<IDFUWorkUnitFactory> dfuwu_factory = getDFUWorkUnitFactory();
            Owned<IConstDFUWorkUnit> dfuwu = dfuwu_factory->openWorkUnit(dfuwuid, false);
            if(dfuwu)
            {   
                dfuwu->toXML(wuxml);

                Owned<IPropertyTree> wu = createPTreeFromXMLString(wuxml.str());
                if (wu)
                {
                    const char* ip = wu->queryProp("Source/Part/@node");
                    if (ip && *ip)
                        dfuwuidSourcePartIP.append(ip);
                }
            }
        }

        Owned<IPropertyTreeIterator> it = pEnvSoftware->getElements("DropZone");
        ForEach(*it)
        {
            IPropertyTree* pDropZone = pSoftware->addPropTree("DropZone", &it->get());
            //get IP Address of the computer associated with this drop zone
            const char* pszComputer = it->query().queryProp("@computer");
            if (!strcmp(pszComputer, "."))
                pszComputer = "localhost";

            StringBuffer xpath;
            xpath.appendf("Hardware/Computer[@name='%s']/@netAddress", pszComputer);

            StringBuffer sNetAddr;
            const char* pszNetAddr = pEnvRoot->queryProp(xpath.str());
            if (strcmp(pszNetAddr, "."))
            {       
                sNetAddr.append(pszNetAddr);
            }
            else
            {
                StringBuffer ipStr;
                IpAddress ipaddr = queryHostIP();
                ipaddr.getIpText(ipStr);
                if (ipStr.length() > 0)
                {
#ifdef MACHINE_IP
                    sNetAddr.append(MACHINE_IP);
#else
                    sNetAddr.append(ipStr.str());
#endif
                }
            }
            pDropZone->addProp("@netAddress", sNetAddr.str());
            if ((dfuwuidSourcePartIP.length() > 0) && (sNetAddr.length() > 0))
            {
                IpAddress ip1(dfuwuidSourcePartIP.str()), ip2(sNetAddr.str());
                if (ip1.ipequals(ip2))              
                    pDropZone->addProp("@sourceNode", "1");
            }

            Owned<IConstMachineInfo> machine;
            if (strcmp(pszNetAddr, "."))
                machine.setown(m_constEnv->getMachineByAddress(sNetAddr.str()));
            else
            {
                machine.setown(m_constEnv->getMachineByAddress(pszNetAddr));
                if (!machine)
                    machine.setown(m_constEnv->getMachineByAddress(sNetAddr.str()));
            }

            if (machine)
            {
                //int os = machine->getOS();
                StringBuffer dir;
                pDropZone->getProp("@directory", dir);
                if (machine->getOS() == MachineOsLinux || machine->getOS() == MachineOsSolaris)
                {         
                    dir.replace('\\', '/');//replace all '\\' by '/'
                    pDropZone->setProp("@linux", "true");
                }
                else
                {       
                    dir.replace('/', '\\');
                    dir.replace('$', ':');
                }
                pDropZone->setProp("@directory", dir);
            }
        }

        //For Spray files on Thor Cluster, fetch all the group names for all the thor instances (and dedup them)
        BoolHash uniqueThorClusterGroupNames;
        it.setown(pEnvSoftware->getElements("ThorCluster"));
        ForEach(*it)
        {
            StringBuffer thorClusterGroupName;
            IPropertyTree& cluster = it->query();
            getClusterGroupName(cluster, thorClusterGroupName);
            if (!thorClusterGroupName.length())
                continue;
            bool* found = uniqueThorClusterGroupNames.getValue(thorClusterGroupName.str());
            if (found && *found)
                continue;

            uniqueThorClusterGroupNames.setValue(thorClusterGroupName.str(), true);
            IPropertyTree* newClusterTree = pSoftware->addPropTree("ThorCluster", &it->get());
            newClusterTree->setProp("@name", thorClusterGroupName.str()); //set group name into @name for spray target
        }

        it.setown(pEnvSoftware->getElements("EclAgentProcess"));
        ForEach(*it)
        {
            IPropertyTree &cluster = it->query();
            const char* name = cluster.queryProp("@name");
            if (!name||!*name)
                continue;
            
            unsigned ins = 0;
            Owned<IPropertyTreeIterator> insts = cluster.getElements("Instance");
            ForEach(*insts) 
            {
                const char *na = insts->query().queryProp("@netAddress");
                if (!na || !*na) 
                {
                    insts->query().setProp("@gname", name);
                    continue;
                }
                
                SocketEndpoint ep(na);
                if (ep.isNull())
                    continue;

                ins++;
                StringBuffer gname("hthor__");
                //StringBuffer gname;
                gname.append(name);
                if (ins>1)
                    gname.append('_').append(ins);

                insts->query().setProp("@gname", gname.str());

            }

            pSoftware->addPropTree("EclAgentProcess", &it->get());
        }

        if (stricmp(method, "CopyInput") == 0) //Limit for this method only
        {
            it.setown(pEnvSoftware->getElements("RoxieCluster"));
            ForEach(*it)
                pSoftware->addPropTree("RoxieCluster", &it->get());
        }

        if (wuxml.length() > 0)
            pSoftware->addPropTree("DfuWorkunit", createPTreeFromXMLString(wuxml.str()));
    }
    return pRoot.getClear();
}
IPropertyTree* CFileSpraySoapBindingEx::createPTreeForXslt(double clientVersion, const char* method, const char* dfuwuid)
{
    Owned<IEnvironmentFactory> factory = getEnvironmentFactory(true);
    Owned<IConstEnvironment> constEnv = factory->openEnvironment();
    Owned<IPropertyTree> pEnvRoot = &constEnv->getPTree();
    IPropertyTree* pEnvSoftware = pEnvRoot->queryPropTree("Software");

    Owned<IPropertyTree> pRoot = createPTreeFromXMLString("<Environment/>");
    IPropertyTree* pSoftware = pRoot->addPropTree("Software", createPTree("Software"));

    if (pEnvSoftware)
    {
        StringBuffer dfuwuidSourcePartIP, wuxml;
        if(dfuwuid && *dfuwuid)
        {
            Owned<IDFUWorkUnitFactory> dfuwu_factory = getDFUWorkUnitFactory();
            Owned<IConstDFUWorkUnit> dfuwu = dfuwu_factory->openWorkUnit(dfuwuid, false);
            if(dfuwu)
            {   
                dfuwu->toXML(wuxml);

                Owned<IPropertyTree> wu = createPTreeFromXMLString(wuxml.str());
                if (wu)
                {
                    const char* ip = wu->queryProp("Source/Part/@node");
                    if (ip && *ip)
                        dfuwuidSourcePartIP.append(ip);
                }
            }
        }

        appendDropZones(clientVersion, constEnv, dfuwuidSourcePartIP.str(), pSoftware);

        //For Spray files on Thor Cluster, fetch all the group names for all the thor instances (and dedup them)
        BoolHash uniqueThorClusterGroupNames;
        Owned<IPropertyTreeIterator> it =pEnvSoftware->getElements("ThorCluster");
        ForEach(*it)
        {
            StringBuffer thorClusterGroupName;
            IPropertyTree& cluster = it->query();
            getClusterGroupName(cluster, thorClusterGroupName);
            if (!thorClusterGroupName.length())
                continue;
            bool* found = uniqueThorClusterGroupNames.getValue(thorClusterGroupName.str());
            if (found && *found)
                continue;

            uniqueThorClusterGroupNames.setValue(thorClusterGroupName.str(), true);
            IPropertyTree* newClusterTree = pSoftware->addPropTree("ThorCluster", &it->get());
            newClusterTree->setProp("@name", thorClusterGroupName.str()); //set group name into @name for spray target
        }

        it.setown(pEnvSoftware->getElements("EclAgentProcess"));
        ForEach(*it)
        {
            IPropertyTree &cluster = it->query();
            const char* name = cluster.queryProp("@name");
            if (!name||!*name)
                continue;
            
            unsigned ins = 0;
            Owned<IPropertyTreeIterator> insts = cluster.getElements("Instance");
            ForEach(*insts) 
            {
                const char *na = insts->query().queryProp("@netAddress");
                if (!na || !*na) 
                {
                    insts->query().setProp("@gname", name);
                    continue;
                }
                
                SocketEndpoint ep(na);
                if (ep.isNull())
                    continue;

                ins++;
                StringBuffer gname("hthor__");
                //StringBuffer gname;
                gname.append(name);
                if (ins>1)
                    gname.append('_').append(ins);

                insts->query().setProp("@gname", gname.str());

            }

            pSoftware->addPropTree("EclAgentProcess", &it->get());
        }

        if (stricmp(method, "CopyInput") == 0) //Limit for this method only
        {
            it.setown(pEnvSoftware->getElements("RoxieCluster"));
            ForEach(*it)
                pSoftware->addPropTree("RoxieCluster", &it->get());
        }

        if (wuxml.length() > 0)
            pSoftware->addPropTree("DfuWorkunit", createPTreeFromXMLString(wuxml.str()));
    }
    return pRoot.getClear();
}