Package org.rhq.core.domain.cloud

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


    }

    private void updateServerOperationMode() {
        try {
            // Set the server operation mode to DOWN unless in MM
            Server server = serverManager.getServer();
            if (Server.OperationMode.MAINTENANCE != server.getOperationMode()) {
                topologyManager.updateServerMode(LookupUtil.getSubjectManager().getOverlord(), new Integer[] { server.getId() }, OperationMode.DOWN);
            }
        } catch (Throwable t) {
            // only show ugly stack traces if the user runs the server in debug mode
            if (log.isDebugEnabled()) {
                log.warn("Could not update this server's OperationMode to DOWN in the database", t);
View Full Code Here


        q.setParameter("serverId", serverId);

        @SuppressWarnings("unchecked")
        List<Plugin> plugins = q.getResultList();

        Server server = entityManager.find(Server.class, serverId);

        for (Plugin p : plugins) {
            p.getServersAcknowledgedDelete().add(server);
            entityManager.merge(p);
        }
View Full Code Here

        q.setParameter("serverId", serverId);

        @SuppressWarnings("unchecked")
        List<ServerPlugin> plugins = q.getResultList();

        Server server = entityManager.find(Server.class, serverId);

        for (ServerPlugin p : plugins) {
            p.getServersAcknowledgedDelete().add(server);
            entityManager.merge(p);
        }
View Full Code Here

                    throw new AgentRegistrationException(msg);
                }
            }
        }

        Server registeringServer = getServerManager().getServer();

        // if the agent is registering with a loopback address, log a warning since you probably do not want this in production
        try {
            String address = request.getAddress();
            String fullEndpoint = request.getRemoteEndpoint();
            boolean loopbackRegistration = false;
            if (address.equals("127.0.0.1") || address.equalsIgnoreCase("localhost")) {
                loopbackRegistration = true;
            } else {
                // jboss/remoting transport params might be telling us to have our client connect to a different address
                if (fullEndpoint != null) {
                    if (fullEndpoint.contains("127.0.0.1") || fullEndpoint.contains("localhost")) {
                        loopbackRegistration = true;
                    }
                }
            }

            if (loopbackRegistration) {
                log.warn("An agent [" + request.getName()
                    + "] has registered with a loopback address. This should only be done "
                    + "for testing or demo purposes - this agent can only ever interact with this server. " + request);
            }
        } catch (Exception ignore) {
        }

        if (agentByName != null) {
            log.info("Got agent registration request for existing agent: " + agentByName.getName() + "["
                + agentByName.getAddress() + ":" + agentByName.getPort() + "][" + request.getAgentVersion()
                + "] - Will " + (request.getRegenerateToken() ? "" : "not") + " regenerate a new token");

            final String oldAddress = agentByName.getAddress();
            final int oldPort = agentByName.getPort();
            final String oldRemoteEndpoint = agentByName.getRemoteEndpoint();

            agentByName.setServer(registeringServer);
            agentByName.setAddress(request.getAddress());
            agentByName.setPort(request.getPort());
            agentByName.setRemoteEndpoint(request.getRemoteEndpoint());

            if (request.getRegenerateToken()) {
                agentByName.setAgentToken(generateAgentToken());
            }

            try {
                agentManager.updateAgent(agentByName);
            } catch (Exception e) {
                log.warn("Could not update the agent in database", e);
                throw new AgentRegistrationException(new WrappedRemotingException(e));
            }

            // if agent is re-registering in order to change its remote endpoint, destroy our old client.
            if (!oldAddress.equals(request.getAddress()) || oldPort != request.getPort()
                || !oldRemoteEndpoint.equals(request.getRemoteEndpoint())) {
                try {
                    final Agent oldAgent = new Agent();
                    oldAgent.setName(agentByName.getName());
                    oldAgent.setAddress(oldAddress);
                    oldAgent.setPort(oldPort);
                    oldAgent.setRemoteEndpoint(oldRemoteEndpoint);
                    agentManager.destroyAgentClient(oldAgent);
                } catch (Exception e) {
                    log.warn("Could not destroy the agent client - will continue but agent comm may be broken", e);
                }
            }
        } else {
            log.info("Got agent registration request for new agent: " + request.getName() + "[" + request.getAddress()
                + ":" + request.getPort() + "][" + request.getAgentVersion() + "]");

            // the agent does not yet exist, we need to create it
            try {
                agentByName = new Agent(request.getName(), request.getAddress(), request.getPort(),
                    request.getRemoteEndpoint(), generateAgentToken());

                agentByName.setServer(registeringServer);
                agentManager.createAgent(agentByName);
            } catch (Exception e) {
                log.warn("Failed to create agent in database", e);
                throw new AgentRegistrationException(new WrappedRemotingException(e));
            }
        }

        // get existing or generate new server list for the registering agent
        FailoverListComposite failoverList = getPartitionEventManager().agentPartitionEvent(
            getSubjectManager().getOverlord(), agentByName.getName(), PartitionEventType.AGENT_REGISTRATION,
            agentByName.getName() + " - " + registeringServer.getName());

        AgentRegistrationResults results = new AgentRegistrationResults();
        results.setAgentToken(agentByName.getAgentToken());
        results.setFailoverList(failoverList);
