|
@@ -21,6 +21,7 @@ package org.apache.hadoop.mapreduce.v2.app;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.lang.reflect.Constructor;
|
|
import java.lang.reflect.Constructor;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
import java.security.PrivilegedExceptionAction;
|
|
import java.security.PrivilegedExceptionAction;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
@@ -47,6 +48,7 @@ import org.apache.hadoop.mapred.LocalContainerLauncher;
|
|
import org.apache.hadoop.mapred.TaskAttemptListenerImpl;
|
|
import org.apache.hadoop.mapred.TaskAttemptListenerImpl;
|
|
import org.apache.hadoop.mapred.TaskLog;
|
|
import org.apache.hadoop.mapred.TaskLog;
|
|
import org.apache.hadoop.mapred.TaskUmbilicalProtocol;
|
|
import org.apache.hadoop.mapred.TaskUmbilicalProtocol;
|
|
|
|
+import org.apache.hadoop.mapreduce.CryptoUtils;
|
|
import org.apache.hadoop.mapreduce.JobContext;
|
|
import org.apache.hadoop.mapreduce.JobContext;
|
|
import org.apache.hadoop.mapreduce.MRJobConfig;
|
|
import org.apache.hadoop.mapreduce.MRJobConfig;
|
|
import org.apache.hadoop.mapreduce.OutputCommitter;
|
|
import org.apache.hadoop.mapreduce.OutputCommitter;
|
|
@@ -146,6 +148,8 @@ import org.apache.log4j.LogManager;
|
|
|
|
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
|
|
|
|
|
|
+import javax.crypto.KeyGenerator;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* The Map-Reduce Application Master.
|
|
* The Map-Reduce Application Master.
|
|
* The state machine is encapsulated in the implementation of Job interface.
|
|
* The state machine is encapsulated in the implementation of Job interface.
|
|
@@ -173,6 +177,7 @@ public class MRAppMaster extends CompositeService {
|
|
* Priority of the MRAppMaster shutdown hook.
|
|
* Priority of the MRAppMaster shutdown hook.
|
|
*/
|
|
*/
|
|
public static final int SHUTDOWN_HOOK_PRIORITY = 30;
|
|
public static final int SHUTDOWN_HOOK_PRIORITY = 30;
|
|
|
|
+ public static final String INTERMEDIATE_DATA_ENCRYPTION_ALGO = "HmacSHA1";
|
|
|
|
|
|
private Clock clock;
|
|
private Clock clock;
|
|
private final long startTime;
|
|
private final long startTime;
|
|
@@ -203,6 +208,7 @@ public class MRAppMaster extends CompositeService {
|
|
private JobEventDispatcher jobEventDispatcher;
|
|
private JobEventDispatcher jobEventDispatcher;
|
|
private JobHistoryEventHandler jobHistoryEventHandler;
|
|
private JobHistoryEventHandler jobHistoryEventHandler;
|
|
private SpeculatorEventDispatcher speculatorEventDispatcher;
|
|
private SpeculatorEventDispatcher speculatorEventDispatcher;
|
|
|
|
+ private byte[] encryptedSpillKey;
|
|
|
|
|
|
// After a task attempt completes from TaskUmbilicalProtocol's point of view,
|
|
// After a task attempt completes from TaskUmbilicalProtocol's point of view,
|
|
// it will be transitioned to finishing state.
|
|
// it will be transitioned to finishing state.
|
|
@@ -686,8 +692,22 @@ public class MRAppMaster extends CompositeService {
|
|
try {
|
|
try {
|
|
this.currentUser = UserGroupInformation.getCurrentUser();
|
|
this.currentUser = UserGroupInformation.getCurrentUser();
|
|
this.jobCredentials = ((JobConf)conf).getCredentials();
|
|
this.jobCredentials = ((JobConf)conf).getCredentials();
|
|
|
|
+ if (CryptoUtils.isEncryptedSpillEnabled(conf)) {
|
|
|
|
+ int keyLen = conf.getInt(
|
|
|
|
+ MRJobConfig.MR_ENCRYPTED_INTERMEDIATE_DATA_KEY_SIZE_BITS,
|
|
|
|
+ MRJobConfig
|
|
|
|
+ .DEFAULT_MR_ENCRYPTED_INTERMEDIATE_DATA_KEY_SIZE_BITS);
|
|
|
|
+ KeyGenerator keyGen =
|
|
|
|
+ KeyGenerator.getInstance(INTERMEDIATE_DATA_ENCRYPTION_ALGO);
|
|
|
|
+ keyGen.init(keyLen);
|
|
|
|
+ encryptedSpillKey = keyGen.generateKey().getEncoded();
|
|
|
|
+ } else {
|
|
|
|
+ encryptedSpillKey = new byte[] {0};
|
|
|
|
+ }
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
throw new YarnRuntimeException(e);
|
|
throw new YarnRuntimeException(e);
|
|
|
|
+ } catch (NoSuchAlgorithmException e) {
|
|
|
|
+ throw new YarnRuntimeException(e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -743,7 +763,7 @@ public class MRAppMaster extends CompositeService {
|
|
protected TaskAttemptListener createTaskAttemptListener(AppContext context) {
|
|
protected TaskAttemptListener createTaskAttemptListener(AppContext context) {
|
|
TaskAttemptListener lis =
|
|
TaskAttemptListener lis =
|
|
new TaskAttemptListenerImpl(context, jobTokenSecretManager,
|
|
new TaskAttemptListenerImpl(context, jobTokenSecretManager,
|
|
- getRMHeartbeatHandler());
|
|
|
|
|
|
+ getRMHeartbeatHandler(), encryptedSpillKey);
|
|
return lis;
|
|
return lis;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -910,6 +930,8 @@ public class MRAppMaster extends CompositeService {
|
|
if (job.isUber()) {
|
|
if (job.isUber()) {
|
|
this.containerLauncher = new LocalContainerLauncher(context,
|
|
this.containerLauncher = new LocalContainerLauncher(context,
|
|
(TaskUmbilicalProtocol) taskAttemptListener, jobClassLoader);
|
|
(TaskUmbilicalProtocol) taskAttemptListener, jobClassLoader);
|
|
|
|
+ ((LocalContainerLauncher) this.containerLauncher)
|
|
|
|
+ .setEncryptedSpillKey(encryptedSpillKey);
|
|
} else {
|
|
} else {
|
|
this.containerLauncher = new ContainerLauncherImpl(context);
|
|
this.containerLauncher = new ContainerLauncherImpl(context);
|
|
}
|
|
}
|