You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mapreduce-commits@hadoop.apache.org by to...@apache.org on 2011/05/17 05:50:40 UTC
svn commit: r1103993 - in /hadoop/mapreduce/trunk: CHANGES.txt
src/java/org/apache/hadoop/mapred/JobTracker.java
src/java/org/apache/hadoop/mapreduce/server/jobtracker/JTConfig.java
src/test/unit/org/apache/hadoop/mapred/TestJobTrackerPlugins.java
Author: tomwhite
Date: Tue May 17 03:50:39 2011
New Revision: 1103993
URL: http://svn.apache.org/viewvc?rev=1103993&view=rev
Log:
MAPREDUCE-461. Enable ServicePlugins for the JobTracker. Contributed by Fredrik Hedberg.
Added:
hadoop/mapreduce/trunk/src/test/unit/org/apache/hadoop/mapred/TestJobTrackerPlugins.java (with props)
Modified:
hadoop/mapreduce/trunk/CHANGES.txt
hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java
hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapreduce/server/jobtracker/JTConfig.java
Modified: hadoop/mapreduce/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/CHANGES.txt?rev=1103993&r1=1103992&r2=1103993&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/CHANGES.txt (original)
+++ hadoop/mapreduce/trunk/CHANGES.txt Tue May 17 03:50:39 2011
@@ -9,6 +9,9 @@ Trunk (unreleased changes)
MAPREDUCE-2473. Add "mapred groups" command to query the server-side groups
resolved for a user. (Aaron T. Myers via todd)
+ MAPREDUCE-461. Enable ServicePlugins for the JobTracker.
+ (Fredrik Hedberg via tomwhite)
+
IMPROVEMENTS
MAPREDUCE-2153. Bring in more job configuration properties in to the trace
Modified: hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java?rev=1103993&r1=1103992&r2=1103993&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java (original)
+++ hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java Tue May 17 03:50:39 2011
@@ -117,6 +117,7 @@ import org.apache.hadoop.security.token.
import org.apache.hadoop.tools.GetUserMappingsProtocol;
import org.apache.hadoop.util.HostsFileReader;
import org.apache.hadoop.util.ReflectionUtils;
+import org.apache.hadoop.util.ServicePlugin;
import org.apache.hadoop.util.StringUtils;
import org.apache.hadoop.util.VersionInfo;
@@ -191,6 +192,8 @@ public class JobTracker implements MRCon
final TaskScheduler taskScheduler;
private final List<JobInProgressListener> jobInProgressListeners =
new CopyOnWriteArrayList<JobInProgressListener>();
+
+ private List<ServicePlugin> plugins;
// system directory is completely owned by the JobTracker
final static FsPermission SYSTEM_DIR_PERMISSION =
@@ -1659,6 +1662,17 @@ public class JobTracker implements MRCon
//initializes the job status store
completedJobStatusStore = new CompletedJobStatusStore(conf, aclsManager);
+
+ plugins = conf.getInstances(JT_PLUGINS, ServicePlugin.class);
+ for (ServicePlugin p : plugins) {
+ try {
+ p.start(this);
+ LOG.info("Started plug-in " + p + " of type " + p.getClass());
+ } catch (Throwable t) {
+ LOG.warn("ServicePlugin " + p + " of type " + p.getClass() +
+ " could not be started", t);
+ }
+ }
}
/**
@@ -1806,6 +1820,17 @@ public class JobTracker implements MRCon
}
void close() throws IOException {
+ if (plugins != null) {
+ for (ServicePlugin p : plugins) {
+ try {
+ p.stop();
+ LOG.info("Stopped plug-in " + p + " of type " + p.getClass());
+ } catch (Throwable t) {
+ LOG.warn("ServicePlugin " + p + " of type " + p.getClass() +
+ " could not be stopped", t);
+ }
+ }
+ }
if (this.infoServer != null) {
LOG.info("Stopping infoServer");
try {
Modified: hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapreduce/server/jobtracker/JTConfig.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapreduce/server/jobtracker/JTConfig.java?rev=1103993&r1=1103992&r2=1103993&view=diff
==============================================================================
--- hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapreduce/server/jobtracker/JTConfig.java (original)
+++ hadoop/mapreduce/trunk/src/java/org/apache/hadoop/mapreduce/server/jobtracker/JTConfig.java Tue May 17 03:50:39 2011
@@ -107,4 +107,6 @@ public interface JTConfig extends MRConf
public static final String JT_USER_NAME = "mapreduce.jobtracker.kerberos.principal";
public static final String JT_KEYTAB_FILE =
"mapreduce.jobtracker.keytab.file";
+ public static final String JT_PLUGINS =
+ "mapreduce.jobtracker.plugins";
}
Added: hadoop/mapreduce/trunk/src/test/unit/org/apache/hadoop/mapred/TestJobTrackerPlugins.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/trunk/src/test/unit/org/apache/hadoop/mapred/TestJobTrackerPlugins.java?rev=1103993&view=auto
==============================================================================
--- hadoop/mapreduce/trunk/src/test/unit/org/apache/hadoop/mapred/TestJobTrackerPlugins.java (added)
+++ hadoop/mapreduce/trunk/src/test/unit/org/apache/hadoop/mapred/TestJobTrackerPlugins.java Tue May 17 03:50:39 2011
@@ -0,0 +1,90 @@
+/**
+ * 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.hadoop.mapred;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.hadoop.mapreduce.server.jobtracker.JTConfig;
+import org.apache.hadoop.util.ServicePlugin;
+import org.junit.Test;
+
+public class TestJobTrackerPlugins extends TestCase {
+
+ static class FakeServicePlugin implements ServicePlugin {
+
+ private static FakeServicePlugin instance;
+
+ public static FakeServicePlugin getInstance() {
+ return instance;
+ }
+
+ private Object service;
+ private boolean stopped;
+
+ public Object getService() {
+ return service;
+ }
+
+ public boolean isStopped() {
+ return stopped;
+ }
+
+ public FakeServicePlugin() {
+ // store static reference to instance so we can retrieve it in the test
+ instance = this;
+ }
+
+ @Override
+ public void start(Object service) {
+ this.service = service;
+ }
+
+ @Override
+ public void stop() {
+ stopped = true;
+ }
+
+ @Override
+ public void close() throws IOException {
+ }
+ }
+
+ @Test
+ public void test() throws Exception {
+ JobConf conf = new JobConf();
+ conf.set(JTConfig.JT_IPC_ADDRESS, "localhost:0");
+ conf.set(JTConfig.JT_HTTP_ADDRESS, "0.0.0.0:0");
+ conf.setClass(JTConfig.JT_PLUGINS, FakeServicePlugin.class,
+ ServicePlugin.class);
+
+ assertNull("Plugin not created", FakeServicePlugin.getInstance());
+
+ JobTracker jobTracker = JobTracker.startTracker(conf);
+ assertNotNull("Plugin created", FakeServicePlugin.getInstance());
+ assertSame("Service is jobTracker",
+ FakeServicePlugin.getInstance().getService(), jobTracker);
+ assertFalse("Plugin not stopped",
+ FakeServicePlugin.getInstance().isStopped());
+
+ jobTracker.close();
+ assertTrue("Plugin stopped", FakeServicePlugin.getInstance().isStopped());
+ }
+
+}
Propchange: hadoop/mapreduce/trunk/src/test/unit/org/apache/hadoop/mapred/TestJobTrackerPlugins.java
------------------------------------------------------------------------------
svn:eol-style = native