HADOOP-7970. HAServiceProtocol methods must throw IOException.Contributed by Hari Mankude.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-1623@1230351 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Suresh Srinivas 2012-01-12 01:39:30 +00:00
parent 3e76f00baa
commit 09e5af76f3
6 changed files with 33 additions and 10 deletions

View File

@ -28,3 +28,6 @@ HADOOP-7932. Make client connection retries on socket time outs configurable.
HADOOP-7924. FailoverController for client-based configuration (eli)
HADOOP-7961. Move HA fencing to common. (eli)
HADOOP-7970. HAServiceProtocol methods must throw IOException.
(Hari Mankude via suresh).

View File

@ -17,6 +17,8 @@
*/
package org.apache.hadoop.ha;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -51,7 +53,7 @@ private static void preFailoverChecks(HAServiceProtocol toSvc,
HAServiceState toSvcState;
try {
toSvcState = toSvc.getServiceState();
} catch (Exception e) {
} catch (IOException e) {
String msg = "Unable to get service state for " + toSvcName;
LOG.error(msg, e);
throw new FailoverFailedException(msg, e);
@ -65,6 +67,9 @@ private static void preFailoverChecks(HAServiceProtocol toSvc,
} catch (HealthCheckFailedException hce) {
throw new FailoverFailedException(
"Can't failover to an unhealthy service", hce);
} catch (IOException e) {
throw new FailoverFailedException(
"Got an io exception", e);
}
// TODO(HA): ask toSvc if it's capable. Eg not in SM.
}

View File

@ -21,6 +21,8 @@
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.ipc.VersionedProtocol;
import java.io.IOException;
/**
* Protocol interface that provides High Availability related primitives to
* monitor and fail-over the service.
@ -69,8 +71,11 @@ public String toString() {
*
* @throws HealthCheckFailedException
* if the health check of a service fails.
* @throws IOException
* if other errors happen
*/
public void monitorHealth() throws HealthCheckFailedException;
public void monitorHealth() throws HealthCheckFailedException,
IOException;
/**
* Request service to transition to active state. No operation, if the
@ -78,8 +83,11 @@ public String toString() {
*
* @throws ServiceFailedException
* if transition from standby to active fails.
* @throws IOException
* if other errors happen
*/
public void transitionToActive() throws ServiceFailedException;
public void transitionToActive() throws ServiceFailedException,
IOException;
/**
* Request service to transition to standby state. No operation, if the
@ -87,11 +95,17 @@ public String toString() {
*
* @throws ServiceFailedException
* if transition from active to standby fails.
* @throws IOException
* if other errors happen
*/
public void transitionToStandby() throws ServiceFailedException;
public void transitionToStandby() throws ServiceFailedException,
IOException;
/**
* Return the current state of the service.
*
* @throws IOException
* if other errors happen
*/
public HAServiceState getServiceState();
public HAServiceState getServiceState() throws IOException;
}

View File

@ -17,6 +17,8 @@
*/
package org.apache.hadoop.ha;
import java.io.IOException;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
@ -25,7 +27,7 @@
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
public class HealthCheckFailedException extends Exception {
public class HealthCheckFailedException extends IOException {
private static final long serialVersionUID = 1L;
public HealthCheckFailedException(final String message) {

View File

@ -17,6 +17,8 @@
*/
package org.apache.hadoop.ha;
import java.io.IOException;
import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
@ -27,7 +29,7 @@
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
public class ServiceFailedException extends Exception {
public class ServiceFailedException extends IOException {
private static final long serialVersionUID = 1L;
public ServiceFailedException(final String message) {

View File

@ -551,9 +551,6 @@ protected NameNode(Configuration conf, NamenodeRole role)
} catch (HadoopIllegalArgumentException e) {
this.stop();
throw e;
} catch (ServiceFailedException e) {
this.stop();
throw new IOException("Service failed to start", e);
}
}