Skip to content
This repository has been archived by the owner on Apr 4, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/apache/falcon
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepSamudrala committed Dec 26, 2016
2 parents b1546ed + 299b827 commit 4a2e23e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,22 @@ public String deleteExtension(final String extensionName, String currentUser) th
}
}

private void assertURI(String part, String value) throws ValidationException {
if (value == null) {
String msg = "Invalid Path supplied. " + part + " is missing. "
+ " Path must contain scheme, authority and path.";
LOG.error(msg);
throw new ValidationException(msg);
}
}

public String registerExtension(final String extensionName, final String path, final String description,
String extensionOwner) throws URISyntaxException, FalconException {
Configuration conf = new Configuration();
URI uri = new URI(path);
assertURI("Scheme", uri.getScheme());
assertURI("Authority", uri.getAuthority());
assertURI("Path", uri.getPath());
conf.set("fs.defaultFS", uri.getScheme() + "://" + uri.getAuthority());
FileSystem fileSystem = HadoopClientFactory.get().createFalconFileSystem(uri);
try {
Expand Down Expand Up @@ -313,6 +325,7 @@ public boolean accept(Path file) {
} else {
throw new ValidationException(extensionName + " already exists.");
}
LOG.info("Extension :" + extensionName + " registered successfully.");
return "Extension :" + extensionName + " registered successfully.";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ public void clean() {
}
}

@Test(expectedExceptions=ValidationException.class)
public void testFailureCaseRegisterExtensionForURL() throws IOException, URISyntaxException, FalconException{
store = ExtensionStore.get();
createLibs(EXTENSION_PATH);
store.registerExtension("test", EXTENSION_PATH, "test desc", "falconUser");
}

@Test
public void testRegisterExtension() throws IOException, URISyntaxException, FalconException {
String extensionPath = EXTENSION_PATH + "testRegister";
Expand Down
19 changes: 17 additions & 2 deletions unit/src/test/java/org/apache/falcon/unit/TestFalconUnit.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@
import org.apache.falcon.resource.InstancesResult;
import org.apache.falcon.resource.InstancesSummaryResult;
import org.apache.falcon.service.FalconJPAService;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.LocalFileSystem;
import org.apache.hadoop.fs.Path;
import org.codehaus.jettison.json.JSONObject;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import javax.persistence.EntityManager;
Expand Down Expand Up @@ -67,6 +71,16 @@ public class TestFalconUnit extends FalconUnitTestBase {
private static final String SLEEP_WORKFLOW = "sleepWorkflow.xml";
private static final String EXTENSION_PATH = "/projects/falcon/extension/testExtension";
public static final String JARS_DIR = "file:///" + System.getProperty("user.dir") + "/src/test/resources";
private FileSystem fileSystem;

private static final String STORAGE_URL = "jail://global:00";

@BeforeClass
public void init() throws IOException{
Configuration conf = new Configuration();
conf.set("fs.defaultFS", STORAGE_URL);
fs.initialize(LocalFileSystem.getDefaultUri(conf), conf);
}

@Test
public void testProcessInstanceExecution() throws Exception {
Expand Down Expand Up @@ -407,7 +421,8 @@ public void testRegisterAndUnregisterExtension() throws Exception {
submitCluster();
createExtensionPackage();

String result = registerExtension("testExtension", new Path(EXTENSION_PATH).toString(), "testExtension");
String result = registerExtension("testExtension", new Path(STORAGE_URL + EXTENSION_PATH).toString()
, "testExtension");
Assert.assertEquals(result, "Extension :testExtension registered successfully.");

result = unregisterExtension("testExtension");
Expand All @@ -420,7 +435,7 @@ public void testSubmitAndScheduleExtensionJob() throws Exception {
submitCluster();
createExtensionPackage();
String packageBuildLib = new Path(EXTENSION_PATH, "libs/build/").toString();
String result = registerExtension("testExtension", EXTENSION_PATH, "testExtension");
String result = registerExtension("testExtension", STORAGE_URL + EXTENSION_PATH, "testExtension");
Assert.assertEquals(result, "Extension :testExtension registered successfully.");

createDir(PROCESS_APP_PATH);
Expand Down

0 comments on commit 4a2e23e

Please sign in to comment.