Examples of AgentClient


Examples of org.rhq.enterprise.server.agentclient.AgentClient

        // Package into transfer object
        DeleteResourceRequest request = new DeleteResourceRequest(persistedHistory.getId(), resourceId);

        try {
            AgentClient agentClient = agentManager.getAgentClient(agent);
            ResourceFactoryAgentService resourceFactoryAgentService = agentClient.getResourceFactoryAgentService();
            resourceFactoryAgentService.deleteResource(request);

            return persistedHistory;
        } catch (CannotConnectException e) {
            LOG.error("Error while sending delete resource request to agent service", e);
View Full Code Here

Examples of org.rhq.enterprise.server.agentclient.AgentClient

        return agent;
    }

    @ExcludeDefaultInterceptors
    public AgentClient getAgentClient(Agent agent) {
        AgentClient client = null;

        try {
            ServerCommunicationsServiceMBean bootstrap = ServerCommunicationsServiceUtil.getService();
            client = bootstrap.getKnownAgentClient(agent);

            if (client != null) {
                // We assume the caller is asking for a client so it can send the agent messages,
                // so let's start the sender automatically for the caller so it doesn't need to remember to do it
                client.startSending();
            } else {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("There is no agent client for agent: " + agent);
                }
            }
View Full Code Here

Examples of org.rhq.enterprise.server.agentclient.AgentClient

        try {
            //insert call to method doing logged in check and view resources perm check as method calld from GWT*Service
            agent = getAgentByResourceId(subject, resourceId);

            //now ping
            AgentClient client = getAgentClient(agent);
            pingResults = client.pingService(5000L);

        } catch (NoResultException e) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Failed to lookup agent for resource with ID of [" + resourceId + "] : " + e);
            }
View Full Code Here

Examples of org.rhq.enterprise.server.agentclient.AgentClient

            agent = agentManager.getAgentByResourceId(subjectManager.getOverlord(), resourceId);
            if (agent == null) {
                throw new IllegalStateException("No agent is associated with the resource with id " + resourceId + ".");
            }

            AgentClient client = agentManager.getAgentClient(agent);
            pingResults = client.ping(5000L);
        } catch (Throwable t) {
            pingResults = Boolean.FALSE;
        }
    }
View Full Code Here

Examples of org.rhq.enterprise.server.agentclient.AgentClient

    public AgentClient getAgentClientForSchedule(MeasurementSchedule sched) {
        Resource pRes = sched.getResource();

        // Get agent and open a connection to it
        Agent agent = pRes.getAgent();
        AgentClient ac = agentManager.getAgentClient(agent);
        return ac;
    }
View Full Code Here

Examples of org.rhq.enterprise.server.agentclient.AgentClient

            }

            boolean markResources = false;
            try {
                Agent nextAgent = agentManager.getAgentByID(nextAgentId);
                AgentClient agentClient = agentManager.getAgentClient(nextAgent);

                boolean couldPing = agentClient.pingService(2000); // see if agent is up for sending
                if (couldPing) {
                    Set<ResourceMeasurementScheduleRequest> requestsToSend = new HashSet<ResourceMeasurementScheduleRequest>(
                        agentRequests.values());
                    agentClient.getMeasurementAgentService().updateCollection(requestsToSend);
                } else {
                    log.error("Could not send measurement schedule updates to agent[id=" + nextAgentId
                        + "], marking resources for update; agent ping failed");
                    markResources = true;
                }
View Full Code Here

Examples of org.rhq.enterprise.server.agentclient.AgentClient

    }

    private boolean sendUpdatedSchedulesToAgent(Agent agent,
        Set<ResourceMeasurementScheduleRequest> resourceMeasurementScheduleRequest) {
        try {
            AgentClient agentClient = LookupUtil.getAgentManager().getAgentClient(agent);
            if (!agentClient.pingService(2000)) {
                if (log.isDebugEnabled()) {
                    log.debug("Won't send MeasurementSchedules to offline Agent[id=" + agent.getId() + "]");
                }
                return false;
            }
            agentClient.getMeasurementAgentService().updateCollection(resourceMeasurementScheduleRequest);
            return true; // successfully sync'ed schedules down to the agent
        } catch (Throwable t) {
            log.error("Error updating MeasurementSchedules for Agent[id=" + agent.getId() + "]: ", t);
        }
        return false; // catch all and presume the live sync failed
View Full Code Here

Examples of org.rhq.enterprise.server.agentclient.AgentClient

        return m_container.getServerEndpoint();
    }

    @Override
    public AgentClient getKnownAgentClient(Agent agent) {
        AgentClient agent_client;

        if (agent == null) {
            throw new IllegalStateException("Agent must be non-null - is a resource not assigned an agent?");
        }

        // first see if its already cached, if not we need to create one.
        synchronized (m_knownAgentClients) {
            String agent_address = agent.getAddress();
            int agent_port = agent.getPort();

            agent_client = m_knownAgentClients.get(getEndpointKey(agent_address, agent_port));

            // BZ1071994: Note that this cache can be dirty in an HA environment.  As such, we need to ensure cache
            // entries are correct. Do a quick token match on the cache entry, when accessed, and recreate as needed.
            if ((agent_client == null) || !agent_client.getAgent().getAgentToken().equals(agent.getAgentToken())) {
                String remote_uri;
                InvokerLocator locator = m_knownAgents.getAgent(agent_address, agent_port);

                if (locator != null) {
                    remote_uri = locator.getLocatorURI();
View Full Code Here

Examples of org.rhq.enterprise.server.agentclient.AgentClient

        return agent_client;
    }

    @Override
    public void destroyKnownAgentClient(Agent agent) {
        AgentClient agent_client;

        // first see if its already cached, if not we need to create one
        synchronized (m_knownAgentClients) {
            String agent_address = agent.getAddress();
            int agent_port = agent.getPort();

            agent_client = m_knownAgentClients.remove(getEndpointKey(agent_address, agent_port));

            if (agent_client != null) {
                agent_client.stopSending();
            }

            // purge the spool file, if it exists
            File spool_file = null;
View Full Code Here

Examples of org.rhq.enterprise.server.agentclient.AgentClient

    public void addStartedAgent(Agent agent) {
        String endpoint = agent.getRemoteEndpoint();

        m_knownAgents.addAgent(endpoint);

        AgentClient client = getKnownAgentClient(agent);

        if (client != null) {
            client.startSending(); // we start it now because it allows it to start sending persisted guaranteed delivery messages
        }

        return;
    }
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.