Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
wire in metrics-jersey to the rest api
  • Loading branch information
cbeer committed Apr 24, 2013
1 parent 75e327d commit eba4259
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 2 deletions.
5 changes: 5 additions & 0 deletions fcrepo-http-api/pom.xml
Expand Up @@ -43,6 +43,11 @@
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
</dependency>
<dependency>
<groupId>com.yammer.metrics</groupId>
<artifactId>metrics-jersey</artifactId>
<version>${metrics.version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
Expand Down
Expand Up @@ -43,6 +43,7 @@
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;

import com.yammer.metrics.annotation.Timed;
import org.fcrepo.AbstractResource;
import org.fcrepo.Datastream;
import org.fcrepo.exception.InvalidChecksumException;
Expand Down Expand Up @@ -87,6 +88,7 @@ public class FedoraDatastreams extends AbstractResource {

@GET
@Path("/")
@Timed
@Produces({TEXT_XML, APPLICATION_JSON})
public ObjectDatastreams getDatastreams(@PathParam("pid")
final String pid) throws RepositoryException, IOException {
Expand All @@ -103,6 +105,7 @@ public ObjectDatastreams getDatastreams(@PathParam("pid")

@POST
@Path("/")
@Timed
public Response modifyDatastreams(@PathParam("pid")
final String pid, @QueryParam("delete")
final List<String> dsidList, final MultiPart multipart)
Expand Down Expand Up @@ -143,6 +146,7 @@ public Response modifyDatastreams(@PathParam("pid")

@DELETE
@Path("/")
@Timed
public Response deleteDatastreams(@PathParam("pid")
final String pid, @QueryParam("dsid")
final List<String> dsidList) throws RepositoryException {
Expand All @@ -162,6 +166,7 @@ public Response deleteDatastreams(@PathParam("pid")
@GET
@Path("/__content__")
@Produces("multipart/mixed")
@Timed
public Response getDatastreamsContents(@PathParam("pid")
final String pid, @QueryParam("dsid")
final List<String> dsids) throws RepositoryException, IOException {
Expand Down Expand Up @@ -209,6 +214,7 @@ public Response getDatastreamsContents(@PathParam("pid")
*/
@POST
@Path("/{dsid}")
@Timed
public Response addDatastream(@PathParam("pid")
final String pid, @QueryParam("checksumType")
final String checksumType, @QueryParam("checksum")
Expand Down Expand Up @@ -252,6 +258,7 @@ public Response addDatastream(@PathParam("pid")
*/
@PUT
@Path("/{dsid}")
@Timed
public Response modifyDatastream(@PathParam("pid")
final String pid, @PathParam("dsid")
final String dsid, @HeaderParam("Content-Type")
Expand Down Expand Up @@ -288,6 +295,7 @@ public Response modifyDatastream(@PathParam("pid")
*/
@GET
@Path("/{dsid}")
@Timed
@Produces({TEXT_XML, APPLICATION_JSON})
public DatastreamProfile getDatastream(@PathParam("pid")
final String pid, @PathParam("dsid")
Expand Down Expand Up @@ -348,6 +356,7 @@ public Response getDatastreamContent(@PathParam("pid")
*/
@GET
@Path("/{dsid}/versions")
@Timed
@Produces({TEXT_XML, APPLICATION_JSON})
public DatastreamHistory getDatastreamHistory(@PathParam("pid")
final String pid, @PathParam("dsid")
Expand All @@ -363,6 +372,7 @@ public DatastreamHistory getDatastreamHistory(@PathParam("pid")

@GET
@Path("/{dsid}/fixity")
@Timed
@Produces({TEXT_XML, APPLICATION_JSON})
public DatastreamFixity getDatastreamFixity(@PathParam("pid")
final String pid, @PathParam("dsid")
Expand Down Expand Up @@ -393,6 +403,7 @@ public DatastreamFixity getDatastreamFixity(@PathParam("pid")
*/
@DELETE
@Path("/{dsid}")
@Timed
public Response deleteDatastream(@PathParam("pid")
final String pid, @PathParam("dsid")
final String dsid) throws RepositoryException {
Expand Down
Expand Up @@ -22,6 +22,7 @@
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

import com.yammer.metrics.annotation.Timed;
import org.fcrepo.AbstractResource;
import org.fcrepo.jaxb.search.FieldSearchResult;
import org.fcrepo.jaxb.search.ObjectFields;
Expand All @@ -46,12 +47,14 @@ public class FedoraFieldSearch extends AbstractResource implements
private static final String QUERY_STRING = buildQueryString();

@GET
@Timed
@Produces(TEXT_HTML)
public String searchForm() throws RepositoryException {
return new VelocityViewer().getFieldSearch(null);
}

@POST
@Timed
@Produces(TEXT_HTML)
public String searchSubmit(@FormParam("terms")
final String terms, @FormParam("offSet")
Expand Down
Expand Up @@ -15,6 +15,7 @@
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;

import com.yammer.metrics.annotation.Timed;
import org.fcrepo.AbstractResource;
import org.fcrepo.jaxb.responses.management.NextPid;
import org.springframework.stereotype.Component;
Expand All @@ -37,6 +38,7 @@ public class FedoraIdentifiers extends AbstractResource {
* @throws TemplateException
*/
@POST
@Timed
@Produces({TEXT_XML, APPLICATION_JSON})
public NextPid getNextPid(@QueryParam("numPids")
@DefaultValue("1")
Expand Down
Expand Up @@ -20,6 +20,7 @@
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;

import com.yammer.metrics.annotation.Timed;
import org.fcrepo.AbstractResource;
import org.fcrepo.jaxb.responses.management.NamespaceListing;
import org.fcrepo.jaxb.responses.management.NamespaceListing.Namespace;
Expand Down Expand Up @@ -50,6 +51,7 @@ public class FedoraNamespaces extends AbstractResource {
* @throws RepositoryException
*/
@POST
@Timed
@Path("/{prefix}")
public Response registerObjectNamespace(@PathParam("prefix")
final String prefix, final String uri) throws RepositoryException {
Expand All @@ -73,6 +75,7 @@ public Response registerObjectNamespace(@PathParam("prefix")
* @throws RepositoryException
*/
@POST
@Timed
@Consumes({TEXT_XML, APPLICATION_JSON})
public Response registerObjectNamespaces(final NamespaceListing nses)
throws RepositoryException {
Expand All @@ -99,6 +102,7 @@ public Response registerObjectNamespaces(final NamespaceListing nses)
*/
@GET
@Path("/{prefix}")
@Timed
@Produces(APPLICATION_JSON)
public Namespace retrieveObjectNamespace(@PathParam("ns")
final String prefix) throws RepositoryException {
Expand All @@ -123,6 +127,7 @@ public Namespace retrieveObjectNamespace(@PathParam("ns")
* @throws IOException
*/
@GET
@Timed
@Produces({TEXT_XML, APPLICATION_JSON})
public NamespaceListing getNamespaces() throws RepositoryException,
IOException {
Expand Down
Expand Up @@ -25,6 +25,7 @@
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;

import com.yammer.metrics.annotation.Timed;
import org.fcrepo.AbstractResource;
import org.fcrepo.FedoraObject;
import org.fcrepo.jaxb.responses.access.ObjectProfile;
Expand All @@ -50,6 +51,7 @@ public class FedoraObjects extends AbstractResource {
* @throws RepositoryException
*/
@GET
@Timed
public Response getObjects() throws RepositoryException {

return ok(objectService.getObjectNames().toString()).build();
Expand All @@ -64,6 +66,7 @@ public Response getObjects() throws RepositoryException {
*/
@POST
@Path("/new")
@Timed
public Response ingestAndMint() throws RepositoryException {
return ingest(pidMinter.mintPid(), "");
}
Expand All @@ -77,6 +80,7 @@ public Response ingestAndMint() throws RepositoryException {
*/
@PUT
@Path("/{pid}")
@Timed
public Response modify(@PathParam("pid")
final String pid) throws RepositoryException {
final Session session = getAuthenticatedSession();
Expand All @@ -98,6 +102,7 @@ public Response modify(@PathParam("pid")
*/
@POST
@Path("/{pid}")
@Timed
public Response ingest(@PathParam("pid")
final String pid, @QueryParam("label")
@DefaultValue("")
Expand Down Expand Up @@ -131,6 +136,7 @@ public Response ingest(@PathParam("pid")
*/
@GET
@Path("/{pid}")
@Timed
@Produces({TEXT_XML, APPLICATION_JSON, TEXT_HTML})
public ObjectProfile getObject(@PathParam("pid")
final String pid) throws RepositoryException, IOException {
Expand Down Expand Up @@ -160,6 +166,7 @@ public ObjectProfile getObject(@PathParam("pid")
*/
@DELETE
@Path("/{pid}")
@Timed
public Response deleteObject(@PathParam("pid")
final String pid) throws RepositoryException {
final Session session = getAuthenticatedSession();
Expand Down
Expand Up @@ -23,6 +23,7 @@
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;

import com.yammer.metrics.annotation.Timed;
import org.fcrepo.AbstractResource;
import org.fcrepo.jaxb.responses.access.DescribeRepository;
import org.fcrepo.provider.VelocityViewer;
Expand All @@ -47,6 +48,7 @@ public class FedoraRepository extends AbstractResource {

@GET
@Path("modeshape")
@Timed
public Response describeModeshape() throws IOException, RepositoryException {
final Session session = getAuthenticatedSession();
logger.debug("Repository name: " + repo.getDescriptor(REP_NAME_DESC));
Expand Down Expand Up @@ -75,6 +77,7 @@ public Response describeModeshape() throws IOException, RepositoryException {
}

@GET
@Timed
@Produces({TEXT_XML, APPLICATION_XML, APPLICATION_JSON})
public DescribeRepository describe() throws RepositoryException {

Expand All @@ -92,6 +95,7 @@ public DescribeRepository describe() throws RepositoryException {
}

@GET
@Timed
@Produces(TEXT_HTML)
public String describeHtml() throws RepositoryException {

Expand Down
Expand Up @@ -19,6 +19,7 @@
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

import com.yammer.metrics.annotation.Timed;
import org.fcrepo.AbstractResource;
import org.fcrepo.jaxb.responses.sitemap.SitemapEntry;
import org.fcrepo.jaxb.responses.sitemap.SitemapIndex;
Expand All @@ -40,6 +41,7 @@ public class FedoraSitemap extends AbstractResource {
private ObjectService objectService;

@GET
@Timed
@Produces(TEXT_XML)
public SitemapIndex getSitemapIndex() throws RepositoryException {
logger.trace("Executing getSitemapIndex()...");
Expand Down Expand Up @@ -67,6 +69,7 @@ public SitemapIndex getSitemapIndex() throws RepositoryException {

@GET
@Path("/{page}")
@Timed
@Produces(TEXT_XML)
public SitemapUrlSet getSitemap(@PathParam("page")
final String page) throws RepositoryException {
Expand Down
4 changes: 2 additions & 2 deletions fcrepo-metrics/pom.xml
Expand Up @@ -17,14 +17,14 @@
<dependency>
<groupId>com.yammer.metrics</groupId>
<artifactId>metrics-core</artifactId>
<version>3.0.0-BETA1</version>
<version>${metrics.version}</version>
</dependency>


<dependency>
<groupId>com.yammer.metrics</groupId>
<artifactId>metrics-graphite</artifactId>
<version>3.0.0-BETA1</version>
<version>${metrics.version}</version>
</dependency>

</dependencies>
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Expand Up @@ -33,6 +33,7 @@
<sesame.version>2.7.0</sesame.version>
<slf4j.version>1.7.5</slf4j.version>
<spring.version>3.2.0.RELEASE</spring.version>
<metrics.version>3.0.0-BETA1</metrics.version>

<!-- https://github.com/github/maven-plugins/blob/master/README.md -->
<github.global.server>github</github.global.server>
Expand Down

0 comments on commit eba4259

Please sign in to comment.