You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/11/25 20:21:58 UTC
[1/5] incubator-slider git commit: SLIDER-673 serialized application
report saved with lookup operation doesn't save URLs
Repository: incubator-slider
Updated Branches:
refs/heads/develop f0a30fd9f -> a3b6fa5b0
SLIDER-673 serialized application report saved with lookup operation doesn't save URLs
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/a2966af9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/a2966af9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/a2966af9
Branch: refs/heads/develop
Commit: a2966af9a75551402a045a9daf62ca82069904f2
Parents: 524446d
Author: Steve Loughran <st...@apache.org>
Authored: Mon Nov 24 17:05:17 2014 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Tue Nov 25 19:20:47 2014 +0000
----------------------------------------------------------------------
.../org/apache/slider/core/launch/SerializedApplicationReport.java | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/a2966af9/slider-core/src/main/java/org/apache/slider/core/launch/SerializedApplicationReport.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/launch/SerializedApplicationReport.java b/slider-core/src/main/java/org/apache/slider/core/launch/SerializedApplicationReport.java
index 116aeb3..c1880b5 100644
--- a/slider-core/src/main/java/org/apache/slider/core/launch/SerializedApplicationReport.java
+++ b/slider-core/src/main/java/org/apache/slider/core/launch/SerializedApplicationReport.java
@@ -81,6 +81,8 @@ public class SerializedApplicationReport {
FinalApplicationStatus appStatus = report.getFinalApplicationStatus();
this.finalStatus = appStatus == null ? "" : appStatus.toString();
this.progress = report.getProgress();
+ this.url = report.getTrackingUrl();
+ this.origTrackingUrl= report.getTrackingUrl();
}
@Override
[2/5] incubator-slider git commit: SLIDER-319 codahale metrics
integration, including web view and tests for it
Posted by st...@apache.org.
SLIDER-319 codahale metrics integration, including web view and tests for it
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/524446db
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/524446db
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/524446db
Branch: refs/heads/develop
Commit: 524446dbba7c9a5efa6900cd53823488d363ae5d
Parents: 00eca8f
Author: Steve Loughran <st...@apache.org>
Authored: Mon Nov 24 17:04:41 2014 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Tue Nov 25 19:20:47 2014 +0000
----------------------------------------------------------------------
.../server/appmaster/SliderAppMaster.java | 33 +++--
.../management/MetricsAndMonitoring.java | 62 +++++++++
.../management/MetricsBindingService.java | 128 +++++++++++++++++++
.../management/YarnServiceHealthCheck.java | 38 ++++++
.../slider/server/appmaster/state/AppState.java | 12 +-
.../server/appmaster/web/SliderAMWebApp.java | 13 +-
.../slider/server/appmaster/web/WebAppApi.java | 4 +-
.../server/appmaster/web/WebAppApiImpl.java | 12 +-
.../server/appmaster/web/rest/RestPaths.java | 2 +-
.../appmaster/web/rest/agent/AgentWebApp.java | 1 -
.../server/appmaster/web/view/NavBlock.java | 12 +-
.../services/utility/MetricsBindingService.java | 128 -------------------
.../standalone/TestStandaloneAgentWeb.groovy | 5 +-
.../appmaster/model/mock/MockAppState.groovy | 6 +-
.../model/monkey/TestMockMonkey.groovy | 2 +-
.../web/view/TestContainerStatsBlock.groovy | 2 +-
.../appmaster/web/view/TestIndexBlock.groovy | 2 +-
.../apache/slider/test/SliderTestBase.groovy | 3 +-
.../web/rest/agent/TestAMAgentWebServices.java | 4 +-
.../management/TestAMManagementWebServices.java | 4 +-
.../funtest/framework/CommandTestBase.groovy | 51 ++++++++
.../funtest/lifecycle/AgentWebPagesIT.groovy | 92 +++++++++++++
.../lifecycle/AppsThroughAgentDemo.groovy | 2 +-
23 files changed, 444 insertions(+), 174 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java
index 9530bc0..1bafe4b 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java
@@ -19,6 +19,7 @@
package org.apache.slider.server.appmaster;
import com.codahale.metrics.MetricRegistry;
+import com.codahale.metrics.health.HealthCheckRegistry;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.protobuf.BlockingService;
@@ -123,6 +124,8 @@ import org.apache.slider.server.appmaster.actions.RenewingAction;
import org.apache.slider.server.appmaster.actions.ResetFailureWindow;
import org.apache.slider.server.appmaster.actions.ReviewAndFlexApplicationSize;
import org.apache.slider.server.appmaster.actions.UnregisterComponentInstance;
+import org.apache.slider.server.appmaster.management.MetricsAndMonitoring;
+import org.apache.slider.server.appmaster.management.YarnServiceHealthCheck;
import org.apache.slider.server.appmaster.monkey.ChaosKillAM;
import org.apache.slider.server.appmaster.monkey.ChaosKillContainer;
import org.apache.slider.server.appmaster.monkey.ChaosMonkeyService;
@@ -149,7 +152,7 @@ import org.apache.slider.server.appmaster.web.rest.RestPaths;
import org.apache.slider.server.services.security.CertificateManager;
import org.apache.slider.server.services.security.FsDelegationTokenManager;
import org.apache.slider.server.services.utility.AbstractSliderLaunchedService;
-import org.apache.slider.server.services.utility.MetricsBindingService;
+import org.apache.slider.server.appmaster.management.MetricsBindingService;
import org.apache.slider.server.services.utility.WebAppService;
import org.apache.slider.server.services.workflow.ServiceThreadFactory;
import org.apache.slider.server.services.workflow.WorkflowExecutorService;
@@ -209,9 +212,13 @@ public class SliderAppMaster extends AbstractSliderLaunchedService
public static final int NUM_RPC_HANDLERS = 5;
/**
- * Singleton of metrics registry
+ * Metrics and monitoring services
*/
- public static final MetricRegistry metrics = new MetricRegistry();
+ private final MetricsAndMonitoring metricsAndMonitoring = new MetricsAndMonitoring();
+ /**
+ * metrics registry
+ */
+ public MetricRegistry metrics;
public static final String E_TRIGGERED_LAUNCH_FAILURE =
"Chaos monkey triggered launch failure";
@@ -270,8 +277,8 @@ public class SliderAppMaster extends AbstractSliderLaunchedService
* Ongoing state of the cluster: containers, nodes they
* live on, etc.
*/
- private final AppState appState = new AppState(new ProtobufRecordFactory(),
- metrics);
+ private final AppState appState =
+ new AppState(new ProtobufRecordFactory(), metricsAndMonitoring);
private final ProviderAppState stateForProviders =
new ProviderAppState("undefined", appState);
@@ -436,6 +443,11 @@ public class SliderAppMaster extends AbstractSliderLaunchedService
false);
SliderUtils.validateSliderServerEnvironment(log, dependencyChecks);
+ // create app state and monitoring
+ addService(metricsAndMonitoring);
+ metrics = metricsAndMonitoring.getMetrics();
+
+
executorService = new WorkflowExecutorService<ExecutorService>("AmExecutor",
Executors.newFixedThreadPool(2,
new ServiceThreadFactory("AmExecutor", true)));
@@ -443,8 +455,6 @@ public class SliderAppMaster extends AbstractSliderLaunchedService
addService(actionQueues);
- addService(new MetricsBindingService("MetricsBindingService",
- metrics));
//init all child services
super.serviceInit(conf);
}
@@ -452,6 +462,8 @@ public class SliderAppMaster extends AbstractSliderLaunchedService
@Override
protected void serviceStart() throws Exception {
super.serviceStart();
+ HealthCheckRegistry health = metricsAndMonitoring.getHealth();
+ health.register("AM Health", new YarnServiceHealthCheck(this));
}
/**
@@ -708,7 +720,7 @@ public class SliderAppMaster extends AbstractSliderLaunchedService
providerService,
certificateManager,
registryOperations,
- metrics);
+ metricsAndMonitoring);
webApp = new SliderAMWebApp(webAppApi);
WebApps.$for(SliderAMWebApp.BASE_PATH, WebAppApi.class,
webAppApi,
@@ -1005,10 +1017,11 @@ public class SliderAppMaster extends AbstractSliderLaunchedService
providerService,
certificateManager,
registryOperations,
- metrics),
+ metricsAndMonitoring),
RestPaths.AGENT_WS_CONTEXT)
.withComponentConfig(getInstanceDefinition().getAppConfOperations()
- .getComponent(SliderKeys.COMPONENT_AM))
+ .getComponent(
+ SliderKeys.COMPONENT_AM))
.start();
agentOpsUrl =
"https://" + appMasterHostname + ":" + agentWebApp.getSecuredPort();
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/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
new file mode 100644
index 0000000..77204d6
--- /dev/null
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/management/MetricsAndMonitoring.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.slider.server.appmaster.management;
+
+import com.codahale.metrics.MetricRegistry;
+import com.codahale.metrics.health.HealthCheckRegistry;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.service.AbstractService;
+import org.apache.hadoop.service.CompositeService;
+
+/**
+ * Class for all metrics and monitoring
+ */
+public class MetricsAndMonitoring extends CompositeService {
+
+ public MetricsAndMonitoring(String name) {
+ super(name);
+ }
+
+ public MetricsAndMonitoring() {
+ super("MetricsAndMonitoring");
+ }
+
+ /**
+ * Singleton of metrics registry
+ */
+ final MetricRegistry metrics = new MetricRegistry();
+
+ final HealthCheckRegistry health = new HealthCheckRegistry();
+
+ public MetricRegistry getMetrics() {
+ return metrics;
+ }
+
+ public HealthCheckRegistry getHealth() {
+ return health;
+ }
+
+ @Override
+ protected void serviceInit(Configuration conf) throws Exception {
+ addService(new MetricsBindingService("MetricsBindingService",
+ metrics));
+ super.serviceInit(conf);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-core/src/main/java/org/apache/slider/server/appmaster/management/MetricsBindingService.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/management/MetricsBindingService.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/management/MetricsBindingService.java
new file mode 100644
index 0000000..b49cf30
--- /dev/null
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/management/MetricsBindingService.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.slider.server.appmaster.management;
+
+import com.codahale.metrics.MetricRegistry;
+import com.codahale.metrics.ScheduledReporter;
+import com.codahale.metrics.ganglia.GangliaReporter;
+import info.ganglia.gmetric4j.gmetric.GMetric;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.IOUtils;
+import org.apache.hadoop.service.AbstractService;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * YARN service which hooks up Codahale metrics to
+ * Ganglia (if enabled)
+ */
+public class MetricsBindingService extends AbstractService {
+
+ /**
+ * {@value}
+ */
+ public static final String METRICS_GANGLIA_ENABLED =
+ "metrics.ganglia.enabled";
+ /**
+ * {@value}
+ */
+ public static final String METRICS_GANGLIA_HOST = "metrics.ganglia.host";
+
+ /**
+ * {@value}
+ */
+ public static final String METRICS_GANGLIA_PORT = "metrics.ganglia.port";
+
+ /**
+ * {@value}
+ */
+ public static final String METRICS_GANGLIA_VERSION_31 = "metrics.ganglia.version.31";
+
+ /**
+ * {@value}
+ */
+ public static final String METRICS_GANGLIA_REPORT_INTERVAL = "metrics.ganglia.report.interval";
+
+ /**
+ * {@value}
+ */
+ public static final int DEFAULT_GANGLIA_PORT = 8649;
+
+ private final MetricRegistry metrics;
+ private ScheduledReporter reporter;
+
+ public MetricsBindingService(String name,
+ MetricRegistry metrics) {
+ super(name);
+ this.metrics = metrics;
+ }
+
+ /**
+ * Instantiate...create a metric registry in the process
+ * @param name service name
+ */
+ public MetricsBindingService(String name) {
+ this(name, new MetricRegistry());
+ }
+
+ public MetricRegistry getMetrics() {
+ return metrics;
+ }
+
+ @Override
+ protected void serviceStart() throws Exception {
+ super.serviceStart();
+ Configuration conf = getConfig();
+ boolean enabled = conf.getBoolean(METRICS_GANGLIA_ENABLED, false);
+
+ if (enabled) {
+ String host = conf.getTrimmed(METRICS_GANGLIA_HOST, "");
+ int port = conf.getInt(METRICS_GANGLIA_PORT, DEFAULT_GANGLIA_PORT);
+ int interval = conf.getInt(METRICS_GANGLIA_REPORT_INTERVAL, 60);
+ int ttl = 1;
+ GMetric.UDPAddressingMode
+ mcast = GMetric.UDPAddressingMode.getModeForAddress(host);
+ boolean ganglia31 = conf.getBoolean(METRICS_GANGLIA_VERSION_31, true);
+
+ final GMetric ganglia =
+ new GMetric(
+ host,
+ port,
+ mcast,
+ ttl,
+ ganglia31);
+ reporter = GangliaReporter.forRegistry(metrics)
+ .convertRatesTo(TimeUnit.SECONDS)
+ .convertDurationsTo(TimeUnit.MILLISECONDS)
+ .build(ganglia);
+ reporter.start(interval, TimeUnit.SECONDS);
+ }
+ }
+
+ @Override
+ protected void serviceStop() throws Exception {
+ IOUtils.closeStream(reporter);
+ super.serviceStop();
+ }
+
+ public boolean isEnabled() {
+ return reporter != null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-core/src/main/java/org/apache/slider/server/appmaster/management/YarnServiceHealthCheck.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/management/YarnServiceHealthCheck.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/management/YarnServiceHealthCheck.java
new file mode 100644
index 0000000..936563c
--- /dev/null
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/management/YarnServiceHealthCheck.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.slider.server.appmaster.management;
+
+import com.codahale.metrics.health.HealthCheck;
+import org.apache.hadoop.service.Service;
+
+public class YarnServiceHealthCheck extends HealthCheck {
+
+ private final Service service;
+
+ public YarnServiceHealthCheck(Service service) {
+ this.service = service;
+ }
+
+ @Override
+ protected Result check() throws Exception {
+ return service.isInState(Service.STATE.STARTED)
+ ? Result.healthy()
+ : Result.unhealthy("Service is not running: %s", service);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java
index 348a063..ddba5e2 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java
@@ -18,7 +18,6 @@
package org.apache.slider.server.appmaster.state;
-import com.codahale.metrics.MetricRegistry;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import org.apache.hadoop.conf.Configuration;
@@ -61,6 +60,7 @@ import org.apache.slider.core.exceptions.SliderInternalStateException;
import org.apache.slider.core.exceptions.TriggerClusterTeardownException;
import org.apache.slider.providers.PlacementPolicy;
import org.apache.slider.providers.ProviderRole;
+import org.apache.slider.server.appmaster.management.MetricsAndMonitoring;
import org.apache.slider.server.appmaster.operations.AbstractRMOperation;
import org.apache.slider.server.appmaster.operations.CancelRequestOperation;
import org.apache.slider.server.appmaster.operations.ContainerReleaseOperation;
@@ -98,6 +98,8 @@ public class AppState {
private final AbstractRecordFactory recordFactory;
+ private final MetricsAndMonitoring metricsAndMonitoring;
+
/**
* Flag set to indicate the application is live -this only happens
* after the buildInstance operation
@@ -262,16 +264,14 @@ public class AppState {
private ContainerReleaseSelector containerReleaseSelector;
- private MetricRegistry metrics;
-
/**
* Create an instance
* @param recordFactory factory for YARN records
- * @param metrics metrics registry or null if a new one
+ * @param metricsAndMonitoring metrics and monitoring services
*/
- public AppState(AbstractRecordFactory recordFactory, MetricRegistry metrics) {
+ public AppState(AbstractRecordFactory recordFactory, MetricsAndMonitoring metricsAndMonitoring) {
this.recordFactory = recordFactory;
- this.metrics = metrics;
+ this.metricsAndMonitoring = metricsAndMonitoring;
}
public int getFailedCountainerCount() {
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-core/src/main/java/org/apache/slider/server/appmaster/web/SliderAMWebApp.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/SliderAMWebApp.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/SliderAMWebApp.java
index 18c1a46..f2fc903 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/SliderAMWebApp.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/SliderAMWebApp.java
@@ -16,6 +16,7 @@
*/
package org.apache.slider.server.appmaster.web;
+import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.servlets.HealthCheckServlet;
import com.codahale.metrics.servlets.MetricsServlet;
import com.codahale.metrics.servlets.PingServlet;
@@ -25,10 +26,10 @@ import com.sun.jersey.api.container.filter.GZIPContentEncodingFilter;
import com.sun.jersey.api.core.ResourceConfig;
import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
import com.sun.jersey.spi.container.servlet.ServletContainer;
-import org.apache.hadoop.registry.client.api.RegistryOperations;
import org.apache.hadoop.yarn.webapp.Dispatcher;
import org.apache.hadoop.yarn.webapp.GenericExceptionHandler;
import org.apache.hadoop.yarn.webapp.WebApp;
+import org.apache.slider.server.appmaster.management.MetricsAndMonitoring;
import org.apache.slider.server.appmaster.web.rest.AMWadlGeneratorConfig;
import org.apache.slider.server.appmaster.web.rest.AMWebServices;
import static org.apache.slider.server.appmaster.web.rest.RestPaths.*;
@@ -82,10 +83,12 @@ public class SliderAMWebApp extends WebApp {
}
// metrics
-// serve(SYSTEM_HEALTHCHECK).with(new HealthCheckServlet());
- serve(SYSTEM_METRICS).with(new MetricsServlet(webAppApi.getMetrics()));
-// serve(SYSTEM_PING).with(PingServlet.class);
-// serve(SYSTEM_THREADS).with(ThreadDumpServlet.class);
+ MetricsAndMonitoring monitoring =
+ webAppApi.getMetricsAndMonitoring();
+ serve(SYSTEM_HEALTHCHECK).with(new HealthCheckServlet(monitoring.getHealth()));
+ serve(SYSTEM_METRICS).with(new MetricsServlet(monitoring.getMetrics()));
+ serve(SYSTEM_PING).with(new PingServlet());
+ serve(SYSTEM_THREADS).with(new ThreadDumpServlet());
String regex = "(?!/ws)";
serveRegex(regex).with(SliderDefaultWrapperServlet.class);
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApi.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApi.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApi.java
index 43f8cf6..6aa24c4 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApi.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApi.java
@@ -16,10 +16,10 @@
*/
package org.apache.slider.server.appmaster.web;
-import com.codahale.metrics.MetricRegistry;
import org.apache.hadoop.registry.client.api.RegistryOperations;
import org.apache.slider.api.SliderClusterProtocol;
import org.apache.slider.providers.ProviderService;
+import org.apache.slider.server.appmaster.management.MetricsAndMonitoring;
import org.apache.slider.server.appmaster.state.AppState;
import org.apache.slider.server.appmaster.state.RoleStatus;
import org.apache.slider.server.appmaster.state.StateAccessForProviders;
@@ -68,5 +68,5 @@ public interface WebAppApi {
RegistryOperations getRegistryOperations();
- MetricRegistry getMetrics();
+ MetricsAndMonitoring getMetricsAndMonitoring();
}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApiImpl.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApiImpl.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApiImpl.java
index 81e6564..36d4a8f 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApiImpl.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApiImpl.java
@@ -16,10 +16,10 @@
*/
package org.apache.slider.server.appmaster.web;
-import com.codahale.metrics.MetricRegistry;
import org.apache.hadoop.registry.client.api.RegistryOperations;
import org.apache.slider.api.SliderClusterProtocol;
import org.apache.slider.providers.ProviderService;
+import org.apache.slider.server.appmaster.management.MetricsAndMonitoring;
import org.apache.slider.server.appmaster.state.RoleStatus;
import org.apache.slider.server.appmaster.state.StateAccessForProviders;
import org.apache.slider.server.appmaster.web.rest.agent.AgentRestOperations;
@@ -44,14 +44,14 @@ public class WebAppApiImpl implements WebAppApi {
protected final ProviderService provider;
protected final CertificateManager certificateManager;
private final RegistryOperations registryOperations;
- private final MetricRegistry metrics;
+ private final MetricsAndMonitoring metricsAndMonitoring;
public WebAppApiImpl(SliderClusterProtocol clusterProto,
StateAccessForProviders appState,
ProviderService provider,
CertificateManager certificateManager,
RegistryOperations registryOperations,
- MetricRegistry metrics) {
+ MetricsAndMonitoring metricsAndMonitoring) {
this.registryOperations = registryOperations;
checkNotNull(clusterProto);
checkNotNull(appState);
@@ -61,7 +61,7 @@ public class WebAppApiImpl implements WebAppApi {
this.appState = appState;
this.provider = provider;
this.certificateManager = certificateManager;
- this.metrics = metrics;
+ this.metricsAndMonitoring = metricsAndMonitoring;
}
@Override
@@ -106,7 +106,7 @@ public class WebAppApiImpl implements WebAppApi {
}
@Override
- public MetricRegistry getMetrics() {
- return metrics;
+ public MetricsAndMonitoring getMetricsAndMonitoring() {
+ return metricsAndMonitoring;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/RestPaths.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/RestPaths.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/RestPaths.java
index 75788f9..9efd93b 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/RestPaths.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/RestPaths.java
@@ -65,7 +65,7 @@ public class RestPaths {
public static final String SLIDER_CLASSPATH = "classpath";
public static final String SYSTEM = "/system";
- public static final String SYSTEM_HEALTHCHECK = SYSTEM + "/healthcheck";
+ public static final String SYSTEM_HEALTHCHECK = SYSTEM + "/health";
public static final String SYSTEM_METRICS = SYSTEM + "/metrics";
public static final String SYSTEM_PING = SYSTEM + "/ping";
public static final String SYSTEM_THREADS = SYSTEM + "/threads";
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentWebApp.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentWebApp.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentWebApp.java
index f8d7b88..f9ea06d 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentWebApp.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/agent/AgentWebApp.java
@@ -115,7 +115,6 @@ public class AgentWebApp implements Closeable {
AgentWebApp webApp = new AgentWebApp();
webApp.setPort(getConnectorPort(agentServer, 0));
webApp.setSecuredPort(getConnectorPort(agentServer, 1));
-
return webApp;
}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-core/src/main/java/org/apache/slider/server/appmaster/web/view/NavBlock.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/view/NavBlock.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/view/NavBlock.java
index d367d18..cf5e3ae 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/view/NavBlock.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/view/NavBlock.java
@@ -18,6 +18,7 @@ package org.apache.slider.server.appmaster.web.view;
import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
import org.apache.slider.server.appmaster.web.SliderAMWebApp;
+import org.apache.slider.server.appmaster.web.rest.RestPaths;
/**
*
@@ -32,6 +33,15 @@ public class NavBlock extends HtmlBlock {
ul().
li().a(this.prefix(), "Overview")._().
li().a(this.prefix() + SliderAMWebApp.CONTAINER_STATS, "Statistics")._().
- li().a(this.prefix() + SliderAMWebApp.CLUSTER_SPEC, "Specification")._()._()._();
+ li().a(this.prefix() + SliderAMWebApp.CLUSTER_SPEC, "Specification")._().
+ li().a(rootPath(RestPaths.SYSTEM_METRICS), "Metrics")._().
+ li().a(rootPath(RestPaths.SYSTEM_HEALTHCHECK), "Health")._().
+ li().a(rootPath(RestPaths.SYSTEM_THREADS), "Threads")._()
+ ._()
+ ._();
+ }
+
+ private String rootPath(String absolutePath) {
+ return root_url(absolutePath);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-core/src/main/java/org/apache/slider/server/services/utility/MetricsBindingService.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/services/utility/MetricsBindingService.java b/slider-core/src/main/java/org/apache/slider/server/services/utility/MetricsBindingService.java
deleted file mode 100644
index afd2c1a..0000000
--- a/slider-core/src/main/java/org/apache/slider/server/services/utility/MetricsBindingService.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.slider.server.services.utility;
-
-import com.codahale.metrics.MetricRegistry;
-import com.codahale.metrics.ScheduledReporter;
-import com.codahale.metrics.ganglia.GangliaReporter;
-import info.ganglia.gmetric4j.gmetric.GMetric;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.io.IOUtils;
-import org.apache.hadoop.service.AbstractService;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * YARN service which hooks up Codahale metrics to
- * Ganglia (if enabled)
- */
-public class MetricsBindingService extends AbstractService {
-
- /**
- * {@value}
- */
- public static final String METRICS_GANGLIA_ENABLED =
- "metrics.ganglia.enabled";
- /**
- * {@value}
- */
- public static final String METRICS_GANGLIA_HOST = "metrics.ganglia.host";
-
- /**
- * {@value}
- */
- public static final String METRICS_GANGLIA_PORT = "metrics.ganglia.port";
-
- /**
- * {@value}
- */
- public static final String METRICS_GANGLIA_VERSION_31 = "metrics.ganglia.version.31";
-
- /**
- * {@value}
- */
- public static final String METRICS_GANGLIA_REPORT_INTERVAL = "metrics.ganglia.report.interval";
-
- /**
- * {@value}
- */
- public static final int DEFAULT_GANGLIA_PORT = 8649;
-
- private final MetricRegistry metrics;
- private ScheduledReporter reporter;
-
- public MetricsBindingService(String name,
- MetricRegistry metrics) {
- super(name);
- this.metrics = metrics;
- }
-
- /**
- * Instantiate...create a metric registry in the process
- * @param name service name
- */
- public MetricsBindingService(String name) {
- this(name, new MetricRegistry());
- }
-
- public MetricRegistry getMetrics() {
- return metrics;
- }
-
- @Override
- protected void serviceStart() throws Exception {
- super.serviceStart();
- Configuration conf = getConfig();
- boolean enabled = conf.getBoolean(METRICS_GANGLIA_ENABLED, false);
-
- if (enabled) {
- String host = conf.getTrimmed(METRICS_GANGLIA_HOST, "");
- int port = conf.getInt(METRICS_GANGLIA_PORT, DEFAULT_GANGLIA_PORT);
- int interval = conf.getInt(METRICS_GANGLIA_REPORT_INTERVAL, 60);
- int ttl = 1;
- GMetric.UDPAddressingMode
- mcast = GMetric.UDPAddressingMode.getModeForAddress(host);
- boolean ganglia31 = conf.getBoolean(METRICS_GANGLIA_VERSION_31, true);
-
- final GMetric ganglia =
- new GMetric(
- host,
- port,
- mcast,
- ttl,
- ganglia31);
- reporter = GangliaReporter.forRegistry(metrics)
- .convertRatesTo(TimeUnit.SECONDS)
- .convertDurationsTo(TimeUnit.MILLISECONDS)
- .build(ganglia);
- reporter.start(interval, TimeUnit.SECONDS);
- }
- }
-
- @Override
- protected void serviceStop() throws Exception {
- IOUtils.closeStream(reporter);
- super.serviceStop();
- }
-
- public boolean isEnabled() {
- return reporter != null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentWeb.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentWeb.groovy b/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentWeb.groovy
index 458c921..e868b8f 100644
--- a/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentWeb.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentWeb.groovy
@@ -71,8 +71,9 @@ class TestStandaloneAgentWeb extends AgentMiniClusterTestBase {
GET(appmaster)
-// GET(appmaster, RestPaths.SYSTEM_HEALTHCHECK)
-// GET(appmaster, RestPaths.SYSTEM_PING)
+ log.info GET(appmaster, RestPaths.SYSTEM_PING)
+ log.info GET(appmaster, RestPaths.SYSTEM_THREADS)
+ log.info GET(appmaster, RestPaths.SYSTEM_HEALTHCHECK)
}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockAppState.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockAppState.groovy b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockAppState.groovy
index 7abb123..2cc13c2 100644
--- a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockAppState.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockAppState.groovy
@@ -17,8 +17,8 @@
package org.apache.slider.server.appmaster.model.mock
-import com.codahale.metrics.MetricRegistry
import org.apache.slider.providers.ProviderRole
+import org.apache.slider.server.appmaster.management.MetricsAndMonitoring
import org.apache.slider.server.appmaster.state.AbstractRecordFactory
import org.apache.slider.server.appmaster.state.AppState
@@ -28,7 +28,7 @@ import org.apache.slider.server.appmaster.state.AppState
class MockAppState extends AppState {
public MockAppState(AbstractRecordFactory recordFactory) {
- super(recordFactory, new MetricRegistry());
+ super(recordFactory, new MetricsAndMonitoring());
}
long time = 0;
@@ -37,7 +37,7 @@ class MockAppState extends AppState {
* Instance with a mock record factory
*/
public MockAppState() {
- super(new MockRecordFactory(), new MetricRegistry());
+ super(new MockRecordFactory(), new MetricsAndMonitoring());
}
public Map<String, ProviderRole> getRoleMap() {
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/monkey/TestMockMonkey.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/monkey/TestMockMonkey.groovy b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/monkey/TestMockMonkey.groovy
index e4a42fc..82192b9 100644
--- a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/monkey/TestMockMonkey.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/monkey/TestMockMonkey.groovy
@@ -54,7 +54,7 @@ class TestMockMonkey extends BaseMockAppStateTest {
def configuration = new YarnConfiguration()
queues = new QueueService();
queues.init(configuration)
- monkey = new ChaosMonkeyService(metricRegistry, queues)
+ monkey = new ChaosMonkeyService(metrics.metrics, queues)
monkey.init(configuration)
}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestContainerStatsBlock.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestContainerStatsBlock.groovy b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestContainerStatsBlock.groovy
index 4f1d52d..669c00e 100644
--- a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestContainerStatsBlock.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestContainerStatsBlock.groovy
@@ -64,7 +64,7 @@ public class TestContainerStatsBlock extends BaseMockAppStateTest {
providerAppState,
providerService,
null,
- null, metricRegistry);
+ null, metrics);
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestIndexBlock.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestIndexBlock.groovy b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestIndexBlock.groovy
index ff24b82..82e36f5 100644
--- a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestIndexBlock.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestIndexBlock.groovy
@@ -56,7 +56,7 @@ public class TestIndexBlock extends BaseMockAppStateTest {
providerAppState,
providerService,
null,
- null, metricRegistry);
+ null, metrics);
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-core/src/test/groovy/org/apache/slider/test/SliderTestBase.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestBase.groovy b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestBase.groovy
index e0798a4..7be7869 100644
--- a/slider-core/src/test/groovy/org/apache/slider/test/SliderTestBase.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/test/SliderTestBase.groovy
@@ -22,6 +22,7 @@ import com.codahale.metrics.MetricRegistry
import groovy.transform.CompileStatic
import org.apache.hadoop.fs.FileUtil
import org.apache.slider.common.SliderXMLConfKeysForTesting
+import org.apache.slider.server.appmaster.management.MetricsAndMonitoring
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Rule
@@ -41,7 +42,7 @@ public abstract class SliderTestBase extends SliderTestUtils {
/**
* Singleton metric registry
*/
- public static final MetricRegistry metricRegistry = new MetricRegistry()
+ public static final MetricsAndMonitoring metrics = new MetricsAndMonitoring()
@Rule
public TestName methodName = new TestName();
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/agent/TestAMAgentWebServices.java
----------------------------------------------------------------------
diff --git a/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/agent/TestAMAgentWebServices.java b/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/agent/TestAMAgentWebServices.java
index db8223a..f2a7569 100644
--- a/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/agent/TestAMAgentWebServices.java
+++ b/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/agent/TestAMAgentWebServices.java
@@ -18,7 +18,6 @@
package org.apache.slider.server.appmaster.web.rest.agent;
-import com.codahale.metrics.MetricRegistry;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
@@ -34,6 +33,7 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.slider.common.SliderKeys;
import org.apache.slider.common.tools.SliderUtils;
import org.apache.slider.core.conf.MapOperations;
+import org.apache.slider.server.appmaster.management.MetricsAndMonitoring;
import org.apache.slider.server.appmaster.model.mock.MockFactory;
import org.apache.slider.server.appmaster.model.mock.MockProviderService;
import org.apache.slider.server.appmaster.model.mock.MockRecordFactory;
@@ -122,7 +122,7 @@ public class TestAMAgentWebServices {
historyPath =
new org.apache.hadoop.fs.Path(historyWorkDir.toURI());
fs.delete(historyPath, true);
- appState = new AppState(new MockRecordFactory(), new MetricRegistry());
+ appState = new AppState(new MockRecordFactory(), new MetricsAndMonitoring());
appState.setContainerLimits(RM_MAX_RAM, RM_MAX_CORES);
appState.buildInstance(
factory.newInstanceDefinition(0, 0, 0),
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/management/TestAMManagementWebServices.java
----------------------------------------------------------------------
diff --git a/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/management/TestAMManagementWebServices.java b/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/management/TestAMManagementWebServices.java
index 9bfcd25..0776afc 100644
--- a/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/management/TestAMManagementWebServices.java
+++ b/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/management/TestAMManagementWebServices.java
@@ -18,7 +18,6 @@
package org.apache.slider.server.appmaster.web.rest.management;
-import com.codahale.metrics.MetricRegistry;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
@@ -40,6 +39,7 @@ import org.apache.slider.core.conf.ConfTree;
import org.apache.slider.core.exceptions.BadClusterStateException;
import org.apache.slider.core.exceptions.BadConfigException;
import org.apache.slider.core.persist.JsonSerDeser;
+import org.apache.slider.server.appmaster.management.MetricsAndMonitoring;
import org.apache.slider.server.appmaster.model.mock.MockFactory;
import org.apache.slider.server.appmaster.model.mock.MockProviderService;
import org.apache.slider.server.appmaster.model.mock.MockRecordFactory;
@@ -168,7 +168,7 @@ public class TestAMManagementWebServices extends JerseyTest {
historyPath =
new org.apache.hadoop.fs.Path(historyWorkDir.toURI());
fs.delete(historyPath, true);
- appState = new AppState(new MockRecordFactory(), new MetricRegistry());
+ appState = new AppState(new MockRecordFactory(), new MetricsAndMonitoring());
appState.setContainerLimits(RM_MAX_RAM, RM_MAX_CORES);
appState.buildInstance(
factory.newInstanceDefinition(0, 0, 0),
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy b/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy
index b3959af..4757d77 100644
--- a/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy
+++ b/slider-funtest/src/main/groovy/org/apache/slider/funtest/framework/CommandTestBase.groovy
@@ -1225,6 +1225,7 @@ abstract class CommandTestBase extends SliderTestUtils {
fail(errorText + "\n" + outfile.text)
}
}
+
/**
* Is the registry accessible for an application?
* @param args argument map containing <code>"application"</code>
@@ -1262,4 +1263,54 @@ abstract class CommandTestBase extends SliderTestUtils {
assert f.exists()
return Outcome.fromBool(f.text.contains(text))
}
+
+ /**
+ * Probe callback for is the the app root web page up
+ * @param args map where 'applicationId' must be set
+ * @return the outcome
+ */
+ protected static Outcome isRootWebPageUp(
+ Map<String, String> args) {
+ assert args['applicationId'] != null
+ String applicationId = args['applicationId'];
+ def sar = lookupApplication(applicationId)
+ assert sar != null;
+ if (!sar.url) {
+ return Outcome.Retry;
+ }
+ try {
+ GET(sar.url)
+ return Outcome.Success
+ } catch (Exception e) {
+ return Outcome.Retry;
+ }
+ }
+
+ /**
+ * Await for the root web page of an app to come up
+ * @param applicationId app ID
+ * @param launch_timeout launch timeout
+ */
+ void expectRootWebPageUp(
+ String applicationId,
+ int launch_timeout) {
+
+ repeatUntilSuccess(
+ "await root web page",
+ this.&isRootWebPageUp,
+ launch_timeout,
+ PROBE_SLEEP_TIME,
+ [
+ applicationId: applicationId
+ ],
+ false,
+ "web page not up") {
+
+ def sar = lookupApplication(applicationId)
+ assert sar != null;
+ assert sar.url
+ // this is the final failure cause
+ GET(sar.url)
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentWebPagesIT.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentWebPagesIT.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentWebPagesIT.groovy
new file mode 100644
index 0000000..416fa11
--- /dev/null
+++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AgentWebPagesIT.groovy
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.slider.funtest.lifecycle
+
+import groovy.transform.CompileStatic
+import groovy.util.logging.Slf4j
+import org.apache.hadoop.registry.client.binding.RegistryUtils
+import org.apache.hadoop.registry.client.types.Endpoint
+import org.apache.hadoop.registry.client.types.ServiceRecord
+import org.apache.hadoop.yarn.api.records.YarnApplicationState
+import org.apache.slider.common.SliderExitCodes
+import org.apache.slider.common.SliderKeys
+import org.apache.slider.common.params.Arguments
+import org.apache.slider.common.params.SliderActions
+import org.apache.slider.funtest.framework.AgentCommandTestBase
+import org.apache.slider.funtest.framework.FuntestProperties
+import org.apache.slider.funtest.framework.SliderShell
+import org.apache.slider.server.appmaster.web.rest.RestPaths
+import org.apache.slider.test.Outcome
+import org.junit.After
+import org.junit.Before
+import org.junit.Test
+
+import static org.apache.slider.core.registry.info.CustomRegistryConstants.*
+
+@CompileStatic
+@Slf4j
+public class AgentWebPagesIT extends AgentCommandTestBase
+ implements FuntestProperties, Arguments, SliderExitCodes, SliderActions {
+
+
+ static String CLUSTER = "test-agent-web"
+
+ static String APP_RESOURCE2 = "../slider-core/src/test/app_packages/test_command_log/resources_no_role.json"
+
+
+ @Before
+ public void prepareCluster() {
+ setupCluster(CLUSTER)
+ }
+
+ @After
+ public void destroyCluster() {
+ cleanup(CLUSTER)
+ }
+
+ @Test
+ public void testAgentWeb() throws Throwable {
+ describe("Create a 0-role cluster and make web queries against it")
+ def clusterpath = buildClusterPath(CLUSTER)
+ File launchReportFile = createTempJsonFile();
+ SliderShell shell = createTemplatedSliderApplication(CLUSTER,
+ APP_TEMPLATE,
+ APP_RESOURCE2,
+ [],
+ launchReportFile)
+
+ logShell(shell)
+
+ def appId = ensureYarnApplicationIsUp(launchReportFile)
+ assert appId
+ expectRootWebPageUp(appId, instanceLaunchTime)
+ File liveReportFile = createTempJsonFile();
+
+ lookup(appId,liveReportFile)
+ def report = loadAppReport(liveReportFile)
+ assert report.url
+
+ def root = report.url
+ log.info GET(root, RestPaths.SYSTEM_METRICS)
+ GET(root, RestPaths.SYSTEM_THREADS)
+ log.info GET(root, RestPaths.SYSTEM_HEALTHCHECK)
+ log.info GET(root, RestPaths.SYSTEM_PING)
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/524446db/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AppsThroughAgentDemo.groovy
----------------------------------------------------------------------
diff --git a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AppsThroughAgentDemo.groovy b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AppsThroughAgentDemo.groovy
index 0f940cf..3dd7857 100644
--- a/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AppsThroughAgentDemo.groovy
+++ b/slider-funtest/src/test/groovy/org/apache/slider/funtest/lifecycle/AppsThroughAgentDemo.groovy
@@ -39,7 +39,7 @@ public class AppsThroughAgentDemo extends AppsThroughAgentIT {
@Override
void destroyCluster() {
- super.destroyCluster()
+// super.destroyCluster()
}
}
[4/5] incubator-slider git commit: SLIDER-670 NPE in
RMAuthenticationFilter chain, missing httpclient method
Posted by st...@apache.org.
SLIDER-670 NPE in RMAuthenticationFilter chain, missing httpclient method
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/00eca8fc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/00eca8fc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/00eca8fc
Branch: refs/heads/develop
Commit: 00eca8fc98bd151cb551354c518376f552806a36
Parents: 867b67d
Author: Steve Loughran <st...@apache.org>
Authored: Sat Nov 22 18:46:53 2014 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Tue Nov 25 19:20:47 2014 +0000
----------------------------------------------------------------------
pom.xml | 18 +++++++++++++++++-
slider-core/pom.xml | 11 ++++++++++-
.../standalone/TestStandaloneAgentWeb.groovy | 2 +-
3 files changed, 28 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/00eca8fc/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 03a1907..7f73bbd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -509,6 +509,10 @@
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly2</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>net.java.dev.jets3t</groupId>
+ <artifactId>jets3t</artifactId>
+ </exclusion>
</exclusions>
</dependency>
@@ -613,7 +617,19 @@
</exclusion>
</exclusions>
</dependency>
-
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.2.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>4.2.5</version>
+ </dependency>
+
<!-- ======================================================== -->
<!-- HBASE -->
<!-- ======================================================== -->
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/00eca8fc/slider-core/pom.xml
----------------------------------------------------------------------
diff --git a/slider-core/pom.xml b/slider-core/pom.xml
index 6bb7c09..a36e915 100644
--- a/slider-core/pom.xml
+++ b/slider-core/pom.xml
@@ -282,7 +282,6 @@
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -320,6 +319,16 @@
</dependency>
<dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/00eca8fc/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentWeb.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentWeb.groovy b/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentWeb.groovy
index 717d98f..458c921 100644
--- a/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentWeb.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentWeb.groovy
@@ -69,7 +69,7 @@ class TestStandaloneAgentWeb extends AgentMiniClusterTestBase {
def appmaster = report.trackingUrl
-// GET(appmaster)
+ GET(appmaster)
// GET(appmaster, RestPaths.SYSTEM_HEALTHCHECK)
// GET(appmaster, RestPaths.SYSTEM_PING)
[3/5] incubator-slider git commit: SLIDER-319 hooking up codahale
metrics to source and in to web
Posted by st...@apache.org.
SLIDER-319 hooking up codahale metrics to source and in to web
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/867b67d4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/867b67d4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/867b67d4
Branch: refs/heads/develop
Commit: 867b67d4e1b80ad1072a9347b310dc1f3d1d576b
Parents: f0a30fd
Author: Steve Loughran <st...@apache.org>
Authored: Fri Nov 21 19:05:53 2014 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Tue Nov 25 19:20:47 2014 +0000
----------------------------------------------------------------------
pom.xml | 12 ++
slider-core/pom.xml | 10 ++
.../core/registry/retrieve/AMWebClient.java | 129 +++++++++++++++++++
.../registry/retrieve/RegistryRetriever.java | 87 +------------
.../server/appmaster/SliderAppMaster.java | 35 ++---
.../server/appmaster/monkey/ChaosEntry.java | 2 -
.../slider/server/appmaster/state/AppState.java | 11 +-
.../server/appmaster/web/SliderAMWebApp.java | 21 ++-
.../slider/server/appmaster/web/WebAppApi.java | 15 ++-
.../server/appmaster/web/WebAppApiImpl.java | 25 ++--
.../server/appmaster/web/rest/RestPaths.java | 5 +
.../services/utility/MetricsBindingService.java | 128 ++++++++++++++++++
.../standalone/TestStandaloneAgentAM.groovy | 14 +-
.../standalone/TestStandaloneAgentWeb.groovy | 80 ++++++++++++
.../appmaster/model/mock/MockAppState.groovy | 5 +-
.../view/TestClusterSpecificationBlock.groovy | 2 +-
.../web/view/TestContainerStatsBlock.groovy | 2 +-
.../appmaster/web/view/TestIndexBlock.groovy | 2 +-
.../web/rest/agent/TestAMAgentWebServices.java | 5 +-
.../management/TestAMManagementWebServices.java | 5 +-
20 files changed, 450 insertions(+), 145 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 7fb955b..03a1907 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1224,6 +1224,18 @@
<version>${metrics.version}</version>
</dependency>
+ <dependency>
+ <groupId>com.codahale.metrics</groupId>
+ <artifactId>metrics-ganglia</artifactId>
+ <version>${metrics.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.codahale.metrics</groupId>
+ <artifactId>metrics-servlets</artifactId>
+ <version>${metrics.version}</version>
+ </dependency>
+
<!-- ======================================================== -->
<!-- Mocking -->
<!-- ======================================================== -->
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/slider-core/pom.xml
----------------------------------------------------------------------
diff --git a/slider-core/pom.xml b/slider-core/pom.xml
index 2c3aaa6..6bb7c09 100644
--- a/slider-core/pom.xml
+++ b/slider-core/pom.xml
@@ -333,6 +333,16 @@
<groupId>com.codahale.metrics</groupId>
<artifactId>metrics-core</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>com.codahale.metrics</groupId>
+ <artifactId>metrics-ganglia</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.codahale.metrics</groupId>
+ <artifactId>metrics-servlets</artifactId>
+ </dependency>
<!-- ======================================================== -->
<!-- service registry -->
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/slider-core/src/main/java/org/apache/slider/core/registry/retrieve/AMWebClient.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/registry/retrieve/AMWebClient.java b/slider-core/src/main/java/org/apache/slider/core/registry/retrieve/AMWebClient.java
new file mode 100644
index 0000000..24b1525
--- /dev/null
+++ b/slider-core/src/main/java/org/apache/slider/core/registry/retrieve/AMWebClient.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.slider.core.registry.retrieve;
+
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+import com.sun.jersey.api.json.JSONConfiguration;
+import com.sun.jersey.client.urlconnection.HttpURLConnectionFactory;
+import com.sun.jersey.client.urlconnection.URLConnectionClientHandler;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.security.ssl.SSLFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLSocketFactory;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URI;
+import java.net.URL;
+
+/**
+ * Class to retrieve artifacts from the AM's web site. This sets up
+ * the redirection and security logic properly
+ */
+public class AMWebClient {
+ private static final Client client;
+ private static final Logger
+ log = LoggerFactory.getLogger(AMWebClient.class);
+
+
+ static {
+ ClientConfig clientConfig = new DefaultClientConfig();
+ clientConfig.getFeatures().put(
+ JSONConfiguration.FEATURE_POJO_MAPPING,
+ Boolean.TRUE);
+ clientConfig.getProperties().put(
+ URLConnectionClientHandler.PROPERTY_HTTP_URL_CONNECTION_SET_METHOD_WORKAROUND,
+ true);
+ URLConnectionClientHandler handler = getUrlConnectionClientHandler();
+ client = new Client(handler, clientConfig);
+ client.setFollowRedirects(true);
+ }
+
+ /**
+ * Get the Jersey Client
+ * @return
+ */
+ public static Client getClient() {
+ return client;
+ }
+
+ private static URLConnectionClientHandler getUrlConnectionClientHandler() {
+ return new URLConnectionClientHandler(new HttpURLConnectionFactory() {
+ @Override
+ public HttpURLConnection getHttpURLConnection(URL url)
+ throws IOException {
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ if (connection.getResponseCode() == HttpURLConnection.HTTP_MOVED_TEMP) {
+ // is a redirect - are we changing schemes?
+ String redirectLocation = connection.getHeaderField(HttpHeaders.LOCATION);
+ String originalScheme = url.getProtocol();
+ String redirectScheme = URI.create(redirectLocation).getScheme();
+ if (!originalScheme.equals(redirectScheme)) {
+ // need to fake it out by doing redirect ourselves
+ log.info("Protocol change during redirect. Redirecting {} to URL {}",
+ url, redirectLocation);
+ URL redirectURL = new URL(redirectLocation);
+ connection = (HttpURLConnection) redirectURL.openConnection();
+ }
+ }
+ if (connection instanceof HttpsURLConnection) {
+ log.debug("Attempting to configure HTTPS connection using client "
+ + "configuration");
+ final SSLFactory factory;
+ final SSLSocketFactory sf;
+ final HostnameVerifier hv;
+
+ try {
+ HttpsURLConnection c = (HttpsURLConnection) connection;
+ factory = new SSLFactory(SSLFactory.Mode.CLIENT, new Configuration());
+ factory.init();
+ sf = factory.createSSLSocketFactory();
+ hv = factory.getHostnameVerifier();
+ c.setSSLSocketFactory(sf);
+ c.setHostnameVerifier(hv);
+ } catch (Exception e) {
+ log.info("Unable to configure HTTPS connection from "
+ + "configuration. Leveraging JDK properties.");
+ }
+
+ }
+ return connection;
+ }
+ });
+ }
+
+ public WebResource resource(String url) {
+ WebResource resource = client.resource(url);
+ return resource;
+ }
+
+ public WebResource jsonResource(String url) {
+ WebResource resource = resource(url);
+ resource.type(MediaType.APPLICATION_JSON);
+ return resource;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/slider-core/src/main/java/org/apache/slider/core/registry/retrieve/RegistryRetriever.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/core/registry/retrieve/RegistryRetriever.java b/slider-core/src/main/java/org/apache/slider/core/registry/retrieve/RegistryRetriever.java
index 1194270..0d32807 100644
--- a/slider-core/src/main/java/org/apache/slider/core/registry/retrieve/RegistryRetriever.java
+++ b/slider-core/src/main/java/org/apache/slider/core/registry/retrieve/RegistryRetriever.java
@@ -19,20 +19,12 @@
package org.apache.slider.core.registry.retrieve;
import com.beust.jcommander.Strings;
-import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.UniformInterfaceException;
import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.api.client.config.ClientConfig;
-import com.sun.jersey.api.client.config.DefaultClientConfig;
-import com.sun.jersey.api.json.JSONConfiguration;
-import com.sun.jersey.client.urlconnection.HttpURLConnectionFactory;
-import com.sun.jersey.client.urlconnection.URLConnectionClientHandler;
-import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.registry.client.binding.RegistryTypeUtils;
import org.apache.hadoop.registry.client.exceptions.RegistryIOException;
import org.apache.hadoop.registry.client.types.Endpoint;
import org.apache.hadoop.registry.client.types.ServiceRecord;
-import org.apache.hadoop.security.ssl.SSLFactory;
import org.apache.slider.common.tools.SliderUtils;
import org.apache.slider.core.exceptions.ExceptionConverter;
import org.apache.slider.core.registry.docstore.PublishedConfigSet;
@@ -43,17 +35,8 @@ import org.apache.slider.core.registry.info.CustomRegistryConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLSocketFactory;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
import java.io.FileNotFoundException;
import java.io.IOException;
-import java.net.HttpURLConnection;
-import java.net.URI;
-import java.net.URL;
-import java.security.GeneralSecurityException;
import java.util.List;
/**
@@ -61,71 +44,13 @@ import java.util.List;
* This hides the HTTP operations that take place to
* get the actual content
*/
-public class RegistryRetriever {
+public class RegistryRetriever extends AMWebClient {
private static final Logger log = LoggerFactory.getLogger(RegistryRetriever.class);
private final String externalConfigurationURL;
private final String internalConfigurationURL;
private final String externalExportsURL;
private final String internalExportsURL;
- private static final Client jerseyClient;
-
- static {
- ClientConfig clientConfig = new DefaultClientConfig();
- clientConfig.getFeatures().put(
- JSONConfiguration.FEATURE_POJO_MAPPING,
- Boolean.TRUE);
- clientConfig.getProperties().put(
- URLConnectionClientHandler.PROPERTY_HTTP_URL_CONNECTION_SET_METHOD_WORKAROUND, true);
- URLConnectionClientHandler handler = getUrlConnectionClientHandler();
- jerseyClient = new Client(handler, clientConfig);
- jerseyClient.setFollowRedirects(true);
- }
-
- private static URLConnectionClientHandler getUrlConnectionClientHandler() {
- return new URLConnectionClientHandler(new HttpURLConnectionFactory() {
- @Override
- public HttpURLConnection getHttpURLConnection(URL url)
- throws IOException {
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- if (connection.getResponseCode() == HttpURLConnection.HTTP_MOVED_TEMP) {
- // is a redirect - are we changing schemes?
- String redirectLocation = connection.getHeaderField(HttpHeaders.LOCATION);
- String originalScheme = url.getProtocol();
- String redirectScheme = URI.create(redirectLocation).getScheme();
- if (!originalScheme.equals(redirectScheme)) {
- // need to fake it out by doing redirect ourselves
- log.info("Protocol change during redirect. Redirecting {} to URL {}",
- url, redirectLocation);
- URL redirectURL = new URL(redirectLocation);
- connection = (HttpURLConnection) redirectURL.openConnection();
- }
- }
- if (connection instanceof HttpsURLConnection) {
- log.debug("Attempting to configure HTTPS connection using client "
- + "configuration");
- final SSLFactory factory;
- final SSLSocketFactory sf;
- final HostnameVerifier hv;
-
- try {
- HttpsURLConnection c = (HttpsURLConnection) connection;
- factory = new SSLFactory(SSLFactory.Mode.CLIENT, new Configuration());
- factory.init();
- sf = factory.createSSLSocketFactory();
- hv = factory.getHostnameVerifier();
- c.setSSLSocketFactory(sf);
- c.setHostnameVerifier(hv);
- } catch (Exception e) {
- log.info("Unable to configure HTTPS connection from "
- + "configuration. Leveraging JDK properties.");
- }
-
- }
- return connection;
- }
- });
- }
public RegistryRetriever(String externalConfigurationURL, String internalConfigurationURL,
String externalExportsURL, String internalExportsURL) {
@@ -255,16 +180,6 @@ public class RegistryRetriever {
}
}
- private WebResource resource(String url) {
- WebResource resource = jerseyClient.resource(url);
- return resource;
- }
-
- private WebResource jsonResource(String url) {
- WebResource resource = resource(url);
- resource.type(MediaType.APPLICATION_JSON);
- return resource;
- }
/**
* Get a complete configuration, with all values
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java
index e26bc3f..9530bc0 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/SliderAppMaster.java
@@ -149,6 +149,7 @@ import org.apache.slider.server.appmaster.web.rest.RestPaths;
import org.apache.slider.server.services.security.CertificateManager;
import org.apache.slider.server.services.security.FsDelegationTokenManager;
import org.apache.slider.server.services.utility.AbstractSliderLaunchedService;
+import org.apache.slider.server.services.utility.MetricsBindingService;
import org.apache.slider.server.services.utility.WebAppService;
import org.apache.slider.server.services.workflow.ServiceThreadFactory;
import org.apache.slider.server.services.workflow.WorkflowExecutorService;
@@ -204,13 +205,6 @@ public class SliderAppMaster extends AbstractSliderLaunchedService
public static final String SERVICE_CLASSNAME =
"org.apache.slider.server.appmaster." + SERVICE_CLASSNAME_SHORT;
-
- /**
- * time to wait from shutdown signal being rx'd to telling
- * the AM: {@value}
- */
- public static final int TERMINATION_SIGNAL_PROPAGATION_DELAY = 1000;
-
public static final int HEARTBEAT_INTERVAL = 1000;
public static final int NUM_RPC_HANDLERS = 5;
@@ -276,7 +270,8 @@ public class SliderAppMaster extends AbstractSliderLaunchedService
* Ongoing state of the cluster: containers, nodes they
* live on, etc.
*/
- private final AppState appState = new AppState(new ProtobufRecordFactory());
+ private final AppState appState = new AppState(new ProtobufRecordFactory(),
+ metrics);
private final ProviderAppState stateForProviders =
new ProviderAppState("undefined", appState);
@@ -447,6 +442,9 @@ public class SliderAppMaster extends AbstractSliderLaunchedService
addService(executorService);
addService(actionQueues);
+
+ addService(new MetricsBindingService("MetricsBindingService",
+ metrics));
//init all child services
super.serviceInit(conf);
}
@@ -705,12 +703,15 @@ public class SliderAppMaster extends AbstractSliderLaunchedService
int port = getPortToRequest(instanceDefinition);
- webApp = new SliderAMWebApp(registryOperations);
+ WebAppApi webAppApi = new WebAppApiImpl(this,
+ stateForProviders,
+ providerService,
+ certificateManager,
+ registryOperations,
+ metrics);
+ webApp = new SliderAMWebApp(webAppApi);
WebApps.$for(SliderAMWebApp.BASE_PATH, WebAppApi.class,
- new WebAppApiImpl(this,
- stateForProviders,
- providerService,
- certificateManager, registryOperations),
+ webAppApi,
RestPaths.WS_CONTEXT)
.withHttpPolicy(serviceConf, HttpConfig.Policy.HTTP_ONLY)
.at(port)
@@ -1000,9 +1001,11 @@ public class SliderAppMaster extends AbstractSliderLaunchedService
// Start up the agent web app and track the URL for it
AgentWebApp agentWebApp = AgentWebApp.$for(AgentWebApp.BASE_PATH,
new WebAppApiImpl(this,
- stateForProviders,
- providerService,
- certificateManager, registryOperations),
+ stateForProviders,
+ providerService,
+ certificateManager,
+ registryOperations,
+ metrics),
RestPaths.AGENT_WS_CONTEXT)
.withComponentConfig(getInstanceDefinition().getAppConfOperations()
.getComponent(SliderKeys.COMPONENT_AM))
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/slider-core/src/main/java/org/apache/slider/server/appmaster/monkey/ChaosEntry.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/monkey/ChaosEntry.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/monkey/ChaosEntry.java
index 87a0aaa..a397e19 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/monkey/ChaosEntry.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/monkey/ChaosEntry.java
@@ -37,7 +37,6 @@ public class ChaosEntry {
public final ChaosTarget target;
public final long probability;
- private final MetricRegistry metrics;
private final Counter invocationCounter;
@@ -57,7 +56,6 @@ public class ChaosEntry {
this.name = name;
this.target = target;
this.probability = probability;
- this.metrics = metrics;
invocationCounter =
metrics.counter(MetricRegistry.name(ChaosEntry.class, name));
}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java
index 9956db2..348a063 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/state/AppState.java
@@ -18,6 +18,7 @@
package org.apache.slider.server.appmaster.state;
+import com.codahale.metrics.MetricRegistry;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import org.apache.hadoop.conf.Configuration;
@@ -261,8 +262,16 @@ public class AppState {
private ContainerReleaseSelector containerReleaseSelector;
- public AppState(AbstractRecordFactory recordFactory) {
+ private MetricRegistry metrics;
+
+ /**
+ * Create an instance
+ * @param recordFactory factory for YARN records
+ * @param metrics metrics registry or null if a new one
+ */
+ public AppState(AbstractRecordFactory recordFactory, MetricRegistry metrics) {
this.recordFactory = recordFactory;
+ this.metrics = metrics;
}
public int getFailedCountainerCount() {
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/slider-core/src/main/java/org/apache/slider/server/appmaster/web/SliderAMWebApp.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/SliderAMWebApp.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/SliderAMWebApp.java
index 7f30440..18c1a46 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/SliderAMWebApp.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/SliderAMWebApp.java
@@ -16,6 +16,10 @@
*/
package org.apache.slider.server.appmaster.web;
+import com.codahale.metrics.servlets.HealthCheckServlet;
+import com.codahale.metrics.servlets.MetricsServlet;
+import com.codahale.metrics.servlets.PingServlet;
+import com.codahale.metrics.servlets.ThreadDumpServlet;
import com.google.common.base.Preconditions;
import com.sun.jersey.api.container.filter.GZIPContentEncodingFilter;
import com.sun.jersey.api.core.ResourceConfig;
@@ -27,6 +31,7 @@ import org.apache.hadoop.yarn.webapp.GenericExceptionHandler;
import org.apache.hadoop.yarn.webapp.WebApp;
import org.apache.slider.server.appmaster.web.rest.AMWadlGeneratorConfig;
import org.apache.slider.server.appmaster.web.rest.AMWebServices;
+import static org.apache.slider.server.appmaster.web.rest.RestPaths.*;
import org.apache.slider.server.appmaster.web.rest.SliderJacksonJaxbJsonProvider;
import java.util.HashMap;
@@ -42,11 +47,11 @@ public class SliderAMWebApp extends WebApp {
public static final String CONTAINER_STATS = "/stats";
public static final String CLUSTER_SPEC = "/spec";
- private final RegistryOperations registry;
+ private final WebAppApi webAppApi;
- public SliderAMWebApp(RegistryOperations registry) {
- Preconditions.checkArgument(registry != null, "registry null");
- this.registry = registry;
+ public SliderAMWebApp(WebAppApi webAppApi) {
+ Preconditions.checkArgument(webAppApi != null, "webAppApi null");
+ this.webAppApi = webAppApi;
}
@Override
@@ -76,8 +81,14 @@ public class SliderAMWebApp extends WebApp {
serve(path).with(Dispatcher.class);
}
+ // metrics
+// serve(SYSTEM_HEALTHCHECK).with(new HealthCheckServlet());
+ serve(SYSTEM_METRICS).with(new MetricsServlet(webAppApi.getMetrics()));
+// serve(SYSTEM_PING).with(PingServlet.class);
+// serve(SYSTEM_THREADS).with(ThreadDumpServlet.class);
+
String regex = "(?!/ws)";
- serveRegex(regex).with(SliderDefaultWrapperServlet.class);
+ serveRegex(regex).with(SliderDefaultWrapperServlet.class);
Map<String, String> params = new HashMap<String, String>();
params.put(ResourceConfig.FEATURE_IMPLICIT_VIEWABLES, "true");
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApi.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApi.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApi.java
index c8c47c9..43f8cf6 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApi.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApi.java
@@ -16,6 +16,7 @@
*/
package org.apache.slider.server.appmaster.web;
+import com.codahale.metrics.MetricRegistry;
import org.apache.hadoop.registry.client.api.RegistryOperations;
import org.apache.slider.api.SliderClusterProtocol;
import org.apache.slider.providers.ProviderService;
@@ -35,35 +36,37 @@ public interface WebAppApi {
/**
* The {@link AppState} for the current cluster
*/
- public StateAccessForProviders getAppState();
+ StateAccessForProviders getAppState();
/**
* The {@link ProviderService} for the current cluster
*/
- public ProviderService getProviderService();
+ ProviderService getProviderService();
/**
* The {@link CertificateManager} for the current cluster
*/
- public CertificateManager getCertificateManager();
+ CertificateManager getCertificateManager();
/**
* The {@link SliderClusterProtocol} for the current cluster
*/
- public SliderClusterProtocol getClusterProtocol();
+ SliderClusterProtocol getClusterProtocol();
/**
* Generate a mapping from role name to its {@link RoleStatus}. Be aware that this
* is a computed value and not just a getter
*/
- public Map<String, RoleStatus> getRoleStatusByName();
+ Map<String, RoleStatus> getRoleStatusByName();
/**
* Returns an interface that can support the agent-based REST operations.
*/
- public AgentRestOperations getAgentRestOperations();
+ AgentRestOperations getAgentRestOperations();
RegistryOperations getRegistryOperations();
+
+ MetricRegistry getMetrics();
}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApiImpl.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApiImpl.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApiImpl.java
index 3b47ed1..81e6564 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApiImpl.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/WebAppApiImpl.java
@@ -16,6 +16,7 @@
*/
package org.apache.slider.server.appmaster.web;
+import com.codahale.metrics.MetricRegistry;
import org.apache.hadoop.registry.client.api.RegistryOperations;
import org.apache.slider.api.SliderClusterProtocol;
import org.apache.slider.providers.ProviderService;
@@ -43,12 +44,14 @@ public class WebAppApiImpl implements WebAppApi {
protected final ProviderService provider;
protected final CertificateManager certificateManager;
private final RegistryOperations registryOperations;
+ private final MetricRegistry metrics;
public WebAppApiImpl(SliderClusterProtocol clusterProto,
StateAccessForProviders appState,
ProviderService provider,
CertificateManager certificateManager,
- RegistryOperations registryOperations) {
+ RegistryOperations registryOperations,
+ MetricRegistry metrics) {
this.registryOperations = registryOperations;
checkNotNull(clusterProto);
checkNotNull(appState);
@@ -58,19 +61,14 @@ public class WebAppApiImpl implements WebAppApi {
this.appState = appState;
this.provider = provider;
this.certificateManager = certificateManager;
+ this.metrics = metrics;
}
- /* (non-Javadoc)
- * @see org.apache.slider.server.appmaster.web.WebAppApi#getAppState()
- */
@Override
public StateAccessForProviders getAppState() {
return appState;
}
- /* (non-Javadoc)
- * @see org.apache.slider.server.appmaster.web.WebAppApi#getProviderService()
- */
@Override
public ProviderService getProviderService() {
return provider;
@@ -81,21 +79,15 @@ public class WebAppApiImpl implements WebAppApi {
return certificateManager;
}
- /* (non-Javadoc)
- * @see org.apache.slider.server.appmaster.web.WebAppApi#getClusterProtocol()
- */
@Override
public SliderClusterProtocol getClusterProtocol() {
return clusterProto;
}
- /* (non-Javadoc)
- * @see org.apache.slider.server.appmaster.web.WebAppApi#getRoleStatusByName()
- */
@Override
public Map<String,RoleStatus> getRoleStatusByName() {
List<RoleStatus> roleStatuses = appState.cloneRoleStatusList();
- TreeMap<String, RoleStatus> map =
+ Map<String, RoleStatus> map =
new TreeMap<String, RoleStatus>();
for (RoleStatus status : roleStatuses) {
map.put(status.getName(), status);
@@ -112,4 +104,9 @@ public class WebAppApiImpl implements WebAppApi {
public RegistryOperations getRegistryOperations() {
return registryOperations;
}
+
+ @Override
+ public MetricRegistry getMetrics() {
+ return metrics;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/RestPaths.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/RestPaths.java b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/RestPaths.java
index 94f1e4c..75788f9 100644
--- a/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/RestPaths.java
+++ b/slider-core/src/main/java/org/apache/slider/server/appmaster/web/rest/RestPaths.java
@@ -64,4 +64,9 @@ public class RestPaths {
public static final String SLIDER_EXPORTS = "exports";
public static final String SLIDER_CLASSPATH = "classpath";
+ public static final String SYSTEM = "/system";
+ public static final String SYSTEM_HEALTHCHECK = SYSTEM + "/healthcheck";
+ public static final String SYSTEM_METRICS = SYSTEM + "/metrics";
+ public static final String SYSTEM_PING = SYSTEM + "/ping";
+ public static final String SYSTEM_THREADS = SYSTEM + "/threads";
}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/slider-core/src/main/java/org/apache/slider/server/services/utility/MetricsBindingService.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/server/services/utility/MetricsBindingService.java b/slider-core/src/main/java/org/apache/slider/server/services/utility/MetricsBindingService.java
new file mode 100644
index 0000000..afd2c1a
--- /dev/null
+++ b/slider-core/src/main/java/org/apache/slider/server/services/utility/MetricsBindingService.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.slider.server.services.utility;
+
+import com.codahale.metrics.MetricRegistry;
+import com.codahale.metrics.ScheduledReporter;
+import com.codahale.metrics.ganglia.GangliaReporter;
+import info.ganglia.gmetric4j.gmetric.GMetric;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.io.IOUtils;
+import org.apache.hadoop.service.AbstractService;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * YARN service which hooks up Codahale metrics to
+ * Ganglia (if enabled)
+ */
+public class MetricsBindingService extends AbstractService {
+
+ /**
+ * {@value}
+ */
+ public static final String METRICS_GANGLIA_ENABLED =
+ "metrics.ganglia.enabled";
+ /**
+ * {@value}
+ */
+ public static final String METRICS_GANGLIA_HOST = "metrics.ganglia.host";
+
+ /**
+ * {@value}
+ */
+ public static final String METRICS_GANGLIA_PORT = "metrics.ganglia.port";
+
+ /**
+ * {@value}
+ */
+ public static final String METRICS_GANGLIA_VERSION_31 = "metrics.ganglia.version.31";
+
+ /**
+ * {@value}
+ */
+ public static final String METRICS_GANGLIA_REPORT_INTERVAL = "metrics.ganglia.report.interval";
+
+ /**
+ * {@value}
+ */
+ public static final int DEFAULT_GANGLIA_PORT = 8649;
+
+ private final MetricRegistry metrics;
+ private ScheduledReporter reporter;
+
+ public MetricsBindingService(String name,
+ MetricRegistry metrics) {
+ super(name);
+ this.metrics = metrics;
+ }
+
+ /**
+ * Instantiate...create a metric registry in the process
+ * @param name service name
+ */
+ public MetricsBindingService(String name) {
+ this(name, new MetricRegistry());
+ }
+
+ public MetricRegistry getMetrics() {
+ return metrics;
+ }
+
+ @Override
+ protected void serviceStart() throws Exception {
+ super.serviceStart();
+ Configuration conf = getConfig();
+ boolean enabled = conf.getBoolean(METRICS_GANGLIA_ENABLED, false);
+
+ if (enabled) {
+ String host = conf.getTrimmed(METRICS_GANGLIA_HOST, "");
+ int port = conf.getInt(METRICS_GANGLIA_PORT, DEFAULT_GANGLIA_PORT);
+ int interval = conf.getInt(METRICS_GANGLIA_REPORT_INTERVAL, 60);
+ int ttl = 1;
+ GMetric.UDPAddressingMode
+ mcast = GMetric.UDPAddressingMode.getModeForAddress(host);
+ boolean ganglia31 = conf.getBoolean(METRICS_GANGLIA_VERSION_31, true);
+
+ final GMetric ganglia =
+ new GMetric(
+ host,
+ port,
+ mcast,
+ ttl,
+ ganglia31);
+ reporter = GangliaReporter.forRegistry(metrics)
+ .convertRatesTo(TimeUnit.SECONDS)
+ .convertDurationsTo(TimeUnit.MILLISECONDS)
+ .build(ganglia);
+ reporter.start(interval, TimeUnit.SECONDS);
+ }
+ }
+
+ @Override
+ protected void serviceStop() throws Exception {
+ IOUtils.closeStream(reporter);
+ super.serviceStop();
+ }
+
+ public boolean isEnabled() {
+ return reporter != null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentAM.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentAM.groovy b/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentAM.groovy
index 160f4b7..3707b85 100644
--- a/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentAM.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentAM.groovy
@@ -44,7 +44,9 @@ import org.junit.Test
@CompileStatic
@Slf4j
class TestStandaloneAgentAM extends AgentMiniClusterTestBase {
-
+
+ public static final String PORT_RANGE = "60000-60010"
+
@After
void fixclientname() {
sliderClientClassName = DEFAULT_SLIDER_CLIENT
@@ -66,8 +68,8 @@ class TestStandaloneAgentAM extends AgentMiniClusterTestBase {
ApplicationReport report = waitForClusterLive(client)
URI uri = new URI(report.originalTrackingUrl)
- assert uri.port in [60000, 60001, 60002, 60003]
- assert report.rpcPort in [60000, 60001, 60002, 60003]
+ assert uri.port in 60000..60010
+ assert report.rpcPort in 60000..60010
logReport(report)
List<ApplicationReport> apps = client.applications;
@@ -167,7 +169,7 @@ class TestStandaloneAgentAM extends AgentMiniClusterTestBase {
// do a quick registry listing here expecting a usage failure.
ActionRegistryArgs registryArgs = new ActionRegistryArgs()
- registryArgs.name=clustername;
+ registryArgs.name = clustername;
def exitCode = client.actionRegistry(registryArgs)
assert LauncherExitCodes.EXIT_USAGE == exitCode
@@ -203,7 +205,7 @@ class TestStandaloneAgentAM extends AgentMiniClusterTestBase {
throws IOException, SliderException, LockAcquireFailedException {
AggregateConf conf = builder.instanceDescription
conf.appConfOperations.
- globalOptions[SliderKeys.KEY_ALLOWED_PORT_RANGE]= "60000-60003"
+ globalOptions[SliderKeys.KEY_ALLOWED_PORT_RANGE]= PORT_RANGE
super.persistInstanceDefinition(overwrite, appconfdir, builder)
}
@@ -214,7 +216,7 @@ class TestStandaloneAgentAM extends AgentMiniClusterTestBase {
boolean debugAM)
throws YarnException, IOException {
instanceDefinition.appConfOperations.
- globalOptions[SliderKeys.KEY_ALLOWED_PORT_RANGE] ="60000-60003"
+ globalOptions[SliderKeys.KEY_ALLOWED_PORT_RANGE] =PORT_RANGE
return super.launchApplication(clustername, clusterDirectory, instanceDefinition, debugAM)
}
}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentWeb.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentWeb.groovy b/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentWeb.groovy
new file mode 100644
index 0000000..717d98f
--- /dev/null
+++ b/slider-core/src/test/groovy/org/apache/slider/agent/standalone/TestStandaloneAgentWeb.groovy
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.slider.agent.standalone
+
+import groovy.transform.CompileStatic
+import groovy.util.logging.Slf4j
+import org.apache.hadoop.fs.Path
+import org.apache.hadoop.yarn.api.records.ApplicationId
+import org.apache.hadoop.yarn.api.records.ApplicationReport
+import org.apache.hadoop.yarn.api.records.YarnApplicationState
+import org.apache.hadoop.yarn.exceptions.YarnException
+import org.apache.slider.agent.AgentMiniClusterTestBase
+import org.apache.slider.api.ClusterNode
+import org.apache.slider.client.SliderClient
+import org.apache.slider.common.SliderKeys
+import org.apache.slider.common.params.ActionRegistryArgs
+import org.apache.slider.common.tools.Duration
+import org.apache.slider.core.build.InstanceBuilder
+import org.apache.slider.core.conf.AggregateConf
+import org.apache.slider.core.exceptions.SliderException
+import org.apache.slider.core.launch.LaunchedApplication
+import org.apache.slider.core.main.LauncherExitCodes
+import org.apache.slider.core.main.ServiceLauncher
+import org.apache.slider.core.persist.LockAcquireFailedException
+import org.apache.slider.core.registry.retrieve.AMWebClient
+import org.apache.slider.server.appmaster.web.rest.RestPaths
+import org.junit.After
+import org.junit.Test
+
+@CompileStatic
+@Slf4j
+class TestStandaloneAgentWeb extends AgentMiniClusterTestBase {
+
+
+ @Test
+ public void testStandaloneAgentWeb() throws Throwable {
+
+ describe "create a standalone AM then perform actions on it"
+ //launch fake master
+ String clustername = createMiniCluster("", configuration, 1, true)
+
+
+ ServiceLauncher<SliderClient> launcher =
+ createStandaloneAM(clustername, true, false)
+ SliderClient client = launcher.service
+ addToTeardown(client);
+
+ ApplicationReport report = waitForClusterLive(client)
+ def realappmaster = report.originalTrackingUrl
+ GET(realappmaster)
+ def metrics = GET(realappmaster, RestPaths.SYSTEM_METRICS)
+ log.info metrics
+
+ def appmaster = report.trackingUrl
+
+// GET(appmaster)
+
+// GET(appmaster, RestPaths.SYSTEM_HEALTHCHECK)
+// GET(appmaster, RestPaths.SYSTEM_PING)
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockAppState.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockAppState.groovy b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockAppState.groovy
index e683587..7abb123 100644
--- a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockAppState.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/model/mock/MockAppState.groovy
@@ -17,6 +17,7 @@
package org.apache.slider.server.appmaster.model.mock
+import com.codahale.metrics.MetricRegistry
import org.apache.slider.providers.ProviderRole
import org.apache.slider.server.appmaster.state.AbstractRecordFactory
import org.apache.slider.server.appmaster.state.AppState
@@ -27,7 +28,7 @@ import org.apache.slider.server.appmaster.state.AppState
class MockAppState extends AppState {
public MockAppState(AbstractRecordFactory recordFactory) {
- super(recordFactory);
+ super(recordFactory, new MetricRegistry());
}
long time = 0;
@@ -36,7 +37,7 @@ class MockAppState extends AppState {
* Instance with a mock record factory
*/
public MockAppState() {
- super(new MockRecordFactory());
+ super(new MockRecordFactory(), new MetricRegistry());
}
public Map<String, ProviderRole> getRoleMap() {
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestClusterSpecificationBlock.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestClusterSpecificationBlock.groovy b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestClusterSpecificationBlock.groovy
index c49abec..164d93c 100644
--- a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestClusterSpecificationBlock.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestClusterSpecificationBlock.groovy
@@ -57,7 +57,7 @@ public class TestClusterSpecificationBlock {
providerAppState,
providerService,
null,
- null);
+ null, null);
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestContainerStatsBlock.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestContainerStatsBlock.groovy b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestContainerStatsBlock.groovy
index 9292285..4f1d52d 100644
--- a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestContainerStatsBlock.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestContainerStatsBlock.groovy
@@ -64,7 +64,7 @@ public class TestContainerStatsBlock extends BaseMockAppStateTest {
providerAppState,
providerService,
null,
- null);
+ null, metricRegistry);
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestIndexBlock.groovy
----------------------------------------------------------------------
diff --git a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestIndexBlock.groovy b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestIndexBlock.groovy
index d232ecb..ff24b82 100644
--- a/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestIndexBlock.groovy
+++ b/slider-core/src/test/groovy/org/apache/slider/server/appmaster/web/view/TestIndexBlock.groovy
@@ -56,7 +56,7 @@ public class TestIndexBlock extends BaseMockAppStateTest {
providerAppState,
providerService,
null,
- null);
+ null, metricRegistry);
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/agent/TestAMAgentWebServices.java
----------------------------------------------------------------------
diff --git a/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/agent/TestAMAgentWebServices.java b/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/agent/TestAMAgentWebServices.java
index faec5d8..db8223a 100644
--- a/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/agent/TestAMAgentWebServices.java
+++ b/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/agent/TestAMAgentWebServices.java
@@ -18,6 +18,7 @@
package org.apache.slider.server.appmaster.web.rest.agent;
+import com.codahale.metrics.MetricRegistry;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
@@ -121,7 +122,7 @@ public class TestAMAgentWebServices {
historyPath =
new org.apache.hadoop.fs.Path(historyWorkDir.toURI());
fs.delete(historyPath, true);
- appState = new AppState(new MockRecordFactory());
+ appState = new AppState(new MockRecordFactory(), new MetricRegistry());
appState.setContainerLimits(RM_MAX_RAM, RM_MAX_CORES);
appState.buildInstance(
factory.newInstanceDefinition(0, 0, 0),
@@ -138,7 +139,7 @@ public class TestAMAgentWebServices {
appState);
slider = new WebAppApiImpl(new MockSliderClusterProtocol(), providerAppState,
- new MockProviderService(), null, null);
+ new MockProviderService(), null, null, null);
MapOperations compOperations = new MapOperations();
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/867b67d4/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/management/TestAMManagementWebServices.java
----------------------------------------------------------------------
diff --git a/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/management/TestAMManagementWebServices.java b/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/management/TestAMManagementWebServices.java
index 20889ac..9bfcd25 100644
--- a/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/management/TestAMManagementWebServices.java
+++ b/slider-core/src/test/java/org/apache/slider/server/appmaster/web/rest/management/TestAMManagementWebServices.java
@@ -18,6 +18,7 @@
package org.apache.slider.server.appmaster.web.rest.management;
+import com.codahale.metrics.MetricRegistry;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
@@ -167,7 +168,7 @@ public class TestAMManagementWebServices extends JerseyTest {
historyPath =
new org.apache.hadoop.fs.Path(historyWorkDir.toURI());
fs.delete(historyPath, true);
- appState = new AppState(new MockRecordFactory());
+ appState = new AppState(new MockRecordFactory(), new MetricRegistry());
appState.setContainerLimits(RM_MAX_RAM, RM_MAX_CORES);
appState.buildInstance(
factory.newInstanceDefinition(0, 0, 0),
@@ -191,7 +192,7 @@ public class TestAMManagementWebServices extends JerseyTest {
appState);
slider = new WebAppApiImpl(new MockSliderClusterProtocol(), providerAppState,
- new MockProviderService(), null, null);
+ new MockProviderService(), null, null, null);
bind(SliderJacksonJaxbJsonProvider.class);
bind(MockSliderAMWebServices.class);
[5/5] incubator-slider git commit: Merge branch
'feature/SLIDER-319_codahale_metrics' into develop
Posted by st...@apache.org.
Merge branch 'feature/SLIDER-319_codahale_metrics' into develop
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/a3b6fa5b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/a3b6fa5b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/a3b6fa5b
Branch: refs/heads/develop
Commit: a3b6fa5b0aeaddf401dbba49529d763ec4d8278c
Parents: f0a30fd a2966af
Author: Steve Loughran <st...@apache.org>
Authored: Tue Nov 25 19:21:45 2014 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Tue Nov 25 19:21:45 2014 +0000
----------------------------------------------------------------------
pom.xml | 30 ++++-
slider-core/pom.xml | 21 ++-
.../launch/SerializedApplicationReport.java | 2 +
.../core/registry/retrieve/AMWebClient.java | 129 +++++++++++++++++++
.../registry/retrieve/RegistryRetriever.java | 87 +------------
.../server/appmaster/SliderAppMaster.java | 54 +++++---
.../management/MetricsAndMonitoring.java | 62 +++++++++
.../management/MetricsBindingService.java | 128 ++++++++++++++++++
.../management/YarnServiceHealthCheck.java | 38 ++++++
.../server/appmaster/monkey/ChaosEntry.java | 2 -
.../slider/server/appmaster/state/AppState.java | 11 +-
.../server/appmaster/web/SliderAMWebApp.java | 26 +++-
.../slider/server/appmaster/web/WebAppApi.java | 15 ++-
.../server/appmaster/web/WebAppApiImpl.java | 25 ++--
.../server/appmaster/web/rest/RestPaths.java | 5 +
.../appmaster/web/rest/agent/AgentWebApp.java | 1 -
.../server/appmaster/web/view/NavBlock.java | 12 +-
.../standalone/TestStandaloneAgentAM.groovy | 14 +-
.../standalone/TestStandaloneAgentWeb.groovy | 81 ++++++++++++
.../appmaster/model/mock/MockAppState.groovy | 5 +-
.../model/monkey/TestMockMonkey.groovy | 2 +-
.../view/TestClusterSpecificationBlock.groovy | 2 +-
.../web/view/TestContainerStatsBlock.groovy | 2 +-
.../appmaster/web/view/TestIndexBlock.groovy | 2 +-
.../apache/slider/test/SliderTestBase.groovy | 3 +-
.../web/rest/agent/TestAMAgentWebServices.java | 5 +-
.../management/TestAMManagementWebServices.java | 5 +-
.../funtest/framework/CommandTestBase.groovy | 51 ++++++++
.../funtest/lifecycle/AgentWebPagesIT.groovy | 92 +++++++++++++
.../lifecycle/AppsThroughAgentDemo.groovy | 2 +-
30 files changed, 758 insertions(+), 156 deletions(-)
----------------------------------------------------------------------