HDFS-3915. QJM: Failover fails with auth error in secure cluster. Contributed by Todd Lipcon.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-3077@1383242 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Todd Lipcon 2012-09-11 04:53:08 +00:00
parent c5199cace6
commit c859e87d1e
2 changed files with 17 additions and 5 deletions

View File

@ -64,3 +64,5 @@ HDFS-3901. QJM: send 'heartbeat' messages to JNs even when they are out-of-sync
HDFS-3899. QJM: Add client-side metrics (todd) HDFS-3899. QJM: Add client-side metrics (todd)
HDFS-3914. QJM: acceptRecovery should abort current segment (todd) HDFS-3914. QJM: acceptRecovery should abort current segment (todd)
HDFS-3915. QJM: Failover fails with auth error in secure cluster (todd)

View File

@ -21,6 +21,7 @@
import java.io.IOException; import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction;
import java.util.Collection; import java.util.Collection;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -172,11 +173,20 @@ public void catchupDuringFailover() throws IOException {
Preconditions.checkState(tailerThread == null || Preconditions.checkState(tailerThread == null ||
!tailerThread.isAlive(), !tailerThread.isAlive(),
"Tailer thread should not be running once failover starts"); "Tailer thread should not be running once failover starts");
try { // Important to do tailing as the login user, in case the shared
doTailEdits(); // edits storage is implemented by a JournalManager that depends
} catch (InterruptedException e) { // on security credentials to access the logs (eg QuorumJournalManager).
throw new IOException(e); SecurityUtil.doAsLoginUser(new PrivilegedExceptionAction<Void>() {
} @Override
public Void run() throws Exception {
try {
doTailEdits();
} catch (InterruptedException e) {
throw new IOException(e);
}
return null;
}
});
} }
@VisibleForTesting @VisibleForTesting