Repository: falcon Updated Branches: refs/heads/master e44872584 -> 0897c346a
FALCON-109. Submission of clusters for non registered colos. Contributed by Pallavi Rao Project: http://git-wip-us.apache.org/repos/asf/falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/falcon/commit/0897c346 Tree: http://git-wip-us.apache.org/repos/asf/falcon/tree/0897c346 Diff: http://git-wip-us.apache.org/repos/asf/falcon/diff/0897c346 Branch: refs/heads/master Commit: 0897c346a52ad35e86ee0d0373feea0316532834 Parents: e448725 Author: Suhas Vasu <[email protected]> Authored: Tue Jan 20 14:34:18 2015 +0530 Committer: Suhas Vasu <[email protected]> Committed: Tue Jan 20 14:34:18 2015 +0530 ---------------------------------------------------------------------- CHANGES.txt | 3 +++ .../apache/falcon/util/RuntimeProperties.java | 18 +++++++++++++++ .../proxy/SchedulableEntityManagerProxy.java | 24 ++++++++++++++++---- 3 files changed, 41 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/falcon/blob/0897c346/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 31e35e0..d212fba 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -75,6 +75,9 @@ Trunk (Unreleased) (Suhas vasu) BUG FIXES + FALCON-109 submission of clusters for non registered colos + (Pallavi Rao via Suhas Vasu) + FALCON-995 Sharelib directory does not exist in webapp (Peeyush Bishnoi via Suhas Vasu) http://git-wip-us.apache.org/repos/asf/falcon/blob/0897c346/common/src/main/java/org/apache/falcon/util/RuntimeProperties.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/falcon/util/RuntimeProperties.java b/common/src/main/java/org/apache/falcon/util/RuntimeProperties.java index 87b67d0..3ff30ee 100644 --- a/common/src/main/java/org/apache/falcon/util/RuntimeProperties.java +++ b/common/src/main/java/org/apache/falcon/util/RuntimeProperties.java @@ -51,6 +51,7 @@ public final class RuntimeProperties extends ApplicationProperties { if (INSTANCE.get() == null) { RuntimeProperties properties = new RuntimeProperties(); properties.loadProperties(); + properties.validateProperties(); INSTANCE.compareAndSet(null, properties); if (INSTANCE.get() == properties) { Thread refreshThread = new Thread(new DynamicLoader()); @@ -63,6 +64,22 @@ public final class RuntimeProperties extends ApplicationProperties { } } + protected void validateProperties() throws FalconException { + String colosProp = getProperty("all.colos"); + if (colosProp == null || colosProp.isEmpty()) { + return; + } + String[] colos = colosProp.split(","); + for (int i = 0; i < colos.length; i++) { + colos[i] = colos[i].trim(); + String falconEndpoint = getProperty("falcon." + colos[i] + ".endpoint"); + if (falconEndpoint == null || falconEndpoint.isEmpty()) { + throw new FalconException("No falcon server endpoint mentioned in Prism runtime for colo, " + + colos[i] + "."); + } + } + } + /** * Thread for loading properties periodically. */ @@ -79,6 +96,7 @@ public final class RuntimeProperties extends ApplicationProperties { try { RuntimeProperties newProperties = new RuntimeProperties(); newProperties.loadProperties(); + newProperties.validateProperties(); INSTANCE.set(newProperties); backOffDelay = REFRESH_DELAY; } catch (FalconException e) { http://git-wip-us.apache.org/repos/asf/falcon/blob/0897c346/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java ---------------------------------------------------------------------- diff --git a/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java b/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java index 85e846f..34ff0f7 100644 --- a/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java +++ b/prism/src/main/java/org/apache/falcon/resource/proxy/SchedulableEntityManagerProxy.java @@ -25,6 +25,7 @@ import org.apache.falcon.entity.EntityNotRegisteredException; import org.apache.falcon.entity.EntityUtil; import org.apache.falcon.entity.v0.Entity; import org.apache.falcon.entity.v0.EntityType; +import org.apache.falcon.entity.v0.cluster.Cluster; import org.apache.falcon.monitors.Dimension; import org.apache.falcon.monitors.Monitored; import org.apache.falcon.resource.APIResult; @@ -33,8 +34,8 @@ import org.apache.falcon.resource.EntityList; import org.apache.falcon.resource.EntitySummaryResult; import org.apache.falcon.resource.channel.Channel; import org.apache.falcon.resource.channel.ChannelFactory; -import org.apache.falcon.util.DeploymentUtil; +import org.apache.falcon.util.DeploymentUtil; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.*; import javax.ws.rs.core.Context; @@ -110,10 +111,13 @@ public class SchedulableEntityManagerProxy extends AbstractSchedulableEntityMana final HttpServletRequest bufferedRequest = getBufferedRequest(request); - final String entity = getEntity(bufferedRequest, type).getName(); + final Entity entity = getEntity(bufferedRequest, type); Map<String, APIResult> results = new HashMap<String, APIResult>(); - final Set<String> colos = getApplicableColos(type, getEntity(bufferedRequest, type)); - results.put(FALCON_TAG, new EntityProxy(type, entity) { + final Set<String> colos = getApplicableColos(type, entity); + + validateEntity(entity, colos); + + results.put(FALCON_TAG, new EntityProxy(type, entity.getName()) { @Override protected Set<String> getColosToApply() { return colos; @@ -131,6 +135,18 @@ public class SchedulableEntityManagerProxy extends AbstractSchedulableEntityMana return consolidateResult(results, APIResult.class); } + private void validateEntity(Entity entity, Set<String> applicableColos) { + if (entity.getEntityType() != EntityType.CLUSTER || embeddedMode) { + return; + } + // If the submitted entity is a cluster, ensure its spec. has one of the valid colos + String colo = ((Cluster) entity).getColo(); + if (!applicableColos.contains(colo)) { + throw FalconWebException.newException("The colo mentioned in the cluster specification, " + + colo + ", is not listed in Prism runtime.", Response.Status.BAD_REQUEST); + } + } + private Entity getEntity(HttpServletRequest request, String type) { try { request.getInputStream().reset();
