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

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


            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


        if (server.indexOf(':') > -1) {
            try {
                InvokerLocator endpointUrl = new InvokerLocator(server);
                String host = endpointUrl.getHost();
                int port = endpointUrl.getPort();
                serverEndpoint.namePort = new ServerEntry(host, port, port);
                serverEndpoint.transport = endpointUrl.getProtocol();
                String path = endpointUrl.getPath();
                Map<Object, Object> parameters = endpointUrl.getParameters();
                serverEndpoint.transportParams = "/" + ((path != null) ? path : "");
                if (parameters != null && parameters.size() > 0) {
                    serverEndpoint.transportParams += "?";
                    boolean needAmp = false;
                    for (Map.Entry<Object, Object> configEntry : parameters.entrySet()) {
                        if (needAmp) {
                            serverEndpoint.transportParams += "&";
                        }
                        serverEndpoint.transportParams += configEntry.getKey().toString() + "="
                            + configEntry.getValue().toString();
                        needAmp = true;
                    }
                }
            } catch (Exception e) {
                throw new IllegalArgumentException(e);
            }
        } else {
            if (agentConfig != null) {
                int currentServerPort = agentConfig.getServerBindPort();
                String currentServerTransport = agentConfig.getServerTransport();
                String currentServerTransportParams = agentConfig.getServerTransportParams();

                serverEndpoint.namePort = new ServerEntry(server, currentServerPort, currentServerPort);
                serverEndpoint.transport = currentServerTransport;
                serverEndpoint.transportParams = currentServerTransportParams;
            } else {
                throw new IllegalArgumentException("agentConfig==null, server==[" + server + ']');
            }
View Full Code Here

                        String transport = config.getServerTransport();
                        String transportParams = config.getServerTransportParams();
                        String currentServerAddress = config.getServerBindAddress();
                        int currentServerPort = config.getServerBindPort();

                        ServerEntry primary = failoverList.get(0); // get the top of the list, aka primary server
                        String primaryAddress = primary.address;
                        int primaryPort = (SecurityUtil.isTransportSecure(transport)) ? primary.securePort
                            : primary.port;

                        if (!primaryAddress.equals(currentServerAddress) || primaryPort != currentServerPort) {
View Full Code Here

                                // we don't have to failover to another server; the current one is the one we already want
                                if (failover_list.hasNext()) {
                                    String currentAddress = agent_config.getServerBindAddress();
                                    int currentPort = agent_config.getServerBindPort();
                                    String currentTransport = agent_config.getServerTransport();
                                    ServerEntry nextServer = failover_list.peek();

                                    if (currentAddress.equals(nextServer.address)
                                        && currentPort == (SecurityUtil.isTransportSecure(currentTransport) ? nextServer.securePort
                                            : nextServer.port)) {
                                        // we are already pointing to the primary server, so all we have to do is
View Full Code Here

            AgentConfiguration config = getConfiguration();
            String currentTransport = config.getServerTransport();
            String currentTransportParams = config.getServerTransportParams();

            ServerEntry nextServer = failoverList.next();

            boolean ok = switchCommServer(comm, nextServer, currentTransport, currentTransportParams);
            if (ok) {
                // we've successfully failed over; the design of the HA system calls for us to start
                // over at the top of the failover list the next time we get a failure.
View Full Code Here

    private List<String> testFailoverList(FailoverListComposite failoverList) {
        List<String> failedServers = new ArrayList<String>(0);

        if (failoverList != null) {
            for (int i = 0; i < failoverList.size(); i++) {
                ServerEntry server = failoverList.get(i);
                Socket socket = null;
                boolean connectError = true; // assume a failure will occur
                try {
                    LOG.debug(AgentI18NResourceKeys.TEST_FAILOVER_LIST_ENTRY, server.address, server.port);
                    InetAddress inetAddress = InetAddress.getByName(server.address);
                    InetSocketAddress socketAddress = new InetSocketAddress(inetAddress, server.port);
                    socket = new Socket();
                    socket.setSoTimeout(5000);
                    socket.connect(socketAddress, 5000);
                    connectError = false; // we successfully connected to the server
                } catch (UnknownHostException e) {
                    LOG.error(AgentI18NResourceKeys.FAILOVER_LIST_UNKNOWN_HOST, server.address);
                } catch (Exception e) {
                    if (socket != null) {
                        try {
                            socket.close(); // just clean up our last socket connect attempt
                        } catch (Exception ignore) {
                        }
                    }
                    try {
                        LOG.debug(AgentI18NResourceKeys.TEST_FAILOVER_LIST_ENTRY, server.address, server.securePort);
                        InetAddress inetAddress = InetAddress.getByName(server.address);
                        InetSocketAddress socketAddress = new InetSocketAddress(inetAddress, server.securePort);
                        socket = new Socket();
                        socket.setSoTimeout(5000);
                        socket.connect(socketAddress, 5000);
                        connectError = false; // we successfully connected to the server
                    } catch (Exception e1) {
                        String err = ThrowableUtil.getAllMessages(e1);
                        LOG.warn(AgentI18NResourceKeys.FAILOVER_LIST_UNREACHABLE_HOST, server.address, server.port,
                            server.securePort, err);
                    }
                } finally {
                    if (socket != null) {
                        try {
                            socket.close();
                        } catch (Exception e) {
                        }
                    }
                    if (connectError) {
                        failedServers.add(server.toString());
                    }
                }
            }
        }
View Full Code Here

            // a way for them to turn off this warning - it could get annoying since it will show up everytime
            // the primary switchover thread triggers and needs to persist the list as well as during initial startup/registration.
            if (!Boolean.getBoolean("rhq.hide-server-localhost-warning")) {
                int numServers = failoverList.size();
                for (int i = 0; i < numServers; i++) {
                    ServerEntry server = failoverList.get(i);
                    String addr = (server.address != null) ? server.address : "";
                    if ("localhost".equals(addr) || addr.startsWith("127.0.0.") || addr.startsWith("localhost.")) {
                        LOG.warn(AgentI18NResourceKeys.FAILOVER_LIST_HAS_LOCALHOST, server.address);
                        getOut().println(MSG.getMsg(AgentI18NResourceKeys.FAILOVER_LIST_HAS_LOCALHOST, server.address));
                        break; // just show the warning once
View Full Code Here

    }

    public void testTextForm() {
        ArrayList<ServerEntry> servers = new ArrayList<ServerEntry>();
        FailoverListComposite listToTest;
        ServerEntry server;

        FailoverListComposite list = new FailoverListComposite(servers);
        String text = list.writeAsText();
        assert text != null;
        assert text.length() == 0 : text.length();
View Full Code Here

TOP

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

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.