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:
parent
3e76f00baa
commit
09e5af76f3
|
@ -28,3 +28,6 @@ HADOOP-7932. Make client connection retries on socket time outs configurable.
|
||||||
HADOOP-7924.
FailoverController for client-based configuration (eli)
|
HADOOP-7924.
FailoverController for client-based configuration (eli)
|
||||||
|
|
||||||
HADOOP-7961. Move HA fencing to common. (eli)
|
HADOOP-7961. Move HA fencing to common. (eli)
|
||||||
|
|
||||||
|
HADOOP-7970. HAServiceProtocol methods must throw IOException.
|
||||||
|
(Hari Mankude via suresh).
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.ha;
|
package org.apache.hadoop.ha;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
@ -51,7 +53,7 @@ public class FailoverController {
|
||||||
HAServiceState toSvcState;
|
HAServiceState toSvcState;
|
||||||
try {
|
try {
|
||||||
toSvcState = toSvc.getServiceState();
|
toSvcState = toSvc.getServiceState();
|
||||||
} catch (Exception e) {
|
} catch (IOException e) {
|
||||||
String msg = "Unable to get service state for " + toSvcName;
|
String msg = "Unable to get service state for " + toSvcName;
|
||||||
LOG.error(msg, e);
|
LOG.error(msg, e);
|
||||||
throw new FailoverFailedException(msg, e);
|
throw new FailoverFailedException(msg, e);
|
||||||
|
@ -65,6 +67,9 @@ public class FailoverController {
|
||||||
} catch (HealthCheckFailedException hce) {
|
} catch (HealthCheckFailedException hce) {
|
||||||
throw new FailoverFailedException(
|
throw new FailoverFailedException(
|
||||||
"Can't failover to an unhealthy service", hce);
|
"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.
|
// TODO(HA): ask toSvc if it's capable. Eg not in SM.
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@ import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.classification.InterfaceStability;
|
import org.apache.hadoop.classification.InterfaceStability;
|
||||||
import org.apache.hadoop.ipc.VersionedProtocol;
|
import org.apache.hadoop.ipc.VersionedProtocol;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Protocol interface that provides High Availability related primitives to
|
* Protocol interface that provides High Availability related primitives to
|
||||||
* monitor and fail-over the service.
|
* monitor and fail-over the service.
|
||||||
|
@ -69,8 +71,11 @@ public interface HAServiceProtocol extends VersionedProtocol {
|
||||||
*
|
*
|
||||||
* @throws HealthCheckFailedException
|
* @throws HealthCheckFailedException
|
||||||
* if the health check of a service fails.
|
* 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
|
* Request service to transition to active state. No operation, if the
|
||||||
|
@ -78,8 +83,11 @@ public interface HAServiceProtocol extends VersionedProtocol {
|
||||||
*
|
*
|
||||||
* @throws ServiceFailedException
|
* @throws ServiceFailedException
|
||||||
* if transition from standby to active fails.
|
* 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
|
* Request service to transition to standby state. No operation, if the
|
||||||
|
@ -87,11 +95,17 @@ public interface HAServiceProtocol extends VersionedProtocol {
|
||||||
*
|
*
|
||||||
* @throws ServiceFailedException
|
* @throws ServiceFailedException
|
||||||
* if transition from active to standby fails.
|
* 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.
|
* Return the current state of the service.
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* if other errors happen
|
||||||
*/
|
*/
|
||||||
public HAServiceState getServiceState();
|
public HAServiceState getServiceState() throws IOException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.ha;
|
package org.apache.hadoop.ha;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.classification.InterfaceStability;
|
import org.apache.hadoop.classification.InterfaceStability;
|
||||||
|
|
||||||
|
@ -25,7 +27,7 @@ import org.apache.hadoop.classification.InterfaceStability;
|
||||||
*/
|
*/
|
||||||
@InterfaceAudience.Public
|
@InterfaceAudience.Public
|
||||||
@InterfaceStability.Evolving
|
@InterfaceStability.Evolving
|
||||||
public class HealthCheckFailedException extends Exception {
|
public class HealthCheckFailedException extends IOException {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public HealthCheckFailedException(final String message) {
|
public HealthCheckFailedException(final String message) {
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.ha;
|
package org.apache.hadoop.ha;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.classification.InterfaceStability;
|
import org.apache.hadoop.classification.InterfaceStability;
|
||||||
|
|
||||||
|
@ -27,7 +29,7 @@ import org.apache.hadoop.classification.InterfaceStability;
|
||||||
*/
|
*/
|
||||||
@InterfaceAudience.Public
|
@InterfaceAudience.Public
|
||||||
@InterfaceStability.Evolving
|
@InterfaceStability.Evolving
|
||||||
public class ServiceFailedException extends Exception {
|
public class ServiceFailedException extends IOException {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public ServiceFailedException(final String message) {
|
public ServiceFailedException(final String message) {
|
||||||
|
|
|
@ -551,9 +551,6 @@ public class NameNode {
|
||||||
} catch (HadoopIllegalArgumentException e) {
|
} catch (HadoopIllegalArgumentException e) {
|
||||||
this.stop();
|
this.stop();
|
||||||
throw e;
|
throw e;
|
||||||
} catch (ServiceFailedException e) {
|
|
||||||
this.stop();
|
|
||||||
throw new IOException("Service failed to start", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue