This repository has been archived by the owner on Apr 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/apache/falcon
- Loading branch information
Showing
27 changed files
with
314 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
common/src/main/java/org/apache/falcon/util/FSDRUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* 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.falcon.util; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.falcon.FalconException; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.fs.FileSystem; | ||
import org.apache.hadoop.fs.Path; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
/** | ||
* Util class for FS DR. | ||
*/ | ||
public final class FSDRUtils { | ||
private FSDRUtils() { | ||
} | ||
|
||
private static final List<String> HDFS_SCHEME_PREFIXES = | ||
Arrays.asList("file", "hdfs", "hftp", "hsftp", "webhdfs", "swebhdfs"); | ||
|
||
private static Configuration defaultConf = new Configuration(); | ||
|
||
public static Configuration getDefaultConf() { | ||
return defaultConf; | ||
} | ||
|
||
public static void setDefaultConf(Configuration conf) { | ||
defaultConf = conf; | ||
} | ||
|
||
public static boolean isHCFS(Path filePath) throws FalconException { | ||
if (filePath == null) { | ||
throw new FalconException("filePath cannot be empty"); | ||
} | ||
|
||
String scheme; | ||
try { | ||
FileSystem f = FileSystem.get(filePath.toUri(), getDefaultConf()); | ||
scheme = f.getScheme(); | ||
if (StringUtils.isBlank(scheme)) { | ||
throw new FalconException("Cannot get valid scheme for " + filePath); | ||
} | ||
} catch (IOException e) { | ||
throw new FalconException(e); | ||
} | ||
|
||
return HDFS_SCHEME_PREFIXES.contains(scheme.toLowerCase().trim()) ? false : true; | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
common/src/test/java/org/apache/falcon/util/FSDRUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* 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.falcon.util; | ||
|
||
import org.apache.falcon.FalconException; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.fs.Path; | ||
import org.testng.Assert; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
/** | ||
* Tests FSDRUtils. | ||
*/ | ||
public final class FSDRUtilsTest { | ||
|
||
@BeforeClass | ||
private void setup() throws Exception { | ||
Configuration conf = new Configuration(); | ||
conf.set("fs.s3n.awsAccessKeyId", "testS3KeyId"); | ||
conf.set("fs.s3n.awsSecretAccessKey", "testS3AccessKey"); | ||
conf.set("fs.azure.account.key.mystorage.blob.core.windows.net", "dGVzdEF6dXJlQWNjZXNzS2V5"); | ||
FSDRUtils.setDefaultConf(conf); | ||
} | ||
|
||
@Test(expectedExceptions = FalconException.class, expectedExceptionsMessageRegExp = "filePath cannot be empty") | ||
public void testIsHCFSEmptyPath() throws Exception { | ||
FSDRUtils.isHCFS(null); | ||
} | ||
|
||
@Test | ||
public void testIsHCFS() throws Exception { | ||
boolean isHCFSPath = FSDRUtils.isHCFS(new Path("/apps/dr")); | ||
Assert.assertFalse(isHCFSPath); | ||
|
||
isHCFSPath = FSDRUtils.isHCFS(new Path("hdfs://localhost:54136/apps/dr")); | ||
Assert.assertFalse(isHCFSPath); | ||
|
||
isHCFSPath = FSDRUtils.isHCFS(new Path("hftp://localhost:54136/apps/dr")); | ||
Assert.assertFalse(isHCFSPath); | ||
|
||
isHCFSPath = FSDRUtils.isHCFS(new Path("s3n://testBucket/apps/dr")); | ||
Assert.assertTrue(isHCFSPath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.