Package org.rhq.core.domain.cloud.composite

Examples of org.rhq.core.domain.cloud.composite.FailoverListComposite


     * The FailoverListComposite that the agent must use in order to communicate with the server in the future.
     *
     * @return the FailoverListComposite assigned to it by the server (will not be <code>null</code> but may be empty)
     */
    public FailoverListComposite getFailoverList() {
        return failoverList != null ? failoverList : new FailoverListComposite(new ArrayList<ServerEntry>());
    }
View Full Code Here


        // validate balance level by level
        for (int level = 0; (level < numServers); ++level) {
            Map<String, Integer> distributionMap = new HashMap<String, Integer>(numServers);
            for (Agent agent : result.keySet()) {
                FailoverListComposite flc = result.get(agent);
                // for debugging
                //if (i == 1) {
                //    System.out.println(agent + " : " + flc);
                //}
                FailoverListComposite.ServerEntry server = flc.get(level);
                Integer count = distributionMap.get(server.address);
                distributionMap.put(server.address, (null == count) ? 1 : ++count);
            }
            for (Integer agentsOnServer : distributionMap.values()) {
                double div = (double) numAgents / (double) numServers;
View Full Code Here

        // validate level by level       
        for (int level = 0; (level < numServers); ++level) {
            Map<Integer, Integer> distributionMap = new HashMap<Integer, Integer>(numServers);
            for (Agent agent : result.keySet()) {
                FailoverListComposite flc = result.get(agent);
                FailoverListComposite.ServerEntry server = flc.get(level);
                Integer agentId = Integer.valueOf(agent.getAddress());
                Integer serverId = Integer.valueOf(server.address);
                if ((level < numAffinityServers) && (agentId < numAffinityAgents))
                    assert (serverId < numAffinityServers) : "serverId [" + serverId + "] >= numAffinityServers ["
                        + numAffinityServers + "]";
View Full Code Here

        }

        // validate no duplicates in server list
        for (Agent agent : result.keySet()) {
            Set<String> names = new HashSet<String>(numServers);
            FailoverListComposite flc = result.get(agent);
            for (int i = 0; (i < numServers); ++i) {
                FailoverListComposite.ServerEntry server = flc.get(i);
                assert names.add(server.address);
            }
        }
    }
View Full Code Here

    public void testGetForSingleAgent_existing() throws Exception {
        setupTest(2, 4);
        Map<Agent, FailoverListComposite> result = failoverListManager.refresh(partitionEvent, servers, agents);
        assert null != result;
        for (Agent agent : result.keySet()) {
            FailoverListComposite flc1 = result.get(agent);
            FailoverListComposite flc2 = failoverListManager.getForSingleAgent(partitionEvent, agent.getName());
            assert flc1.size() == flc2.size();
            for (int i = 0, size = flc1.size(); (i < size); ++i) {
                assert flc1.get(i).equals(flc2.get(i));
            }
        }
    }
View Full Code Here

        return;
    }

    private void showFailoverList(AgentMain agent, PrintWriter out) {
        FailoverListComposite failoverList = agent.getServerFailoverList();
        if (failoverList != null && failoverList.size() > 0) {
            out.println(failoverList.writeAsText());
        } else {
            out.println("<>");
        }
    }
View Full Code Here

        return doGetExistingForSingleAgent(agent);
    }

    private FailoverListComposite doGetExistingForSingleAgent(Agent agent) {

        FailoverListComposite result = null;
        Query query = entityManager.createNamedQuery(FailoverList.QUERY_GET_VIA_AGENT);
        query.setParameter("agent", agent);
        try {
            FailoverList serverList = (FailoverList) query.getSingleResult();

            List<ServerEntry> serverEntries = new ArrayList<ServerEntry>();
            for (FailoverListDetails next : serverList.getServerList()) {
                serverEntries.add(next.getServer().getServerEntry());
            }

            result = new FailoverListComposite(serverEntries);

        } catch (NoResultException e) {
            result = null;
        }
View Full Code Here

        if (null == agent) {
            throw new IllegalArgumentException("No agent found for registration name: " + agentName);
        }

        FailoverListComposite result = doGetExistingForSingleAgent(agent);

        if (null == result) {
            result = generateServerList(event, agent);
        }
View Full Code Here

            for (ServerBucket bucket : agentServerListMap.get(next)) {
                serverEntries.add(bucket.serverEntry);
            }

            result.put(next, new FailoverListComposite(serverEntries));
        }

        return result;
    }
View Full Code Here

        PartitionEventDetails eventDetails = null;

        for (Map.Entry<Agent, FailoverListComposite> next : agentServerListMap.entrySet()) {

            Agent nextAgent = next.getKey();
            FailoverListComposite nextComposite = next.getValue();

            fl = new FailoverList(event, nextAgent);
            entityManager.persist(fl);

            boolean first = true;
            for (int i = 0; i < nextComposite.size(); ++i) {
                ServerEntry serverEntry = nextComposite.get(i);
                Server server = entityManager.find(Server.class, serverEntry.serverId);
                failoverListDetails = new FailoverListDetails(fl, i, server);
                entityManager.persist(failoverListDetails);
                // event details only shows the current primary server topology
                if (first) {
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.cloud.composite.FailoverListComposite

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.