|
@@ -19,10 +19,7 @@
|
|
package org.apache.hadoop.tools.mapred;
|
|
package org.apache.hadoop.tools.mapred;
|
|
|
|
|
|
import java.io.FileNotFoundException;
|
|
import java.io.FileNotFoundException;
|
|
-import java.io.FileOutputStream;
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
-import java.io.OutputStream;
|
|
|
|
-import java.util.Arrays;
|
|
|
|
import java.util.EnumSet;
|
|
import java.util.EnumSet;
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.Log;
|
|
@@ -33,7 +30,6 @@ import org.apache.hadoop.fs.FileStatus;
|
|
import org.apache.hadoop.fs.FileSystem;
|
|
import org.apache.hadoop.fs.FileSystem;
|
|
import org.apache.hadoop.fs.Path;
|
|
import org.apache.hadoop.fs.Path;
|
|
import org.apache.hadoop.io.Text;
|
|
import org.apache.hadoop.io.Text;
|
|
-import org.apache.hadoop.mapreduce.JobContext;
|
|
|
|
import org.apache.hadoop.mapreduce.Mapper;
|
|
import org.apache.hadoop.mapreduce.Mapper;
|
|
import org.apache.hadoop.tools.CopyListingFileStatus;
|
|
import org.apache.hadoop.tools.CopyListingFileStatus;
|
|
import org.apache.hadoop.tools.DistCpConstants;
|
|
import org.apache.hadoop.tools.DistCpConstants;
|
|
@@ -119,73 +115,9 @@ public class CopyMapper extends Mapper<Text, CopyListingFileStatus, Text, Text>
|
|
overWrite = true; // When target is an existing file, overwrite it.
|
|
overWrite = true; // When target is an existing file, overwrite it.
|
|
}
|
|
}
|
|
|
|
|
|
- if (conf.get(DistCpConstants.CONF_LABEL_SSL_CONF) != null) {
|
|
|
|
- initializeSSLConf(context);
|
|
|
|
- }
|
|
|
|
startEpoch = System.currentTimeMillis();
|
|
startEpoch = System.currentTimeMillis();
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * Initialize SSL Config if same is set in conf
|
|
|
|
- *
|
|
|
|
- * @throws IOException - If any
|
|
|
|
- */
|
|
|
|
- private void initializeSSLConf(Context context) throws IOException {
|
|
|
|
- LOG.info("Initializing SSL configuration");
|
|
|
|
-
|
|
|
|
- String workDir = conf.get(JobContext.JOB_LOCAL_DIR) + "/work";
|
|
|
|
- Path[] cacheFiles = context.getLocalCacheFiles();
|
|
|
|
-
|
|
|
|
- Configuration sslConfig = new Configuration(false);
|
|
|
|
- String sslConfFileName = conf.get(DistCpConstants.CONF_LABEL_SSL_CONF);
|
|
|
|
- Path sslClient = findCacheFile(cacheFiles, sslConfFileName);
|
|
|
|
- if (sslClient == null) {
|
|
|
|
- LOG.warn("SSL Client config file not found. Was looking for " + sslConfFileName +
|
|
|
|
- " in " + Arrays.toString(cacheFiles));
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- sslConfig.addResource(sslClient);
|
|
|
|
-
|
|
|
|
- String trustStoreFile = conf.get("ssl.client.truststore.location");
|
|
|
|
- Path trustStorePath = findCacheFile(cacheFiles, trustStoreFile);
|
|
|
|
- sslConfig.set("ssl.client.truststore.location", trustStorePath.toString());
|
|
|
|
-
|
|
|
|
- String keyStoreFile = conf.get("ssl.client.keystore.location");
|
|
|
|
- Path keyStorePath = findCacheFile(cacheFiles, keyStoreFile);
|
|
|
|
- sslConfig.set("ssl.client.keystore.location", keyStorePath.toString());
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- OutputStream out = new FileOutputStream(workDir + "/" + sslConfFileName);
|
|
|
|
- try {
|
|
|
|
- sslConfig.writeXml(out);
|
|
|
|
- } finally {
|
|
|
|
- out.close();
|
|
|
|
- }
|
|
|
|
- conf.set(DistCpConstants.CONF_LABEL_SSL_KEYSTORE, sslConfFileName);
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- LOG.warn("Unable to write out the ssl configuration. " +
|
|
|
|
- "Will fall back to default ssl-client.xml in class path, if there is one", e);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Find entry from distributed cache
|
|
|
|
- *
|
|
|
|
- * @param cacheFiles - All localized cache files
|
|
|
|
- * @param fileName - fileName to search
|
|
|
|
- * @return Path of the filename if found, else null
|
|
|
|
- */
|
|
|
|
- private Path findCacheFile(Path[] cacheFiles, String fileName) {
|
|
|
|
- if (cacheFiles != null && cacheFiles.length > 0) {
|
|
|
|
- for (Path file : cacheFiles) {
|
|
|
|
- if (file.getName().equals(fileName)) {
|
|
|
|
- return file;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Implementation of the Mapper::map(). Does the copy.
|
|
* Implementation of the Mapper::map(). Does the copy.
|
|
* @param relPath The target path.
|
|
* @param relPath The target path.
|