-
Notifications
You must be signed in to change notification settings - Fork 117
FALCON-2188 Rest api to register extension #304
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One uber question I had regarding register, unregister etc. These calls must only go to Prism (in distributed mode) and the metadata store is only present on Prism. How/where are you handling in the code to ensure this?
@@ -158,6 +167,7 @@ public Options createExtensionOptions() { | |||
Option resume = new Option(FalconCLIConstants.RESUME_OPT, false, "Resume an extension job"); | |||
Option delete = new Option(FalconCLIConstants.DELETE_OPT, false, "Delete an extension job"); | |||
Option unregister = new Option(FalconCLIConstants.UREGISTER, false, "Delete metadata of extension job"); | |||
Option register = new Option(FalconCLIConstants.REGISTER, false, "Add metadata of extension job"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description can be better. "Register an extension with Falcon. This will make the extension available for instantiation for all users.
checkIfExtensionServiceIsEnabled(); | ||
validateExtensionName(extensionName); | ||
try { | ||
return ExtensionStore.get().registerExtensionMetadata(extensionName, path, description); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add another validation to ensure description is not empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
had a discussion with @sandeepSamudrala and decided it can be a optional field.Let me know if you think otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine. That is ok. Thanks for clarifying.
return file.getName().endsWith(".jar"); | ||
} | ||
}; | ||
FileStatus[] fileStatusJar = fileSystem.listStatus(new Path(uri.getPath() + "/libs"), filter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Believe we should check under libs/build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we need to correct the doc too because in the doc there is no mention of libs/build or libs/runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which doc are you talking about? The design doc has it.
URI uri = new URI(path); | ||
conf.set("fs.default.name", uri.getScheme() + "://" + uri.getAuthority()); | ||
FileSystem fileSystem = HadoopClientFactory.get().createFalconFileSystem(uri); | ||
FileStatus[] fileStatusReadMe = fileSystem.listStatus(new Path(uri.getPath() + "/README")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess it is sufficient to check for the existence of README and check if it is a file.
}; | ||
FileStatus[] fileStatusJar = fileSystem.listStatus(new Path(uri.getPath() + "/libs"), filter); | ||
|
||
if (fileStatusReadMe.length == 1 && fileStatusJar.length >0){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional check for existence at least 1 file under META is required.
if (fileStatusReadMe.length == 1 && fileStatusJar.length >0){ | ||
metaStore.storeExtensionMetadataBean(extensionName, path, ExtensionType.CUSTOM, description); | ||
}else{ | ||
throw new ValidationException("Packaging structure is not currect please refer to documentation"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message : Packaging structure of extension ${extensionName} is not correct. Please refer the documentation for details
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it is preferable to do individual checks and print the appropriate error message, rather than asking user to refer docs.
@pallavi-rao ExtensionService will only be up at prism and that will take care of the requests. Please correct if I am missing some thing here. |
@PraveenAdlakha ExtensionService may be up only for Prism. However, ExtensionManager is available for prism and falcon webapps. Hence the request will be accepted and may result in an improper error. |
ohhkk got it..Then we can do what we are doing with EntityManager and InstanceManager for better error handling.Will take it up as a separate jira. |
return file.getName().endsWith(".jar"); | ||
} | ||
}; | ||
FileStatus[] fileStatusJar = fileSystem.listStatus(new Path(uri.getPath() + "/libs"), filter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which doc are you talking about? The design doc has it.
checkIfExtensionServiceIsEnabled(); | ||
validateExtensionName(extensionName); | ||
try { | ||
return ExtensionStore.get().registerExtensionMetadata(extensionName, path, description); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine. That is ok. Thanks for clarifying.
|
||
@BeforeMethod | ||
public void clean() { | ||
clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clean up the file system too
Will merge this. There is a test case that this PR breaks. I will address that with a separate PR as @PraveenAdlakha is out on vacation. |
$ bin/falcon extension -register -extensionName test -path hdfs://hostname:8020/user/dataqa/sampleextension -description "test ing" Extension:testregistered succesfully. Also we get file not found exception if jars or Readme is not present please look at the test cases. Author: Praveen Adlakha <adlakha.praveen@gmail.com> Reviewers: @sandeepSamudrala, @pallavi-rao Closes apache#304 from PraveenAdlakha/2188 and squashes the following commits: e4c21a0 [Praveen Adlakha] test case disabled 90e6ec9 [Praveen Adlakha] minor comments addressed 52f6ebc [Praveen Adlakha] comments addressed 05c9c5e [Praveen Adlakha] comments addressed and test cases updated 9a74a2c [Praveen Adlakha] FALCON-2188 Rest api to register extension
$ bin/falcon extension -register -extensionName test -path hdfs://hostname:8020/user/dataqa/sampleextension -description "test ing"
Extension:testregistered succesfully.
Also we get file not found exception if jars or Readme is not present please look at the test cases.