Package net.sourceforge.cruisecontrol.distributed

Examples of net.sourceforge.cruisecontrol.distributed.BuildAgentService


    }


    public Element build(Map projectProperties) throws CruiseControlException {
        try {
            final BuildAgentService agent = pickAgent();
            // agent is now marked as claimed

            final Element buildResults;
            try {
                projectProperties.put(PropertiesHelper.DISTRIBUTED_OVERRIDE_TARGET, overrideTarget);
                projectProperties.put(PropertiesHelper.DISTRIBUTED_MODULE, module);
                projectProperties.put(PropertiesHelper.DISTRIBUTED_AGENT_LOGDIR, getAgentLogDir());
                projectProperties.put(PropertiesHelper.DISTRIBUTED_AGENT_OUTPUTDIR, getAgentOutputDir());

                LOG.info("Starting remote build on agent: " + agent.getMachineName() + " of module: " + module);
                buildResults = agent.doBuild(getChildBuilderElement(), projectProperties);

                final String rootDirPath;
                try {
                    // watch out on Windoze, problems if root dir is c: instead of c:/
                    LOG.debug("rootDir: " + rootDir + "; rootDir.cp: " + rootDir.getCanonicalPath());
                    rootDirPath = rootDir.getCanonicalPath();
                } catch (IOException e) {
                    String message = "Error getting canonical path for: " + rootDir;
                    LOG.error(message);
                    System.err.println(message);
                    throw new CruiseControlException(message, e);
                }


                String masterDir;
                if (getMasterLogDir() == null || "".equals(getMasterLogDir())) {
                    masterDir = rootDirPath + File.separator + PropertiesHelper.RESULT_TYPE_LOGS;
                } else {
                    masterDir = getMasterLogDir();
                }
                getResultsFiles(agent, PropertiesHelper.RESULT_TYPE_LOGS, rootDirPath, masterDir);


                if (getMasterOutputDir() == null || "".equals(getMasterOutputDir())) {
                    masterDir = rootDirPath + File.separator + PropertiesHelper.RESULT_TYPE_OUTPUT;
                } else {
                    masterDir = getMasterOutputDir();
                }
                getResultsFiles(agent, PropertiesHelper.RESULT_TYPE_OUTPUT, rootDirPath, masterDir);

                agent.clearOutputFiles();
            } catch (RemoteException e) {
                String agentMachine = "unknown";
                try {
                    agentMachine = agent.getMachineName();
                } catch (RemoteException e1) {
                    ; // ignored
                }
                String message = "RemoteException from"
                        + "\nagent on: " + agentMachine
                        + "\nwhile building module: " + module;
                LOG.error(message, e);
                System.err.println(message + " - " + e.getMessage());
                try {
                    agent.clearOutputFiles();
                } catch (RemoteException re) {
                    LOG.error("Exception after prior exception while clearing agent output files (to set busy false).",
                            re);
                }
                throw new CruiseControlException(message, e);
View Full Code Here


            LOG.info(message);
        }
    }

    protected BuildAgentService pickAgent() throws CruiseControlException {
        BuildAgentService agent = null;

        while (agent == null) {
            final ServiceItem serviceItem;
            try {
                serviceItem = getDiscovery().findMatchingService();
            } catch (RemoteException e) {
                throw new CruiseControlException("Error finding matching agent.", e);
            }
            if (serviceItem != null) {
                agent = (BuildAgentService) serviceItem.service;
                try {
                    LOG.info("Found available agent on: " + agent.getMachineName());
                } catch (RemoteException e) {
                    throw new CruiseControlException("Error calling agent method.", e);
                }
            } else if (isFailFast()) {
                break;
View Full Code Here

            LOG.debug("Service Filter: item.service: " + item.service);
            if (!(item.service instanceof BuildAgentService)) {
                return false;
            }

            final BuildAgentService agent = (BuildAgentService) item.service;
            // read agent machine name to make sure agent is still valid
            final String agentMachine;
            try {
                agentMachine = agent.getMachineName();
            } catch (RemoteException e) {
                final String msg = "Error reading agent machine name. Filtering out agent.";
                LOG.debug(msg, e);
                return false; // filter out this agent by returning false
            }

            if (!findOnlyNonBusy) {
                return true; // we don't care if agent is busy or not
            }

            try {
                return !agent.isBusy();
            } catch (RemoteException e) {
                final String msg = "Error checking agent busy status. Filtering out agent on machine: "
                        + agentMachine;
                LOG.debug(msg, e);
                return false; // filter out this agent by returning false
View Full Code Here

            System.exit(1);
        }
        Element project = getProjectFromConfig(configFile);
        distributedBuilderElement = getBuilderFromProject(project);
        ServiceItem[] serviceItems = findAgents(distributedBuilderElement.getAttribute("entries"));
        final BuildAgentService agent = selectAgent(serviceItems);
        doBuild();
        retrieveResults(agent);
    }
View Full Code Here

        System.out.println();
        return serviceItems;
    }

    private BuildAgentService selectAgent(final ServiceItem[] serviceItems) {
        BuildAgentService agent = null;

        if (serviceItems.length < 1) {
            String message = "No matching serviceItems found - quitting...";
            LOG.error(message);
            System.err.println(message);
            System.exit(1);
        } else if (serviceItems.length == 1) {
            agent = (BuildAgentService) serviceItems[0].service;
            String agentName = null;
            try {
                agentName = agent.getMachineName();
            } catch (RemoteException e) {
                String message = "Error getting machine name from agent - quitting...";
                System.err.println(message);
                LOG.error(message, e);
                System.exit(1);
View Full Code Here

                lstServiceItems.add(serviceItems[i]);
            }

            result.append("Found: " + serviceItems.length + " agents.\n");
            ServiceItem serviceItem;
            BuildAgentService agent;
            String agentInfo;
            for (int x = 0; x < serviceItems.length; x++) {
                serviceItem = serviceItems[x];
                agent = (BuildAgentService) serviceItem.service;
                agentInfo = "Build Agent: " + serviceItem.serviceID + "\n"
                        + agent.asString()
                        + MulticastDiscovery.toStringEntries(serviceItem.attributeSets)
                        + "\n";
                LOG.debug(agentInfo);
                result.append(agentInfo);
            }
View Full Code Here

            assertFalse(agentAvailable2.getService().isBusy());

            DistributedMasterBuilder masterBuilder = createMasterBuilder();

            // try to find agents
            final BuildAgentService agentFoundFirst = masterBuilder.pickAgent();
            assertNotNull("Couldn't find first agent", agentFoundFirst);
            assertTrue(agentFoundFirst.isBusy());
            final BuildAgentService agentFoundSecond = masterBuilder.pickAgent();
            assertNotNull("Couldn't find second agent", agentFoundSecond);

            assertTrue(agentFoundFirst.isBusy());
            assertTrue(agentFoundSecond.isBusy());
            final BuildAgentService agentFoundThird = masterBuilder.pickAgent();
            assertNull("Shouldn't find third agent", agentFoundThird);

            // set Agent to Not busy, then make sure it can be found again.
            // callTestDoBuild() only needed to clearOuputFiles() will succeed
            BuildAgentServiceImplTest.callTestDoBuild(false, agentAvailable.getService());
            agentAvailable.getService().clearOutputFiles();
            final BuildAgentService agentRefound = masterBuilder.pickAgent();
            assertNotNull("Couldn't find released agent", agentRefound);
            assertTrue("Claimed agent should show as busy. (Did we find a better way?)",
                    agentRefound.isBusy());

        } finally {
            // terminate JoinManager in BuildAgent
            agentAvailable.terminate();
            agentAvailable2.terminate();
View Full Code Here

            agentAvailable.getService().claim(); // mark as busy

            DistributedMasterBuilder masterBuilder = createMasterBuilder();

            // try to find agent, shouldn't find any available
            final BuildAgentService agentBusy = masterBuilder.pickAgent();
            assertNull("Shouldn't find any available agents", agentBusy);

            // set Agent to Not busy, then make sure it can be found again.
            // callTestDoBuild() only needed to clearOuputFiles() will succeed
            BuildAgentServiceImplTest.callTestDoBuild(false, agentAvailable.getService());
            agentAvailable.getService().clearOutputFiles();
            final BuildAgentService agentRefound = masterBuilder.pickAgent();
            assertNotNull("Couldn't find released agent", agentRefound);
            assertTrue("Claimed agent should show as busy. (Did we find a better way?)",
                    agentRefound.isBusy());

        } finally {
            // terminate JoinManager in BuildAgent
            agentAvailable.terminate();
        }
View Full Code Here

        try {
            assertFalse(agentAvailable.getService().isBusy());

            DistributedMasterBuilder masterBuilder = createMasterBuilder();

            final BuildAgentService agent = masterBuilder.pickAgent();
            assertNotNull("Couldn't find agent", agent);
            assertTrue("Claimed agent should show as busy. (Did we find a better way?)",
                    agent.isBusy());

            // try to find agent, shouldn't find any available
            final BuildAgentService agentBusy = masterBuilder.pickAgent();
            assertNull("Shouldn't find any available agents", agentBusy);

            // set Agent to Not busy, then make sure it can be found again.
            BuildAgentServiceImplTest.callTestDoBuild(false, agent); // only needed to clearOuputFiles() will succeed
            agent.clearOutputFiles();
            final BuildAgentService agentRefound = masterBuilder.pickAgent();
            assertNotNull("Couldn't find released agent", agentRefound);
            assertTrue("Claimed agent should show as busy. (Did we find a better way?)",
                    agentRefound.isBusy());
        } finally {
            // terminate JoinManager in BuildAgent
            agentAvailable.terminate();
        }
    }
View Full Code Here

        DistributedMasterBuilder masterBuilder = getMasterBuilder_LocalhostAndTestPropsONLY(
                BuildAgentServiceImplTest.TEST_USER_DEFINED_PROPERTIES_FILE
        );

        BuildAgentService agent = masterBuilder.pickAgent();
        assertNull(agent);
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.cruisecontrol.distributed.BuildAgentService

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.