Repository: incubator-slider Updated Branches: refs/heads/develop 68d57cf2a -> 2522f65b3
SLIDER-754 all application/ URLs are now instrumented Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/2522f65b Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/2522f65b Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/2522f65b Branch: refs/heads/develop Commit: 2522f65b33a24e702b8466b3989b44cab1162373 Parents: 28d296a Author: Steve Loughran <[email protected]> Authored: Wed Jan 14 16:27:48 2015 +0000 Committer: Steve Loughran <[email protected]> Committed: Wed Jan 14 16:28:27 2015 +0000 ---------------------------------------------------------------------- .../management/MetricsAndMonitoring.java | 9 +++ .../web/rest/AbstractSliderResource.java | 58 ++++++++++++++++++++ .../rest/application/ApplicationResource.java | 22 +++++++- 3 files changed, 88 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2522f65b/slider-core/src/main/java/org/apache/slider/server/appmaster/management/MetricsAndMonitoring.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/management/MetricsAndMonitoring.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/management/MetricsAndMonitoring.java index c14639d..5b96256 100644 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/management/MetricsAndMonitoring.java +++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/management/MetricsAndMonitoring.java @@ -91,4 +91,13 @@ public class MetricsAndMonitoring extends CompositeService { return instance; } + /** + * Get a specific meter and mark it + * @param name name of meter/counter + */ + public void markMeterAndCounter(String name) { + MeterAndCounter meter = getOrCreateMeterAndCounter(name); + meter.mark(); + } + } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2522f65b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/AbstractSliderResource.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/AbstractSliderResource.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/AbstractSliderResource.java index dc07c10..cfddb12 100644 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/AbstractSliderResource.java +++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/AbstractSliderResource.java @@ -23,6 +23,7 @@ import org.apache.hadoop.registry.client.exceptions.AuthenticationFailedExceptio import org.apache.hadoop.registry.client.exceptions.NoPathPermissionsException; import org.apache.hadoop.yarn.webapp.ForbiddenException; import org.apache.hadoop.yarn.webapp.NotFoundException; +import org.apache.slider.server.appmaster.management.MetricsAndMonitoring; import org.apache.slider.server.appmaster.web.WebAppApi; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,9 +43,11 @@ public abstract class AbstractSliderResource { private static final Logger log = LoggerFactory.getLogger(AbstractSliderResource.class); protected final WebAppApi slider; + protected final MetricsAndMonitoring metricsAndMonitoring; public AbstractSliderResource(WebAppApi slider) { this.slider = slider; + metricsAndMonitoring = slider.getMetricsAndMonitoring(); } @@ -93,4 +96,59 @@ public abstract class AbstractSliderResource { return new WebApplicationException(e); } } + + /** + * Mark an GET operation on a path + * @param verb HTTP Verb + * @param path path relative to slider API + */ + protected void mark(String verb, String path) { + metricsAndMonitoring.markMeterAndCounter(verb + "-" + path); + } + /** + * Mark an GET operation on a path + * @param verb HTTP Verb + * @param path path relative to slider API + */ + protected void mark(String verb, String path, String subpath) { + metricsAndMonitoring.markMeterAndCounter(verb + "-" + path + subpath); + } + + /** + * Mark a GET operation on a path + * @param path path relative to slider API + */ + protected void markGet(String path) { + mark("GET", path); + } + + /** + * Mark a GET operation on a path + * @param path path relative to slider API + */ + protected void markGet(String path, String subpath) { + mark("GET", path, subpath); + } + /** + * Mark a GET operation on a path + * @param path path relative to slider API + */ + protected void markPost(String path, String subpath) { + mark("POST", path, subpath); + } + /** + * Mark a GET operation on a path + * @param path path relative to slider API + */ + protected void markPut(String path, String subpath) { + mark("PUT", path, subpath); + } + /** + * Mark a GET operation on a path + * @param path path relative to slider API + */ + protected void markDelete(String path, String subpath) { + mark("DELETE", path, subpath); + } + } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/2522f65b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/ApplicationResource.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/ApplicationResource.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/ApplicationResource.java index 6734f73..d72a486 100644 --- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/ApplicationResource.java +++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/application/ApplicationResource.java @@ -140,6 +140,7 @@ public class ApplicationResource extends AbstractSliderResource { @Path("/") @Produces({APPLICATION_JSON}) public List<String> getRoot() { + markGet(SLIDER_SUBPATH_APPLICATION); return ROOT_ENTRIES; } @@ -151,6 +152,7 @@ public class ApplicationResource extends AbstractSliderResource { @Path(MODEL) @Produces({APPLICATION_JSON}) public List<String> getModel() { + markGet(SLIDER_SUBPATH_APPLICATION, MODEL); return MODEL_ENTRIES; } @@ -158,6 +160,7 @@ public class ApplicationResource extends AbstractSliderResource { @Path(MODEL_DESIRED) @Produces({APPLICATION_JSON}) public AggregateConf getModelDesired() { + markGet(SLIDER_SUBPATH_APPLICATION, MODEL_DESIRED); return lookupAggregateConf(MODEL_DESIRED); } @@ -165,6 +168,7 @@ public class ApplicationResource extends AbstractSliderResource { @Path(MODEL_DESIRED_APPCONF) @Produces({APPLICATION_JSON}) public ConfTree getModelDesiredAppconf() { + markGet(SLIDER_SUBPATH_APPLICATION, MODEL_DESIRED_APPCONF); return lookupConfTree(MODEL_DESIRED_APPCONF); } @@ -172,6 +176,7 @@ public class ApplicationResource extends AbstractSliderResource { @Path(MODEL_DESIRED_RESOURCES) @Produces({APPLICATION_JSON}) public ConfTree getModelDesiredResources() { + markGet(SLIDER_SUBPATH_APPLICATION, MODEL_DESIRED_RESOURCES); return lookupConfTree(MODEL_DESIRED_RESOURCES); } @@ -179,6 +184,7 @@ public class ApplicationResource extends AbstractSliderResource { @Path(MODEL_RESOLVED) @Produces({APPLICATION_JSON}) public AggregateConf getModelResolved() { + markGet(SLIDER_SUBPATH_APPLICATION, MODEL_RESOLVED); return lookupAggregateConf(MODEL_RESOLVED); } @@ -186,6 +192,7 @@ public class ApplicationResource extends AbstractSliderResource { @Path(MODEL_RESOLVED_APPCONF) @Produces({APPLICATION_JSON}) public ConfTree getModelResolvedAppconf() { + markGet(SLIDER_SUBPATH_APPLICATION, MODEL_RESOLVED_APPCONF); return lookupConfTree(MODEL_RESOLVED_APPCONF); } @@ -193,6 +200,7 @@ public class ApplicationResource extends AbstractSliderResource { @Path(MODEL_RESOLVED_RESOURCES) @Produces({APPLICATION_JSON}) public ConfTree getModelResolvedResources() { + markGet(SLIDER_SUBPATH_APPLICATION, MODEL_RESOLVED_RESOURCES); return lookupConfTree(MODEL_RESOLVED_RESOURCES); } @@ -200,6 +208,7 @@ public class ApplicationResource extends AbstractSliderResource { @Path(LIVE) @Produces({APPLICATION_JSON}) public List<String> getLive() { + markGet(SLIDER_SUBPATH_APPLICATION, LIVE); return LIVE_ENTRIES; } @@ -207,6 +216,7 @@ public class ApplicationResource extends AbstractSliderResource { @Path(LIVE_RESOURCES) @Produces({APPLICATION_JSON}) public Object getLiveResources() { + markGet(SLIDER_SUBPATH_APPLICATION, LIVE_RESOURCES); return lookupConfTree(LIVE_RESOURCES); } @@ -214,6 +224,7 @@ public class ApplicationResource extends AbstractSliderResource { @Path(LIVE_CONTAINERS) @Produces({APPLICATION_JSON}) public Map<String, SerializedContainerInformation> getLiveContainers() { + markGet(SLIDER_SUBPATH_APPLICATION, LIVE_CONTAINERS); try { return (Map<String, SerializedContainerInformation>)cache.lookup( LIVE_CONTAINERS); @@ -227,6 +238,7 @@ public class ApplicationResource extends AbstractSliderResource { @Produces({APPLICATION_JSON}) public SerializedContainerInformation getLiveContainer( @PathParam("containerId") String containerId) { + markGet(SLIDER_SUBPATH_APPLICATION, LIVE_CONTAINERS); try { RoleInstance id = state.getLiveInstanceByContainerID(containerId); return id.serialize(); @@ -241,6 +253,7 @@ public class ApplicationResource extends AbstractSliderResource { @Path(LIVE_COMPONENTS) @Produces({APPLICATION_JSON}) public Map<String, SerializedComponentInformation> getLiveComponents() { + markGet(SLIDER_SUBPATH_APPLICATION, LIVE_COMPONENTS); try { return (Map<String, SerializedComponentInformation>) cache.lookup( LIVE_COMPONENTS); @@ -254,6 +267,7 @@ public class ApplicationResource extends AbstractSliderResource { @Produces({APPLICATION_JSON}) public SerializedComponentInformation getLiveComponent( @PathParam("component") String component) { + markGet(SLIDER_SUBPATH_APPLICATION, LIVE_COMPONENTS); try { RoleStatus roleStatus = state.lookupRoleStatus(component); SerializedComponentInformation info = roleStatus.serialize(); @@ -315,6 +329,7 @@ public class ApplicationResource extends AbstractSliderResource { @Produces({APPLICATION_JSON}) public PingResource actionPingGet(@Context HttpServletRequest request, @Context UriInfo uriInfo) { + markGet(SLIDER_SUBPATH_APPLICATION, ACTION_PING); return new RestActionPing().ping(request, uriInfo, ""); } @@ -324,6 +339,7 @@ public class ApplicationResource extends AbstractSliderResource { public PingResource actionPingPost(@Context HttpServletRequest request, @Context UriInfo uriInfo, String body) { + markPost(SLIDER_SUBPATH_APPLICATION, ACTION_PING); return new RestActionPing().ping(request, uriInfo, body); } @@ -334,6 +350,7 @@ public class ApplicationResource extends AbstractSliderResource { public PingResource actionPingPut(@Context HttpServletRequest request, @Context UriInfo uriInfo, String body) { + markPut(SLIDER_SUBPATH_APPLICATION, ACTION_PING); return new RestActionPing().ping(request, uriInfo, body); } @@ -343,6 +360,7 @@ public class ApplicationResource extends AbstractSliderResource { @Produces({APPLICATION_JSON}) public PingResource actionPingDelete(@Context HttpServletRequest request, @Context UriInfo uriInfo) { + markDelete(SLIDER_SUBPATH_APPLICATION, ACTION_PING); return new RestActionPing().ping(request, uriInfo, ""); } @@ -351,10 +369,11 @@ public class ApplicationResource extends AbstractSliderResource { @Produces({APPLICATION_JSON}) public Object actionPingHead(@Context HttpServletRequest request, @Context UriInfo uriInfo) { + mark("HEAD", SLIDER_SUBPATH_APPLICATION, ACTION_PING); return new RestActionPing().ping(request, uriInfo, ""); } - /* ************************************************************************ + /* ************************************************************************ ACTION STOP @@ -367,6 +386,7 @@ public class ApplicationResource extends AbstractSliderResource { public StopResponse actionStop(@Context HttpServletRequest request, @Context UriInfo uriInfo, String body) { + markPost(SLIDER_SUBPATH_APPLICATION, ACTION_STOP); return new RestActionStop(slider).stop(request, uriInfo, body); }
