Repository: cassandra Updated Branches: refs/heads/trunk dad0bfac6 -> 24b18a9e5
Fix pig tests on Windows patch by Benjamin Lerer; reviewed by Josh McKenzie for CASSANDRA-7986 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/24b18a9e Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/24b18a9e Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/24b18a9e Branch: refs/heads/trunk Commit: 24b18a9e5d050a28c3f359ee29d496fda4b38e98 Parents: dad0bfa Author: blerer <b_le...@hotmail.com> Authored: Wed Sep 24 11:01:43 2014 -0500 Committer: Joshua McKenzie <josh.mcken...@datastax.com> Committed: Wed Sep 24 11:01:43 2014 -0500 ---------------------------------------------------------------------- test/pig/org/apache/pig/test/MiniCluster.java | 9 ++- .../apache/pig/test/WindowsLocalFileSystem.java | 62 ++++++++++++++++++++ 2 files changed, 69 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/24b18a9e/test/pig/org/apache/pig/test/MiniCluster.java ---------------------------------------------------------------------- diff --git a/test/pig/org/apache/pig/test/MiniCluster.java b/test/pig/org/apache/pig/test/MiniCluster.java index e8f1f6e..ad50f69 100644 --- a/test/pig/org/apache/pig/test/MiniCluster.java +++ b/test/pig/org/apache/pig/test/MiniCluster.java @@ -21,7 +21,9 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.util.Locale; +import org.apache.cassandra.utils.FBUtilities; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hdfs.MiniDFSCluster; import org.apache.hadoop.mapred.MiniMRCluster; @@ -48,6 +50,8 @@ public class MiniCluster extends MiniGenericCluster { // Builds and starts the mini dfs and mapreduce clusters Configuration config = new Configuration(); + if (!FBUtilities.isUnix()) + config.set("fs.file.impl", WindowsLocalFileSystem.class.getName()); m_dfs = new MiniDFSCluster(config, dataNodes, true, null); m_fileSys = m_dfs.getFileSystem(); m_mr = new MiniMRCluster(taskTrackers, m_fileSys.getUri().toString(), 1); @@ -76,7 +80,8 @@ public class MiniCluster extends MiniGenericCluster { @Override protected void shutdownMiniMrClusters() { - if (m_mr != null) { m_mr.shutdown(); } - m_mr = null; + if (m_mr != null) + m_mr.shutdown(); + m_mr = null; } } http://git-wip-us.apache.org/repos/asf/cassandra/blob/24b18a9e/test/pig/org/apache/pig/test/WindowsLocalFileSystem.java ---------------------------------------------------------------------- diff --git a/test/pig/org/apache/pig/test/WindowsLocalFileSystem.java b/test/pig/org/apache/pig/test/WindowsLocalFileSystem.java new file mode 100644 index 0000000..9193341 --- /dev/null +++ b/test/pig/org/apache/pig/test/WindowsLocalFileSystem.java @@ -0,0 +1,62 @@ +/* + * 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.pig.test; + +import java.io.IOException; + +import org.apache.hadoop.fs.LocalFileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.permission.FsPermission; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Workaround for https://issues.apache.org/jira/browse/HADOOP-7682 used to allow the Pig-tests to run on Cygwin on + * a Windows box. This workaround was suggested by Joshua Caplan in the comments of HADOOP-7682. + */ +public final class WindowsLocalFileSystem extends LocalFileSystem +{ + private final Logger logger = LoggerFactory.getLogger(getClass()); + + public WindowsLocalFileSystem() + { + logger.warn("Using {} instead of org.apache.hadoop.fs.LocalFileSystem to avoid the problem linked to HADOOP-7682. " + + "IOException thrown when setting permissions will be swallowed.", getClass().getName()); + } + + @Override + public boolean mkdirs(Path path, FsPermission permission) throws IOException + { + boolean result = super.mkdirs(path); + setPermission(path, permission); + return result; + } + + @Override + public void setPermission(Path p, FsPermission permission) throws IOException + { + try + { + super.setPermission(p, permission); + } + catch (IOException e) + { + // Just swallow the Exception as logging it produces too much output. + } + } +}