Examples of AgentRegistrationException


Examples of com.cisco.oss.foundation.monitoring.exception.AgentRegistrationException

    }

    static void validateGenericParams(MonitoringMXBean exposedObject) throws AgentRegistrationException {
        if ((ComponentInfo.INSTANCE.getName() == null)
                || !ComponentInfo.INSTANCE.getName().matches(FoundationMonitoringConstants.APP_INSTANCE_NAMING_STANDARD)) {
            throw new AgentRegistrationException("Name attributes does not follow the naming standard, which is "
                    + FoundationMonitoringConstants.APP_NAME_NAMING_STANDARD);
        }

        if ((ComponentInfo.INSTANCE.getInstance() != null) && (!ComponentInfo.INSTANCE.getInstance().trim().equals(""))
                && !ComponentInfo.INSTANCE.getInstance().matches(FoundationMonitoringConstants.APP_INSTANCE_NAMING_STANDARD)) {
            throw new AgentRegistrationException("Instance attributes does not follow the naming standard, which is "
                    + FoundationMonitoringConstants.APP_NAME_NAMING_STANDARD);
        }
    }
View Full Code Here

Examples of com.cisco.oss.foundation.monitoring.exception.AgentRegistrationException

        String javaVersion = System.getProperty("java.version").substring(0, 3);

        if (javaVersion.equals("1.0") || javaVersion.equals("1.1") || javaVersion.equals("1.2")
                || javaVersion.equals("1.3") || javaVersion.equals("1.4") || javaVersion.equals("1.5")) {
            LOGGER.error("Attempt to use RMIMonitoringAgent in an unsupported version of Java");
            throw new AgentRegistrationException("Unsupported java version");
        }
    }
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationException

            if (agentByToken != null) {
                if (!agentByToken.getName().equals(request.getName())) {
                    String msg = "The agent asking for registration is already registered with the name ["
                        + agentByToken.getName() + "], it cannot change its name to [" + request.getName() + "]";
                    throw new AgentRegistrationException(msg);
                } else {
                    Agent agentByAddressPort = getAgentManager().getAgentByAddressAndPort(request.getAddress(),
                        request.getPort());
                    if (agentByAddressPort != null && !agentByAddressPort.getName().equals(request.getName())) {
                        // the agent request provided information about an authentic agent but it is trying to
                        // steal another agent's host/port. Thus, we will abort this request.
                        String msg = "The agent asking for registration [" + request.getName()
                            + "] is trying to register the same address/port [" + request.getAddress() + ":"
                            + request.getPort() + "] that is already registered under a different name ["
                            + agentByAddressPort.getName() + "]";
                        throw new AgentRegistrationException(msg);
                    }
                }
            } else {
                if (agentByName != null) {
                    // the agent request provided a name that already is in use by an agent. However, the request
                    // provided a security token that was not assigned to any agent! How can this be? Something is fishy.
                    String msg = "The agent asking for registration under the name [" + request.getName()
                        + "] provided an invalid security token. This request will fail. " + securityTokenMessage();
                    throw new AgentRegistrationException(msg);
                }
                Agent agentByAddressPort = getAgentManager().getAgentByAddressAndPort(request.getAddress(),
                    request.getPort());
                if (agentByAddressPort != null) {
                    // The agent is requesting to register an unused agent name - so this is considered a new agent.
                    // It provided a security token but it is an unknown/obsolete/bogus token (usually due to the
                    // fact that someone purged the platform/agent from the server database but the old agent is
                    // still around with its old token).
                    // However, the IP/port it wants to use is already in-use. This sounds fishy. If we let this
                    // go through, this agent with an unknown/bogus token will essentially hijack this IP/port
                    // belonging to an existing agent. If the agent wants to reuse an IP/port already in existence, it should
                    // already know its security token associated with that IP/port. Thus, we will abort this request.
                    String msg = "The agent asking for registration under the name [" + request.getName()
                        + "] is attempting to take another agent's address/port [" + request.getAddress() + ":"
                        + request.getPort() + "] with an unknown security token. This request will fail.";
                    throw new AgentRegistrationException(msg);
                }
            }
        } else {
            Agent agentByAddressPort = getAgentManager().getAgentByAddressAndPort(request.getAddress(),
                request.getPort());
            if (agentByAddressPort != null) {
                if (!agentByAddressPort.getName().equals(request.getName())) {
                    String msg = "The agent asking for registration is trying to register the same address/port ["
                        + request.getAddress()
                        + ":"
                        + request.getPort()
                        + "] that is already registered under a different name ["
                        + agentByAddressPort.getName()
                        + "]. If this new agent is actually the same as the original, then re-register with the same name"
                        + " and same security token. Otherwise, you should uninventory the Platform resource for agent ["
                        + agentByAddressPort.getName() + "] and re-register this new agent.";
                    throw new AgentRegistrationException(msg);
                } else {
                    String msg = "The agent [" + request.getName()
                        + "] is attempting to re-register without a security token. " + securityTokenMessage();
                    throw new AgentRegistrationException(msg);

                }
            } else {
                if (agentByName != null) {
                    // the name being registered already exists - but there is no security token to authenticate this request!
                    // Therefore, because this agent name is already registered and because this current request
                    // cannot authenticate itself with the proper security token, we fail.
                    String msg = "An agent is trying to register with an existing agent name ["
                        + request.getName()
                        + "] without providing a valid security token. If you are attempting to re-register this agent, "
                        + "you will need the agent's security token. " + securityTokenMessage();
                    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(
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationException

            throw new AgentNotSupportedException("Agent [" + agentName + "] is an unsupported agent: " + agentVersion);
        }

        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()));
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationException

        return this.subjectManager;
    }

    private void pingEndpoint(String endpoint) throws AgentRegistrationException {
        AgentRegistrationException failure = null;

        try {
            ServerCommunicationsServiceMBean sc = ServerCommunicationsServiceUtil.getService();
            boolean ping = sc.pingEndpoint(endpoint, 10000L);

            if (!ping) {
                // this is mainly to support agentspawn environments but I suppose this could happen
                // on "real" systems.  If the agent's machine is heavily loaded, it is possible that
                // the agent wasn't given enough time to respond to the ping.  Let's at least try
                // one more time, because once this ping failure is confirmed, it means the agent
                // will be dead in the water and hang until an admin can reconfigure it (a second
                // failure probably means it really is a configuration problem)
                ping = sc.pingEndpoint(endpoint, 20000L);

                if (!ping) {
                    failure = new AgentRegistrationException("Server cannot ping the agent's endpoint. "
                        + "The agent's endpoint is probably invalid "
                        + "or there is a firewall preventing the server from connecting to the agent. " + "Endpoint: "
                        + endpoint);
                }
            }
        } catch (Exception e) {
            failure = new AgentRegistrationException("Cannot verify agent endpoint due to internal error.",
                new WrappedRemotingException(e));
        }

        if (failure != null) {
            log.warn(failure);
View Full Code Here

Examples of org.rhq.core.clientapi.server.core.AgentRegistrationException

                            // If we got here, we know a server is up and the agent needs to be registered, but it isn't registered.
                            // This usually means an unrecoverable registration error occurred, so abort.
                            // But there have been cases were there is a race condition and the server just isn't ready yet
                            // so let's at least retry a few times before giving up (BZ 1152154)
                            if (--serverUpWaitCounter < 0) {
                                throw new AgentRegistrationException(
                                    MSG.getMsg(AgentI18NResourceKeys.AGENT_CANNOT_REGISTER));
                            } else {
                                keepWaitingForServer = true;
                                LOG.warn(AgentI18NResourceKeys.STARTUP_REGISTRATION_FAILED_RETRY, serverUpWaitCounter);
                            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.