View Full Code Here

        Agent agent = getAgentManager().getAgentByName(agentName);
        if (agent == null) {
            throw new AgentRegistrationException("Agent [" + agentName + "] is not registered");
        }

        Server server = getServerManager().getServer();
        agent.setServer(server);
        agent.setLastAvailabilityPing(Long.valueOf(System.currentTimeMillis()));
        getAgentManager().updateAgent(agent);

        getAlertConditionCacheManager().reloadCachesForAgent(agent.getId());

        getPartitionEventManager().auditPartitionEvent(getSubjectManager().getOverlord(),
            PartitionEventType.AGENT_CONNECT, agentName + " - " + server.getName());

        log.info("Agent [" + agentName + "] has connected to this server at " + new Date());
        return new ConnectAgentResults(System.currentTimeMillis(), agent.isBackFilled(),
            agentVersionCheckResults.getLatestAgentVersion());
    }
View Full Code Here

        log.info("Synchronizing content to the local Cobbler server: " + this);

        try {
            this.syncInProgress = true;

            Server server = LookupUtil.getServerManager().getServer();
            String rootUrl = "http://" + server.getAddress() + ":" + server.getPort() + "/content/";

            Map<String, Distro> cobblerDistros = getAllCobblerDistros(); // Cobbler distros
            Map<Repo, Map<String, Distribution>> reposDistributions = getAllDistributions(); // RHQ distros

            CobblerConnection conn = getConnection();
View Full Code Here

        return result;
    }

    private String addContextParams(String url) {
        StringBuilder sb = new StringBuilder(url);
        Server server = LookupUtil.getServerManager().getServer();
        String host = server.getAddress();
        String port = String.valueOf(server.getPort());
        Subject subject = EnterpriseFacesContextUtility.getSubject();
        String username = subject.getName();
        String sessionId = String.valueOf(subject.getSessionId());
        String resourceId = FacesContextUtility.getOptionalRequestParameter("id", "-1");
View Full Code Here

            }

            ControlResults results = new ControlResults();

            TopologyManagerLocal cloudMgr = LookupUtil.getTopologyManager();
            Server server = cloudMgr.getServerByName(serverName);

            if (server == null) {
                log.warn("Failed to locate server. No address sync will be performed.");
                results.setError("No update performed. Failed to find server " + server.getName());
                return results;
            }

            if (serverAddr != null) {
                SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();

                server.setAddress(serverAddr);
                cloudMgr.updateServer(subjectMgr.getOverlord(), server);
            }

            int updateCount = notifyAgents(server);
View Full Code Here

    @GET
    @Path("/server")
    @ApiOperation(value = "Get the operation mode of this server")
    public StringValue serverState() {
        Server server = serverManager.getServer();
        return new StringValue(server.getOperationMode().name());
    }
View Full Code Here

* @author Thomas Segismont
*/
public class ServerFactory {

    public static Server newInstance() {
        Server server = new Server();
        server.setVersion(Server.class.getPackage().getImplementationVersion());
        return server;
    }
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.