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

FALCON-2226 Submit ,Schedule and submitAndSchedule API for extension #327

Closed
wants to merge 9 commits into from

Conversation

PraveenAdlakha
Copy link
Contributor

No description provided.

@PraveenAdlakha PraveenAdlakha changed the title 2226 FALCON-2226 Submit ,Schedule and submitAndSchedule API for extension Dec 22, 2016
@@ -52,6 +52,7 @@

##Add if you want to use Trusted or User Extensions
## In case of distributed Mode enable ExtensionService only on Prism via prism.application.services

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit : Unnecessary change.

@@ -58,6 +46,7 @@
private static final String CONFIG = "config";
private static final String CREATION_TIME = "creationTime";
private static final String LAST_UPDATE_TIME = "lastUpdatedTime";
public static final String FALCON_TAG = "falcon";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think this is used in this class. May be move it proxy?

@@ -317,8 +330,8 @@ public APIResult submit(

try {
entityMap = getEntityList(extensionName, jobName, feedForms, processForms, config);
submitEntities(extensionName, doAsUser, jobName, entityMap, config);
} catch (FalconException | IOException e) {
submitEntities(extensionName, jobName, entityMap, config, request);
Copy link

@pallavi-rao pallavi-rao Dec 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has doAsUser been knocked off? I know we don't use it now. But, since there is a plan to enable it later, we shouldn't be removing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

submit API in SchedulableEntityManagerProxy doesnot take doAs as a param we should not do it too.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough.


for(Map.Entry<EntityType, List<Entity>> entry : entityMap.entrySet()){
for(final Entity entity : entry.getValue()){
final HttpServletRequest httpServletRequest = getEntityStream(entity, entity.getEntityType(), request);
Copy link

@pallavi-rao pallavi-rao Dec 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the eventual goal is to get the bufferedRequest I think getEntityStream and getBufferedRequest can be merged into a single method.

submitInternal(process, doAsUser);
processNames.add(process.getName());

for(Map.Entry<EntityType, List<Entity>> entry : entityMap.entrySet()){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The feeds have to be submitted before processes are. Else, the process submission will fail due to non-existence of a feed.

@@ -691,4 +778,61 @@ private static void checkIfExtensionServiceIsEnabled() {
ExtensionService.SERVICE_NAME + " is not enabled.", Response.Status.NOT_FOUND);
}
}

private abstract class EntitiesProxy<T extends APIResult> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this class here? Where is it used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed will remove.


for(Map.Entry<EntityType, List<Entity>> entry : entityMap.entrySet()){
for(Entity entity : entry.getValue()){
submitInternal(entity, "falconUser");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feeds before processes, here too. May be create a method and call from both submit and submitAndSchedule.

List<String> processNames = new ArrayList<>();
for(Map.Entry<EntityType, List<Entity>> entry : entityMap.entrySet()){
for(Entity entity : entry.getValue()){
submitInternal(entity, "falconUser");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feeds before processes.

import java.util.List;
import java.util.Map;

/**
* A proxy implementation of the extension operations in local mode.
*/
public class LocalExtensionManager extends AbstractExtensionManager {
public class LocalExtensionManager extends ExtensionManagerProxy {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why extend Proxy? Falcon Unit shouldn't worry about Proxy.

@@ -326,7 +325,7 @@ public APIResult submit(
@FormDataParam("feeds") List<FormDataBodyPart> feedForms,
@FormDataParam("config") InputStream config) {
checkIfExtensionServiceIsEnabled();
Map<EntityType, List<Entity>> entityMap;
TreeMap<EntityType, List<Entity>> entityMap;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declaration should only have Map... Only instantiation should be TreeMap.

@@ -338,15 +337,15 @@ public APIResult submit(
return new APIResult(APIResult.Status.SUCCEEDED, "Extension job submitted successfully:" + jobName);
}

private Map<EntityType, List<Entity>> getEntityList(String extensionName, String jobName,
private TreeMap<EntityType, List<Entity>> getEntityList(String extensionName, String jobName,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declaration should just be Map

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want the contract to be tightly coupled so have changed it to SortedMap.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, as long as it is an Interface as you have used (SortedMap) and not the impl., it is fine.

List<FormDataBodyPart> feedForms,
List<FormDataBodyPart> processForms, InputStream config)
throws FalconException, IOException{
List<Entity> processes = getProcesses(processForms);
List<Entity> feeds = getFeeds(feedForms);
ExtensionType extensionType = getExtensionType(extensionName);
List<Entity> entities;
Map<EntityType, List<Entity>> entityMap = new HashMap<>();
TreeMap<EntityType, List<Entity>> entityMap = new TreeMap<>();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Believe you made this a tree map, so that during submission, feeds go first? But, while putting elements into this map, processes are going in first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internally tree will store in the natural ordering and Enum maintains it in the ordinal value in which feed it the first one so we should be good here.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh.. right.. My bad. In my head, I mixed it up with LinkedHashMap.

@@ -442,7 +441,7 @@ private BufferedRequest getBufferedRequest(HttpServletRequest request) {
}

protected void submitEntities(String extensionName, String jobName,
Map<EntityType, List<Entity>> entityMap, InputStream configStream,
TreeMap<EntityType, List<Entity>> entityMap, InputStream configStream,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method signature should just have the interface name, Map.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed it to SortedMap.

@@ -285,14 +285,14 @@ public APIResult submitExtensionJob(String extensionName, String jobName, String

InputStream configStream = getServletInputStream(configPath);
try {
Map<EntityType, List<Entity>> entityMap = getEntityTypeListMap(extensionName, jobName, configStream);
TreeMap<EntityType, List<Entity>> entityMap = getEntityTypeListMap(extensionName, jobName, configStream);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above for the declarations in this class too. Method signatures and declaration should just have Map.

Copy link

@pallavi-rao pallavi-rao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the TreeMap to SortedMap both in FalconUnitClient and LocalExtensionManager

Copy link

@pallavi-rao pallavi-rao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@pallavi-rao
Copy link

Unrelated build failure.. merging.

@asfgit asfgit closed this in 9946758 Dec 26, 2016
pallavi-rao pushed a commit to pallavi-rao/falcon that referenced this pull request Feb 16, 2018
Author: Praveen Adlakha <adlakha.praveen@gmail.com>

Reviewers: @pallavi-rao

Closes apache#327 from PraveenAdlakha/2226 and squashes the following commits:

59a43ef [Praveen Adlakha] minor changes in falcon client and localextensionmanager
473f04a [Praveen Adlakha] comments addressed
6a346aa [Praveen Adlakha] comments addressed
8733f53 [Praveen Adlakha] checkstyle issue resolved
9ba005e [Praveen Adlakha] FALCON-2226 Submit ,Schedule and submitAndSchedule API for extension in distributed mode
699b06f [Praveen Adlakha] WIP
29da911 [Praveen Adlakha] WIP
0b7d02a [Praveen Adlakha] merge conflicts resolved
6b77cc1 [Praveen Adlakha] FALCON-2223 Distributed mode support for User Extension
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants