All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.terracotta.management.resource.services.AgentsResourceServiceImplV2 Maven / Gradle / Ivy

Go to download

Ehcache is an open source, standards-based cache used to boost performance, offload the database and simplify scalability. Ehcache is robust, proven and full-featured and this has made it the most widely-used Java-based cache.

There is a newer version: 2.10.9.2
Show newest version
/* All content copyright (c) 2003-2012 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice.  All rights reserved.*/

package org.terracotta.management.resource.services;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terracotta.management.ServiceExecutionException;
import org.terracotta.management.ServiceLocator;
import org.terracotta.management.resource.AgentEntityV2;
import org.terracotta.management.resource.AgentMetadataEntityV2;
import org.terracotta.management.resource.Representable;
import org.terracotta.management.resource.ResponseEntityV2;
import org.terracotta.management.resource.exceptions.ResourceRuntimeException;
import org.terracotta.management.resource.services.validator.RequestValidator;

import com.terracotta.management.resource.services.utils.UriInfoUtils;

import java.util.Set;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;

/**
 * REST facade of agents service.
 *
 * @author Anthony Dahanne
 */
@Path("/v2/agents")
public final class AgentsResourceServiceImplV2 {
  private static final Logger LOG = LoggerFactory.getLogger(AgentsResourceServiceImplV2.class);

  private final AgentServiceV2 agentService;

  private final RequestValidator validator;

  public AgentsResourceServiceImplV2() {
    this.agentService = ServiceLocator.locate(AgentServiceV2.class);
    this.validator = ServiceLocator.locate(RequestValidator.class);
  }

  /**
   * 

* A top level resource that provides each agents root {@link Representable} objects. *

* * @param info * - {@link UriInfo} for this resource request * @return a collection of {@link AgentEntityV2} objects when successful. */ @GET @Produces(MediaType.APPLICATION_JSON) public ResponseEntityV2 getAgents(@Context UriInfo info) { LOG.debug(String.format("Invoking AgentsResourceServiceImplV2.getAgents: %s", info.getRequestUri())); Set idSet = UriInfoUtils.extractAgentIds(info); try { return agentService.getAgents(idSet); } catch (ServiceExecutionException see) { throw new ResourceRuntimeException("Failed to get agents", see, Response.Status.BAD_REQUEST.getStatusCode()); } } /** *

* A resource that provides discovery of all agents and reveals metadata about each agents API and state. *

* * @param info * - {@link UriInfo} for this resource request * @return a collection of {@link AgentMetadataEntityV2} objects when successful. */ @GET @Path("/info") @Produces(MediaType.APPLICATION_JSON) public ResponseEntityV2 getAgentsMetadata(@Context UriInfo info) { LOG.debug(String.format("Invoking AgentsResourceServiceImplV2.getAgentsMetadata: %s", info.getRequestUri())); validator.validateSafe(info); Set idSet = UriInfoUtils.extractAgentIds(info); try { return agentService.getAgentsMetadata(idSet); } catch (ServiceExecutionException see) { throw new ResourceRuntimeException("Failed to get agents metadata", see, Response.Status.BAD_REQUEST.getStatusCode()); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy