Package org.rhq.core.domain.cloud

Examples of org.rhq.core.domain.cloud.AffinityGroup


                agent = new Agent("Agent-flm-" + i, "" + i, 1, "endpoint", "token" + i);
                em.persist(agent);
                agents.add(agent);
            }

            ag = new AffinityGroup("AG-flm-1");
            em.persist(ag);

            partitionEvent = new PartitionEvent("FLM-TEST", PartitionEventType.SYSTEM_INITIATED_PARTITION,
                "Test-flm-detail", PartitionEvent.ExecutionStatus.IMMEDIATE);
            em.persist(partitionEvent);
View Full Code Here


    private PartitionEventManagerLocal partitionEventManager;

    @RequiredPermissions({ @RequiredPermission(Permission.MANAGE_SETTINGS),
        @RequiredPermission(Permission.MANAGE_INVENTORY) })
    public AffinityGroup getById(Subject subject, int affinityGroupId) {
        AffinityGroup affinityGroup = entityManager.find(AffinityGroup.class, affinityGroupId);
        return affinityGroup;
    }
View Full Code Here

        Query query = entityManager.createNamedQuery(AffinityGroup.QUERY_FIND_BY_NAME);
        query.setParameter("name", name.toUpperCase());

        try {
            AffinityGroup found = (AffinityGroup) query.getSingleResult();
            if (alreadyExists == false) {
                throw new AffinityGroupCreationException("AffinityGroup with name '" + name + "' already exists");
            }
            if (affinityGroup.getId() != found.getId()) {
                throw new AffinityGroupUpdateException("AffinityGroup with name '" + name + "' already exists");
            }
        } catch (NoResultException e) {
            // this is expected
        }
View Full Code Here

    public int delete(Subject subject, Integer[] affinityGroupIds) {

        // A deleted affinity group forces a cloud repartitioning. Note, it is ok to request multiple
        // cloud repartitions, they will be consolidated by the cloud manager job.  
        for (Integer agId : affinityGroupIds) {
            AffinityGroup ag = entityManager.find(AffinityGroup.class, agId);
            partitionEventManager.cloudPartitionEventRequest(subject, PartitionEventType.AFFINITY_GROUP_DELETE, ag
                .getName());
        }

        Query updateAgentsQuery = entityManager.createNamedQuery(AffinityGroup.QUERY_UPDATE_REMOVE_AGENTS);
        Query updateServersQuery = entityManager.createNamedQuery(AffinityGroup.QUERY_UPDATE_REMOVE_SERVERS);
View Full Code Here

    @RequiredPermissions({ @RequiredPermission(Permission.MANAGE_SETTINGS),
        @RequiredPermission(Permission.MANAGE_INVENTORY) })
    public void addAgentsToGroup(Subject subject, int affinityGroupId, Integer[] agentIds) {
        List<Integer> agentIdsList = Arrays.asList(agentIds);

        AffinityGroup group = entityManager.find(AffinityGroup.class, affinityGroupId);

        Query query = entityManager.createNamedQuery(AffinityGroup.QUERY_UPDATE_ADD_AGENTS);
        query.setParameter("affinityGroup", group);
        query.setParameter("agentIds", agentIdsList);

        query.executeUpdate();

        // Audit each changed affinity group assignment (is this too verbose?)
        String auditString = group.getName() + " <-- ";
        for (Integer agentId : agentIdsList) {
            Agent agent = entityManager.find(Agent.class, agentId);
            partitionEventManager.auditPartitionEvent(subject, PartitionEventType.AGENT_AFFINITY_GROUP_ASSIGN,
                auditString + agent.getName());

        }
        // Now, request a cloud repartitioning due to the affinity group changes
        partitionEventManager.cloudPartitionEventRequest(subject, PartitionEventType.AFFINITY_GROUP_CHANGE, group
            .getName());
    }
View Full Code Here

    @RequiredPermissions({ @RequiredPermission(Permission.MANAGE_SETTINGS),
        @RequiredPermission(Permission.MANAGE_INVENTORY) })
    public void addServersToGroup(Subject subject, int affinityGroupId, Integer[] serverIds) {
        List<Integer> serverIdsList = Arrays.asList(serverIds);

        AffinityGroup group = entityManager.find(AffinityGroup.class, affinityGroupId);

        Query query = entityManager.createNamedQuery(AffinityGroup.QUERY_UPDATE_ADD_SERVERS);
        query.setParameter("affinityGroup", group);
        query.setParameter("serverIds", serverIdsList);

        query.executeUpdate();

        // Audit each changed affinity group assignment (is this too verbose?)
        String auditString = group.getName() + " <-- ";
        for (Integer serverId : serverIdsList) {
            Server server = entityManager.find(Server.class, serverId);
            partitionEventManager.auditPartitionEvent(subject, PartitionEventType.SERVER_AFFINITY_GROUP_ASSIGN,
                auditString + server.getName());

        }
        // Now, request a cloud repartitioning due to the affinity group changes
        partitionEventManager.cloudPartitionEventRequest(subject, PartitionEventType.AFFINITY_GROUP_CHANGE, group
            .getName());
    }
View Full Code Here

                if (bucket == lowBucket) {
                    done = true;
                    break;
                }

                AffinityGroup affinityGroup = bucket.server.getAffinityGroup();
                boolean checkAffinity = ((null != affinityGroup) && !affinityGroup.equals(lowBucket.server
                    .getAffinityGroup()));
                int highIndex = -1;
                double highLoad = 0.0;
                double load = 0.0;

                for (int i = 0, size = bucket.assignedAgents.size(); (i < size); ++i) {
                    Agent agent = bucket.assignedAgents.get(i);

                    // we don't move an agent with satisfied affinity to a bucket that breaks affinity
                    if (checkAffinity && affinityGroup.equals(agent.getAffinityGroup())) {
                        continue;
                    }

                    // we don't move an agent that is already assigned to lowBucket
                    if (agentServerListMap.get(agent).contains(lowBucket)) {
View Full Code Here

    private AffinityGroupManagerLocal affinityGroupManager = LookupUtil.getAffinityGroupManager();
    private AffinityGroup affinityGroup;

    public ViewAffinityGroupDetailsUIBean() {
        if (getMode().equals(CREATE_MODE)) {
            affinityGroup = new AffinityGroup("");
        } else {
            Subject subject = EnterpriseFacesContextUtility.getSubject();
            int affinityGroupId = FacesContextUtility.getRequiredRequestParameter("affinityGroupId", Integer.class);
            affinityGroup = affinityGroupManager.getById(subject, affinityGroupId);
        }
View Full Code Here

        // make clickable link for affinity group
        StaticTextItem affinityGroupItem = new StaticTextItem(FIELD_AFFINITY_GROUP.propertyName(),
            FIELD_AFFINITY_GROUP.title());
        String affinityGroupItemText = "";
        AffinityGroup ag = agent.getAffinityGroup();
        if (ag != null && ag.getName() != null && !ag.getName().isEmpty()) {
            String detailsUrl = "#" + AffinityGroupTableView.VIEW_PATH + "/" + ag.getId();
            String formattedValue = StringUtility.escapeHtml(ag.getName());
            affinityGroupItemText = LinkManager.getHref(detailsUrl, formattedValue);
        }
        affinityGroupItem.setValue(affinityGroupItemText);

        StaticTextItem currentServerItem = new StaticTextItem(FIELD_SERVER.propertyName(), FIELD_SERVER.title());
View Full Code Here

        // make clickable link for affinity group
        StaticTextItem affinityGroupItem = new StaticTextItem(FIELD_AFFINITY_GROUP.propertyName(),
            FIELD_AFFINITY_GROUP.title());
        String affinityGroupItemText = "";
        AffinityGroup ag = server.getAffinityGroup();
        if (ag != null && ag.getName() != null && !ag.getName().isEmpty()) {
            String detailsUrl = "#" + AffinityGroupTableView.VIEW_PATH + "/" + ag.getId();
            String formattedValue = StringUtility.escapeHtml(ag.getName());
            affinityGroupItemText = LinkManager.getHref(detailsUrl, formattedValue);
        }
        affinityGroupItem.setValue(affinityGroupItemText);

        StaticTextItem installationDateItem = new StaticTextItem(FIELD_CTIME.propertyName(), FIELD_CTIME.title());
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.cloud.AffinityGroup

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.