[jira] [Work logged] (CRUNCH-679) Improvements for usage of DistCp
[ https://issues.apache.org/jira/browse/CRUNCH-679?focusedWorklogId=276834=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-276834 ] ASF GitHub Bot logged work on CRUNCH-679: - Author: ASF GitHub Bot Created on: 15/Jul/19 16:42 Start Date: 15/Jul/19 16:42 Worklog Time Spent: 10m Work Description: mkwhitacre commented on pull request #20: CRUNCH-679: Improvements for usage of DistCp URL: https://github.com/apache/crunch/pull/20 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 276834) Time Spent: 1.5h (was: 1h 20m) > Improvements for usage of DistCp > > > Key: CRUNCH-679 > URL: https://issues.apache.org/jira/browse/CRUNCH-679 > Project: Crunch > Issue Type: Improvement > Components: Core >Reporter: Andrew Olson >Assignee: Josh Wills >Priority: Major > Time Spent: 1.5h > Remaining Estimate: 0h > > As a follow-up to CRUNCH-660 and CRUNCH-675, a handful of corrections and > improvements have been identified during testing. > * We need to preserve preferred part names, e.g. part-m-0. Currently the > DistCp support in Crunch does not make use of the FileTargetImpl#getDestFile > method, and would therefore create destination file names like out0-m-0, > which are problematic when there are multiple map-only jobs writing to the > same target path. This can be achieved by providing a custom CopyListing > implementation that is capable of dynamically renaming target paths based on > a given mapping. Unfortunately a substantial amount of code duplication from > the original SimpleCopyListing class is currently required in order to inject > the necessary logic for modifying the sequence file entry keys. HADOOP-16147 > has been opened to allow it to be simplified in the future. > * The handleOutputs implementation in HFileTarget is essentially identical to > the one in FileTargetImpl that it overrides. We can remove it and just share > the same code. > * It could be useful to add a property for configuring the max DistCp task > bandwidth, as the default (100 MB/s per task) may be too high for certain > environments. > * The default of 1000 for max DistCp map tasks may be too high in some > situations resulting in 503 Slow Down errors from S3 especially if there are > multiple jobs writing into the same bucket. Reducing to 100 should help > prevent issues along those lines while still providing adequate parallel > throughput. -- This message was sent by Atlassian JIRA (v7.6.14#76016)
[jira] [Work logged] (CRUNCH-679) Improvements for usage of DistCp
[ https://issues.apache.org/jira/browse/CRUNCH-679?focusedWorklogId=276781=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-276781 ] ASF GitHub Bot logged work on CRUNCH-679: - Author: ASF GitHub Bot Created on: 15/Jul/19 15:29 Start Date: 15/Jul/19 15:29 Worklog Time Spent: 10m Work Description: noslowerdna commented on pull request #20: CRUNCH-679: Improvements for usage of DistCp URL: https://github.com/apache/crunch/pull/20#discussion_r303498022 ## File path: crunch-core/src/main/java/org/apache/crunch/util/CrunchRenameCopyListing.java ## @@ -0,0 +1,272 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the + * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" + * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.apache.crunch.util; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.io.SequenceFile; +import org.apache.hadoop.io.Text; +import org.apache.hadoop.security.Credentials; +import org.apache.hadoop.tools.CopyListing; +import org.apache.hadoop.tools.CopyListingFileStatus; +import org.apache.hadoop.tools.DistCpOptions; +import org.apache.hadoop.tools.DistCpOptions.FileAttribute; +import org.apache.hadoop.tools.SimpleCopyListing; +import org.apache.hadoop.tools.util.DistCpUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Stack; + +/** + * A custom {@link CopyListing} implementation capable of dynamically renaming + * the target paths according to a {@link #DISTCP_PATH_RENAMES configured set of values}. + * + * Once https://issues.apache.org/jira/browse/HADOOP-16147 is available, this + * class can be significantly simplified. + * + */ +public class CrunchRenameCopyListing extends SimpleCopyListing { + /** + * Comma-separated list of original-file:renamed-file path rename pairs. + */ + public static final String DISTCP_PATH_RENAMES = "crunch.distcp.path.renames"; + + private static final Logger LOG = LoggerFactory.getLogger(CrunchRenameCopyListing.class); + private final Map pathRenames; + + private long totalPaths = 0; + private long totalBytesToCopy = 0; + + /** + * Constructor, to initialize configuration. + * + * @param configuration The input configuration, with which the source/target FileSystems may be accessed. + * @param credentials - Credentials object on which the FS delegation tokens are cached. If null + * delegation token caching is skipped + */ + public CrunchRenameCopyListing(Configuration configuration, Credentials credentials) { +super(configuration, credentials); + +pathRenames = new HashMap<>(); + +String[] pathRenameConf = configuration.getStrings(DISTCP_PATH_RENAMES); +if (pathRenameConf == null) { + throw new IllegalArgumentException("Missing required configuration: " + DISTCP_PATH_RENAMES); +} +for (String pathRename : pathRenameConf) { + String[] pathRenameParts = pathRename.split(":"); + if (pathRenameParts.length != 2) { +throw new IllegalArgumentException("Invalid path rename format: " + pathRename); + } + if (pathRenames.put(pathRenameParts[0], pathRenameParts[1]) != null) { +throw new IllegalArgumentException("Invalid duplicate path rename: " + pathRenameParts[0]); + } +} +LOG.info("Loaded {} path rename entries", pathRenames.size()); + +// Clear out the rename configuration property, as it is no longer needed +configuration.unset(DISTCP_PATH_RENAMES); + } + + @Override + public void doBuildListing(SequenceFile.Writer fileListWriter, DistCpOptions options) throws IOException { +try { + for (Path path : options.getSourcePaths()) { +FileSystem sourceFS = path.getFileSystem(getConf()); +final boolean preserveAcls = options.shouldPreserve(FileAttribute.ACL); +final boolean preserveXAttrs = options.shouldPreserve(FileAttribute.XATTR); +final boolean preserveRawXAttrs = options.shouldPreserveRawXattrs(); +path = makeQualified(path); + +FileStatus
[jira] [Work logged] (CRUNCH-679) Improvements for usage of DistCp
[ https://issues.apache.org/jira/browse/CRUNCH-679?focusedWorklogId=276164=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-276164 ] ASF GitHub Bot logged work on CRUNCH-679: - Author: ASF GitHub Bot Created on: 12/Jul/19 21:48 Start Date: 12/Jul/19 21:48 Worklog Time Spent: 10m Work Description: mkwhitacre commented on pull request #20: CRUNCH-679: Improvements for usage of DistCp URL: https://github.com/apache/crunch/pull/20#discussion_r303159612 ## File path: crunch-core/src/main/java/org/apache/crunch/util/CrunchRenameCopyListing.java ## @@ -0,0 +1,272 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the + * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" + * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.apache.crunch.util; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.io.SequenceFile; +import org.apache.hadoop.io.Text; +import org.apache.hadoop.security.Credentials; +import org.apache.hadoop.tools.CopyListing; +import org.apache.hadoop.tools.CopyListingFileStatus; +import org.apache.hadoop.tools.DistCpOptions; +import org.apache.hadoop.tools.DistCpOptions.FileAttribute; +import org.apache.hadoop.tools.SimpleCopyListing; +import org.apache.hadoop.tools.util.DistCpUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Stack; + +/** + * A custom {@link CopyListing} implementation capable of dynamically renaming + * the target paths according to a {@link #DISTCP_PATH_RENAMES configured set of values}. + * + * Once https://issues.apache.org/jira/browse/HADOOP-16147 is available, this + * class can be significantly simplified. + * + */ +public class CrunchRenameCopyListing extends SimpleCopyListing { + /** + * Comma-separated list of original-file:renamed-file path rename pairs. + */ + public static final String DISTCP_PATH_RENAMES = "crunch.distcp.path.renames"; + + private static final Logger LOG = LoggerFactory.getLogger(CrunchRenameCopyListing.class); + private final Map pathRenames; + + private long totalPaths = 0; + private long totalBytesToCopy = 0; + + /** + * Constructor, to initialize configuration. + * + * @param configuration The input configuration, with which the source/target FileSystems may be accessed. + * @param credentials - Credentials object on which the FS delegation tokens are cached. If null + * delegation token caching is skipped + */ + public CrunchRenameCopyListing(Configuration configuration, Credentials credentials) { +super(configuration, credentials); + +pathRenames = new HashMap<>(); + +String[] pathRenameConf = configuration.getStrings(DISTCP_PATH_RENAMES); +if (pathRenameConf == null) { + throw new IllegalArgumentException("Missing required configuration: " + DISTCP_PATH_RENAMES); +} +for (String pathRename : pathRenameConf) { + String[] pathRenameParts = pathRename.split(":"); + if (pathRenameParts.length != 2) { +throw new IllegalArgumentException("Invalid path rename format: " + pathRename); + } + if (pathRenames.put(pathRenameParts[0], pathRenameParts[1]) != null) { +throw new IllegalArgumentException("Invalid duplicate path rename: " + pathRenameParts[0]); + } +} +LOG.info("Loaded {} path rename entries", pathRenames.size()); + +// Clear out the rename configuration property, as it is no longer needed +configuration.unset(DISTCP_PATH_RENAMES); + } + + @Override + public void doBuildListing(SequenceFile.Writer fileListWriter, DistCpOptions options) throws IOException { +try { + for (Path path : options.getSourcePaths()) { +FileSystem sourceFS = path.getFileSystem(getConf()); +final boolean preserveAcls = options.shouldPreserve(FileAttribute.ACL); +final boolean preserveXAttrs = options.shouldPreserve(FileAttribute.XATTR); +final boolean preserveRawXAttrs = options.shouldPreserveRawXattrs(); +path = makeQualified(path); + +FileStatus
[jira] [Work logged] (CRUNCH-679) Improvements for usage of DistCp
[ https://issues.apache.org/jira/browse/CRUNCH-679?focusedWorklogId=209674=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-209674 ] ASF GitHub Bot logged work on CRUNCH-679: - Author: ASF GitHub Bot Created on: 07/Mar/19 17:19 Start Date: 07/Mar/19 17:19 Worklog Time Spent: 10m Work Description: noslowerdna commented on pull request #20: CRUNCH-679: Improvements for usage of DistCp URL: https://github.com/apache/crunch/pull/20#discussion_r263484180 ## File path: crunch-core/src/main/java/org/apache/crunch/util/CrunchRenameCopyListing.java ## @@ -0,0 +1,269 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the + * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" + * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.apache.crunch.util; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.io.SequenceFile; +import org.apache.hadoop.io.Text; +import org.apache.hadoop.security.Credentials; +import org.apache.hadoop.tools.CopyListing; +import org.apache.hadoop.tools.CopyListingFileStatus; +import org.apache.hadoop.tools.DistCpOptions; +import org.apache.hadoop.tools.DistCpOptions.FileAttribute; +import org.apache.hadoop.tools.SimpleCopyListing; +import org.apache.hadoop.tools.util.DistCpUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Stack; + +/** + * A custom {@link CopyListing} implementation capable of dynamically renaming + * the target paths according to a configured set of values. + * + * Once https://issues.apache.org/jira/browse/HADOOP-16147 is available, this + * class can be significantly simplified. + * + */ +public class CrunchRenameCopyListing extends SimpleCopyListing { + /** + * Comma-separated list of original-file:renamed-file path rename pairs. + */ + public static final String DISTCP_PATH_RENAMES = "crunch.distcp.path.renames"; + + private static final Logger LOG = LoggerFactory.getLogger(CrunchRenameCopyListing.class); + private final Map pathRenames; + + private long totalPaths = 0; + private long totalBytesToCopy = 0; + + /** + * Protected constructor, to initialize configuration. + * + * @param configuration The input configuration, with which the source/target FileSystems may be accessed. + * @param credentials - Credentials object on which the FS delegation tokens are cached. If null + * delegation token caching is skipped + */ + protected CrunchRenameCopyListing(Configuration configuration, Credentials credentials) { Review comment: fixed: https://github.com/apache/crunch/pull/20/commits/8794d790b4b63444d61ccb013df8b4dffb1dc7d1 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 209674) Time Spent: 1h (was: 50m) > Improvements for usage of DistCp > > > Key: CRUNCH-679 > URL: https://issues.apache.org/jira/browse/CRUNCH-679 > Project: Crunch > Issue Type: Improvement > Components: Core >Reporter: Andrew Olson >Assignee: Josh Wills >Priority: Major > Time Spent: 1h > Remaining Estimate: 0h > > As a follow-up to CRUNCH-660 and CRUNCH-675, a handful of corrections and > improvements have been identified during testing. > * We need to preserve preferred part names, e.g. part-m-0. Currently the > DistCp support in Crunch does not make use of the FileTargetImpl#getDestFile > method, and would therefore create destination file names like out0-m-0, > which are problematic when there are multiple map-only jobs writing to the > same target path. This can be achieved by providing a custom CopyListing > implementation that
[jira] [Work logged] (CRUNCH-679) Improvements for usage of DistCp
[ https://issues.apache.org/jira/browse/CRUNCH-679?focusedWorklogId=208986=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-208986 ] ASF GitHub Bot logged work on CRUNCH-679: - Author: ASF GitHub Bot Created on: 06/Mar/19 17:13 Start Date: 06/Mar/19 17:13 Worklog Time Spent: 10m Work Description: noslowerdna commented on pull request #20: CRUNCH-679: Improvements for usage of DistCp URL: https://github.com/apache/crunch/pull/20#discussion_r263044336 ## File path: crunch-core/src/main/java/org/apache/crunch/util/CrunchRenameCopyListing.java ## @@ -0,0 +1,269 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the + * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" + * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.apache.crunch.util; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.io.SequenceFile; +import org.apache.hadoop.io.Text; +import org.apache.hadoop.security.Credentials; +import org.apache.hadoop.tools.CopyListing; +import org.apache.hadoop.tools.CopyListingFileStatus; +import org.apache.hadoop.tools.DistCpOptions; +import org.apache.hadoop.tools.DistCpOptions.FileAttribute; +import org.apache.hadoop.tools.SimpleCopyListing; +import org.apache.hadoop.tools.util.DistCpUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Stack; + +/** + * A custom {@link CopyListing} implementation capable of dynamically renaming + * the target paths according to a configured set of values. + * + * Once https://issues.apache.org/jira/browse/HADOOP-16147 is available, this + * class can be significantly simplified. + * + */ +public class CrunchRenameCopyListing extends SimpleCopyListing { + /** + * Comma-separated list of original-file:renamed-file path rename pairs. + */ + public static final String DISTCP_PATH_RENAMES = "crunch.distcp.path.renames"; + + private static final Logger LOG = LoggerFactory.getLogger(CrunchRenameCopyListing.class); + private final Map pathRenames; + + private long totalPaths = 0; + private long totalBytesToCopy = 0; + + /** + * Protected constructor, to initialize configuration. + * + * @param configuration The input configuration, with which the source/target FileSystems may be accessed. + * @param credentials - Credentials object on which the FS delegation tokens are cached. If null + * delegation token caching is skipped + */ + protected CrunchRenameCopyListing(Configuration configuration, Credentials credentials) { Review comment: This constructor needs to be public, otherwise it can fail with the following exception (if HADOOP_CLASSPATH isn't set) ``` Caused by: java.io.IOException: Unable to instantiate org.apache.hadoop.tools.CrunchRenameCopyListing at org.apache.hadoop.tools.CopyListing.getCopyListing(CopyListing.java:284) at org.apache.hadoop.tools.CrunchDistCp.createInputFileListing(CrunchDistCp.java:430) at org.apache.hadoop.tools.CrunchDistCp.prepareFileListing(CrunchDistCp.java:94) at org.apache.hadoop.tools.CrunchDistCp.execute(CrunchDistCp.java:184) at org.apache.crunch.io.impl.FileTargetImpl.handleOutputsDistributedCopy(FileTargetImpl.java:278) ... 11 more Caused by: java.lang.IllegalAccessException: Class org.apache.hadoop.tools.CopyListing can not access a member of class org.apache.hadoop.tools.CrunchRenameCopyListing with modifiers "protected" at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:102) at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:296) at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:288) at java.lang.reflect.Constructor.newInstance(Constructor.java:413) at org.apache.hadoop.tools.CopyListing.getCopyListing(CopyListing.java:282) ... 15 more ``` This is an automated message from the Apache Git Service. To respond to
[jira] [Work logged] (CRUNCH-679) Improvements for usage of DistCp
[ https://issues.apache.org/jira/browse/CRUNCH-679?focusedWorklogId=207918=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-207918 ] ASF GitHub Bot logged work on CRUNCH-679: - Author: ASF GitHub Bot Created on: 05/Mar/19 18:03 Start Date: 05/Mar/19 18:03 Worklog Time Spent: 10m Work Description: noslowerdna commented on pull request #20: CRUNCH-679: Improvements for usage of DistCp URL: https://github.com/apache/crunch/pull/20#discussion_r262615465 ## File path: crunch-core/src/main/java/org/apache/crunch/util/CrunchRenameCopyListing.java ## @@ -0,0 +1,269 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the + * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" + * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.apache.crunch.util; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.io.SequenceFile; +import org.apache.hadoop.io.Text; +import org.apache.hadoop.security.Credentials; +import org.apache.hadoop.tools.CopyListing; +import org.apache.hadoop.tools.CopyListingFileStatus; +import org.apache.hadoop.tools.DistCpOptions; +import org.apache.hadoop.tools.DistCpOptions.FileAttribute; +import org.apache.hadoop.tools.SimpleCopyListing; +import org.apache.hadoop.tools.util.DistCpUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Stack; + +/** + * A custom {@link CopyListing} implementation capable of dynamically renaming + * the target paths according to a configured set of values. + * + * Once https://issues.apache.org/jira/browse/HADOOP-16147 is available, this + * class can be significantly simplified. + * + */ +public class CrunchRenameCopyListing extends SimpleCopyListing { + /** + * Comma-separated list of original-file:renamed-file path rename pairs. + */ + public static final String DISTCP_PATH_RENAMES = "crunch.distcp.path.renames"; + + private static final Logger LOG = LoggerFactory.getLogger(CrunchRenameCopyListing.class); + private final Map pathRenames; + + private long totalPaths = 0; + private long totalBytesToCopy = 0; + + /** + * Protected constructor, to initialize configuration. + * + * @param configuration The input configuration, with which the source/target FileSystems may be accessed. + * @param credentials - Credentials object on which the FS delegation tokens are cached. If null + * delegation token caching is skipped + */ + protected CrunchRenameCopyListing(Configuration configuration, Credentials credentials) { +super(configuration, credentials); + +pathRenames = new HashMap<>(); + +String[] pathRenameConf = configuration.getStrings(DISTCP_PATH_RENAMES); Review comment: I ran some tests and did not encounter any problems I would consider showstopping. My largest concern is it appeared that the DistCp job completion time was delayed roughly proportionally to the size of the configuration, with a delay of nearly two minutes observed in the worst case test - I think probably due to persisting the configuration into job history. ``` 19/03/05 11:04:53 INFO mapreduce.Job: map 100% reduce 0% 19/03/05 11:06:48 INFO mapreduce.Job: Job job_1538164922410_717171 completed successfully ``` Otherwise everything looked good, and viewing the job configuration through the web UI worked fine although slow when the size was in multiple MBs. The configuration property value size was retrieved by, ``` conf.get(CrunchRenameCopyListing.DISTCP_PATH_RENAMES).length() ``` Number of part files | Configuration size | Completion delay -- | -- | -- 10k | 260kb | 0:05 50k | 1.3mb | 0:29 250k | 6.8mb | 0:54 500k | 13.8mb | 1:55 This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[jira] [Work logged] (CRUNCH-679) Improvements for usage of DistCp
[ https://issues.apache.org/jira/browse/CRUNCH-679?focusedWorklogId=206528=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-206528 ] ASF GitHub Bot logged work on CRUNCH-679: - Author: ASF GitHub Bot Created on: 01/Mar/19 17:09 Start Date: 01/Mar/19 17:09 Worklog Time Spent: 10m Work Description: mkwhitacre commented on pull request #20: CRUNCH-679: Improvements for usage of DistCp URL: https://github.com/apache/crunch/pull/20#discussion_r261682765 ## File path: crunch-core/src/main/java/org/apache/crunch/util/CrunchRenameCopyListing.java ## @@ -0,0 +1,261 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the + * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" + * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.apache.crunch.util; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.io.SequenceFile; +import org.apache.hadoop.io.Text; +import org.apache.hadoop.security.Credentials; +import org.apache.hadoop.tools.CopyListing; +import org.apache.hadoop.tools.CopyListingFileStatus; +import org.apache.hadoop.tools.DistCpOptions; +import org.apache.hadoop.tools.DistCpOptions.FileAttribute; +import org.apache.hadoop.tools.SimpleCopyListing; +import org.apache.hadoop.tools.util.DistCpUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Stack; + +/** + * A custom {@link CopyListing} implementation capable of dynamically renaming + * the target paths according to a configured set of values. + * + * Once https://issues.apache.org/jira/browse/HADOOP-16147 is available, this + * class can be significantly simplified. + * + */ +public class CrunchRenameCopyListing extends SimpleCopyListing { + /** + * Comma-separated list of original-file:renamed-file path rename pairs. + */ + public static final String DISTCP_PATH_RENAMES = "crunch.distcp.path.renames"; + + private static final Logger LOG = LoggerFactory.getLogger(CrunchRenameCopyListing.class); + private final Map pathRenames; + + private long totalPaths = 0; + private long totalBytesToCopy = 0; + + /** + * Protected constructor, to initialize configuration. + * + * @param configuration The input configuration, with which the source/target FileSystems may be accessed. + * @param credentials - Credentials object on which the FS delegation tokens are cached. If null + * delegation token caching is skipped + */ + protected CrunchRenameCopyListing(Configuration configuration, Credentials credentials) { +super(configuration, credentials); + +pathRenames = new HashMap<>(); + +String[] pathRenameConf = configuration.getStrings(DISTCP_PATH_RENAMES); +if (pathRenameConf == null) { + throw new IllegalArgumentException("Missing required configuration: " + DISTCP_PATH_RENAMES); +} +for (String pathRename : pathRenameConf) { + String[] pathRenameParts = pathRename.split(":"); + if (pathRenameParts.length != 2) { +throw new IllegalArgumentException("Invalid path rename format: " + pathRename); + } + if (pathRenames.put(pathRenameParts[0], pathRenameParts[1]) != null) { +throw new IllegalArgumentException("Invalid duplicate path rename: " + pathRenameParts[0]); + } +} +LOG.info("Loaded {} path rename entries", pathRenames.size()); + } + + @Override + public void doBuildListing(SequenceFile.Writer fileListWriter, DistCpOptions options) throws IOException { +try { + for (Path path : options.getSourcePaths()) { +FileSystem sourceFS = path.getFileSystem(getConf()); +final boolean preserveAcls = options.shouldPreserve(FileAttribute.ACL); +final boolean preserveXAttrs = options.shouldPreserve(FileAttribute.XATTR); +final boolean preserveRawXAttrs = options.shouldPreserveRawXattrs(); +path = makeQualified(path); + +FileStatus rootStatus = sourceFS.getFileStatus(path); +Path sourcePathRoot = computeSourceRootPath(rootStatus, options); + +FileStatus[]
[jira] [Work logged] (CRUNCH-679) Improvements for usage of DistCp
[ https://issues.apache.org/jira/browse/CRUNCH-679?focusedWorklogId=204700=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-204700 ] ASF GitHub Bot logged work on CRUNCH-679: - Author: ASF GitHub Bot Created on: 26/Feb/19 19:33 Start Date: 26/Feb/19 19:33 Worklog Time Spent: 10m Work Description: noslowerdna commented on pull request #20: CRUNCH-679: Improvements for usage of DistCp URL: https://github.com/apache/crunch/pull/20 This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking --- Worklog Id: (was: 204700) Time Spent: 10m Remaining Estimate: 0h > Improvements for usage of DistCp > > > Key: CRUNCH-679 > URL: https://issues.apache.org/jira/browse/CRUNCH-679 > Project: Crunch > Issue Type: Improvement > Components: Core >Reporter: Andrew Olson >Assignee: Josh Wills >Priority: Major > Time Spent: 10m > Remaining Estimate: 0h > > As a follow-up to CRUNCH-660 and CRUNCH-675, a handful of corrections and > improvements have been identified during testing. > * We need to preserve preferred part names, e.g. part-m-0. Currently the > DistCp support in Crunch does not make use of the FileTargetImpl#getDestFile > method, and would therefore create destination file names like out0-m-0, > which are problematic when there are multiple map-only jobs writing to the > same target path. This can be achieved by providing a custom CopyListing > implementation that is capable of dynamically renaming target paths based on > a given mapping. Unfortunately a substantial amount of code duplication from > the original SimpleCopyListing class is currently required in order to inject > the necessary logic for modifying the sequence file entry keys. HADOOP-16147 > has been opened to allow it to be simplified in the future. > * The handleOutputs implementation in HFileTarget is essentially identical to > the one in FileTargetImpl that it overrides. We can remove it and just share > the same code. > * It could be useful to add a property for configuring the max DistCp task > bandwidth, as the default (100 MB/s per task) may be too high for certain > environments. -- This message was sent by Atlassian JIRA (v7.6.3#76005)