Package org.rhq.core.domain.cloud

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


        List<Integer> results = agentStatusManager.getAndClearAgentsWithStatusForServer(getServerName());
        return results;
    }

    public boolean getAndClearServerStatus() {
        Server server = topologyManager.getServerByName(getServerName());
        if (server == null) {
            return false; // don't reload caches if we don't know who we are
        }
        boolean hadStatus = (server.hasStatus(Status.ALERT_DEFINITION) || server
            .hasStatus(Status.RESOURCE_HIERARCHY_UPDATED));
        server.clearStatus(Status.ALERT_DEFINITION);
        server.clearStatus(Status.RESOURCE_HIERARCHY_UPDATED);
        return hadStatus;
    }
View Full Code Here


        server.clearStatus(Status.RESOURCE_HIERARCHY_UPDATED);
        return hadStatus;
    }

    public Server getServer() throws ServerNotFoundException {
        Server result = topologyManager.getServerByName(getServerName());
        if (result == null) {
            throw new ServerNotFoundException("Could not find server name [" + getServerName()
                + "]. If the rhq-server.properties property [" + RHQ_SERVER_NAME_PROPERTY
                + "] is unset the server name defaults to the host name (via InetAddress.getLocalHost()). "
                + "If this value, possibly an IP address, has changed it can cause this issue.");
View Full Code Here

            LogFactory.getLog("HighAvailabilityLogic").fatal(stackTrace);
        }
    }

    public void establishCurrentServerMode() {
        Server server = getServer();
        Server.OperationMode serverMode = determineServerOperationMode(
            server.hasStatus(Server.Status.MANUAL_MAINTENANCE_MODE), storageClientManager.isClusterAvailable(),
            server.getOperationMode());

        // no state change means no work
        if (serverMode == lastEstablishedServerMode)
            return;

        // whenever starting up clear the agent references to this server. Agent references will exist
        // for previously connected agents that did not fail-over while this server was unavailable. This
        // is done to avoid unnecessary cache re/load and moreover provides a logically initialized environment.
        if (null == lastEstablishedServerMode) {
            printWithTrace("establishCurrentServerMode: NULL->" + serverMode + ", clearing agent references");
            clearAgentReferences(server);
        }

        try {
            if (Server.OperationMode.NORMAL == serverMode) {

                // If moving into normal operating mode from Maintenance Mode then:
                // 1) Ensure lingering agent references are cleared
                //    - this may have been done at startup already, this covers the case when we go in and
                //    - out of MM without ever taking down the server
                // 2) Re-establish server communication by taking away the MM listener
                if (Server.OperationMode.MAINTENANCE == lastEstablishedServerMode) {
                    printWithTrace("establishCurrentServerMode: MAINTENANCE->NORMAL, clearing agent references");
                    clearAgentReferences(server);

                    ServerCommunicationsServiceUtil.getService().safeGetServiceContainer()
                        .removeCommandListener(getMaintenanceModeListener());

                    log.info("Notified communication layer of server operation mode " + serverMode);
                }
            } else if (Server.OperationMode.MAINTENANCE == serverMode) {

                // If moving into Maintenance Mode from any other mode then stop processing agent commands
                ServerCommunicationsServiceUtil.getService().safeGetServiceContainer()
                    .addCommandListener(getMaintenanceModeListener());

                log.info("Notified communication layer of server operation mode " + serverMode);

            } else if (Server.OperationMode.INSTALLED == serverMode
            // The server must have just been installed and must be coming for the first time
            // up as of this call. So, attempt to update the mode to NORMAL.
            // This will prevent a running CloudManagerJob from resetting to DOWN before the real
            // ServerManagerJob starts updating the heart beat regularly.

                || Server.OperationMode.DOWN == serverMode) {
                // The server can't be DOWN if this code is executing, it means the server must be coming
                // up as of this call. So, attempt to update the mode to NORMAL.
                // This will prevent a running CloudManagerJob from resetting to DOWN before the real
                // ServerManagerJob starts updating the heart beat regularly.

                log.info("Notified communication layer of server operation mode " + serverMode);

                lastEstablishedServerMode = serverMode;
                serverMode = determineServerOperationMode(server.hasStatus(Server.Status.MANUAL_MAINTENANCE_MODE),
                    storageClientManager.isClusterAvailable(), OperationMode.NORMAL);

                if (serverMode == OperationMode.MAINTENANCE) {
                    ServerCommunicationsServiceUtil.getService().safeGetServiceContainer()
                        .addCommandListener(getMaintenanceModeListener());
                }
            }

            // If this server just transitioned from INSTALLED to NORMAL operation mode then it
            // has just been added to the cloud. Changing the number of servers in the cloud requires agent
            // distribution work, even if this is a 1-Server cloud. Generate a request for a repartitioning
            // of agent load, it will be executed on the next invocation of the cluster manager job.
            // Otherwise, audit the operation mode change as a partition event of interest.
            String audit = server.getName() + ": "
                + ((null != lastEstablishedServerMode) ? lastEstablishedServerMode : Server.OperationMode.DOWN)
                + " --> " + serverMode;

            if ((Server.OperationMode.NORMAL == serverMode)
                && (Server.OperationMode.INSTALLED == lastEstablishedServerMode)) {

                partitionEventManager.cloudPartitionEventRequest(subjectManager.getOverlord(),
                    PartitionEventType.OPERATION_MODE_CHANGE, audit);
            } else {
                partitionEventManager.auditPartitionEvent(subjectManager.getOverlord(),
                    PartitionEventType.OPERATION_MODE_CHANGE, audit);
            }

            lastEstablishedServerMode = serverMode;
            server.setOperationMode(lastEstablishedServerMode);
            server.setMtime(System.currentTimeMillis());
        } catch (Throwable e) {
            log.error("Unable to change HA Server Mode from " + lastEstablishedServerMode + " to " + serverMode + ": "
                + e);
        }
    }
