use of org.wso2.siddhi.core.util.transport.TemplateBuilder in project carbon-apimgt by wso2.
the class PolicyExportManager method getSubscriptionPolicySiddhiApps.
/**
* Get execution plan/ siddhi apps for custom policies.
*
* @param subscriptionPolicies SubscriptionPolicy object list
* @return Map<String, String> containing execution plan name and execution plans.
* @throws APITemplateException If template generating fails
*/
private Map<String, String> getSubscriptionPolicySiddhiApps(List<SubscriptionPolicy> subscriptionPolicies) throws APITemplateException {
if (log.isDebugEnabled()) {
log.debug("Get execution plans for Subscription policies.");
}
Map<String, String> siddhiApps = new HashMap<>();
String name;
String executionPlan;
SubscriptionThrottlePolicyTemplateBuilder templateBuilder;
for (SubscriptionPolicy policy : subscriptionPolicies) {
name = SUBSCRIPTION + policy.getPolicyName();
templateBuilder = new SubscriptionThrottlePolicyTemplateBuilder(policy);
executionPlan = templateBuilder.getThrottlePolicyForSubscriptionLevel();
siddhiApps.put(name, executionPlan);
}
return siddhiApps;
}
use of org.wso2.siddhi.core.util.transport.TemplateBuilder in project carbon-apimgt by wso2.
the class PolicyExportManager method getApiPolicySiddhiApps.
/**
* Get execution plan/ siddhi apps for custom policies.
*
* @param apiPolicies APIPolicy object list
* @return Map<String, String> containing execution plan name and execution plans.
* @throws APITemplateException If template generating fails
*/
private List<Map<String, String>> getApiPolicySiddhiApps(List<APIPolicy> apiPolicies) throws APITemplateException {
if (log.isDebugEnabled()) {
log.debug("Get execution plans for API policies.");
}
List<Map<String, String>> policies = new ArrayList<>();
Map<String, String> siddhiApps = new HashMap<>();
APIThrottlePolicyTemplateBuilder templateBuilder;
for (APIPolicy apiPolicy : apiPolicies) {
templateBuilder = new APIThrottlePolicyTemplateBuilder(apiPolicy);
if (apiPolicy.getPipelines() != null) {
siddhiApps = templateBuilder.getThrottlePolicyTemplateForPipelines();
}
siddhiApps.put(RESOURCE + apiPolicy.getPolicyName() + DEFAULT, templateBuilder.getThrottlePolicyTemplateForAPILevelDefaultCondition());
policies.add(siddhiApps);
}
return policies;
}
use of org.wso2.siddhi.core.util.transport.TemplateBuilder in project carbon-apimgt by wso2.
the class PolicyExportManager method getCustomPolicySiddhiApps.
/**
* Get execution plan/ siddhi apps for custom policies.
*
* @param customPolicies custom policy object list
* @return Map<String, String> containing execution plan name and execution plans.
* @throws APITemplateException If template generating fails
*/
private Map<String, String> getCustomPolicySiddhiApps(List<CustomPolicy> customPolicies) throws APITemplateException {
if (log.isDebugEnabled()) {
log.debug("Get execution plans for custom policies.");
}
Map<String, String> siddhiApps = new HashMap<>();
String name;
String executionPlan;
CustomThrottlePolicyTemplateBuilder templateBuilder;
for (CustomPolicy policy : customPolicies) {
templateBuilder = new CustomThrottlePolicyTemplateBuilder(policy);
name = CUSTOM + policy.getPolicyName();
executionPlan = templateBuilder.getThrottlePolicyTemplateForCustomPolicy();
siddhiApps.put(name, executionPlan);
}
return siddhiApps;
}
use of org.wso2.siddhi.core.util.transport.TemplateBuilder in project carbon-apimgt by wso2.
the class PolicyExportManager method getAppPolicySiddhiApps.
/**
* Get execution plan/ siddhi apps for custom policies.
*
* @param applicationPolicies ApplicationPolicy object list
* @return Map<String, String> containing execution plan name and execution plans.
* @throws APITemplateException If template generating fails
*/
private Map<String, String> getAppPolicySiddhiApps(List<ApplicationPolicy> applicationPolicies) throws APITemplateException {
if (log.isDebugEnabled()) {
log.debug("Get execution plans for application policy.");
}
Map<String, String> siddhiApps = new HashMap<>();
String name;
String executionPlan;
ApplicationThrottlePolicyTemplateBuilder templateBuilder;
for (ApplicationPolicy policy : applicationPolicies) {
templateBuilder = new ApplicationThrottlePolicyTemplateBuilder(policy);
name = APPLICATION + policy.getPolicyName();
executionPlan = templateBuilder.getThrottlePolicyForAppLevel();
siddhiApps.put(name, executionPlan);
}
return siddhiApps;
}
use of org.wso2.siddhi.core.util.transport.TemplateBuilder in project siddhi by wso2.
the class SinkMapper method init.
public final void init(StreamDefinition streamDefinition, String type, OptionHolder mapOptionHolder, List<Element> unmappedPayloadList, Sink sink, ConfigReader mapperConfigReader, LatencyTracker mapperLatencyTracker, SiddhiAppContext siddhiAppContext) {
this.mapperLatencyTracker = mapperLatencyTracker;
this.siddhiAppContext = siddhiAppContext;
sink.setTrpDynamicOptions(trpDynamicOptions);
this.sinkListener = sink;
this.optionHolder = mapOptionHolder;
this.type = type;
if (unmappedPayloadList != null && !unmappedPayloadList.isEmpty()) {
templateBuilderMap = new HashMap<>();
for (Element e : unmappedPayloadList) {
TemplateBuilder templateBuilder = new TemplateBuilder(streamDefinition, e.getValue());
if (templateBuilderMap.containsKey(e.getKey())) {
throw new SiddhiAppCreationException("Duplicate Keys, " + e.getKey() + ", in @payload() ");
}
templateBuilderMap.put(e.getKey(), templateBuilder);
}
}
init(streamDefinition, mapOptionHolder, templateBuilderMap, mapperConfigReader, siddhiAppContext);
}
Aggregations