Skip to content

Commit

Permalink
FALCON-2276 Falcon Trusted extensions submission and validation was f…
Browse files Browse the repository at this point in the history
…ailing
  • Loading branch information
sandeepSamudrala committed Feb 8, 2017
1 parent a3bd0e9 commit 84169d6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ private JSONObject getExtensionJobDetailJson(String jobName) {
private List<Entity> getEntities(String extensionName, String jobName, InputStream configStream,
String extensionType, String extensionBuildLocation) {
List<Entity> entities = null;
if (!extensionType.equals(ExtensionType.CUSTOM.name())) {
if (!extensionType.equals(ExtensionType.TRUSTED.toString())) {
try {
entities = ExtensionHandler.loadAndPrepare(extensionName, jobName, configStream,
extensionBuildLocation);
Expand Down Expand Up @@ -1209,7 +1209,7 @@ public APIResult validateExtensionJob(final String extensionName, final String j
final String configPath, final String doAsUser) {
String extensionType = ExtensionHandler.getExtensionType(extensionName, getExtensionDetailJson(extensionName));
InputStream configStream = getServletInputStream(configPath);
if (ExtensionType.TRUSTED.name().equalsIgnoreCase(extensionType)) {
if (extensionType.equals(ExtensionType.TRUSTED.toString())) {
ClientResponse clientResponse = new ResourceBuilder()
.path(ExtensionOperations.VALIDATE.path, extensionName)
.addQueryParam(DO_AS_OPT, doAsUser)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.falcon.FalconException;
import org.apache.falcon.Pair;
import org.apache.falcon.entity.EntityUtil;
import org.apache.falcon.entity.v0.Entity;
import org.apache.falcon.entity.v0.feed.Schema;
import org.apache.falcon.extensions.store.ExtensionStore;
Expand Down Expand Up @@ -109,6 +110,9 @@ public List<Entity> getEntities(final String extensionName, final InputStream co
throw new FalconException("Entity created from the extension template cannot be null");
}
LOG.info("Extension processing complete");
// add tags on extension name and job
String jobName = configProperties.getProperty(ExtensionProperties.JOB_NAME.getName());
EntityUtil.applyTags(extensionName, jobName, Collections.singletonList(entity));
return Collections.singletonList(entity);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
Expand Down Expand Up @@ -56,7 +55,6 @@
import org.apache.falcon.entity.v0.feed.Feed;
import org.apache.falcon.entity.v0.process.Process;
import org.apache.falcon.extensions.Extension;
import org.apache.falcon.extensions.ExtensionProperties;
import org.apache.falcon.extensions.ExtensionService;
import org.apache.falcon.extensions.ExtensionType;
import org.apache.falcon.extensions.jdbc.ExtensionMetaStore;
Expand Down Expand Up @@ -296,7 +294,7 @@ private SortedMap<EntityType, List<Entity>> getEntityList(String extensionName,
List<Entity> entities;
TreeMap<EntityType, List<Entity>> entityMap = new TreeMap<>();
if (ExtensionType.TRUSTED.equals(extensionType)) {
entities = generateEntities(extensionName, config);
entities = extension.getEntities(extensionName, config);
List<Entity> trustedFeeds = new ArrayList<>();
List<Entity> trustedProcesses = new ArrayList<>();
for (Entity entity : entities) {
Expand Down Expand Up @@ -564,7 +562,7 @@ public APIResult validate(
throw FalconWebException.newAPIException("Extension validation is supported only for trusted extensions");
}
try {
List<Entity> entities = generateEntities(extensionName, request.getInputStream());
List<Entity> entities = extension.getEntities(extensionName, request.getInputStream());
for (Entity entity : entities) {
super.validate(entity);
}
Expand Down Expand Up @@ -715,19 +713,6 @@ public APIResult enableExtension(
}
}

private List<Entity> generateEntities(String extensionName, InputStream configStream)
throws FalconException, IOException {
// get entities for extension job
Properties properties = new Properties();
properties.load(configStream);
List<Entity> entities = extension.getEntities(extensionName, configStream);

// add tags on extension name and job
String jobName = properties.getProperty(ExtensionProperties.JOB_NAME.getName());
EntityUtil.applyTags(extensionName, jobName, entities);
return entities;
}

private static void checkIfExtensionServiceIsEnabled() {
if (!Services.get().isRegistered(ExtensionService.SERVICE_NAME)) {
LOG.error(ExtensionService.SERVICE_NAME + " is not enabled.");
Expand Down

0 comments on commit 84169d6

Please sign in to comment.