View Full Code Here

        return new GlobalSuspendCommandListener(Server.OperationMode.MAINTENANCE.name(),
            Server.OperationMode.MAINTENANCE.name());
    }

    public void syncEndpointAddress() throws SyncEndpointAddressException {
        Server server = getServer();
        try {
            String hostName = InetAddress.getLocalHost().getHostName();

            if (!hostName.equals(server.getAddress())) {
                server.setAddress(hostName);
            }
        } catch (UnknownHostException e) {
            throw new SyncEndpointAddressException("Failed to sync endpoint address for " + server, e);
        }
    }
View Full Code Here

    }

    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    public void beat() {
        try {
            Server server = getServer();
            server.setMtime(System.currentTimeMillis());
        } catch (ServerNotFoundException snfe) {
            // an admin removed our server entity, that means we are to be decommissioned so immediately shutdown
            ModelControllerClient mcc = null;
            try {
                log.info("This server has been decommissioned!!! It will now shutdown.");
View Full Code Here

        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

        query.executeUpdate();

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

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

    @EJB
    //@IgnoreDependency
    private ServerManagerLocal serverManager;

    public List<Agent> getAgentsByServerName(String serverName) {
        Server server = topologyManager.getServerByName(serverName);
        List<Agent> agents = server.getAgents();
        agents.size(); // iterating over this collection out of a transactional boundaries will throw LazyInitExceptions
        return agents;
    }
View Full Code Here

        agents.size(); // iterating over this collection out of a transactional boundaries will throw LazyInitExceptions
        return agents;
    }

    public Server getServerById(int serverId) {
        Server server = entityManager.find(Server.class, serverId);
        return server;
    }
View Full Code Here

    public Server getServerByName(String serverName) {
        Query query = entityManager.createNamedQuery(Server.QUERY_FIND_BY_NAME);
        query.setParameter("name", serverName);

        try {
            Server server = (Server) query.getSingleResult();
            return server;
        } catch (NoResultException nre) {
            log.info("Server[name=" + serverName + "] not found, returning null...");
            return null;
        }
View Full Code Here

TOP

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

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.