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 ma...@apache.org on 2011/05/17 20:51:17 UTC
svn commit: r1104464 - in /hadoop/mapreduce/branches/MR-279: CHANGES.txt
yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/service/CompositeService.java
Author: mahadev
Date: Tue May 17 18:51:17 2011
New Revision: 1104464
URL: http://svn.apache.org/viewvc?rev=1104464&view=rev
Log:
Fixed Composite Service to shutdown services if an error occurs on starting any one of those (mahadev & chris)
Modified:
hadoop/mapreduce/branches/MR-279/CHANGES.txt
hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/service/CompositeService.java
Modified: hadoop/mapreduce/branches/MR-279/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/CHANGES.txt?rev=1104464&r1=1104463&r2=1104464&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/CHANGES.txt (original)
+++ hadoop/mapreduce/branches/MR-279/CHANGES.txt Tue May 17 18:51:17 2011
@@ -4,6 +4,9 @@ Trunk (unreleased changes)
MAPREDUCE-279
+ Fixed Composite Service to shutdown services if an error occurs on
+ starting any one of those (mahadev & chris)
+
Fixing a bug to do with setting the staging dir. (ddas)
Fixing a bug in previous patch (r1103657). Now bin/yarn truly shouldn't be
Modified: hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/service/CompositeService.java
URL: http://svn.apache.org/viewvc/hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/service/CompositeService.java?rev=1104464&r1=1104463&r2=1104464&view=diff
==============================================================================
--- hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/service/CompositeService.java (original)
+++ hadoop/mapreduce/branches/MR-279/yarn/yarn-common/src/main/java/org/apache/hadoop/yarn/service/CompositeService.java Tue May 17 18:51:17 2011
@@ -1,20 +1,20 @@
/**
-* 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.
-*/
+ * 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.yarn.service;
@@ -23,13 +23,18 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.yarn.YarnException;
/**
* Composition of services.
*/
public class CompositeService extends AbstractService {
+ private static final Log LOG = LogFactory.getLog(CompositeService.class);
+
private List<Service> serviceList = new ArrayList<Service>();
public CompositeService(String name) {
@@ -56,8 +61,23 @@ public class CompositeService extends Ab
}
public synchronized void start() {
- for (Service service : serviceList) {
- service.start();
+ int i = 0;
+ try {
+ for (int n = serviceList.size(); i < n; i++) {
+ Service service = serviceList.get(i);
+ service.start();
+ }
+ } catch(Throwable e) {
+ LOG.error("Error starting services " + getName(), e);
+ for (int j = i-1; j >= 0; j--) {
+ Service service = serviceList.get(j);
+ try {
+ service.stop();
+ } catch(Throwable t) {
+ LOG.info("Error stopping " + service.getName(), t);
+ }
+ }
+ throw new YarnException("Failed to Start " + getName(), e);
}
super.start();
}