From 20c053c018a9907e0ce5b5e3f3711777e5ace15b Mon Sep 17 00:00:00 2001 From: amali Date: Fri, 22 Jan 2021 10:10:20 +0530 Subject: [PATCH 01/21] Throttle publisher --- enforcer/pom.xml | 20 + .../gateway/enforcer/api/RequestContext.java | 37 ++ .../micro/gateway/enforcer/api/RestAPI.java | 9 + .../enforcer/api/config/ResourceConfig.java | 2 +- .../enforcer/common/CacheableEntity.java | 2 +- .../gateway/enforcer/config/ConfigHolder.java | 80 ++++ .../enforcer/constants/APIConstants.java | 6 +- .../constants/APISecurityConstants.java | 2 +- .../enforcer/constants/ConfigConstants.java | 0 .../enforcer/dto/ThrottleAgentConfigDTO.java | 67 +++ .../enforcer/dto/ThrottleURLGroupDTO.java | 34 ++ .../enforcer/filters/ThrottleFilter.java | 158 ++++++ .../globalthrottle/ThrottleAgent.java | 40 ++ .../databridge/agent/AgentHolder.java | 60 +++ .../databridge/agent/DataEndpointAgent.java | 112 +++++ .../databridge/agent/DataPublisher.java | 313 ++++++++++++ .../client/AbstractClientPoolFactory.java | 79 +++ .../AbstractSecureClientPoolFactory.java | 36 ++ .../databridge/agent/client/ClientPool.java | 76 +++ .../agent/conf/AgentConfiguration.java | 232 +++++++++ .../agent/conf/DataEndpointConfiguration.java | 136 ++++++ .../agent/endpoint/DataEndpoint.java | 388 +++++++++++++++ .../DataEndpointConnectionWorker.java | 143 ++++++ .../endpoint/DataEndpointFailureCallback.java | 37 ++ .../agent/endpoint/DataEndpointGroup.java | 448 ++++++++++++++++++ .../EventPublisherThreadPoolExecutor.java | 64 +++ .../agent/endpoint/WrappedEventFactory.java | 56 +++ .../binary/BinaryClientPoolFactory.java | 72 +++ .../endpoint/binary/BinaryDataEndpoint.java | 94 ++++ .../endpoint/binary/BinaryEventSender.java | 182 +++++++ .../binary/BinarySecureClientPoolFactory.java | 123 +++++ .../DataEndpointAuthenticationException.java | 44 ++ .../DataEndpointConfigurationException.java | 44 ++ .../exception/DataEndpointException.java | 44 ++ .../exception/EventQueueFullException.java | 45 ++ .../agent/util/DataEndpointConstants.java | 38 ++ .../agent/util/DataPublisherUtil.java | 230 +++++++++ .../agent/util/ThrottleEventConstants.java | 47 ++ .../DataProcessAndPublishingAgent.java | 125 +++++ .../publisher/DataPublisherConstants.java | 38 ++ .../publisher/PublisherConfiguration.java | 148 ++++++ .../publisher/ThrottleDataPublisher.java | 139 ++++++ .../publisher/ThrottleDataPublisherPool.java | 86 ++++ .../keymgt/KeyManagerDataService.java | 2 +- .../events/DeployAPIInGatewayEvent.java | 2 +- .../enforcer/listener/events/PolicyEvent.java | 2 +- .../gateway/enforcer/models/ApiPolicy.java | 2 +- .../models/ApplicationKeyMappingCacheKey.java | 2 +- .../enforcer/models/ApplicationPolicy.java | 2 +- .../gateway/enforcer/models/Subscription.java | 2 +- .../enforcer/security/AccessTokenInfo.java | 4 +- .../security/jwt/JWTAuthenticator.java | 4 +- .../enforcer/security/jwt/JWTTransformer.java | 8 +- .../enforcer/security/jwt/JWTUtil.java | 2 +- .../enforcer/security/jwt/SignedJWTInfo.java | 2 +- .../jwt/validator/RevokedJWTDataHolder.java | 2 +- .../enforcer/server/RequestHandler.java | 10 +- .../subscription/SubscriptionDataHolder.java | 2 +- .../subscription/SubscriptionDataLoader.java | 8 +- .../subscription/SubscriptionDataStore.java | 14 +- .../gateway/enforcer/util/FilterUtils.java | 53 ++- pom.xml | 3 + resources/conf/config.toml | 49 ++ 63 files changed, 4269 insertions(+), 42 deletions(-) create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/ConfigConstants.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleAgentConfigDTO.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleURLGroupDTO.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/ThrottleAgent.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/AgentHolder.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/DataEndpointAgent.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/DataPublisher.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractClientPoolFactory.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractSecureClientPoolFactory.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/ClientPool.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/conf/AgentConfiguration.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/conf/DataEndpointConfiguration.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpoint.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointConnectionWorker.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointFailureCallback.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointGroup.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/EventPublisherThreadPoolExecutor.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/WrappedEventFactory.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryClientPoolFactory.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryDataEndpoint.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryEventSender.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinarySecureClientPoolFactory.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointAuthenticationException.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointConfigurationException.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointException.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/EventQueueFullException.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataEndpointConstants.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataPublisherUtil.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/ThrottleEventConstants.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/DataProcessAndPublishingAgent.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/DataPublisherConstants.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/PublisherConfiguration.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/ThrottleDataPublisher.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/ThrottleDataPublisherPool.java diff --git a/enforcer/pom.xml b/enforcer/pom.xml index c8b54f0041..959b2cefae 100644 --- a/enforcer/pom.xml +++ b/enforcer/pom.xml @@ -316,5 +316,25 @@ org.apache.commons commons-lang3 + + org.wso2.carbon.analytics-common + org.wso2.carbon.databridge.commons + ${org.wso2.carbon.analytics-common} + + + org.wso2.carbon.analytics-common + org.wso2.carbon.databridge.commons.binary + ${org.wso2.carbon.analytics-common} + + + commons-pool.wso2 + commons-pool + ${apache.commons.version} + + + org.wso2.orbit.com.lmax + disruptor + ${org.wso2.orbit.com.lmax} + diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RequestContext.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RequestContext.java index 566d3b6d74..eaaa8f4432 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RequestContext.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RequestContext.java @@ -19,6 +19,7 @@ import org.apache.commons.lang3.StringUtils; import org.wso2.micro.gateway.enforcer.api.config.ResourceConfig; +import org.wso2.micro.gateway.enforcer.security.AuthenticationContext; import java.util.HashMap; import java.util.Map; @@ -36,6 +37,9 @@ public class RequestContext { private ResourceConfig matchedResourcePath; private Map headers; private Map properties = new HashMap(); + private AuthenticationContext authenticationContext = new AuthenticationContext(); + private String requestID; + private String address; // Denotes the cluster header name for each environment. Both properties can be null if // the openAPI has production endpoints alone. private String prodClusterHeader; @@ -60,6 +64,9 @@ public static class Builder { private String prodClusterHeader; private String sandClusterHeader; private Map properties = new HashMap(); + private AuthenticationContext authenticationContext = new AuthenticationContext(); + private String requestID; + private String address; public Builder(String requestPath) { this.requestPath = requestPath; @@ -99,6 +106,21 @@ public Builder sandClusterHeader(String cluster) { return this; } + public Builder authenticationContext(AuthenticationContext authenticationContext) { + this.authenticationContext = authenticationContext; + return this; + } + + public Builder requestID(String requestID) { + this.requestID = requestID; + return this; + } + + public Builder address(String address) { + this.address = address; + return this; + } + public RequestContext build() { RequestContext requestContext = new RequestContext(); requestContext.matchedResourcePath = this.matchedResourceConfig; @@ -109,6 +131,9 @@ public RequestContext build() { requestContext.prodClusterHeader = this.prodClusterHeader; requestContext.sandClusterHeader = this.sandClusterHeader; requestContext.properties = this.properties; + requestContext.authenticationContext = this.authenticationContext; + requestContext.requestID = this.requestID; + requestContext.address = this.address; // Adapter assigns header based routing only if both type of endpoints are present. if (!StringUtils.isEmpty(prodClusterHeader) && !StringUtils.isEmpty(sandClusterHeader)) { @@ -118,6 +143,18 @@ public RequestContext build() { } } + public AuthenticationContext getAuthenticationContext() { + return authenticationContext; + } + + public String getRequestID() { + return requestID; + } + + public String getAddress() { + return address; + } + public API getMathedAPI() { return mathedAPI; } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RestAPI.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RestAPI.java index b661ccbe62..0669e5b56f 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RestAPI.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RestAPI.java @@ -25,8 +25,10 @@ import org.wso2.micro.gateway.enforcer.Filter; import org.wso2.micro.gateway.enforcer.api.config.APIConfig; import org.wso2.micro.gateway.enforcer.api.config.ResourceConfig; +import org.wso2.micro.gateway.enforcer.config.ConfigHolder; import org.wso2.micro.gateway.enforcer.constants.APIConstants; import org.wso2.micro.gateway.enforcer.cors.CorsFilter; +import org.wso2.micro.gateway.enforcer.filters.ThrottleFilter; import org.wso2.micro.gateway.enforcer.security.AuthFilter; import java.util.ArrayList; @@ -143,5 +145,12 @@ private void initFilters() { CorsFilter corsFilter = new CorsFilter(); this.filters.add(corsFilter); this.filters.add(authFilter); + // enable throttle filter + if (ConfigHolder.getInstance().getThrottleAgentConfig().isEnabled()) { + ThrottleFilter throttleFilter = new ThrottleFilter(); + throttleFilter.init(apiConfig); + this.filters.add(throttleFilter); + } + } } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/ResourceConfig.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/ResourceConfig.java index 3e18edba94..b87cdc429b 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/ResourceConfig.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/ResourceConfig.java @@ -66,7 +66,7 @@ public void setTier(String tier) { } /** - * ENUM to hold http operations + * ENUM to hold http operations. */ public enum HttpMethods { GET("get"), POST("post"), PUT("put"), DELETE("delete"), HEAD("head"), OPTIONS("options"); diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/common/CacheableEntity.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/common/CacheableEntity.java index f9865478dc..d01e721ed9 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/common/CacheableEntity.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/common/CacheableEntity.java @@ -19,7 +19,7 @@ package org.wso2.micro.gateway.enforcer.common; /** - * An interface to indicate that an entity provides a cacheKey + * An interface to indicate that an entity provides a cacheKey. * * @param Type of the CacheKey */ diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java index e505ecb7fb..879459b8a6 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java @@ -33,7 +33,11 @@ import org.wso2.micro.gateway.enforcer.config.dto.TokenIssuerDto; import org.wso2.micro.gateway.enforcer.constants.Constants; import org.wso2.micro.gateway.enforcer.discovery.ConfigDiscoveryClient; +import org.wso2.micro.gateway.enforcer.dto.ThrottleAgentConfigDTO; +import org.wso2.micro.gateway.enforcer.dto.ThrottleURLGroupDTO; import org.wso2.micro.gateway.enforcer.exception.DiscoveryException; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.AgentConfiguration; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.publisher.PublisherConfiguration; import org.wso2.micro.gateway.enforcer.util.TLSUtils; import java.io.IOException; @@ -64,6 +68,11 @@ public class ConfigHolder { private ConfigHolder() { init(); } + public ThrottleAgentConfigDTO getThrottleAgentConfig() { + return throttleAgentConfig; + } + + private ThrottleAgentConfigDTO throttleAgentConfig; public static ConfigHolder getInstance() { if (configHolder != null) { @@ -111,6 +120,7 @@ private void parseConfigs(Config config) { //Read credentials used to connect with APIM services populateAPIMCredentials(config.getApimCredentials()); + populateTMBinaryConfig(); } private void populateAuthService(AuthService cdsAuth) { @@ -176,6 +186,21 @@ private void populateJWTIssuerConfiguration(List cdsIssuers) { } } + private void populateTMBinaryConfig() { + throttleAgentConfig = + configToml.getTable(ConfigConstants.TM_BINARY_THROTTLE_CONF_INSTANCE_ID) + .to(ThrottleAgentConfigDTO.class); + AgentConfiguration agentConfiguration = throttleAgentConfig.getAgent(); + agentConfiguration.setTrustStore(trustStore); + AgentConfiguration.setInstance(agentConfiguration); + + PublisherConfiguration pubConfiguration = throttleAgentConfig.getPublisher(); + pubConfiguration.setUserName(throttleAgentConfig.getUsername()); + pubConfiguration.setPassword(throttleAgentConfig.getPassword()); + processTMPublisherURLGroup(throttleAgentConfig.getUrlGroup(), pubConfiguration); + PublisherConfiguration.setInstance(pubConfiguration); + } + private void loadTrustStore() { try { trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); @@ -227,4 +252,59 @@ public void setTrustManagerFactory(TrustManagerFactory trustManagerFactory) { public EnvVarConfig getEnvVarConfig() { return envVarConfig; } + /** + * The receiverURLGroup and the authURLGroup is preprocessed + * such that to make them compatible with the binary agent. + */ + private void processTMPublisherURLGroup(List urlGroups, + PublisherConfiguration pubConfiguration) { + StringBuilder restructuredReceiverURL = new StringBuilder(); + StringBuilder restructuredAuthURL = new StringBuilder(); + + for (ThrottleURLGroupDTO urlGroup : urlGroups) { + String[] receiverUrls = urlGroup.getReceiverURLs(); + String[] authUrls = urlGroup.getAuthURLs(); + if (receiverUrls.length == 1 && authUrls.length == 1) { + restructuredReceiverURL.append("{").append(receiverUrls[0]).append("},"); + restructuredAuthURL.append("{").append(authUrls[0]).append("},"); + continue; + } + String urlType = urlGroup.getType(); + if (urlType == null || urlType.isBlank() || !(ConfigConstants.LOADBALANCE.equalsIgnoreCase(urlType) + || ConfigConstants.FAILOVER.equalsIgnoreCase(urlType))) { + logger.warn("Type is not " + + ConfigConstants.LOADBALANCE + " or " + ConfigConstants.FAILOVER + ". Hence proceeding as a " + + ConfigConstants.FAILOVER + " configuration."); + urlType = ConfigConstants.FAILOVER; + } + restructuredReceiverURL.append(processSingleURLGroup(receiverUrls, urlType)).append(","); + restructuredAuthURL.append(processSingleURLGroup(authUrls, urlType)).append(","); + + } + //to remove the final ',' in the URLs and set to publisher config + if (!restructuredReceiverURL.toString().isBlank() && !restructuredAuthURL.toString().isBlank()) { + pubConfiguration.setReceiverUrlGroup(restructuredReceiverURL.substring(0, + restructuredReceiverURL.length() - 1)); + pubConfiguration.setAuthUrlGroup(restructuredAuthURL.substring(0, restructuredAuthURL.length() - 1)); + } + } + + + private String processSingleURLGroup(String[] urlArray, String urlType) { + StringBuilder concatenatedURLString = new StringBuilder("{"); + for (String url : urlArray) { + if (ConfigConstants.LOADBALANCE.equalsIgnoreCase(urlType)) { + concatenatedURLString.append(url).append(ConfigConstants.TM_BINARY_LOADBALANCE_SEPARATOR); + } else if (ConfigConstants.FAILOVER.equalsIgnoreCase(urlType)) { + concatenatedURLString.append(url).append(ConfigConstants.TM_BINARY_FAILOVER_SEPARATOR); + } else { + concatenatedURLString.append(url).append(ConfigConstants.TM_BINARY_FAILOVER_SEPARATOR); + } + } + //to remove the trailing '|' or ',' + concatenatedURLString = new StringBuilder( + concatenatedURLString.substring(0, concatenatedURLString.length() - 1) + "}"); + return concatenatedURLString.toString(); + } + } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java index d9989e9a5d..49fbeb9ad1 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java @@ -23,6 +23,8 @@ public class APIConstants { public static final String UNLIMITED_TIER = "Unlimited"; + public static final String IP = "ip"; + public static final String IPV6 = "ipv6"; //open API extensions public static final String X_WSO2_BASE_PATH = "x-wso2-basepath"; @@ -79,7 +81,7 @@ private KeyValidationStatus() { } /** - * Holds the common set of constants for output of the subscription validation + * Holds the common set of constants for output of the subscription validation. */ public static class SubscriptionStatus { @@ -96,7 +98,7 @@ private SubscriptionStatus() { } /** - * Holds the common set of constants for validating the JWT tokens + * Holds the common set of constants for validating the JWT tokens. */ public static class JwtTokenConstants { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APISecurityConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APISecurityConstants.java index 5eb4c07e12..0347a9699e 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APISecurityConstants.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APISecurityConstants.java @@ -87,7 +87,7 @@ public class APISecurityConstants { public static final String DESCRIPTION_SEPARATOR = ". "; /** - * returns an String that corresponds to errorCode passed in + * returns an String that corresponds to errorCode passed in. * * @param errorCode * @return String diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/ConfigConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/ConfigConstants.java new file mode 100644 index 0000000000..e69de29bb2 diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleAgentConfigDTO.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleAgentConfigDTO.java new file mode 100644 index 0000000000..876277db14 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleAgentConfigDTO.java @@ -0,0 +1,67 @@ +package org.wso2.micro.gateway.enforcer.dto; + +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.AgentConfiguration; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.publisher.PublisherConfiguration; + +import java.util.ArrayList; +import java.util.List; + +/** + * This contains throttle configurations. + */ +public class ThrottleAgentConfigDTO { + boolean enabled = false; + String username; + String password; + List urlGroup = new ArrayList<>(); + PublisherConfiguration publisher; + AgentConfiguration agent; + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public List getUrlGroup() { + return urlGroup; + } + + public void setUrlGroup(List urlGroup) { + this.urlGroup = urlGroup; + } + + public PublisherConfiguration getPublisher() { + return publisher; + } + + public void setPublisher(PublisherConfiguration publisher) { + this.publisher = publisher; + } + + public AgentConfiguration getAgent() { + return agent; + } + + public void setAgent(AgentConfiguration agent) { + this.agent = agent; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleURLGroupDTO.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleURLGroupDTO.java new file mode 100644 index 0000000000..049e1e6fc0 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleURLGroupDTO.java @@ -0,0 +1,34 @@ +package org.wso2.micro.gateway.enforcer.dto; + +/** + * Throttle URL groups configurations. + */ +public class ThrottleURLGroupDTO { + String[] receiverURLs; + String[] authURLs; + String type; + + public String[] getReceiverURLs() { + return receiverURLs; + } + + public void setReceiverURLs(String[] receiverURLs) { + this.receiverURLs = receiverURLs; + } + + public String[] getAuthURLs() { + return authURLs; + } + + public void setAuthURLs(String[] authURLs) { + this.authURLs = authURLs; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java new file mode 100644 index 0000000000..3475500728 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.micro.gateway.enforcer.filters; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.json.JSONObject; +import org.wso2.micro.gateway.enforcer.Filter; +import org.wso2.micro.gateway.enforcer.api.RequestContext; +import org.wso2.micro.gateway.enforcer.api.config.APIConfig; +import org.wso2.micro.gateway.enforcer.api.config.ResourceConfig; +import org.wso2.micro.gateway.enforcer.constants.APIConstants; +import org.wso2.micro.gateway.enforcer.globalthrottle.ThrottleAgent; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.ThrottleEventConstants; +import org.wso2.micro.gateway.enforcer.security.AuthenticationContext; +import org.wso2.micro.gateway.enforcer.util.FilterUtils; + +import java.net.Inet4Address; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.HashMap; +import java.util.Map; + +/** + * This is the filter handling the authentication for the requests flowing through the gateway. + */ +public class ThrottleFilter implements Filter { + private static final Logger log = LogManager.getLogger(ThrottleFilter.class); + private APIConfig apiConfig; + + @Override + public void init(APIConfig apiConfig) { + this.apiConfig = apiConfig; + } + + @Override + public boolean handleRequest(RequestContext requestContext) { + log.info("handle request called"); + ThrottleAgent.publishNonThrottledEvent(getThrottleEventMap(requestContext)); + return true; + } + + //TODO (amaliMatharaarachchi) Add default values to keys. + // Handle fault invocations. + // Test all flows. + // Add unit tests. + /** + * This will generate the throttling event map to be publish to the traffic manager. + * + * @param requestContext request context + * @return Map of throttle event data + */ + private Map getThrottleEventMap(RequestContext requestContext) { + AuthenticationContext authenticationContext = requestContext.getAuthenticationContext(); + Map throttleEvent = new HashMap<>(); + + String basePath = requestContext.getMathedAPI().getAPIConfig().getBasePath(); + String apiVersion = requestContext.getMathedAPI().getAPIConfig().getVersion(); + String apiContext = basePath + ":" + apiVersion; + String apiName = requestContext.getMathedAPI().getAPIConfig().getName(); + String tenantDomain = FilterUtils.getTenantDomainFromRequestURL(apiContext); + if (tenantDomain == null) { + tenantDomain = APIConstants.SUPER_TENANT_DOMAIN_NAME; + } + String resourceTier; + String resourceKey; + + if (!APIConstants.UNLIMITED_TIER.equals(authenticationContext.getApiTier()) && + authenticationContext.getApiTier() != null && + !authenticationContext.getApiTier().isBlank()) { + resourceTier = authenticationContext.getApiTier(); + resourceKey = apiContext; + } else { + resourceTier = getResourceTier(requestContext.getMatchedResourcePath()); + resourceKey = getResourceThrottleKey(requestContext, apiContext, apiVersion); + } + + + throttleEvent.put(ThrottleEventConstants.MESSAGE_ID, requestContext.getRequestID()); + throttleEvent.put(ThrottleEventConstants.APP_KEY, authenticationContext.getApplicationId() + ":" + + authenticationContext.getUsername()); + throttleEvent.put(ThrottleEventConstants.APP_TIER, authenticationContext.getApplicationTier()); + throttleEvent.put(ThrottleEventConstants.API_KEY, apiContext); + throttleEvent.put(ThrottleEventConstants.API_TIER, authenticationContext.getApiTier()); + throttleEvent.put(ThrottleEventConstants.SUBSCRIPTION_KEY, authenticationContext.getApplicationId() + ":" + + apiContext); + throttleEvent.put(ThrottleEventConstants.SUBSCRIPTION_TIER, authenticationContext.getTier()); + throttleEvent.put(ThrottleEventConstants.RESOURCE_KEY, resourceKey); + throttleEvent.put(ThrottleEventConstants.RESOURCE_TIER, resourceTier); + throttleEvent.put(ThrottleEventConstants.USER_ID, authenticationContext.getUsername()); + throttleEvent.put(ThrottleEventConstants.API_CONTEXT, basePath); + throttleEvent.put(ThrottleEventConstants.API_VERSION, apiVersion); + throttleEvent.put(ThrottleEventConstants.APP_TENANT, authenticationContext.getSubscriberTenantDomain()); + throttleEvent.put(ThrottleEventConstants.API_TENANT, tenantDomain); + throttleEvent.put(ThrottleEventConstants.APP_ID, authenticationContext.getApplicationId()); + throttleEvent.put(ThrottleEventConstants.API_NAME, apiName); + throttleEvent.put(ThrottleEventConstants.PROPERTIES, getProperties(requestContext).toString()); + return throttleEvent; + } + + private String getResourceThrottleKey(RequestContext requestContext, String apiContext, String apiVersion) { + String resourceLevelThrottleKey = apiContext; + if (!apiVersion.isBlank()) { + resourceLevelThrottleKey += "/" + apiVersion; + } + resourceLevelThrottleKey += requestContext.getMatchedResourcePath().getPath() + ":" + + requestContext.getRequestMethod(); + return resourceLevelThrottleKey; + } + + private String getResourceTier(ResourceConfig resourceConfig) { + if (!resourceConfig.getTier().isBlank()) { + return resourceConfig.getTier(); + } + return APIConstants.UNLIMITED_TIER; + } + + + private JSONObject getProperties(RequestContext requestContext) { + String remoteIP = requestContext.getAddress(); + JSONObject jsonObMap = new JSONObject(); + if (remoteIP != null && remoteIP.length() > 0) { + try { + InetAddress address = InetAddress.getByName(remoteIP); + if (address instanceof Inet4Address) { + jsonObMap.put(APIConstants.IP, FilterUtils.ipToLong(remoteIP)); + jsonObMap.put(APIConstants.IPV6, 0); + } else if (address instanceof Inet6Address) { + jsonObMap.put(APIConstants.IPV6, FilterUtils.ipToBigInteger(remoteIP)); + jsonObMap.put(APIConstants.IP, 0); + } + } catch (UnknownHostException e) { + //send empty value as ip + log.error("Error while parsing host IP " + remoteIP, e); + jsonObMap.put(APIConstants.IPV6, 0); + jsonObMap.put(APIConstants.IP, 0); + } + } + // TODO(amaliMatharaarachchi) Add advance throttling data to additional properties. + return jsonObMap; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/ThrottleAgent.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/ThrottleAgent.java new file mode 100644 index 0000000000..64dd80ad1f --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/ThrottleAgent.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.globalthrottle; + +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.publisher.ThrottleDataPublisher; + +import java.util.Map; + +/** + * This class is used for ballerina interop invocations related to Global Throttle Event Publishing + * via binary communication. + */ +public class ThrottleAgent { + + private static ThrottleDataPublisher throttleDataPublisher = null; + + public static void startThrottlePublisherPool() { + throttleDataPublisher = new ThrottleDataPublisher(); + } + + public static void publishNonThrottledEvent(Map throttleEvent) { + throttleDataPublisher.publishNonThrottledEvent(throttleEvent); + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/AgentHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/AgentHolder.java new file mode 100644 index 0000000000..3fb72123e9 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/AgentHolder.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent; + + +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.AgentConfiguration; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; + +/** + * The holder the created agent and this is singleton class. + */ +public class AgentHolder { + + private static AgentHolder instance; + private DataEndpointAgent agent; + + private AgentHolder() { + agent = new DataEndpointAgent(AgentConfiguration.getInstance()); + } + + public static synchronized AgentHolder getInstance() { + if (instance == null) { + instance = new AgentHolder(); + } + return instance; + } + + public static synchronized void shutdown() throws DataEndpointException { + if (instance != null) { + instance.agent.shutDown(); + instance = null; + } + } + + /** + * Returns the default agent,and the first element in the data.agent.config.yaml + * is taken as default data publisher type. + * + * @return DataEndpointAgent for the default endpoint name. + */ + public DataEndpointAgent getDataEndpointAgent() { + return agent; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/DataEndpointAgent.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/DataEndpointAgent.java new file mode 100644 index 0000000000..07abaec429 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/DataEndpointAgent.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent; + +import org.apache.commons.pool.impl.GenericKeyedObjectPool; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.client.AbstractClientPoolFactory; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.client.AbstractSecureClientPoolFactory; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.client.ClientPool; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.AgentConfiguration; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.DataEndpoint; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary.BinaryClientPoolFactory; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary.BinaryDataEndpoint; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary.BinarySecureClientPoolFactory; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; + + +import java.util.ArrayList; + +/** + * One agent is created for a specific data endpoint type,and this has the resources such as transport pool, etc + * which are shared by all the data publishers created for the endpoint type. + */ + +public class DataEndpointAgent { + + private ArrayList dataPublishers = new ArrayList<>(); + + private GenericKeyedObjectPool transportPool; + + private GenericKeyedObjectPool securedTransportPool; + + private AgentConfiguration agentConfiguration; + + public DataEndpointAgent(AgentConfiguration agentConfiguration) { + this.agentConfiguration = agentConfiguration; + initialize(); + } + + private void initialize() { + AbstractClientPoolFactory clientPoolFactory = new BinaryClientPoolFactory(); + AbstractSecureClientPoolFactory secureClientPoolFactory = new BinarySecureClientPoolFactory( + agentConfiguration.getTrustStore()); + ClientPool clientPool = new ClientPool(); + this.transportPool = clientPool.getClientPool( + clientPoolFactory, + agentConfiguration.getMaxTransportPoolSize(), + agentConfiguration.getMaxIdleConnections(), + true, + agentConfiguration.getEvictionTimePeriod(), + agentConfiguration.getMinIdleTimeInPool()); + + this.securedTransportPool = clientPool.getClientPool( + secureClientPoolFactory, + agentConfiguration.getSecureMaxTransportPoolSize(), + agentConfiguration.getSecureMaxIdleConnections(), + true, + agentConfiguration.getSecureEvictionTimePeriod(), + agentConfiguration.getSecureMinIdleTimeInPool()); + } + + public void addDataPublisher(DataPublisher dataPublisher) { + dataPublishers.add(dataPublisher); + } + + public AgentConfiguration getAgentConfiguration() { + return agentConfiguration; + } + + public GenericKeyedObjectPool getTransportPool() { + return transportPool; + } + + public GenericKeyedObjectPool getSecuredTransportPool() { + return securedTransportPool; + } + + public synchronized void shutDown(DataPublisher dataPublisher) { + dataPublishers.remove(dataPublisher); + } + + public DataEndpoint getNewDataEndpoint() { + return new BinaryDataEndpoint(); + } + + public synchronized void shutDown() throws DataEndpointException { + for (DataPublisher dataPublisher : dataPublishers) { + dataPublisher.shutdown(); + } + try { + transportPool.close(); + securedTransportPool.close(); + } catch (Exception e) { + throw new DataEndpointException("Error while closing the transport pool", e); + } + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/DataPublisher.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/DataPublisher.java new file mode 100644 index 0000000000..5d05e23761 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/DataPublisher.java @@ -0,0 +1,313 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.wso2.carbon.databridge.commons.Event; +import org.wso2.carbon.databridge.commons.exception.TransportException; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.DataEndpointConfiguration; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.DataEndpoint; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.DataEndpointGroup; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointAuthenticationException; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointConfigurationException; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.EventQueueFullException; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.DataPublisherUtil; + + + +import java.util.ArrayList; +import java.util.Map; + +/** + * API Used to communicate with Data Receivers WSO2 BAM/CEP. It can be used to send events to + * multiple DAS/CEP nodes with load balancing and failover logic. + */ +public class DataPublisher { + + private static final Logger log = LogManager.getLogger(DataPublisher.class); + + /** + * List of group of endpoints where events needs to dispatched when + * events are published using this API. + */ + private ArrayList endpointGroups = new ArrayList<>(); + + /** + * The Agent for which the data publisher belongs to. + */ + private DataEndpointAgent dataEndpointAgent; + + private static final int FAILED_EVENT_LOG_INTERVAL = 10000; + + /** + * The last failed event time kept, use to determine when to log an warning + * message, without continuously doing so. + */ + private long lastFailedEventTime; + + /** + * The current failed event count. A normal long is used here, rather + * than an AtomicLong, since this is not a critical stat. + */ + private long failedEventCount; + + /** + * Creates the DataPublisher instance for a specific user, and the it creates + * connection asynchronously to receiver endpoint. + * + * @param receiverURLSet The receiving endpoint URL Set. This can be either load balancing URL set, + * or Failover URL set. + * @param authURLSet The authenticating URL Set for the endpoints given in receiverURLSet parameter. + * This should be in the same format as receiverURL set parameter. If null is passed + * the authURLs will be offsetted by value of 100. + * @param username Authorized username at receiver. + * @param password The password of the username provided. + * @throws DataEndpointException Exception to be thrown when communicating with DataEndpoint. + * @throws DataEndpointConfigurationException Exception to be thrown When parsing the Data Endpoint + * configurations when initializing data publisher + * @throws DataEndpointAuthenticationException Exception to be thrown when connecting the Data Endpoint + * @throws TransportException Transport level exception + */ + public DataPublisher(String receiverURLSet, String authURLSet, String username, String password) + throws DataEndpointException, DataEndpointConfigurationException, + DataEndpointAuthenticationException, TransportException { + dataEndpointAgent = AgentHolder.getInstance().getDataEndpointAgent(); + if (authURLSet == null) { + authURLSet = DataPublisherUtil.getDefaultAuthURLSet(receiverURLSet); + } + processEndpoints(dataEndpointAgent, receiverURLSet, authURLSet, username, password); + dataEndpointAgent.addDataPublisher(this); + } + + /** + * This validates the input that are passed in the DataPublisher creation, + * and initiates the endpoints connection. + * + * @param dataEndpointAgent Agent of the DataPublisher. + * @param receiverURLSet The receiving endpoint URL Set. This can be either load balancing URL set, + * or Failover URL set. + * @param authURLSet The authenticating URL Set for the endpoints given in receiverURLSet parameter. + * This should be in the same format as receiverURL set parameter. If the authURLSet + * is null, then default authURLSet will be generated from the receiverURL. + * @param username Authorized username at receiver. + * @param password The password of the username provided. + * @throws DataEndpointConfigurationException Exception to be thrown When parsing the Data Endpoint + * configurations when initializing data publisher + * @throws DataEndpointException Exception to be thrown when communicating with DataEndpoint. + * @throws DataEndpointAuthenticationException Exception to be thrown when connecting the Data Endpoint + * @throws TransportException Transport level exception + */ + private void processEndpoints(DataEndpointAgent dataEndpointAgent, + String receiverURLSet, String authURLSet, String username, String password) + throws DataEndpointConfigurationException, DataEndpointException, + DataEndpointAuthenticationException, TransportException { + ArrayList receiverURLGroups = DataPublisherUtil.getEndpointGroups(receiverURLSet); + ArrayList authURLGroups = DataPublisherUtil.getEndpointGroups(authURLSet); + DataPublisherUtil.validateURLs(receiverURLGroups, authURLGroups); + + for (int i = 0; i < receiverURLGroups.size(); i++) { + Object[] receiverGroup = (Object[]) receiverURLGroups.get(i); + Object[] authGroup = (Object[]) authURLGroups.get(i); + boolean failOver = (Boolean) receiverGroup[0]; + + DataEndpointGroup endpointGroup; + if (failOver) { + endpointGroup = new DataEndpointGroup(DataEndpointGroup.HAType.FAILOVER, dataEndpointAgent); + } else { + endpointGroup = new DataEndpointGroup(DataEndpointGroup.HAType.LOADBALANCE, + dataEndpointAgent); + } + /* + * Since the first element holds the failover/LB settings + * we need to start iterating from 2nd element. + */ + for (int j = 1; j < receiverGroup.length; j++) { + DataEndpointConfiguration endpointConfiguration = + new DataEndpointConfiguration((String) receiverGroup[j], + (String) authGroup[j], username, password, dataEndpointAgent.getTransportPool(), + dataEndpointAgent.getSecuredTransportPool(), dataEndpointAgent. + getAgentConfiguration().getBatchSize(), + dataEndpointAgent.getAgentConfiguration().getCorePoolSize(), + dataEndpointAgent.getAgentConfiguration().getMaxPoolSize(), + dataEndpointAgent.getAgentConfiguration().getKeepAliveTimeInPool()); + DataEndpoint dataEndpoint = dataEndpointAgent.getNewDataEndpoint(); + dataEndpoint.initialize(endpointConfiguration); + endpointGroup.addDataEndpoint(dataEndpoint); + } + endpointGroups.add(endpointGroup); + } + } + + /** + * Publish an event based on the event properties that are passed + * for all receiver groups which has been specified in the DataPublisher. + * This is a blocking invocation until the event can be inserted in to internal + * queue for the publishing to the endpoint groups. But in case if any one or all of the receiver + * groups cannot send the event to the endpoint due to network connection failure, + * or Receiver node is unreachable or Receiver node has shutdown, and + * internal queue has become full then it will be blocked until the receiver is reachable again. + * + * @param event The Event that needs to sent for the receiver groups + */ + public void publish(Event event) { + for (DataEndpointGroup endpointGroup : endpointGroups) { + endpointGroup.publish(event); + } + } + + /** + * Publish an event based on the event properties that are passed + * for all receiver groups which has been specified in the DataPublisher. + * This is a blocking invocation until the event can be inserted in to internal + * queue for the publishing to the endpoint groups. But in case if any one or all of the receiver + * groups cannot send the event to the endpoint due to network connection failure, + * or Receiver node is unreachable or Receiver node has shutdown, and + * internal queue has become full then it will be blocked until the receiver is reachable again. + * + * @param streamId StreamId for which the event belongs to. + * @param metaDataArray Meta data element of the event. + * @param correlationDataArray Correlation data element of the event. + * @param payloadDataArray Payload data element of the event. + */ + public void publish(String streamId, Object[] metaDataArray, Object[] correlationDataArray, + Object[] payloadDataArray) { + publish(new Event(streamId, System.currentTimeMillis(), metaDataArray, + correlationDataArray, payloadDataArray)); + } + + /** + * Publish an event based on the event properties that are passed + * for all receiver groups which has been specified in the DataPublisher. + * This is a blocking invocation until the event can be inserted in to internal + * queue for the publishing to the endpoint groups. But in case if any one or all of the receiver + * groups cannot send the event to the endpoint due to network connection failure, + * or Receiver node is unreachable or Receiver node has shutdown, and + * internal queue has become full then it will be blocked until the receiver is reachable again. + * + * @param streamId StreamId for which the event belongs to. + * @param metaDataArray Meta data element of the event. + * @param correlationDataArray Correlation data element of the event. + * @param payloadDataArray Payload data element of the event. + * @param arbitraryDataMap Arbitrary data element of the event, which was not included in the stream + * definition of the event, and intermittent data. + */ + public void publish(String streamId, Object[] metaDataArray, Object[] correlationDataArray, + Object[] payloadDataArray, Map arbitraryDataMap) { + publish(new Event(streamId, System.currentTimeMillis(), metaDataArray, + correlationDataArray, payloadDataArray, arbitraryDataMap)); + } + + /** + * Publish an event based on the event properties that are passed + * for all receiver groups which has been specified in the DataPublisher. + * This is a blocking invocation until the event can be inserted in to internal + * queue for the publishing to the endpoint groups. But in case if any one or all of the receiver + * groups cannot send the event to the endpoint due to network connection failure, + * or Receiver node is unreachable or Receiver node has shutdown, and + * internal queue has become full then it will be blocked until the receiver is reachable again. + * + * @param streamId StreamId for which the event belongs to. + * @param metaDataArray Meta data element of the event. + * @param correlationDataArray Correlation data element of the event. + * @param payloadDataArray Payload data element of the event. + * @param timeStamp Timestamp of the event. + */ + public void publish(String streamId, long timeStamp, Object[] metaDataArray, + Object[] correlationDataArray, Object[] payloadDataArray) { + publish(new Event(streamId, timeStamp, metaDataArray, correlationDataArray, payloadDataArray)); + } + + /** + * Publish an event based on the event properties that are passed + * for all receiver groups which has been specified in the DataPublisher. + * This is a blocking invocation until the event can be inserted in to internal + * queue for the publishing to the endpoint groups. But in case if any one or all of the receiver + * groups cannot send the event to the endpoint due to network connection failure, + * or Receiver node is unreachable or Receiver node has shutdown, and + * internal queue has become full then it will be blocked until the receiver is reachable again. + * + * @param streamId StreamId for which the event belongs to. + * @param metaDataArray Meta data element of the event. + * @param correlationDataArray Correlation data element of the event. + * @param payloadDataArray Payload data element of the event. + * @param timeStamp Timestamp of the event. + * @param arbitraryDataMap Arbitrary data element of the event, which was not included in the stream + * definition of the event, and intermittent data. + */ + public void publish(String streamId, long timeStamp, Object[] metaDataArray, + Object[] correlationDataArray, Object[] payloadDataArray, + Map arbitraryDataMap) { + publish(new Event(streamId, timeStamp, metaDataArray, correlationDataArray, + payloadDataArray, arbitraryDataMap)); + } + + private void onEventQueueFull(DataEndpointGroup endpointGroup, Event event) { + this.failedEventCount++; + long currentTime = System.currentTimeMillis(); + if (currentTime - this.lastFailedEventTime > FAILED_EVENT_LOG_INTERVAL) { + log.warn("Event queue is full, unable to process the event for endpoint group " + + endpointGroup.toString() + ", " + this.failedEventCount + " events dropped so far."); + this.lastFailedEventTime = currentTime; + } + if (log.isDebugEnabled()) { + log.debug("Dropped Event: " + event.toString() + " for the endpoint group " + + endpointGroup.toString()); + } + } + + /** + * Publish an event based on the event properties that are passed + * for all receiver groups which has been specified in the DataPublisher. + * This is a non-blocking invocation and if the queue if full + * then it will simply drop the event. + * + * @param event The event which needs to be published to the receiver groups + * @return the success/failure of the event that has been published/dropped. + */ + public boolean tryPublish(Event event) { + boolean sent = true; + for (DataEndpointGroup endpointGroup : endpointGroups) { + try { + endpointGroup.tryPublish(event); + sent = true; + } catch (EventQueueFullException e) { + this.onEventQueueFull(endpointGroup, event); + sent = false; + } + } + return sent; + } + + /** + * Graceful shutdown of all the operations of the data publisher. + * It will flush all the events to the relevant endpoint, and closes all the + * resources and thread pools used for its operation. Once the shutdown operation + * is called you can't publish events using the data publisher. + * + * @throws DataEndpointException Exception to be thrown when communicating with DataEndpoint. + */ + public void shutdown() throws DataEndpointException { + for (DataEndpointGroup dataEndpointGroup : endpointGroups) { + dataEndpointGroup.shutdown(); + } + dataEndpointAgent.shutDown(this); + } + +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractClientPoolFactory.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractClientPoolFactory.java new file mode 100644 index 0000000000..9c8ece075d --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractClientPoolFactory.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.client; + +import org.apache.commons.pool.BaseKeyedPoolableObjectFactory; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointConfigurationException; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.DataPublisherUtil; + + +/** + * The abstract class that needs to be implemented when supporting a new non-secure transport + * to mainly create, validate and terminate the client to the endpoint. + */ + +public abstract class AbstractClientPoolFactory extends BaseKeyedPoolableObjectFactory { + + @Override + public Object makeObject(Object key) + throws DataEndpointException, DataEndpointConfigurationException { + Object[] urlParams = DataPublisherUtil.getProtocolHostPort(key.toString()); + return createClient(urlParams[0].toString(), urlParams[1].toString(), + Integer.parseInt(urlParams[2].toString())); + } + + /** + * Make a connection to the receiver and return the client. + * + * @param protocol protocol that is used to connect to the endpoint + * @param hostName hostname of the endpoint + * @param port port of the endpoint that is listening to + * @return A valid client which has connected to the receiver and can be used + * for rest of the operations regarding the endpoint. + * @throws DataEndpointException Exception to be thrown when communicating with DataEndpoint. + */ + public abstract Object createClient(String protocol, String hostName, int port) + throws DataEndpointException; + + @Override + public boolean validateObject(Object key, Object obj) { + return validateClient(obj); + } + + /** + * Check the validity of the client whether it's in the position to make the + * communication with endpoint. + * + * @param client Client object which needs to be validated. + * @return Returns true/false based on the client is valid or invalid. + */ + public abstract boolean validateClient(Object client); + + public void destroyObject(Object key, Object obj) { + terminateClient(obj); + } + + /** + * Terminates the connection between the client and the endpoint. + * + * @param client The client which needs to be terminated. + */ + public abstract void terminateClient(Object client); + +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractSecureClientPoolFactory.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractSecureClientPoolFactory.java new file mode 100644 index 0000000000..04f14f081b --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractSecureClientPoolFactory.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.client; + +import java.security.KeyStore; + +/** + * This abstract class needs to be implemented to handling secure communication with the endpoint. + */ +public abstract class AbstractSecureClientPoolFactory extends AbstractClientPoolFactory { + + private KeyStore trustStore; + + public AbstractSecureClientPoolFactory(KeyStore trustStore) { + this.trustStore = trustStore; + } + + public KeyStore getTrustStore() { + return trustStore; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/ClientPool.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/ClientPool.java new file mode 100644 index 0000000000..58ca0ea9d2 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/ClientPool.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.client; + +import org.apache.commons.pool.impl.GenericKeyedObjectPool; + +/** + * This class is used hold the secure/non-secure connections for an Agent. + */ + +public class ClientPool { + private GenericKeyedObjectPool socketPool; + private GenericKeyedObjectPool secureSocketPool; + + public GenericKeyedObjectPool getClientPool(AbstractClientPoolFactory factory, + int maxActive, + int maxIdle, + boolean testOnBorrow, + long timeBetweenEvictionRunsMillis, + long minEvictableIdleTimeMillis) { + if (socketPool == null) { + synchronized (this) { + if (socketPool == null) { + socketPool = new GenericKeyedObjectPool(); + socketPool.setFactory(factory); + socketPool.setMaxActive(maxActive); + socketPool.setTestOnBorrow(testOnBorrow); + socketPool.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); + socketPool.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); + socketPool.setMaxIdle(maxIdle); + socketPool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW); + } + } + } + return socketPool; + } + + public GenericKeyedObjectPool getClientPool(AbstractSecureClientPoolFactory factory, + int maxActive, + int maxIdle, + boolean testOnBorrow, + long timeBetweenEvictionRunsMillis, + long minEvictableIdleTimeMillis) { + if (secureSocketPool == null) { + synchronized (this) { + if (secureSocketPool == null) { + secureSocketPool = new GenericKeyedObjectPool(); + secureSocketPool.setFactory(factory); + secureSocketPool.setMaxActive(maxActive); + secureSocketPool.setTestOnBorrow(testOnBorrow); + secureSocketPool.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); + secureSocketPool.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); + secureSocketPool.setMaxIdle(maxIdle); + secureSocketPool.setWhenExhaustedAction(GenericKeyedObjectPool.WHEN_EXHAUSTED_BLOCK); + } + } + } + return secureSocketPool; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/conf/AgentConfiguration.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/conf/AgentConfiguration.java new file mode 100644 index 0000000000..750a9037d4 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/conf/AgentConfiguration.java @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf; + +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.DataEndpointConstants; + +import java.security.KeyStore; + +/** + * Agent configurations for throttle publisher. + */ +public class AgentConfiguration { + + private final String publishingStrategy = DataEndpointConstants.ASYNC_STRATEGY; + private KeyStore trustStore; + private int queueSize; + private int batchSize; + private int corePoolSize; + private int socketTimeoutMS; + private int maxPoolSize; + private int keepAliveTimeInPool; + private int reconnectionInterval; + private int maxTransportPoolSize; + private int maxIdleConnections; + private int evictionTimePeriod; + private int minIdleTimeInPool; + private int secureMaxTransportPoolSize; + private int secureMaxIdleConnections; + private int secureEvictionTimePeriod; + private int secureMinIdleTimeInPool; + private String sslEnabledProtocols; + private String ciphers; + + private static AgentConfiguration instance = new AgentConfiguration(); + + private AgentConfiguration() { + } + + public int getQueueSize() { + return queueSize; + } + + public void setQueueSize(int queueSize) { + this.queueSize = queueSize; + } + + public int getBatchSize() { + return batchSize; + } + + public void setBatchSize(int batchSize) { + this.batchSize = batchSize; + } + + public int getCorePoolSize() { + return corePoolSize; + } + + public void setCorePoolSize(int corePoolSize) { + this.corePoolSize = corePoolSize; + } + + public int getSocketTimeoutMS() { + return socketTimeoutMS; + } + + public void setSocketTimeoutMS(int socketTimeoutMS) { + this.socketTimeoutMS = socketTimeoutMS; + } + + public int getMaxPoolSize() { + return maxPoolSize; + } + + public void setMaxPoolSize(int maxPoolSize) { + this.maxPoolSize = maxPoolSize; + } + + public int getKeepAliveTimeInPool() { + return keepAliveTimeInPool; + } + + public void setKeepAliveTimeInPool(int keepAliveTimeInPool) { + this.keepAliveTimeInPool = keepAliveTimeInPool; + } + + public int getReconnectionInterval() { + return reconnectionInterval; + } + + public void setReconnectionInterval(int reconnectionInterval) { + this.reconnectionInterval = reconnectionInterval; + } + + public int getMaxTransportPoolSize() { + return maxTransportPoolSize; + } + + public void setMaxTransportPoolSize(int maxTransportPoolSize) { + this.maxTransportPoolSize = maxTransportPoolSize; + } + + public int getMaxIdleConnections() { + return maxIdleConnections; + } + + public void setMaxIdleConnections(int maxIdleConnections) { + this.maxIdleConnections = maxIdleConnections; + } + + public int getEvictionTimePeriod() { + return evictionTimePeriod; + } + + public void setEvictionTimePeriod(int evictionTimePeriod) { + this.evictionTimePeriod = evictionTimePeriod; + } + + public int getMinIdleTimeInPool() { + return minIdleTimeInPool; + } + + public void setMinIdleTimeInPool(int minIdleTimeInPool) { + this.minIdleTimeInPool = minIdleTimeInPool; + } + + public int getSecureMaxTransportPoolSize() { + return secureMaxTransportPoolSize; + } + + public void setSecureMaxTransportPoolSize(int secureMaxTransportPoolSize) { + this.secureMaxTransportPoolSize = secureMaxTransportPoolSize; + } + + public int getSecureMaxIdleConnections() { + return secureMaxIdleConnections; + } + + public void setSecureMaxIdleConnections(int secureMaxIdleConnections) { + this.secureMaxIdleConnections = secureMaxIdleConnections; + } + + public int getSecureEvictionTimePeriod() { + return secureEvictionTimePeriod; + } + + public void setSecureEvictionTimePeriod(int secureEvictionTimePeriod) { + this.secureEvictionTimePeriod = secureEvictionTimePeriod; + } + + public int getSecureMinIdleTimeInPool() { + return secureMinIdleTimeInPool; + } + + public void setSecureMinIdleTimeInPool(int secureMinIdleTimeInPool) { + this.secureMinIdleTimeInPool = secureMinIdleTimeInPool; + } + + public KeyStore getTrustStore() { + return trustStore; + } + + public void setTrustStore(KeyStore trustStore) { + this.trustStore = trustStore; + } + + public String getSslEnabledProtocols() { + return sslEnabledProtocols; + } + + public void setSslEnabledProtocols(String sslEnabledProtocols) { + this.sslEnabledProtocols = sslEnabledProtocols; + } + + public String getCiphers() { + return ciphers; + } + + public void setCiphers(String ciphers) { + this.ciphers = ciphers; + } + + public String getPublishingStrategy() { + return publishingStrategy; + } + + @Override + public String toString() { + return ", PublishingStrategy : " + publishingStrategy + + "QueueSize" + queueSize + + "BatchSize" + batchSize + + "CorePoolSize" + corePoolSize + + "SocketTimeoutMS" + socketTimeoutMS + + "MaxPoolSize" + maxPoolSize + + "KeepAliveTimeInPool" + keepAliveTimeInPool + + "ReconnectionInterval" + reconnectionInterval + + "MaxTransportPoolSize" + maxTransportPoolSize + + "MaxIdleConnections" + maxIdleConnections + + "EvictionTimePeriod" + evictionTimePeriod + + "MinIdleTimeInPool" + minIdleTimeInPool + + "SecureMaxTransportPoolSize" + secureMaxTransportPoolSize + + "SecureMaxIdleConnections" + secureMaxIdleConnections + + "SecureEvictionTimePeriod" + secureEvictionTimePeriod + + "SecureMinIdleTimeInPool" + secureMinIdleTimeInPool + + "SSLEnabledProtocols" + sslEnabledProtocols + + "Ciphers" + ciphers; + } + + public static AgentConfiguration getInstance() { + return instance; + } + + public static synchronized void setInstance(AgentConfiguration agentConfiguration) { + instance = agentConfiguration; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/conf/DataEndpointConfiguration.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/conf/DataEndpointConfiguration.java new file mode 100644 index 0000000000..7d8c4dbeae --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/conf/DataEndpointConfiguration.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf; + +import org.apache.commons.pool.impl.GenericKeyedObjectPool; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.DataEndpointConstants; + + +/** + * Data Endpoint Configuration. + */ +public class DataEndpointConfiguration { + + private final String receiverURL; + private final String authURL; + private final String username; + private final char[] password; + + private final GenericKeyedObjectPool transportPool; + private final GenericKeyedObjectPool securedTransportPool; + private final int batchSize; + private final String publisherKey; + private final String authKey; + private String sessionId; + private final int corePoolSize; + private final int maxPoolSize; + private final int keepAliveTimeInPool; + + /** + * Protocol Type. + */ + public enum Protocol { + TCP, SSL; + + @Override + public String toString() { + return super.toString().toLowerCase(); + } + } + + public DataEndpointConfiguration(String receiverURL, String authURL, String username, String password, + GenericKeyedObjectPool transportPool, + GenericKeyedObjectPool securedTransportPool, + int batchSize, int corePoolSize, int maxPoolSize, int keepAliveTimeInPool) { + this.receiverURL = receiverURL; + this.authURL = authURL; + this.username = username; + this.password = password.toCharArray(); + this.transportPool = transportPool; + this.securedTransportPool = securedTransportPool; + this.publisherKey = this.receiverURL + DataEndpointConstants.SEPARATOR + username; + this.authKey = this.authURL + DataEndpointConstants.SEPARATOR + username; + this.batchSize = batchSize; + this.corePoolSize = corePoolSize; + this.maxPoolSize = maxPoolSize; + this.keepAliveTimeInPool = keepAliveTimeInPool; + } + + public String getReceiverURL() { + return receiverURL; + } + + public String getUsername() { + return username; + } + + public String getAuthURL() { + return authURL; + } + + public String getPassword() { + return String.valueOf(password); + } + + public String toString() { + return "ReceiverURL: " + receiverURL + "," + + "Authentication URL: " + authURL + "," + + "Username: " + username; + } + + public String getPublisherKey() { + return publisherKey; + } + + public String getAuthKey() { + return authKey; + } + + public String getSessionId() { + return sessionId; + } + + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + public GenericKeyedObjectPool getTransportPool() { + return transportPool; + } + + public GenericKeyedObjectPool getSecuredTransportPool() { + return securedTransportPool; + } + + public int getCorePoolSize() { + return corePoolSize; + } + + public int getMaxPoolSize() { + return maxPoolSize; + } + + public int getKeepAliveTimeInPool() { + return keepAliveTimeInPool; + } + + public int getBatchSize() { + return batchSize; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpoint.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpoint.java new file mode 100644 index 0000000000..60a86f9820 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpoint.java @@ -0,0 +1,388 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint; + +import org.apache.commons.pool.impl.GenericKeyedObjectPool; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.wso2.carbon.databridge.commons.Event; +import org.wso2.carbon.databridge.commons.exception.SessionTimeoutException; +import org.wso2.carbon.databridge.commons.exception.TransportException; +import org.wso2.carbon.databridge.commons.exception.UndefinedEventTypeException; +import org.wso2.carbon.databridge.commons.utils.DataBridgeThreadFactory; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.DataEndpointConfiguration; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointAuthenticationException; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.DataEndpointConstants; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Semaphore; +import java.util.concurrent.TimeUnit; + +/** + * Abstract class for DataEndpoint, and this is a main class that needs to be implemented + * for supporting different transports to DataPublisher. This abstraction provides the additional + * functionality to handle failover, asynchronous connection to the endpoint, etc. + */ + +public abstract class DataEndpoint { + + private static final Logger log = LogManager.getLogger(DataEndpoint.class); + + private DataEndpointConnectionWorker connectionWorker; + + private GenericKeyedObjectPool transportPool; + + private int batchSize; + + private EventPublisherThreadPoolExecutor threadPoolExecutor; + + private DataEndpointFailureCallback dataEndpointFailureCallback; + + private ExecutorService connectionService; + + private int maxPoolSize; + + private List events; + + private State state; + + private Semaphore immediateDispatchSemaphore; + + /** + * Endpoint state. + */ + public enum State { + ACTIVE, UNAVAILABLE, BUSY, INITIALIZING + } + + public DataEndpoint() { + this.batchSize = DataEndpointConstants.DEFAULT_DATA_AGENT_BATCH_SIZE; + this.state = State.INITIALIZING; + events = new ArrayList<>(); + } + + void collectAndSend(Event event) { + events.add(event); + if (events.size() >= batchSize) { + threadPoolExecutor.submitJobAndSetState(new EventPublisher(events), this); + events = new ArrayList<>(); + } + } + + void flushEvents() { + if (events.size() != 0) { + threadPoolExecutor.submitJobAndSetState(new EventPublisher(events), this); + events = new ArrayList<>(); + } + } + + void syncSend(Event event) { + List events = new ArrayList<>(1); + events.add(event); + EventPublisher eventPublisher = new EventPublisher(events); + setStateBusy(); + acquireImmediateDispatchSemaphore(); + try { + eventPublisher.run(); + } finally { + releaseImmediateDispatchSemaphore(); + } + } + + private void acquireImmediateDispatchSemaphore() { + boolean acquired = false; + do { + try { + immediateDispatchSemaphore.acquire(); + acquired = true; + } catch (final InterruptedException e) { + // Do nothing + } + } while (!acquired); + } + + private void releaseImmediateDispatchSemaphore() { + immediateDispatchSemaphore.release(); + } + + private void setStateBusy() { + int permits = immediateDispatchSemaphore.availablePermits(); + if (permits <= 1) { + setState(State.BUSY); + } + } + + void setState(State state) { + if (!this.state.equals(state)) { + this.state = state; + } + } + + void connect() + throws TransportException, + DataEndpointAuthenticationException, DataEndpointException { + if (connectionWorker != null) { + connectionService.submit(connectionWorker); + } else { + throw new DataEndpointException("Data Endpoint is not initialized"); + } + } + + synchronized void syncConnect(String oldSessionId) throws DataEndpointException { + if (oldSessionId == null || oldSessionId.equalsIgnoreCase(getDataEndpointConfiguration().getSessionId())) { + if (connectionWorker != null) { + connectionWorker.run(); + } else { + throw new DataEndpointException("Data Endpoint is not initialized"); + } + } + } + + public void initialize(DataEndpointConfiguration dataEndpointConfiguration) + throws DataEndpointException, DataEndpointAuthenticationException, + TransportException { + this.transportPool = dataEndpointConfiguration.getTransportPool(); + this.batchSize = dataEndpointConfiguration.getBatchSize(); + this.connectionWorker = new DataEndpointConnectionWorker(); + this.connectionWorker.initialize(this, dataEndpointConfiguration); + this.threadPoolExecutor = new EventPublisherThreadPoolExecutor(dataEndpointConfiguration.getCorePoolSize(), + dataEndpointConfiguration.getMaxPoolSize(), dataEndpointConfiguration.getKeepAliveTimeInPool(), + dataEndpointConfiguration.getReceiverURL()); + this.connectionService = Executors.newSingleThreadExecutor(new DataBridgeThreadFactory( + "ConnectionService-" + + dataEndpointConfiguration.getReceiverURL())); + this.maxPoolSize = dataEndpointConfiguration.getMaxPoolSize(); + this.immediateDispatchSemaphore = new Semaphore(maxPoolSize); + connect(); + } + + /** + * Login to the endpoint and return the sessionId. + * + * @param client The client which can be used to connect to the endpoint. + * @param userName The username which is used to login, + * @param password The password which is required for the login operation. + * @return returns the sessionId + * @throws DataEndpointAuthenticationException + */ + protected abstract String login(Object client, String userName, String password) + throws DataEndpointAuthenticationException; + + /** + * Logout from the endpoint. + * + * @param client The client that is used to logout operation. + * @param sessionId The current session Id. + * @throws DataEndpointAuthenticationException + */ + protected abstract void logout(Object client, String sessionId) + throws DataEndpointAuthenticationException; + + + public State getState() { + return state; + } + + void activate() { + this.setState(State.ACTIVE); + } + + void deactivate() { + this.setState(State.UNAVAILABLE); + } + + /** + * Send the list of events to the actual endpoint. + * + * @param client The client that can be used to send the events. + * @param events List of events that needs to be sent. + * @throws DataEndpointException + * @throws SessionTimeoutException + * @throws UndefinedEventTypeException + */ + protected abstract void send(Object client, List events) throws + DataEndpointException, SessionTimeoutException, UndefinedEventTypeException; + + protected DataEndpointConfiguration getDataEndpointConfiguration() { + if (connectionWorker == null) { + return null; + } + return this.connectionWorker.getDataEndpointConfiguration(); + } + + private Object getClient() throws DataEndpointException { + try { + return transportPool.borrowObject(getDataEndpointConfiguration().getPublisherKey()); + } catch (Exception e) { + throw new DataEndpointException("Cannot borrow client for " + + getDataEndpointConfiguration().getPublisherKey(), e); + } + } + + private void returnClient(Object client) { + try { + transportPool.returnObject(getDataEndpointConfiguration().getPublisherKey(), client); + } catch (Exception e) { + log.warn("Error occurred while returning object to connection pool", e); + discardClient(client); + } + } + + private void discardClient(Object client) { + if (client != null) { + try { + transportPool.invalidateObject(getDataEndpointConfiguration().getPublisherKey(), client); + } catch (Exception e) { + log.error("Error while invalidating the client ", e); + } + } + } + + void registerDataEndpointFailureCallback(DataEndpointFailureCallback callback) { + dataEndpointFailureCallback = callback; + } + + /** + * Event Publisher worker thread to actually sends the events to the endpoint. + */ + class EventPublisher implements Runnable { + List events; + private Semaphore semaphore; + + public EventPublisher(List events) { + this.events = events; + } + + @Override + public void run() { + String sessionId = getDataEndpointConfiguration().getSessionId(); + try { + publish(); + } catch (SessionTimeoutException e) { + try { + if (sessionId == null || sessionId.equalsIgnoreCase(getDataEndpointConfiguration(). + getSessionId())) { + syncConnect(sessionId); + } + publish(); + } catch (UndefinedEventTypeException ex) { + log.error("Unable to process this event.", ex); + semaphoreRelease(); + } catch (Exception ex) { + log.error("Unexpected error occurred while sending the event. ", ex); + handleFailedEvents(this.events); + } + } catch (DataEndpointException e) { + log.error("Unable to send events to the endpoint. ", e); + handleFailedEvents(this.events); + } catch (UndefinedEventTypeException e) { + log.error("Unable to process this event.", e); + semaphoreRelease(); + } catch (Exception ex) { + log.error("Unexpected error occurred while sending the event. ", ex); + handleFailedEvents(this.events); + } catch (Throwable t) { + //There can be situations where runtime exceptions/class not found exceptions occur, + // This block help to catch those exceptions. + //No need to retry send events. Deactivating the state would be enough. + log.error("Unexpected error occurred while sending events. ", t); + semaphoreRelease(); + deactivate(); + } finally { + //If any processing error occurred the state will be changed to unavailable, + // Hence the state switch should be happening only in busy state where the publishing was success. + if (state.equals(State.BUSY)) { + activate(); + } + if (log.isDebugEnabled()) { + log.debug("Current threads count is : " + threadPoolExecutor.getActiveCount() + + ", maxPoolSize is : " + + maxPoolSize + ", therefore state is now : " + getState() + " at time : " + + System.nanoTime()); + } + } + } + + public void setPoolSemaphore(Semaphore semaphore) { + this.semaphore = semaphore; + } + + private void publish() throws DataEndpointException, SessionTimeoutException, UndefinedEventTypeException { + Object client = getClient(); + try { + send(client, this.events); + semaphoreRelease(); + } finally { + returnClient(client); + } + } + + private void semaphoreRelease() { + if (this.semaphore != null) { + this.semaphore.release(); + } + } + } + + private void handleFailedEvents(List events) { + deactivate(); + dataEndpointFailureCallback.tryResendEvents(events, this); + } + + boolean isConnected() { + return !state.equals(State.UNAVAILABLE); + } + + public String toString() { + if (getDataEndpointConfiguration() == null) { + return "null"; + } + return "( Receiver URL : " + getDataEndpointConfiguration().getReceiverURL() + ", Authentication URL : " + + getDataEndpointConfiguration().getAuthURL() + ")"; + } + + /** + * Graceful shutdown until publish all the events given to the endpoint. + */ + public void shutdown() { + log.info("Shutdown triggered for data publisher endpoint URL - " + + getDataEndpointConfiguration().getReceiverURL()); + while (threadPoolExecutor.getActiveCount() != 0) { + try { + Thread.sleep(100); + } catch (InterruptedException ignored) { + } + } + connectionWorker.disconnect(getDataEndpointConfiguration()); + connectionService.shutdownNow(); + threadPoolExecutor.shutdownNow(); + try { + connectionService.awaitTermination(10, TimeUnit.SECONDS); + threadPoolExecutor.awaitTermination(10, TimeUnit.SECONDS); + } catch (InterruptedException e) { + + } + log.info("Completed shutdown for data publisher endpoint URL - " + + getDataEndpointConfiguration().getReceiverURL()); + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointConnectionWorker.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointConnectionWorker.java new file mode 100644 index 0000000000..0dbea618fc --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointConnectionWorker.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.DataEndpointConfiguration; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointAuthenticationException; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; + +/** + * DataEndpoint Connection worker class implementation. + */ +public class DataEndpointConnectionWorker implements Runnable { + + private static final Logger log = LogManager.getLogger(DataEndpointConnectionWorker.class); + + private DataEndpointConfiguration dataEndpointConfiguration; + + private DataEndpoint dataEndpoint; + + @Override + public void run() { + if (isInitialized()) { + try { + connect(); + dataEndpoint.activate(); + } catch (DataEndpointAuthenticationException e) { + log.error("Error while trying to connect to the endpoint. " + e.getErrorMessage(), e); + dataEndpoint.deactivate(); + } + } else { + String errorMsg = "Data endpoint connection worker is not properly initialized "; + if (dataEndpoint == null) { + errorMsg += ", data Endpoint is not provided "; + } + if (dataEndpointConfiguration == null) { + errorMsg += ", data Endpoint configuration is not provided"; + } + errorMsg += "."; + log.error(errorMsg); + } + } + + DataEndpointConfiguration getDataEndpointConfiguration() { + return dataEndpointConfiguration; + } + + /** + * Initialize the data endpoint connection worker. + * A connection worker can be instantiated only ONE time. + * + * @param dataEndpoint DataEndpoint instance to handle the connection. + * @param dataEndpointConfiguration DataEndpointConfiguration to handle the connection. + * @throws DataEndpointException if data endpoint configuration is already set or the data endpoint is + * already configured with connection worker + */ + public void initialize(DataEndpoint dataEndpoint, DataEndpointConfiguration dataEndpointConfiguration) + throws DataEndpointException { + if (this.dataEndpointConfiguration == null) { + this.dataEndpointConfiguration = dataEndpointConfiguration; + } else { + throw new DataEndpointException("Already data endpoint configuration is set: " + + this.dataEndpointConfiguration.toString() + " for the endpoint " + + dataEndpointConfiguration.toString()); + } + + if (this.dataEndpoint == null) { + this.dataEndpoint = dataEndpoint; + } else { + throw new DataEndpointException("Already data endpoint is configured for the connection worker"); + } + } + + private void connect() throws DataEndpointAuthenticationException { + Object client = null; + try { + client = this.dataEndpointConfiguration.getSecuredTransportPool(). + borrowObject(dataEndpointConfiguration.getAuthKey()); + String sessionId = this.dataEndpoint. + login(client, dataEndpointConfiguration.getUsername(), + dataEndpointConfiguration.getPassword()); + dataEndpointConfiguration.setSessionId(sessionId); + } catch (Throwable e) { + log.error(e.getMessage(), e); + throw new DataEndpointAuthenticationException("Cannot borrow client for " + + dataEndpointConfiguration.getAuthURL(), e); + } finally { + try { + this.dataEndpointConfiguration.getSecuredTransportPool(). + returnObject(dataEndpointConfiguration.getAuthKey(), client); + } catch (Exception e) { + this.dataEndpointConfiguration.getSecuredTransportPool(). + clear(dataEndpointConfiguration.getAuthKey()); + } + } + + } + + public void disconnect(DataEndpointConfiguration dataPublisherConfiguration) { + Object client = null; + try { + client = this.dataEndpointConfiguration.getSecuredTransportPool(). + borrowObject(dataPublisherConfiguration.getAuthKey()); + this.dataEndpoint.logout(client, dataPublisherConfiguration.getSessionId()); + } catch (Exception e) { + if (log.isDebugEnabled()) { + log.debug("Cannot connect to the server at " + dataPublisherConfiguration.getAuthURL() + + ", for user: " + dataPublisherConfiguration.getUsername(), e); + } + log.warn("Cannot connect to the server at " + dataPublisherConfiguration.getAuthURL() + + ", for user: " + dataPublisherConfiguration.getUsername()); + } finally { + try { + this.dataEndpointConfiguration.getSecuredTransportPool().returnObject( + dataPublisherConfiguration.getAuthKey(), client); + } catch (Exception e) { + this.dataEndpointConfiguration.getSecuredTransportPool().clear( + dataPublisherConfiguration.getAuthKey()); + } + } + } + + private boolean isInitialized() { + return dataEndpoint != null && dataEndpointConfiguration != null; + } + +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointFailureCallback.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointFailureCallback.java new file mode 100644 index 0000000000..7fc32451a7 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointFailureCallback.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint; + +import org.wso2.carbon.databridge.commons.Event; + +import java.util.List; + +/** + * This interface is used to implement a call back for get the notifications upon the unsuccessful event publishing. + */ +public interface DataEndpointFailureCallback { + + /** + * Notifies the The failed events, and should try to send the events again successfully. + * In case if this couldn't send the events, then the unsuccessful events list needs to be returned back. + * + * @param events List failed events + */ + public void tryResendEvents(List events, DataEndpoint failedEP); + +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointGroup.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointGroup.java new file mode 100644 index 0000000000..5de63476bb --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointGroup.java @@ -0,0 +1,448 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint; + +import com.lmax.disruptor.BlockingWaitStrategy; +import com.lmax.disruptor.EventHandler; +import com.lmax.disruptor.InsufficientCapacityException; +import com.lmax.disruptor.RingBuffer; +import com.lmax.disruptor.dsl.Disruptor; +import com.lmax.disruptor.dsl.ProducerType; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.wso2.carbon.databridge.commons.Event; +import org.wso2.carbon.databridge.commons.utils.DataBridgeThreadFactory; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.DataEndpointAgent; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointConfigurationException; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.EventQueueFullException; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.DataEndpointConstants; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.DataPublisherUtil; + +import java.io.IOException; +import java.net.Socket; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * This class holds the endpoints associated within a group. Also it has a queue + * to hold the list of events that needs to be processed by the endpoints with + * provided the load balancing, or failover configuration. + */ +public class DataEndpointGroup implements DataEndpointFailureCallback { + private static final Logger log = LogManager.getLogger(DataEndpointGroup.class); + + private List dataEndpoints; + + private HAType haType; + + private EventQueue eventQueue = null; + + private int reconnectionInterval; + + private final Integer startIndex = 0; + + private AtomicInteger currentDataPublisherIndex = new AtomicInteger(startIndex); + + private AtomicInteger maximumDataPublisherIndex = new AtomicInteger(); + + private ScheduledExecutorService reconnectionService; + + private final String publishingStrategy; + + private boolean isShutdown = false; + + /** + * HA Type. + */ + public enum HAType { + FAILOVER, LOADBALANCE + } + + public DataEndpointGroup(HAType haType, DataEndpointAgent agent) { + this.dataEndpoints = new ArrayList<>(); + this.haType = haType; + this.reconnectionService = Executors.newScheduledThreadPool(1, + new DataBridgeThreadFactory("ReconnectionService")); + this.reconnectionInterval = agent.getAgentConfiguration().getReconnectionInterval(); + this.publishingStrategy = agent.getAgentConfiguration().getPublishingStrategy(); + if (!publishingStrategy.equalsIgnoreCase(DataEndpointConstants.SYNC_STRATEGY)) { + this.eventQueue = new EventQueue(agent.getAgentConfiguration().getQueueSize()); + } + this.reconnectionService.scheduleAtFixedRate(new ReconnectionTask(), reconnectionInterval, + reconnectionInterval, TimeUnit.SECONDS); + currentDataPublisherIndex.set(startIndex); + } + + public void addDataEndpoint(DataEndpoint dataEndpoint) { + dataEndpoints.add(dataEndpoint); + dataEndpoint.registerDataEndpointFailureCallback(this); + maximumDataPublisherIndex.incrementAndGet(); + } + + public void tryPublish(Event event) throws EventQueueFullException { + if (eventQueue != null) { + eventQueue.tryPut(event); + } else if (!isShutdown) { + trySyncPublish(event); + } + } + + public void publish(Event event) { + if (eventQueue != null) { + eventQueue.put(event); + } else if (!isShutdown) { + syncPublish(event); + } + } + + private void trySyncPublish(Event event) { + try { + DataEndpoint endpoint = getDataEndpoint(false); + if (endpoint != null) { + endpoint.syncSend(event); + } else { + if (log.isDebugEnabled()) { + log.debug("DataEndpoint not available, dropping event : " + event); + } + } + } catch (Throwable t) { + log.error("Unexpected error: " + t.getMessage(), t); + } + } + + private void syncPublish(Event event) { + try { + DataEndpoint endpoint = getDataEndpoint(true); + if (endpoint != null) { + endpoint.syncSend(event); + } else { + log.error("Dropping event as DataPublisher is shutting down."); + if (log.isDebugEnabled()) { + log.debug("Data publisher is shutting down, dropping event : " + event); + } + } + } catch (Throwable t) { + log.error("Unexpected error: " + t.getMessage(), t); + } + } + + /** + * Event Queue Class. + */ + class EventQueue { + private RingBuffer ringBuffer = null; + private Disruptor eventQueueDisruptor = null; + private ExecutorService eventQueuePool = null; + + EventQueue(int queueSize) { + eventQueuePool = Executors.newCachedThreadPool( + new DataBridgeThreadFactory("EventQueue")); + eventQueueDisruptor = new Disruptor<>(new WrappedEventFactory(), queueSize, eventQueuePool, + ProducerType.MULTI, new BlockingWaitStrategy()); + eventQueueDisruptor.handleEventsWith(new EventQueueWorker()); + this.ringBuffer = eventQueueDisruptor.start(); + } + + private void tryPut(Event event) throws EventQueueFullException { + + long sequence; + try { + sequence = this.ringBuffer.tryNext(1); + WrappedEventFactory.WrappedEvent bufferedEvent = this.ringBuffer.get(sequence); + bufferedEvent.setEvent(event); + this.ringBuffer.publish(sequence); + } catch (InsufficientCapacityException e) { + throw new EventQueueFullException("Cannot send events because the event queue is full", e); + } + } + + //Endless wait if at-least once endpoint is available. + private void put(Event event) { + do { + try { + long sequence = this.ringBuffer.tryNext(1); + WrappedEventFactory.WrappedEvent bufferedEvent = this.ringBuffer.get(sequence); + bufferedEvent.setEvent(event); + this.ringBuffer.publish(sequence); + return; + } catch (InsufficientCapacityException ex) { + try { + Thread.sleep(2); + } catch (InterruptedException ignored) { + } + } + } while (isActiveDataEndpointExists()); + } + + private void shutdown() { + eventQueuePool.shutdown(); + eventQueueDisruptor.shutdown(); + } + } + + /** + * Event Queue Worker. + */ + class EventQueueWorker implements EventHandler { + + boolean isLastEventDropped = false; + + @Override + public void onEvent(WrappedEventFactory.WrappedEvent wrappedEvent, long sequence, boolean endOfBatch) { + DataEndpoint endpoint = getDataEndpoint(true); + Event event = wrappedEvent.getEvent(); + if (endpoint != null) { + isLastEventDropped = false; + endpoint.collectAndSend(event); + if (endOfBatch) { + flushAllDataEndpoints(); + } + } else { + if (!isLastEventDropped) { + log.error("Dropping all events as DataPublisher is shutting down."); + } + if (log.isDebugEnabled()) { + log.debug("Data publisher is shutting down, dropping event : " + event); + } + isLastEventDropped = true; + } + } + } + + private void flushAllDataEndpoints() { + for (DataEndpoint dataEndpoint : dataEndpoints) { + if (dataEndpoint.getState().equals(DataEndpoint.State.ACTIVE)) { + dataEndpoint.flushEvents(); + } + } + } + + private DataEndpoint getDataEndpoint(boolean isBusyWait) { + return getDataEndpoint(isBusyWait, null); + } + + /** + * Find the next event processable endpoint to the + * data endpoint based on load balancing and failover logic, and wait + * indefinitely until at least one data endpoint becomes available based + * on busywait parameter. + * + * @param isBusyWait waitUntil atleast one endpoint becomes available + * @return DataEndpoint which can accept and send the events. + */ + private DataEndpoint getDataEndpoint(boolean isBusyWait, DataEndpoint failedEP) { + int startIndex; + if (haType.equals(HAType.LOADBALANCE)) { + startIndex = getDataPublisherIndex(); + } else { + startIndex = this.startIndex; + } + int index = startIndex; + + while (true) { + DataEndpoint dataEndpoint = dataEndpoints.get(index); + if (dataEndpoint.getState().equals(DataEndpoint.State.ACTIVE) && dataEndpoint != failedEP) { + return dataEndpoint; + } else if (haType.equals(HAType.FAILOVER) && (dataEndpoint.getState().equals(DataEndpoint.State.BUSY) || + dataEndpoint.getState().equals(DataEndpoint.State.INITIALIZING))) { + /** + * Wait for some time until the failover endpoint finish publishing + * + */ + busyWait(1); + } else { + index++; + if (index > maximumDataPublisherIndex.get() - 1) { + index = this.startIndex; + } + if (index == startIndex) { + if (isBusyWait) { + if (!reconnectionService.isShutdown()) { + + /** + * Have fully iterated the data publisher list, + * and busy wait until data publisher + * becomes available + */ + busyWait(1); + } else { + if (!isActiveDataEndpointExists()) { + return null; + } else { + busyWait(1); + } + } + } else { + return null; + } + } + } + } + } + + private void busyWait(long timeInMilliSec) { + try { + Thread.sleep(timeInMilliSec); + } catch (InterruptedException ignored) { + } + } + + private boolean isActiveDataEndpointExists() { + int index = startIndex; + while (index < maximumDataPublisherIndex.get()) { + DataEndpoint dataEndpoint = dataEndpoints.get(index); + if (dataEndpoint.getState() != DataEndpoint.State.UNAVAILABLE) { + if (log.isDebugEnabled()) { + log.debug("Available endpoint : " + dataEndpoint + " existing in state - " + + dataEndpoint.getState()); + } + return true; + } + index++; + } + return false; + } + + private synchronized int getDataPublisherIndex() { + int index = currentDataPublisherIndex.getAndIncrement(); + if (index == maximumDataPublisherIndex.get() - 1) { + currentDataPublisherIndex.set(startIndex); + } + return index; + } + + public void tryResendEvents(List events, DataEndpoint dataEndpoint) { + List unsuccessfulEvents = trySendActiveEndpoints(events, dataEndpoint); + for (Event event : unsuccessfulEvents) { + try { + if (eventQueue != null) { + eventQueue.tryPut(event); + } else { + trySyncPublish(event); + } + } catch (EventQueueFullException e) { + log.error("Unable to put the event :" + event, e); + } + } + } + + private List trySendActiveEndpoints(List events, DataEndpoint failedEP) { + ArrayList unsuccessfulEvents = new ArrayList<>(); + for (Event event : events) { + DataEndpoint endpoint = getDataEndpoint(false, failedEP); + if (endpoint != null) { + endpoint.collectAndSend(event); + } else { + unsuccessfulEvents.add(event); + } + } + flushAllDataEndpoints(); + return unsuccessfulEvents; + } + + private class ReconnectionTask implements Runnable { + String failedDataEndpoints = ""; + public void run() { + boolean isOneReceiverConnected = false; + for (int i = startIndex; i < maximumDataPublisherIndex.get(); i++) { + DataEndpoint dataEndpoint = dataEndpoints.get(i); + if (!dataEndpoint.isConnected()) { + try { + dataEndpoint.connect(); + } catch (Exception ex) { + dataEndpoint.deactivate(); + } + } else { + try { + String[] urlElements = DataPublisherUtil.getProtocolHostPort( + dataEndpoint.getDataEndpointConfiguration().getReceiverURL()); + if (!isServerExists(urlElements[1], Integer.parseInt(urlElements[2]))) { + dataEndpoint.deactivate(); + } + } catch (DataEndpointConfigurationException exception) { + log.warn("Data Endpoint with receiver URL:" + + dataEndpoint.getDataEndpointConfiguration().getReceiverURL() + + " could not be deactivated", exception); + } + } + if (dataEndpoint.isConnected()) { + isOneReceiverConnected = true; + } else { + failedDataEndpoints = (dataEndpoint.getDataEndpointConfiguration() != null + ? dataEndpoint.getDataEndpointConfiguration().getReceiverURL() : "Null") + ","; + } + } + if (!isOneReceiverConnected) { + log.warn("Receiver is not reachable at reconnection for the endpoints: " + failedDataEndpoints + + ", will try to reconnect every " + reconnectionInterval + " sec"); + } + } + + private boolean isServerExists(String ip, int port) { + try { + Socket socket = new Socket(ip, port); + socket.close(); + return true; + } catch (UnknownHostException e) { + return false; + } catch (IOException e) { + return false; + } catch (Exception e) { + return false; + } + } + + } + + public String toString() { + StringBuilder group = new StringBuilder(); + group.append("[ "); + for (int i = 0; i < dataEndpoints.size(); i++) { + DataEndpoint endpoint = dataEndpoints.get(i); + group.append(endpoint.toString()); + if (i == dataEndpoints.size() - 1) { + group.append(" ]"); + return group.toString(); + } else { + if (haType == HAType.FAILOVER) { + group.append(DataEndpointConstants.FAILOVER_URL_GROUP_SEPARATOR); + } else { + group.append(DataEndpointConstants.LB_URL_GROUP_SEPARATOR); + } + } + } + return group.toString(); + } + + public void shutdown() { + reconnectionService.shutdownNow(); + if (eventQueue != null) { + eventQueue.shutdown(); + } + isShutdown = true; + for (DataEndpoint dataEndpoint : dataEndpoints) { + dataEndpoint.shutdown(); + } + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/EventPublisherThreadPoolExecutor.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/EventPublisherThreadPoolExecutor.java new file mode 100644 index 0000000000..c857bca1ab --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/EventPublisherThreadPoolExecutor.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint; + +import org.wso2.carbon.databridge.commons.utils.DataBridgeThreadFactory; + +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.Semaphore; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +/** + * Event Publisher Threadpool Executor. + */ +public class EventPublisherThreadPoolExecutor extends ThreadPoolExecutor { + + private final Semaphore semaphore; + + public EventPublisherThreadPoolExecutor(int corePoolSize, int maxPoolSize, long keepAliveTimeInPool, + String receiverURL) { + super(corePoolSize, maxPoolSize, keepAliveTimeInPool, TimeUnit.SECONDS, new LinkedBlockingQueue(), + new DataBridgeThreadFactory(receiverURL)); + semaphore = new Semaphore(maxPoolSize); + } + + @Override + public void execute(final Runnable task) { + boolean acquired = false; + do { + try { + semaphore.acquire(); + acquired = true; + } catch (final InterruptedException e) { + // Do nothing + } + } while (!acquired); + super.execute(task); + } + + public void submitJobAndSetState(DataEndpoint.EventPublisher publisher, DataEndpoint dataEndpoint) { + int permits = semaphore.availablePermits(); + if (permits <= 1) { + dataEndpoint.setState(DataEndpoint.State.BUSY); + } + publisher.setPoolSemaphore(semaphore); + submit(new Thread(publisher)); + } + +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/WrappedEventFactory.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/WrappedEventFactory.java new file mode 100644 index 0000000000..9527389638 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/WrappedEventFactory.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint; + +import com.lmax.disruptor.EventFactory; +import org.wso2.carbon.databridge.commons.Event; + +/** + * Wrapper Event Factory. + */ +public class WrappedEventFactory implements EventFactory { + + public WrappedEvent newInstance() { + return new WrappedEvent(); + } + + /** + * Wrapped Event. + */ + public static class WrappedEvent { + + private Event event; + + public Event getEvent() { + return event; + } + + public void setEvent(Event event) { + this.event = event; + } + + @Override + public String toString() { + return "WrappedEvent{" + + "event=" + event + + "}"; + } + } + +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryClientPoolFactory.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryClientPoolFactory.java new file mode 100644 index 0000000000..4cad21b15c --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryClientPoolFactory.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.AgentHolder; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.client.AbstractClientPoolFactory; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.DataEndpointConfiguration; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; + + +import java.io.IOException; +import java.net.Socket; + +/** + * This class implements AbstractClientPoolFactory to handle the Binary transport related connections. + */ +public class BinaryClientPoolFactory extends AbstractClientPoolFactory { + private static final Logger log = LogManager.getLogger(BinaryClientPoolFactory.class); + + @Override + public Object createClient(String protocol, String hostName, int port) throws DataEndpointException { + if (protocol.equalsIgnoreCase(DataEndpointConfiguration.Protocol.TCP.toString())) { + int timeout = AgentHolder.getInstance().getDataEndpointAgent().getAgentConfiguration() + .getSocketTimeoutMS(); + try { + Socket socket = new Socket(hostName, port); + socket.setSoTimeout(timeout); + return socket; + } catch (IOException e) { + throw new DataEndpointException("Error while opening socket to " + hostName + ":" + port + ". " + + e.getMessage(), e); + } + } else { + throw new DataEndpointException("Unsupported protocol: " + protocol + ". Currently only " + + DataEndpointConfiguration.Protocol.TCP.toString() + " supported."); + } + } + + @Override + public boolean validateClient(Object client) { + return ((Socket) client).isConnected(); + } + + @Override + public void terminateClient(Object client) { + Socket socket = null; + try { + socket = (Socket) client; + socket.close(); + } catch (IOException e) { + log.warn("Cannot close the socket successfully from " + socket.getLocalAddress().getHostAddress() + + ":" + socket.getPort()); + } + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryDataEndpoint.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryDataEndpoint.java new file mode 100644 index 0000000000..b442e9e462 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryDataEndpoint.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary; + +import org.wso2.carbon.databridge.commons.Event; +import org.wso2.carbon.databridge.commons.exception.SessionTimeoutException; +import org.wso2.carbon.databridge.commons.exception.UndefinedEventTypeException; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.DataEndpoint; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointAuthenticationException; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; + +import java.net.Socket; +import java.util.List; + +import static org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary.BinaryEventSender.processResponse; +import static org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary.BinaryEventSender.sendBinaryLoginMessage; +import static org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary.BinaryEventSender.sendBinaryLogoutMessage; +import static org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary.BinaryEventSender.sendBinaryPublishMessage; + + +/** + * This class is Binary transport implementation for the Data Endpoint. + */ +public class BinaryDataEndpoint extends DataEndpoint { + + @Override + protected String login(Object client, String userName, String password) throws DataEndpointAuthenticationException { + Socket socket = (Socket) client; + try { + sendBinaryLoginMessage(socket, userName, password); + return processResponse(socket); + } catch (Exception e) { + if (e instanceof DataEndpointAuthenticationException) { + throw (DataEndpointAuthenticationException) e; + } else { + throw new DataEndpointAuthenticationException("Error while trying to login to data receiver :" + + socket.getRemoteSocketAddress().toString(), e); + } + } + } + + @Override + protected void logout(Object client, String sessionId) throws DataEndpointAuthenticationException { + Socket socket = (Socket) client; + try { + sendBinaryLogoutMessage(socket, sessionId); + processResponse(socket); + } catch (Exception e) { + if (e instanceof DataEndpointAuthenticationException) { + throw (DataEndpointAuthenticationException) e; + } else { + throw new DataEndpointAuthenticationException("Error while trying to logout to data receiver :" + + socket.getRemoteSocketAddress().toString(), e); + } + } + } + + @Override + protected void send(Object client, List events) throws DataEndpointException, + SessionTimeoutException, UndefinedEventTypeException { + Socket socket = (Socket) client; + String sessionId = getDataEndpointConfiguration().getSessionId(); + try { + sendBinaryPublishMessage(socket, events, sessionId); + processResponse(socket); + } catch (Exception e) { + if (e instanceof DataEndpointException) { + throw (DataEndpointException) e; + } else if (e instanceof UndefinedEventTypeException) { + throw new UndefinedEventTypeException("Undefined Event Type Exception ", e); + } else if (e instanceof SessionTimeoutException) { + throw new SessionTimeoutException("Binary Session Expired Exception ", e); + } else { + throw new DataEndpointException("Error while trying to publish events to data receiver :" + + socket.getRemoteSocketAddress().toString(), e); + } + } + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryEventSender.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryEventSender.java new file mode 100644 index 0000000000..e2d17ba12e --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryEventSender.java @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary; + +import org.wso2.carbon.databridge.commons.Event; +import org.wso2.carbon.databridge.commons.binary.BinaryMessageConstants; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.Socket; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import static org.wso2.carbon.databridge.commons.binary.BinaryMessageConverterUtil.assignData; +import static org.wso2.carbon.databridge.commons.binary.BinaryMessageConverterUtil.getSize; +import static org.wso2.carbon.databridge.commons.binary.BinaryMessageConverterUtil.loadData; + + +/** + * This is a Util class which does the Binary message transformation for publish, login, logout operations. + */ +public class BinaryEventSender { + public static void sendBinaryLoginMessage(Socket socket, String userName, String password) throws IOException { + ByteBuffer buf = ByteBuffer.allocate(13 + userName.length() + password.length()); + buf.put((byte) 0); + buf.putInt(8 + userName.length() + password.length()); + buf.putInt(userName.length()); + buf.putInt(password.length()); + buf.put(userName.getBytes(BinaryMessageConstants.DEFAULT_CHARSET)); + buf.put(password.getBytes(BinaryMessageConstants.DEFAULT_CHARSET)); + + OutputStream outputStream = new BufferedOutputStream(socket.getOutputStream()); + outputStream.write(buf.array()); + outputStream.flush(); + } + + public static void sendBinaryLogoutMessage(Socket socket, String sessionId) throws IOException { + ByteBuffer buf = ByteBuffer.allocate(9 + sessionId.length()); + buf.put((byte) 1); + buf.putInt(4 + sessionId.length()); + buf.putInt(sessionId.length()); + buf.put(sessionId.getBytes(BinaryMessageConstants.DEFAULT_CHARSET)); + + OutputStream outputStream = new BufferedOutputStream(socket.getOutputStream()); + outputStream.write(buf.array()); + outputStream.flush(); + } + + public static void sendBinaryPublishMessage(Socket socket, List events, String sessionId) + throws IOException { + int messageSize = 8 + sessionId.length(); + List bytes = new ArrayList<>(); + + for (Event event : events) { + + int eventSize = getEventSize(event); + messageSize += eventSize + 4; + ByteBuffer eventDataBuffer = ByteBuffer.allocate(4 + eventSize); + eventDataBuffer.putInt(eventSize); + eventDataBuffer.putLong(event.getTimeStamp()); + eventDataBuffer.putInt(event.getStreamId().length()); + eventDataBuffer.put(event.getStreamId().getBytes(BinaryMessageConstants.DEFAULT_CHARSET)); + + if (event.getMetaData() != null && event.getMetaData().length != 0) { + for (Object aMetaData : event.getMetaData()) { + assignData(aMetaData, eventDataBuffer); + } + } + if (event.getCorrelationData() != null && event.getCorrelationData().length != 0) { + for (Object aCorrelationData : event.getCorrelationData()) { + assignData(aCorrelationData, eventDataBuffer); + } + } + if (event.getPayloadData() != null && event.getPayloadData().length != 0) { + for (Object aPayloadData : event.getPayloadData()) { + assignData(aPayloadData, eventDataBuffer); + } + } + if (event.getArbitraryDataMap() != null && event.getArbitraryDataMap().size() != 0) { + for (Map.Entry aArbitraryData : event.getArbitraryDataMap().entrySet()) { + assignData(aArbitraryData.getKey(), eventDataBuffer); + assignData(aArbitraryData.getValue(), eventDataBuffer); + } + } + bytes.add(eventDataBuffer.array()); + } + + ByteBuffer buf = ByteBuffer.allocate(sessionId.length() + 13); + buf.put((byte) 2); //1 + buf.putInt(messageSize); //4 + buf.putInt(sessionId.length()); //4 + buf.put(sessionId.getBytes(BinaryMessageConstants.DEFAULT_CHARSET)); + buf.putInt(events.size()); //4 + + OutputStream outputstream = new BufferedOutputStream(socket.getOutputStream()); + outputstream.write(buf.array()); + for (byte[] byteArray : bytes) { + outputstream.write(byteArray); + } + outputstream.flush(); + } + + private static int getEventSize(Event event) { + int eventSize = 4 + event.getStreamId().length() + 8; + Object[] data = event.getMetaData(); + if (data != null) { + for (Object aData : data) { + eventSize += getSize(aData); + } + } + data = event.getCorrelationData(); + if (data != null) { + for (Object aData : data) { + eventSize += getSize(aData); + } + } + data = event.getPayloadData(); + if (data != null) { + for (Object aData : data) { + eventSize += getSize(aData); + } + } + if (event.getArbitraryDataMap() != null && event.getArbitraryDataMap().size() != 0) { + for (Map.Entry aArbitraryData : event.getArbitraryDataMap().entrySet()) { + eventSize += 8 + aArbitraryData.getKey().length() + aArbitraryData.getValue().length(); + } + } + return eventSize; + } + + public static String processResponse(Socket socket) throws Exception { + + InputStream inputStream = socket.getInputStream(); + BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream); + int messageType = bufferedInputStream.read(); + ByteBuffer bbuf; + switch (messageType) { + case 0: + //OK message + break; + case 1: + //Error Message + bbuf = ByteBuffer.wrap(loadData(bufferedInputStream, new byte[8])); + int errorClassNameLength = bbuf.getInt(); + int errorMsgLength = bbuf.getInt(); + + String className = new String(ByteBuffer.wrap(loadData(bufferedInputStream, + new byte[errorClassNameLength])).array()); + String errorMsg = new String(ByteBuffer.wrap(loadData(bufferedInputStream, + new byte[errorMsgLength])).array()); + + throw (Exception) (BinaryDataEndpoint.class.getClassLoader(). + loadClass(className).getConstructor(String.class).newInstance(errorMsg)); + case 2: + //Logging OK response + bbuf = ByteBuffer.wrap(loadData(bufferedInputStream, new byte[4])); + int sessionIdLength = bbuf.getInt(); + return new String(ByteBuffer.wrap(loadData(bufferedInputStream, new byte[sessionIdLength])).array()); + } + return null; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinarySecureClientPoolFactory.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinarySecureClientPoolFactory.java new file mode 100644 index 0000000000..380af0bf89 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinarySecureClientPoolFactory.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary; + +import org.apache.http.conn.ssl.SSLContexts; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.AgentHolder; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.client.AbstractSecureClientPoolFactory; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.DataEndpointConfiguration; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; + +import java.io.IOException; +import java.net.Socket; +import java.security.KeyManagementException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; + +/** + * This is a Binary Transport secure implementation for AbstractSecureClientPoolFactory to be used by BinaryEndpoint. + */ +public class BinarySecureClientPoolFactory extends AbstractSecureClientPoolFactory { + private static final Logger log = LogManager.getLogger(BinarySecureClientPoolFactory.class); + private static SSLSocketFactory sslSocketFactory; + + public BinarySecureClientPoolFactory(KeyStore trustStore) { + super(trustStore); + SSLContext ctx; + try { + ctx = createSSLContext(); + sslSocketFactory = ctx.getSocketFactory(); + } catch (DataEndpointException e) { + log.error("Error while initializing the SSL Context with provided parameters" + + e.getErrorMessage(), e); + log.warn("Default SSLSocketFactory will be used for the data publishing clients."); + sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); + } + } + + @Override + public Object createClient(String protocol, String hostName, int port) throws DataEndpointException { + if (protocol.equalsIgnoreCase(DataEndpointConfiguration.Protocol.SSL.toString())) { + int timeout = AgentHolder.getInstance().getDataEndpointAgent().getAgentConfiguration() + .getSocketTimeoutMS(); + String sslProtocols = AgentHolder.getInstance().getDataEndpointAgent().getAgentConfiguration() + .getSslEnabledProtocols(); + String ciphers = AgentHolder.getInstance().getDataEndpointAgent().getAgentConfiguration().getCiphers(); + + try { + SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket(hostName, port); + sslSocket.setSoTimeout(timeout); + + if (sslProtocols != null && sslProtocols.length() != 0) { + String[] sslProtocolsArray = sslProtocols.split(","); + sslSocket.setEnabledProtocols(sslProtocolsArray); + } + + if (ciphers != null && ciphers.length() != 0) { + String[] ciphersArray = ciphers.replaceAll(" ", "").split(","); + sslSocket.setEnabledCipherSuites(ciphersArray); + } else { + sslSocket.setEnabledCipherSuites(sslSocket.getSupportedCipherSuites()); + } + return sslSocket; + } catch (IOException e) { + throw new DataEndpointException("Error while opening socket to " + hostName + ":" + port + ". " + + e.getMessage(), e); + } + } else { + throw new DataEndpointException("Unsupported protocol: " + protocol + ". Currently only " + + DataEndpointConfiguration.Protocol.SSL.toString() + " supported."); + } + } + + @Override + public boolean validateClient(Object client) { + Socket socket = (Socket) client; + return socket.isConnected(); + } + + @Override + public void terminateClient(Object client) { + Socket socket = null; + try { + socket = (Socket) client; + socket.close(); + } catch (IOException e) { + log.warn("Cannot close the socket successfully from " + socket.getLocalAddress().getHostAddress() + + ":" + socket.getPort()); + } + } + + private SSLContext createSSLContext() throws DataEndpointException { + SSLContext ctx; + try { + KeyStore trustStore = getTrustStore(); + ctx = SSLContexts.custom().loadTrustMaterial(trustStore).build(); + return ctx; + } catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) { + throw new DataEndpointException("Error while creating the SSLContext with instance type : TLS.", e); + } + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointAuthenticationException.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointAuthenticationException.java new file mode 100644 index 0000000000..0323e37c56 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointAuthenticationException.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception; + +/** + * Exception to be thrown when connecting the Data Endpoint. + */ + +public class DataEndpointAuthenticationException extends Exception { + private String errorMessage; + + public DataEndpointAuthenticationException(String message) { + super(message); + errorMessage = message; + } + + public DataEndpointAuthenticationException(String message, Throwable cause) { + super(message, cause); + errorMessage = message; + } + + public DataEndpointAuthenticationException(Throwable cause) { + super(cause); + } + + public String getErrorMessage() { + return errorMessage; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointConfigurationException.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointConfigurationException.java new file mode 100644 index 0000000000..1a605a089f --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointConfigurationException.java @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* +* WSO2 Inc. licenses this file to you under the Apache License, +* Version 2.0 (the "License"); you may not use this file except +* in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception; + +/** + * Exception to be thrown When parsing the Data Endpoint configurations when initializing data publisher. + */ + +public class DataEndpointConfigurationException extends Exception { + private String errorMessage; + + public DataEndpointConfigurationException(String message) { + super(message); + errorMessage = message; + } + + public DataEndpointConfigurationException(String message, Throwable cause) { + super(message, cause); + errorMessage = message; + } + + public DataEndpointConfigurationException(Throwable cause) { + super(cause); + } + + public String getErrorMessage() { + return errorMessage; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointException.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointException.java new file mode 100644 index 0000000000..f014c664d4 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointException.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception; + +/** + * Exception to be thrown when communicating with DataEndpoint. + */ + +public class DataEndpointException extends Exception { + private String errorMessage; + + public DataEndpointException(String message) { + super(message); + errorMessage = message; + } + + public DataEndpointException(String message, Throwable cause) { + super(message, cause); + errorMessage = message; + } + + public DataEndpointException(Throwable cause) { + super(cause); + } + + public String getErrorMessage() { + return errorMessage; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/EventQueueFullException.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/EventQueueFullException.java new file mode 100644 index 0000000000..5b6a714a0e --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/EventQueueFullException.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception; + +/** + * Exception to be thrown when the event is tried to insert into the queue + * which doesn't have adequate capacity to hold. + */ + +public class EventQueueFullException extends Exception { + private String errorMessage; + + public EventQueueFullException(String message) { + super(message); + errorMessage = message; + } + + public EventQueueFullException(String message, Throwable cause) { + super(message, cause); + errorMessage = message; + } + + public EventQueueFullException(Throwable cause) { + super(cause); + } + + public String getErrorMessage() { + return errorMessage; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataEndpointConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataEndpointConstants.java new file mode 100644 index 0000000000..096da48980 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataEndpointConstants.java @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* +* WSO2 Inc. licenses this file to you under the Apache License, +* Version 2.0 (the "License"); you may not use this file except +* in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util; + +/** + * Class to define the constants that are used. + */ +public class DataEndpointConstants { + + private DataEndpointConstants() { + } + + public static final int DEFAULT_DATA_AGENT_BATCH_SIZE = 100; + public static final String LB_URL_GROUP_SEPARATOR = ","; + public static final String FAILOVER_URL_GROUP_SEPARATOR = "|"; + public static final String FAILOVER_URL_GROUP_SEPARATOR_REGEX = "\\|"; + public static final int DEFAULT_AUTH_PORT_OFFSET = 100; + public static final String SEPARATOR = "##"; + + public static final String SYNC_STRATEGY = "sync"; + public static final String ASYNC_STRATEGY = "async"; + +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataPublisherUtil.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataPublisherUtil.java new file mode 100644 index 0000000000..afc9ad787a --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataPublisherUtil.java @@ -0,0 +1,230 @@ +/* +* Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* +* WSO2 Inc. licenses this file to you under the Apache License, +* Version 2.0 (the "License"); you may not use this file except +* in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util; + + + +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.DataEndpointConfiguration; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointConfigurationException; + +import java.util.ArrayList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * A Util class which holds all the utility processing methods in the data publisher operation. + */ + +public class DataPublisherUtil { + + /** + * Making as private to avoid the instantiation of the class. + */ + private DataPublisherUtil() { + } + + /** + * Process and extracts the receiver Groups from the string of URL set pattern passed in. + * + * @param urlSet receiverGroups URL set + * @return List of Receiver groups + * @throws DataEndpointConfigurationException + */ + public static ArrayList getEndpointGroups(String urlSet) + throws DataEndpointConfigurationException { + ArrayList urlGroups = new ArrayList(); + ArrayList endPointGroups = new ArrayList(); + Pattern regex = Pattern.compile("\\{.*?\\}"); + Matcher regexMatcher = regex.matcher(urlSet); + while (regexMatcher.find()) { + urlGroups.add(regexMatcher.group().replace("{", "").replace("}", "")); + } + if (urlGroups.size() == 0) { + urlGroups.add(urlSet.replace("{", "").replace("}", "")); + } + for (String aURLGroup : urlGroups) { + endPointGroups.add(getEndpoints(aURLGroup)); + } + return endPointGroups; + } + + + /** + * Returns an object array which has first element as boolean + * for specify the URLs are fail over configuration or LB configuration. + * From the 2nd element onwards the object array will hold the separated URLs + * + * @param aURLGroup one receiver group's URL + * @return First element - boolean (isFailOver), next elements are each URLs + * @throws DataEndpointConfigurationException + */ + private static Object[] getEndpoints(String aURLGroup) + throws DataEndpointConfigurationException { + boolean isLBURL = false, isFailOverURL = false; + String[] urls; + if (aURLGroup.contains(",")) { + isLBURL = true; + } + if (aURLGroup.contains("|")) { + isFailOverURL = true; + } + + if (isLBURL && isFailOverURL) { + throw new DataEndpointConfigurationException("Invalid data endpoints URL set provided : " + aURLGroup + + ", a URL group can be configured as failover OR load balancing endpoints."); + } else if (isLBURL) { + urls = aURLGroup.split(DataEndpointConstants.LB_URL_GROUP_SEPARATOR); + } else if (isFailOverURL) { + urls = aURLGroup.split(DataEndpointConstants.FAILOVER_URL_GROUP_SEPARATOR_REGEX); + } else { + urls = new String[]{aURLGroup}; + } + Object[] endpoint = new Object[urls.length + 1]; + endpoint[0] = isFailOverURL; + for (int i = 0; i < urls.length; i++) { + endpoint[i + 1] = urls[i].trim(); + } + return endpoint; + } + + + /** + * Validate whether the receiverGroup and authenticationGroups are matching with pattern. + * Basically if the receiver groups has been configured to be in the failover pattern, + * then the authentication URL also needs to be in the same way. Hence this method validates + * the provided receiverGroups, and authenticationGroup. + * + * @param receiverGroups List of Receiver groups + * @param authGroups List of Authentication groups. + * @throws DataEndpointConfigurationException + */ + public static void validateURLs(ArrayList receiverGroups, ArrayList authGroups) + throws DataEndpointConfigurationException { + if (receiverGroups.size() == authGroups.size()) { + for (int i = 0; i < receiverGroups.size(); i++) { + Object[] receiverGroup = (Object[]) receiverGroups.get(i); + Object[] authGroup = (Object[]) authGroups.get(i); + + if (receiverGroup.length == authGroup.length) { + boolean isFailOver = (Boolean) receiverGroup[0]; + boolean isAuthFailOver = (Boolean) ((Object[]) receiverGroups.get(i))[0]; + if (isFailOver != isAuthFailOver) { + throw new DataEndpointConfigurationException("Receiver and authentication URL group set " + + "doesn't match. Receiver URL group: " + getURLSet(receiverGroup) + + " is configured as failOver : " + isFailOver + ", but Authentication URL group: " + + getURLSet(authGroup) + " is configured as failOver :" + isAuthFailOver); + } + } else { + throw new DataEndpointConfigurationException("Receiver and authentication URL group set " + + "doesn't match. Receiver URL group: " + getURLSet(receiverGroup) + ", " + + "but Authentication URL group: " + getURLSet(authGroup)); + } + } + } else { + throw new DataEndpointConfigurationException("Receiver and authentication URL set doesn't match. " + + "Receiver URL groups: " + receiverGroups.size() + ", but Authentication URL groups: " + + authGroups.size()); + } + } + + + /** + * Returns the URL set string based on the URLs provided. The first element of the array is + * a boolean which indicates whether it's failover or load balancing. + * + * @param urlGroup Array of url and the first element of array should specify + * whether its load balancing or fail over + * @return String representation of URL set. + */ + private static String getURLSet(Object[] urlGroup) { + boolean isFailOver = (Boolean) urlGroup[0]; + StringBuilder urlSet = new StringBuilder(""); + for (int i = 1; i < urlGroup.length; i++) { + urlSet.append(urlGroup[i]); + if (i != urlGroup.length - 1) { + if (isFailOver) { + urlSet.append(DataEndpointConstants.FAILOVER_URL_GROUP_SEPARATOR); + } else { + urlSet.append(DataEndpointConstants.LB_URL_GROUP_SEPARATOR); + } + } + } + return urlSet.toString(); + } + + /** + * Extracts and return the protocol, host, port elements from the URL. + * + * @param url String of URL that needs to be processed. + * @return Array which has elements - protocol, host, and port in the given order. + */ + public static String[] getProtocolHostPort(String url) throws DataEndpointConfigurationException { + String[] keyElements = url.split(DataEndpointConstants.SEPARATOR); + String[] urlElements = keyElements[0].split(":"); + if (urlElements.length != 3) { + throw new DataEndpointConfigurationException("Invalid URL is provided :" + url + + ". Receiver URL property should take the format : " + "protocol://host:port"); + } + return new String[]{urlElements[0], urlElements[1].replace("//", ""), urlElements[2]}; + } + + /** + * Deduce the default authentication URL based on the receiver URL passed in. + * + * @param receiverURL receiver URL for which it's required to get the authentication URL. + * @return default authentication URL. + */ + public static String getDefaultAuthUrl(String receiverURL) throws DataEndpointConfigurationException { + String[] urlElements = getProtocolHostPort(receiverURL); + int port = Integer.parseInt(urlElements[2]); + String host = urlElements[1]; + return DataEndpointConfiguration.Protocol.SSL.toString() + "://" + host + ":" + + (port + DataEndpointConstants.DEFAULT_AUTH_PORT_OFFSET); + } + + /** + * Deduce the default authentication URL set based on the receiver URL set passed in. + * + * @param receiverURLSet receiver URL set for which it's required to get the authentication URL set. + * @return default authentication URL set. + */ + public static String getDefaultAuthURLSet(String receiverURLSet) throws DataEndpointConfigurationException { + ArrayList receiverURLGroups = DataPublisherUtil.getEndpointGroups(receiverURLSet); + StringBuilder authURLSet = new StringBuilder(""); + for (int i = 0; i < receiverURLGroups.size(); i++) { + Object[] receiverGroup = receiverURLGroups.get(i); + boolean failOver = (Boolean) receiverGroup[0]; + authURLSet.append("{"); + for (int j = 1; j < receiverGroup.length; j++) { + authURLSet.append(DataPublisherUtil.getDefaultAuthUrl(receiverGroup[j].toString())); + if (j != receiverGroup.length - 1) { + if (failOver) { + authURLSet.append(DataEndpointConstants.FAILOVER_URL_GROUP_SEPARATOR); + } else { + authURLSet.append(DataEndpointConstants.LB_URL_GROUP_SEPARATOR); + } + } + } + authURLSet.append("}"); + if (i != receiverURLGroups.size() - 1) { + authURLSet.append(","); + } + } + return authURLSet.toString(); + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/ThrottleEventConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/ThrottleEventConstants.java new file mode 100644 index 0000000000..52091db4ff --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/ThrottleEventConstants.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util; + +/** + * This class holds the constants required to fetch the properties from the + * ThrottleEvent . + */ +public class ThrottleEventConstants { + + private ThrottleEventConstants() { + } + + public static final String MESSAGE_ID = "messageID"; + public static final String APP_KEY = "appKey"; + public static final String APP_TIER = "appTier"; + public static final String API_KEY = "apiKey"; + public static final String API_TIER = "apiTier"; + public static final String SUBSCRIPTION_KEY = "subscriptionKey"; + public static final String SUBSCRIPTION_TIER = "subscriptionTier"; + public static final String RESOURCE_KEY = "resourceKey"; + public static final String RESOURCE_TIER = "resourceTier"; + public static final String USER_ID = "userId"; + public static final String API_CONTEXT = "apiContext"; + public static final String API_VERSION = "apiVersion"; + public static final String APP_TENANT = "appTenant"; + public static final String API_TENANT = "apiTenant"; + public static final String APP_ID = "appId"; + public static final String API_NAME = "apiName"; + public static final String PROPERTIES = "properties"; +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/DataProcessAndPublishingAgent.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/DataProcessAndPublishingAgent.java new file mode 100644 index 0000000000..b755a68038 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/DataProcessAndPublishingAgent.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.publisher; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.wso2.carbon.databridge.commons.Event; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.DataPublisher; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.ThrottleEventConstants; + +import java.util.Map; + +/** + * This class is responsible for executing data publishing logic. This class implements runnable interface and + * need to execute using thread pool executor. Primary task of this class it is accept message context as parameter + * and perform time consuming data extraction and publish event to data publisher. Having data extraction and + * transformation logic in this class will help to reduce overhead added to main message flow. + */ +public class DataProcessAndPublishingAgent implements Runnable { + private static final Logger log = LogManager.getLogger(DataProcessAndPublishingAgent.class); + + private static String streamID = "org.wso2.throttle.request.stream:1.0.0"; + private DataPublisher dataPublisher; + + String messageId; + String applicationLevelThrottleKey; + String applicationLevelTier; + String apiLevelThrottleKey; + String apiLevelTier; + String subscriptionLevelThrottleKey; + String subscriptionLevelTier; + String resourceLevelThrottleKey; + String authorizedUser; + String resourceLevelTier; + String apiContext; + String apiVersion; + String appTenant; + String apiTenant; + String apiName; + String appId; + String properties; + + public DataProcessAndPublishingAgent() { + dataPublisher = getDataPublisher(); + } + + /** + * This method will clean data references. This method should call whenever we return data process and publish + * agent back to pool. Every time when we add new property we need to implement cleaning logic as well. + */ + public void clearDataReference() { + this.messageId = null; + this.applicationLevelThrottleKey = null; + this.applicationLevelTier = null; + this.apiLevelThrottleKey = null; + this.apiLevelTier = null; + this.subscriptionLevelThrottleKey = null; + this.subscriptionLevelTier = null; + this.resourceLevelThrottleKey = null; + this.resourceLevelTier = null; + this.authorizedUser = null; + this.apiContext = null; + this.apiVersion = null; + this.appTenant = null; + this.apiTenant = null; + this.appId = null; + this.apiName = null; + } + + /** + * This method will use to set message context. + */ + public void setDataReference(Map throttleEvent) { + this.messageId = throttleEvent.get(ThrottleEventConstants.MESSAGE_ID); + this.applicationLevelThrottleKey = throttleEvent.get(ThrottleEventConstants.APP_KEY); + this.applicationLevelTier = throttleEvent.get(ThrottleEventConstants.APP_TIER); + this.apiLevelThrottleKey = throttleEvent.get(ThrottleEventConstants.API_KEY); + this.apiLevelTier = throttleEvent.get(ThrottleEventConstants.API_TIER); + this.subscriptionLevelThrottleKey = throttleEvent.get(ThrottleEventConstants.SUBSCRIPTION_KEY); + this.subscriptionLevelTier = throttleEvent.get(ThrottleEventConstants.SUBSCRIPTION_TIER); + this.resourceLevelThrottleKey = throttleEvent.get(ThrottleEventConstants.RESOURCE_KEY); + this.resourceLevelTier = throttleEvent.get(ThrottleEventConstants.RESOURCE_TIER); + this.authorizedUser = throttleEvent.get(ThrottleEventConstants.USER_ID); + this.apiContext = throttleEvent.get(ThrottleEventConstants.API_CONTEXT); + this.apiVersion = throttleEvent.get(ThrottleEventConstants.API_VERSION); + this.appTenant = throttleEvent.get(ThrottleEventConstants.APP_TENANT); + this.apiTenant = throttleEvent.get(ThrottleEventConstants.API_TENANT); + this.appId = throttleEvent.get(ThrottleEventConstants.APP_ID); + this.apiName = throttleEvent.get(ThrottleEventConstants.API_NAME); + this.properties = throttleEvent.get(ThrottleEventConstants.PROPERTIES); + } + + public void run() { + + Object[] objects = new Object[]{messageId, + this.applicationLevelThrottleKey, this.applicationLevelTier, + this.apiLevelThrottleKey, this.apiLevelTier, + this.subscriptionLevelThrottleKey, this.subscriptionLevelTier, + this.resourceLevelThrottleKey, this.resourceLevelTier, + this.authorizedUser, this.apiContext, this.apiVersion, + this.appTenant, this.apiTenant, this.appId, this.apiName, properties}; + Event event = new Event(streamID, System.currentTimeMillis(), null, null, objects); + dataPublisher.tryPublish(event); + } + + protected DataPublisher getDataPublisher() { + return ThrottleDataPublisher.getDataPublisher(); + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/DataPublisherConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/DataPublisherConstants.java new file mode 100644 index 0000000000..ea794942e5 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/DataPublisherConstants.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.publisher; + +/** + * Class to define the constants for Data Agent. + */ +public class DataPublisherConstants { + + private DataPublisherConstants() { + } + + public static final String RECEIVER_URL_GROUP = "receiverURLGroup"; + public static final String AUTH_URL_GROUP = "authURLGroup"; + public static final String USERNAME = "username"; + public static final String PASSWORD = "password"; + public static final String MAX_IDLE = "maxIdle"; + public static final String INIT_IDLE_CAPACITY = "initIdleCapacity"; + public static final String CORE_POOL_SIZE = "corePoolSize"; + public static final String MAX_POOL_SIZE = "maxPoolSize"; + public static final String KEEP_ALIVE_TIME = "keepAliveTime"; +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/PublisherConfiguration.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/PublisherConfiguration.java new file mode 100644 index 0000000000..a3e05a2325 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/PublisherConfiguration.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.publisher; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.Map; + +/** + * This class holds the configurations related to binary data publisher. + */ +public class PublisherConfiguration { + private static final Logger log = LogManager.getLogger(PublisherConfiguration.class); + + private int maxIdleDataPublishingAgents; + private int initIdleObjectDataPublishingAgents; + private int publisherThreadPoolCoreSize; + private int publisherThreadPoolMaximumSize; + private int publisherThreadPoolKeepAliveTime; + + private String receiverUrlGroup; + private String authUrlGroup; + private String userName; + private char[] password; + + private static PublisherConfiguration instance = new PublisherConfiguration(); + + private PublisherConfiguration() { + } + + public void setMaxIdleDataPublishingAgents(int maxIdleDataPublishingAgents) { + this.maxIdleDataPublishingAgents = maxIdleDataPublishingAgents; + } + + public void setInitIdleObjectDataPublishingAgents(int initIdleObjectDataPublishingAgents) { + this.initIdleObjectDataPublishingAgents = initIdleObjectDataPublishingAgents; + } + + public void setPublisherThreadPoolCoreSize(int publisherThreadPoolCoreSize) { + this.publisherThreadPoolCoreSize = publisherThreadPoolCoreSize; + } + + public void setPublisherThreadPoolMaximumSize(int publisherThreadPoolMaximumSize) { + this.publisherThreadPoolMaximumSize = publisherThreadPoolMaximumSize; + } + + public void setPublisherThreadPoolKeepAliveTime(int publisherThreadPoolKeepAliveTime) { + this.publisherThreadPoolKeepAliveTime = publisherThreadPoolKeepAliveTime; + } + + public void setAuthUrlGroup(String authUrlGroup) { + this.authUrlGroup = authUrlGroup; + } + + public void setReceiverUrlGroup(String receiverUrlGroup) { + this.receiverUrlGroup = receiverUrlGroup; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public void setPassword(String password) { + this.password = password.toCharArray(); + } + + public int getMaxIdleDataPublishingAgents() { + return maxIdleDataPublishingAgents; + } + + public int getInitIdleObjectDataPublishingAgents() { + return initIdleObjectDataPublishingAgents; + } + + public int getPublisherThreadPoolCoreSize() { + return publisherThreadPoolCoreSize; + } + + public int getPublisherThreadPoolMaximumSize() { + return publisherThreadPoolMaximumSize; + } + + public int getPublisherThreadPoolKeepAliveTime() { + return publisherThreadPoolKeepAliveTime; + } + + public String getReceiverUrlGroup() { + return receiverUrlGroup; + } + + public String getAuthUrlGroup() { + return authUrlGroup; + } + + public String getUserName() { + return userName; + } + + public String getPassword() { + return String.valueOf(password); + } + + public static PublisherConfiguration getInstance() { + return instance; + } + + public static synchronized void setInstance(PublisherConfiguration publisherConfiguration) { + instance = publisherConfiguration; + } + + public void setConfiguration(Map publisherConfiguration) { + this.receiverUrlGroup = String.valueOf(publisherConfiguration.get(DataPublisherConstants.RECEIVER_URL_GROUP)); + this.authUrlGroup = String.valueOf(publisherConfiguration.get(DataPublisherConstants.AUTH_URL_GROUP)); + this.userName = String.valueOf(publisherConfiguration.get(DataPublisherConstants.USERNAME)); + this.password = String.valueOf(publisherConfiguration.get(DataPublisherConstants.PASSWORD)).toCharArray(); + try { + this.maxIdleDataPublishingAgents = + Math.toIntExact((long) publisherConfiguration.get(DataPublisherConstants.MAX_IDLE)); + this.initIdleObjectDataPublishingAgents = + Math.toIntExact((long) publisherConfiguration.get(DataPublisherConstants.INIT_IDLE_CAPACITY)); + this.publisherThreadPoolCoreSize = + Math.toIntExact((long) publisherConfiguration.get(DataPublisherConstants.CORE_POOL_SIZE)); + this.publisherThreadPoolMaximumSize = + (Math.toIntExact((long) publisherConfiguration.get(DataPublisherConstants.MAX_POOL_SIZE))); + this.publisherThreadPoolKeepAliveTime = Math.toIntExact((long) publisherConfiguration + .get(DataPublisherConstants.KEEP_ALIVE_TIME)); + } catch (ArithmeticException e) { + log.error("Error while processing the publisher configuration.", e); + } + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/ThrottleDataPublisher.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/ThrottleDataPublisher.java new file mode 100644 index 0000000000..f01acd5da6 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/ThrottleDataPublisher.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.publisher; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.wso2.carbon.databridge.commons.exception.TransportException; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.DataPublisher; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointAuthenticationException; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointConfigurationException; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; +import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.ThrottleEventConstants; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Map; +import java.util.concurrent.Executor; +import java.util.concurrent.LinkedBlockingDeque; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +/** + * Throttle data publisher class is here to publish throttle data to global policy engine. + * This can publish data according to defined protocol. Protocol can be thrift or binary. + * When we use this for high concurrency usecases proper tuning is mandatory. + */ +public class ThrottleDataPublisher { + public static ThrottleDataPublisherPool dataPublisherPool; + + private static final Logger LOG = LogManager.getLogger(ThrottleDataPublisher.class); + private static volatile DataPublisher dataPublisher = null; + private Executor executor; + + public static DataPublisher getDataPublisher() { + return dataPublisher; + } + + /** + * This method will initialize throttle data publisher. Inside this we will start executor and initialize data + * publisher which we used to publish throttle data. + */ + public ThrottleDataPublisher() { + dataPublisherPool = ThrottleDataPublisherPool.getInstance(); + PublisherConfiguration publisherConfiguration = PublisherConfiguration.getInstance(); + + try { + executor = new DataPublisherThreadPoolExecutor( + publisherConfiguration.getPublisherThreadPoolCoreSize(), + publisherConfiguration.getPublisherThreadPoolMaximumSize(), + publisherConfiguration.getPublisherThreadPoolKeepAliveTime(), + TimeUnit.SECONDS, + new LinkedBlockingDeque() { + }); + dataPublisher = new DataPublisher(publisherConfiguration.getReceiverUrlGroup(), + publisherConfiguration.getAuthUrlGroup(), publisherConfiguration.getUserName(), + publisherConfiguration.getPassword()); + + } catch (DataEndpointException | DataEndpointConfigurationException | DataEndpointAuthenticationException + | TransportException e) { + LOG.error("Error in initializing binary data-publisher to send requests to global throttling engine " + + e.getMessage(), e); + } + } + + /** + * This method used to pass message context and let it run within separate thread. + */ + public void publishNonThrottledEvent(Map throttleEvent) { + try { + if (dataPublisherPool != null) { + DataProcessAndPublishingAgent agent = dataPublisherPool.get(); + agent.setDataReference(throttleEvent); + if (LOG.isDebugEnabled()) { + String messageId = throttleEvent.getOrDefault(ThrottleEventConstants.MESSAGE_ID, "null"); + String apiContext = throttleEvent.getOrDefault(ThrottleEventConstants.API_CONTEXT, "null"); + LOG.debug("Publishing throttle data from gateway to traffic-manager for: " + apiContext + + " with ID: " + messageId + " started" + " at " + + new SimpleDateFormat("[yyyy.MM.dd HH:mm:ss,SSS zzz]").format(new Date())); + } + executor.execute(agent); + if (LOG.isDebugEnabled()) { + String messageId = throttleEvent.getOrDefault(ThrottleEventConstants.MESSAGE_ID, "null"); + String apiContext = throttleEvent.getOrDefault(ThrottleEventConstants.API_CONTEXT, "null"); + LOG.debug("Publishing throttle data from gateway to traffic-manager for: " + apiContext + + " with ID: " + messageId + " ended" + " at " + + new SimpleDateFormat("[yyyy.MM.dd HH:mm:ss,SSS zzz]").format(new Date())); + } + } else { + LOG.debug("Throttle data publisher pool is not initialized."); + } + } catch (Exception e) { + LOG.error("Error while publishing throttling events to global policy server", e); + } + } + + /** + * This class will act as thread pool executor and after executing each thread it will return runnable + * object back to pool. This implementation specifically used to minimize number of objectes created during + * runtime. In this queuing strategy the submitted task will wait in the queue if the corePoolsize theads are + * busy and the task will be allocated if any of the threads become idle.Thus ThreadPool will always have number + * of threads running as mentioned in the corePoolSize. + * LinkedBlockingQueue without the capacity can be used for this queuing strategy.If the corePoolsize of the + * threadpool is less and there are more number of time consuming task were submitted,there is more possibility + * that the task has to wait in the queue for more time before it is run by any of the ideal thread. + * So tuning core pool size is something we need to tune properly. + * Also no task will be rejected in Threadpool until the threadpool was shutdown. + */ + private class DataPublisherThreadPoolExecutor extends ThreadPoolExecutor { + public DataPublisherThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, + TimeUnit unit, LinkedBlockingDeque workQueue) { + super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); + } + + protected void afterExecute(Runnable r, Throwable t) { + try { + DataProcessAndPublishingAgent agent = (DataProcessAndPublishingAgent) r; + ThrottleDataPublisher.dataPublisherPool.release(agent); + } catch (Exception e) { + LOG.error("Error while returning Throttle data publishing agent back to pool" + e.getMessage()); + } + } + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/ThrottleDataPublisherPool.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/ThrottleDataPublisherPool.java new file mode 100644 index 0000000000..68cbfc3052 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/ThrottleDataPublisherPool.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.publisher; + +import org.apache.commons.pool.BasePoolableObjectFactory; +import org.apache.commons.pool.ObjectPool; +import org.apache.commons.pool.impl.StackObjectPool; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +/** + * This class implemented to hold throttle data publishing agent pool. Reason for implement this is to + * reduce unwanted object creation. This is using stack object pool as we may need to handle some scenarios + * where unexpected load comes. In such cases we cannot have fixed size pool. + */ +public class ThrottleDataPublisherPool { + + private static final Logger log = LogManager.getLogger(ThrottleDataPublisherPool.class); + + private ObjectPool clientPool; + + private ThrottleDataPublisherPool() { + //Using stack object pool to handle high concurrency scenarios without droping any messages. + //Tuning this pool is mandatory according to use cases. + //A finite number of "sleeping" or idle instances is enforced, but when the pool is empty, new instances + // are created to support the new load. Hence this following data stricture places no limit on the number of " + // active" instance created by the pool, but is quite useful for re-using Objects without introducing + // artificial limits. + //Proper tuning is mandatory for good performance according to system load. + PublisherConfiguration configuration = PublisherConfiguration.getInstance(); + clientPool = new StackObjectPool(new BasePoolableObjectFactory() { + @Override + public Object makeObject() throws Exception { + if (log.isDebugEnabled()) { + log.debug("Initializing new ThrottleDataPublisher instance"); + } + return new DataProcessAndPublishingAgent(); + } + }, configuration.getMaxIdleDataPublishingAgents(), configuration.getInitIdleObjectDataPublishingAgents()); + } + + private static class ThrottleDataPublisherPoolHolder { + private static final ThrottleDataPublisherPool INSTANCE = new ThrottleDataPublisherPool(); + + private ThrottleDataPublisherPoolHolder() { + } + } + + public static ThrottleDataPublisherPool getInstance() { + return ThrottleDataPublisherPoolHolder.INSTANCE; + } + + public DataProcessAndPublishingAgent get() throws Exception { + return (DataProcessAndPublishingAgent) clientPool.borrowObject(); + } + + public void release(DataProcessAndPublishingAgent client) throws Exception { + //We must clean data references as it can caused to pass old data to global policy server. + client.clearDataReference(); + clientPool.returnObject(client); + } + + public void cleanup() { + try { + clientPool.close(); + } catch (Exception e) { + log.warn("Error while cleaning up the object pool", e); + } + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/keymgt/KeyManagerDataService.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/keymgt/KeyManagerDataService.java index 1ff65e8cc5..d4993a4150 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/keymgt/KeyManagerDataService.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/keymgt/KeyManagerDataService.java @@ -26,7 +26,7 @@ import org.wso2.micro.gateway.enforcer.listener.events.SubscriptionPolicyEvent; /** - * Interface to call keymanager data maps using events + * Interface to call keymanager data maps using events. */ public interface KeyManagerDataService { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/listener/events/DeployAPIInGatewayEvent.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/listener/events/DeployAPIInGatewayEvent.java index fcb7220feb..f6c2c4f85a 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/listener/events/DeployAPIInGatewayEvent.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/listener/events/DeployAPIInGatewayEvent.java @@ -20,7 +20,7 @@ import java.util.Set; /** - * Deploy API in Gateway Event + * Deploy API in Gateway Event. */ public class DeployAPIInGatewayEvent extends Event { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/listener/events/PolicyEvent.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/listener/events/PolicyEvent.java index 639333ea45..33acf5773b 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/listener/events/PolicyEvent.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/listener/events/PolicyEvent.java @@ -22,7 +22,7 @@ import org.wso2.micro.gateway.enforcer.constants.APIConstants; /** - * Policy Event class + * Policy Event class. */ public class PolicyEvent extends Event { protected APIConstants.PolicyType policyType; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApiPolicy.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApiPolicy.java index 72bae01419..1affda7ddc 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApiPolicy.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApiPolicy.java @@ -24,7 +24,7 @@ import java.util.List; /** - * Holds details about API/resource level Policy + * Holds details about API/resource level Policy. */ public class ApiPolicy extends Policy { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApplicationKeyMappingCacheKey.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApplicationKeyMappingCacheKey.java index 9c97589c53..80a9976e51 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApplicationKeyMappingCacheKey.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApplicationKeyMappingCacheKey.java @@ -21,7 +21,7 @@ import java.util.Objects; /** - * Cache Key For Application KeyMapping Entries + * Cache Key For Application KeyMapping Entries. */ public class ApplicationKeyMappingCacheKey { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApplicationPolicy.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApplicationPolicy.java index 438bea95d7..981adb5117 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApplicationPolicy.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/ApplicationPolicy.java @@ -21,7 +21,7 @@ import org.wso2.micro.gateway.enforcer.common.CacheableEntity; /** - * Entity for keeping Application Policy + * Entity for keeping Application Policy. */ public class ApplicationPolicy extends Policy { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/Subscription.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/Subscription.java index a604131382..d56c590e71 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/Subscription.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/models/Subscription.java @@ -22,7 +22,7 @@ import org.wso2.micro.gateway.enforcer.subscription.SubscriptionDataStoreUtil; /** - * Entity for representing a SubscriptionDTO in APIM + * Entity for representing a SubscriptionDTO in APIM. */ public class Subscription implements CacheableEntity { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/AccessTokenInfo.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/AccessTokenInfo.java index c8fd05aac0..48edbe9f4c 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/AccessTokenInfo.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/AccessTokenInfo.java @@ -101,7 +101,7 @@ public void setConsumerKey(String consumerKey) { } /** - * Get consumer secret corresponding to the access token + * Get consumer secret corresponding to the access token. * * @return consumer secret */ @@ -110,7 +110,7 @@ public String getConsumerSecret() { } /** - * Set consumer secret corresponding to the access token + * Set consumer secret corresponding to the access token. * * @param consumerSecret consumer secret to set */ diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTAuthenticator.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTAuthenticator.java index afead51ff1..24764ff473 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTAuthenticator.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTAuthenticator.java @@ -143,8 +143,8 @@ public AuthenticationContext authenticate(RequestContext requestContext) throws // .generateJWTInfoDto(jwtValidationInfo, apiKeyValidationInfoDTO, synCtx); // endUserToken = generateAndRetrieveJWTToken(jti, jwtInfoDto); // } - AuthenticationContext authenticationContext = FilterUtils.generateAuthenticationContext(jti, - validationInfo, apiKeyValidationInfoDTO, endUserToken, true); + AuthenticationContext authenticationContext = FilterUtils.generateAuthenticationContext(requestContext, + jti, validationInfo, apiKeyValidationInfoDTO, endUserToken, true); //TODO: (VirajSalaka) Place the keytype population logic properly for self contained token if (claims.getClaim("keytype") != null) { authenticationContext.setKeyType(claims.getClaim("keytype").toString()); diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTTransformer.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTTransformer.java index c4fa417709..a0ffc5845f 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTTransformer.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTTransformer.java @@ -25,19 +25,19 @@ import java.util.List; /** - * This Class will be used to transform JWT claims to local claims + * This Class will be used to transform JWT claims to local claims. */ public interface JWTTransformer { /** - * This method used to retrieve ConsumerKey From JWT + * This method used to retrieve ConsumerKey From JWT. * @param jwtClaimsSet retrieved JwtClaimSet * @return consumerKey of JWT */ public String getTransformedConsumerKey(JWTClaimsSet jwtClaimsSet) throws MGWException; /** - * This method used to retrieve Scopes From JWT + * This method used to retrieve Scopes From JWT. * @param jwtClaimsSet retrieved JwtClaimSet * @return scopes of JWT */ @@ -45,7 +45,7 @@ public interface JWTTransformer { /** - * This method used to transform JWT claimset from given JWT into required format + * This method used to transform JWT claimset from given JWT into required format. * * @param jwtClaimsSet jwtClaimSet from given JWT * @return transformed JWT Claims. diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTUtil.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTUtil.java index 81aa36caa2..80ffefab82 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTUtil.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTUtil.java @@ -49,7 +49,7 @@ public class JWTUtil { private static final Logger log = LogManager.getLogger(JWTUtil.class); /** - * This method used to retrieve JWKS keys from endpoint + * This method used to retrieve JWKS keys from endpoint. * * @param jwksEndpoint * @return diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/SignedJWTInfo.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/SignedJWTInfo.java index 6d25ec2ae1..5a2ba889d3 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/SignedJWTInfo.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/SignedJWTInfo.java @@ -24,7 +24,7 @@ import java.io.Serializable; /** - * JWT internal Representation + * JWT internal Representation. */ public class SignedJWTInfo implements Serializable { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/validator/RevokedJWTDataHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/validator/RevokedJWTDataHolder.java index d5632ec1ee..b5c64bb39d 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/validator/RevokedJWTDataHolder.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/validator/RevokedJWTDataHolder.java @@ -25,7 +25,7 @@ import java.util.concurrent.ConcurrentHashMap; /** - * Singleton which stores the revoked JWT map + * Singleton which stores the revoked JWT map. */ public class RevokedJWTDataHolder { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/RequestHandler.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/RequestHandler.java index 7c9e6d25ca..738370aaa8 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/RequestHandler.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/RequestHandler.java @@ -66,10 +66,16 @@ private RequestContext buildRequestContext(API api, CheckRequest request) { .get(AdapterConstants.PROD_CLUSTER_HEADER_KEY); String sandCluster = request.getAttributes().getContextExtensionsMap() .get(AdapterConstants.SAND_CLUSTER_HEADER_KEY); + String requestID = request.getAttributes().getRequest().getHttp().getId(); + String address = ""; + if (request.getAttributes().getSource().hasAddress() && + request.getAttributes().getSource().getAddress().hasSocketAddress()) { + address = request.getAttributes().getSource().getAddress().getSocketAddress().getAddress(); + } ResourceConfig resourceConfig = APIFactory.getInstance().getMatchedResource(api, res, method); return new RequestContext.Builder(requestPath).matchedResourceConfig(resourceConfig).requestMethod(method) - .matchedAPI(api).headers(headers).prodClusterHeader(prodCluster).sandClusterHeader(sandCluster) - .build(); + .matchedAPI(api).headers(headers).requestID(requestID).address(address).prodClusterHeader(prodCluster) + .sandClusterHeader(sandCluster).build(); } } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataHolder.java index 45b547f4a1..7cfc9abde0 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataHolder.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataHolder.java @@ -19,7 +19,7 @@ package org.wso2.micro.gateway.enforcer.subscription; /** - * This class holds tenant wise subscription data stores + * This class holds tenant wise subscription data stores. */ public class SubscriptionDataHolder { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataLoader.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataLoader.java index bff3da61ba..64b614f6b3 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataLoader.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataLoader.java @@ -45,7 +45,7 @@ public interface SubscriptionDataLoader { public List loadAllSubscriptions(String tenantDomain) throws DataLoadingException; /** - * Load all Applications from the Database belonging to all Tenants + * Load all Applications from the Database belonging to all Tenants. * * @return A list of all {@link Application}s. * @throws DataLoadingException If any error @@ -53,8 +53,8 @@ public interface SubscriptionDataLoader { public List loadAllApplications(String tenantDomain) throws DataLoadingException; /** - * Load all Key Mappings (Mapping between the Consumer Key and Application) from the Database - * owned by all tenants + * Load all Key Mappings (Mapping between the Consumer Key and Application) from the Database. + * owned by all tenants. * * @return A list of {@link ApplicationKeyMapping}s * @throws DataLoadingException If any error @@ -110,7 +110,7 @@ public interface SubscriptionDataLoader { public Application getApplicationById(int appId) throws DataLoadingException; /** - * Retrieve Key Mapping (Mapping between the Consumer Key and Application) from the Database + * Retrieve Key Mapping (Mapping between the Consumer Key and Application) from the Database. * * @return A list of {@link ApplicationKeyMapping}s * @throws DataLoadingException If any error diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataStore.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataStore.java index cd727fbdaa..69d31f8f56 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataStore.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/subscription/SubscriptionDataStore.java @@ -35,7 +35,7 @@ public interface SubscriptionDataStore { /** - * Gets an {@link Application} by Id + * Gets an {@link Application} by Id. * * @param appId Id of the Application * @return {@link Application} with the appId @@ -43,7 +43,7 @@ public interface SubscriptionDataStore { Application getApplicationById(int appId); /** - * Gets the {@link ApplicationKeyMapping} entry by Key + * Gets the {@link ApplicationKeyMapping} entry by Key. * * @param key . * @param keyManager Keymanager Name @@ -52,7 +52,7 @@ public interface SubscriptionDataStore { ApplicationKeyMapping getKeyMappingByKeyAndKeyManager(String key, String keyManager); /** - * Get API by Context and Version + * Get API by Context and Version. * * @param context Context of the API * @param version Version of the API @@ -61,7 +61,7 @@ public interface SubscriptionDataStore { API getApiByContextAndVersion(String context, String version); /** - * Gets Subscription by ID + * Gets Subscription by ID. * * @param appId Application associated with the Subscription * @param apiId Api associated with the Subscription @@ -70,7 +70,7 @@ public interface SubscriptionDataStore { Subscription getSubscriptionById(int appId, int apiId); /** - * Gets API Throttling Policy by the name and Tenant Id + * Gets API Throttling Policy by the name and Tenant Id. * * @param policyName Name of the Throttling Policy * @param tenantId Tenant ID in the Policy @@ -79,7 +79,7 @@ public interface SubscriptionDataStore { ApiPolicy getApiPolicyByName(String policyName, int tenantId); /** - * Gets Subscription Throttling Policy by the name and Tenant Id + * Gets Subscription Throttling Policy by the name and Tenant Id. * * @param policyName Name of the Throttling Policy * @param tenantId Tenant ID in the Policy @@ -88,7 +88,7 @@ public interface SubscriptionDataStore { SubscriptionPolicy getSubscriptionPolicyByName(String policyName, int tenantId); /** - * Gets Application Throttling Policy by the name and Tenant Id + * Gets Application Throttling Policy by the name and Tenant Id. * * @param policyName Name of the Throttling Policy * @param tenantId Tenant ID in the Policy diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/util/FilterUtils.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/util/FilterUtils.java index cfaf8b9a03..688a2d9783 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/util/FilterUtils.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/util/FilterUtils.java @@ -31,6 +31,7 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.wso2.micro.gateway.enforcer.api.RequestContext; import org.wso2.micro.gateway.enforcer.config.ConfigHolder; import org.wso2.micro.gateway.enforcer.constants.APIConstants; import org.wso2.micro.gateway.enforcer.dto.APIKeyValidationInfoDTO; @@ -38,6 +39,9 @@ import org.wso2.micro.gateway.enforcer.security.AuthenticationContext; import org.wso2.micro.gateway.enforcer.security.jwt.JWTValidationInfo; +import java.math.BigInteger; +import java.net.InetAddress; +import java.net.UnknownHostException; import java.security.KeyManagementException; import java.security.KeyStore; import java.security.KeyStoreException; @@ -65,7 +69,7 @@ public static String getMaskedToken(String token) { } /** - * Return a http client instance + * Return a http client instance. * * @param protocol - service endpoint protocol http/https * @return @@ -92,7 +96,7 @@ public static HttpClient getHttpClient(String protocol) { } /** - * Return a PoolingHttpClientConnectionManager instance + * Return a PoolingHttpClientConnectionManager instance. * * @param protocol- service endpoint protocol. It can be http/https * @return PoolManager @@ -159,10 +163,12 @@ public static String getTenantDomainFromRequestURL(String requestURI) { return domain; } - public static AuthenticationContext generateAuthenticationContext(String jti, JWTValidationInfo jwtValidationInfo, - APIKeyValidationInfoDTO apiKeyValidationInfoDTO, String endUserToken, boolean isOauth) { + public static AuthenticationContext generateAuthenticationContext(RequestContext requestContext, String jti, + JWTValidationInfo jwtValidationInfo, + APIKeyValidationInfoDTO apiKeyValidationInfoDTO, + String endUserToken, boolean isOauth) { - AuthenticationContext authContext = new AuthenticationContext(); + AuthenticationContext authContext = requestContext.getAuthenticationContext(); authContext.setAuthenticated(true); authContext.setApiKey(jti); authContext.setUsername(jwtValidationInfo.getUser()); @@ -195,4 +201,41 @@ public static AuthenticationContext generateAuthenticationContext(String jti, JW return authContext; } + public static long ipToLong(String ipAddress) { + + long result = 0; + String[] ipAddressInArray = ipAddress.split("\\."); + for (int i = 3; i >= 0; i--) { + long ip = Long.parseLong(ipAddressInArray[3 - i]); + //left shifting 24,16,8,0 and bitwise OR + //1. 192 << 24 + //1. 168 << 16 + //1. 1 << 8 + //1. 2 << 0 + result |= ip << (i * 8); + + } + return result; + } + + /** + * This method provides the BigInteger value for the given IP address. This supports both IPv4 and IPv6 address + * + * @param ipAddress ip address + * @return BigInteger value for the given ip address. returns 0 for unknown host + */ + public static BigInteger ipToBigInteger(String ipAddress) { + + InetAddress address; + try { + address = InetAddress.getByName(ipAddress); + byte[] bytes = address.getAddress(); + return new BigInteger(1, bytes); + } catch (UnknownHostException e) { + //ignore the error and log it + log.error("Error while parsing host IP " + ipAddress, e); + } + return BigInteger.ZERO; + } + } diff --git a/pom.xml b/pom.xml index ac2fb1b912..b008519955 100644 --- a/pom.xml +++ b/pom.xml @@ -306,5 +306,8 @@ 6.11 6.0.53 0.7.2 + 6.1.45 + 1.5.6.wso2v1 + 3.4.2.wso2v1 diff --git a/resources/conf/config.toml b/resources/conf/config.toml index 3adf0990dd..b7c7ac9a9e 100644 --- a/resources/conf/config.toml +++ b/resources/conf/config.toml @@ -92,3 +92,52 @@ skipSSLVerification=true # Message broker connection URL of the control plane [controlPlane.eventHub.jmsConnectionParameters] eventListeningEndpoints = "amqp://admin:admin@localhost:5672/" + +# Throttling configurations related to event publishing using a binary connection +[enforcer.throttlingConfig.binary] + enabled = false + # Credentials required to establish connection between Traffic Manager + username = "admin" + password = "admin" + # Receiver URL and the authentication URL of the Traffic manager node/nodes + [[enforcer.throttlingConfig.binary.urlGroup]] + receiverURLs = ["tcp://localhost:9611"] + authURLs = ["ssl://localhost:9711"] + # Data publisher object pool configurations + [enforcer.throttlingConfig.binary.publisher] + maxIdleDataPublishingAgents = 1000 + initIdleObjectDataPublishingAgents = 200 + # Data publisher thread pool configurations + publisherThreadPoolCoreSize = 200 + publisherThreadPoolMaximumSize = 1000 + publisherThreadPoolKeepAliveTime = 200 + [enforcer.throttlingConfig.binary.agent] + # SSL Protocols + sslEnabledProtocols = "TLSv1,TLSv1.1,TLSv1.2" + # ciphers + ciphers="TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA,TLS_ECDH_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 ,TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 ,TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA,TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA,TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA,SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA,TLS_EMPTY_RENEGOTIATION_INFO_SCSV" + # The size of the queue event disruptor which handles events before they are published. + # The value specified should always be the result of an exponent with 2 as the base. + queueSize = 32768 + # The maximum number of events in a batch sent to the queue event disruptor at a given time + batchSize = 200 + # The number of threads that will be reserved to handle events at the time you start + corePoolSize = 1 + # Socket timeout + socketTimeoutMS = 30000 + # The maximum number of threads that should be reserved at any given time to handle events + maxPoolSize = 1 + # The amount of time which threads in excess of the core pool size may remain idle before being terminated. + keepAliveTimeInPool = 20 + # The time interval between reconnection + reconnectionInterval = 30 + # TCP connection pool configurations (for data publishing) + maxTransportPoolSize = 250 + maxIdleConnections = 250 + evictionTimePeriod = 5500 + minIdleTimeInPool = 5000 + # SSL connection pool configurations (for authentication) + secureMaxTransportPoolSize = 250 + secureMaxIdleConnections = 250 + secureEvictionTimePeriod = 5500 + secureMinIdleTimeInPool = 5000 From 1cfb565b4e3ed3e4ccce7d8bf25ff18137bdff9b Mon Sep 17 00:00:00 2001 From: amali Date: Mon, 8 Feb 2021 10:26:54 +0530 Subject: [PATCH 02/21] Update code --- .../gateway/enforcer/config/ConfigHolder.java | 27 ++++++++++--------- .../gateway/enforcer/constants/Constants.java | 6 +++++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java index 879459b8a6..6e0cfa1361 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java @@ -187,9 +187,10 @@ private void populateJWTIssuerConfiguration(List cdsIssuers) { } private void populateTMBinaryConfig() { - throttleAgentConfig = - configToml.getTable(ConfigConstants.TM_BINARY_THROTTLE_CONF_INSTANCE_ID) - .to(ThrottleAgentConfigDTO.class); + // TODO(amalimatharaarachchi) get binary configs from config +// throttleAgentConfig = +// configToml.getTable(Constants.TM_BINARY_THROTTLE_CONF_INSTANCE_ID) +// .to(ThrottleAgentConfigDTO.class); AgentConfiguration agentConfiguration = throttleAgentConfig.getAgent(); agentConfiguration.setTrustStore(trustStore); AgentConfiguration.setInstance(agentConfiguration); @@ -270,12 +271,12 @@ private void processTMPublisherURLGroup(List urlGroups, continue; } String urlType = urlGroup.getType(); - if (urlType == null || urlType.isBlank() || !(ConfigConstants.LOADBALANCE.equalsIgnoreCase(urlType) - || ConfigConstants.FAILOVER.equalsIgnoreCase(urlType))) { + if (urlType == null || urlType.isBlank() || !(Constants.LOADBALANCE.equalsIgnoreCase(urlType) + || Constants.FAILOVER.equalsIgnoreCase(urlType))) { logger.warn("Type is not " - + ConfigConstants.LOADBALANCE + " or " + ConfigConstants.FAILOVER + ". Hence proceeding as a " - + ConfigConstants.FAILOVER + " configuration."); - urlType = ConfigConstants.FAILOVER; + + Constants.LOADBALANCE + " or " + Constants.FAILOVER + ". Hence proceeding as a " + + Constants.FAILOVER + " configuration."); + urlType = Constants.FAILOVER; } restructuredReceiverURL.append(processSingleURLGroup(receiverUrls, urlType)).append(","); restructuredAuthURL.append(processSingleURLGroup(authUrls, urlType)).append(","); @@ -293,12 +294,12 @@ private void processTMPublisherURLGroup(List urlGroups, private String processSingleURLGroup(String[] urlArray, String urlType) { StringBuilder concatenatedURLString = new StringBuilder("{"); for (String url : urlArray) { - if (ConfigConstants.LOADBALANCE.equalsIgnoreCase(urlType)) { - concatenatedURLString.append(url).append(ConfigConstants.TM_BINARY_LOADBALANCE_SEPARATOR); - } else if (ConfigConstants.FAILOVER.equalsIgnoreCase(urlType)) { - concatenatedURLString.append(url).append(ConfigConstants.TM_BINARY_FAILOVER_SEPARATOR); + if (Constants.LOADBALANCE.equalsIgnoreCase(urlType)) { + concatenatedURLString.append(url).append(Constants.TM_BINARY_LOADBALANCE_SEPARATOR); + } else if (Constants.FAILOVER.equalsIgnoreCase(urlType)) { + concatenatedURLString.append(url).append(Constants.TM_BINARY_FAILOVER_SEPARATOR); } else { - concatenatedURLString.append(url).append(ConfigConstants.TM_BINARY_FAILOVER_SEPARATOR); + concatenatedURLString.append(url).append(Constants.TM_BINARY_FAILOVER_SEPARATOR); } } //to remove the trailing '|' or ',' diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/Constants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/Constants.java index d441edb248..a20d0f8694 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/Constants.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/Constants.java @@ -40,4 +40,10 @@ public class Constants { // Config constants public static final String EVENT_HUB_EVENT_LISTENING_ENDPOINT = "eventListeningEndpoints"; + + //Throttle config constants + public static final String LOADBALANCE = "loadbalance"; + public static final String FAILOVER = "failover"; + public static final String TM_BINARY_LOADBALANCE_SEPARATOR = ","; + public static final String TM_BINARY_FAILOVER_SEPARATOR = "|"; } From 84fd76b46940c123b01bdd8ab86eea507638b782 Mon Sep 17 00:00:00 2001 From: Praminda Jayawardana Date: Thu, 25 Feb 2021 14:32:37 +0530 Subject: [PATCH 03/21] enforcer: Fix PR comments for #1539 --- enforcer/pom.xml | 4 -- .../gateway/enforcer/config/ConfigHolder.java | 2 + .../enforcer/dto/ThrottleAgentConfigDTO.java | 18 ++++++++ .../enforcer/dto/ThrottleURLGroupDTO.java | 18 ++++++++ .../client/AbstractClientPoolFactory.java | 14 +++---- .../AbstractSecureClientPoolFactory.java | 14 +++---- .../databridge/agent/client/ClientPool.java | 15 ++++--- .../agent/endpoint/DataEndpoint.java | 14 +++---- .../DataEndpointConnectionWorker.java | 15 +++---- .../endpoint/DataEndpointFailureCallback.java | 15 +++---- .../agent/endpoint/DataEndpointGroup.java | 15 +++---- .../EventPublisherThreadPoolExecutor.java | 15 +++---- .../binary/BinaryClientPoolFactory.java | 16 +++---- .../endpoint/binary/BinaryDataEndpoint.java | 16 +++---- .../endpoint/binary/BinaryEventSender.java | 16 +++---- .../binary/BinarySecureClientPoolFactory.java | 15 +++---- .../DataEndpointAuthenticationException.java | 16 +++---- .../DataEndpointConfigurationException.java | 34 +++++++-------- .../exception/DataEndpointException.java | 16 +++---- .../exception/EventQueueFullException.java | 16 +++---- .../agent/util/DataEndpointConstants.java | 33 ++++++++------- .../agent/util/DataPublisherUtil.java | 42 ++++++++----------- .../agent/util/ThrottleEventConstants.java | 17 ++++---- pom.xml | 24 ++++++++++- 24 files changed, 235 insertions(+), 185 deletions(-) diff --git a/enforcer/pom.xml b/enforcer/pom.xml index ea76dfc3fc..47239e5a7f 100644 --- a/enforcer/pom.xml +++ b/enforcer/pom.xml @@ -319,22 +319,18 @@ org.wso2.carbon.analytics-common org.wso2.carbon.databridge.commons - ${org.wso2.carbon.analytics-common} org.wso2.carbon.analytics-common org.wso2.carbon.databridge.commons.binary - ${org.wso2.carbon.analytics-common} commons-pool.wso2 commons-pool - ${apache.commons.version} org.wso2.orbit.com.lmax disruptor - ${org.wso2.orbit.com.lmax} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java index 7781468ed1..6afa28ea6b 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java @@ -50,6 +50,7 @@ import java.util.Properties; import javax.net.ssl.TrustManagerFactory; + /** * Configuration holder class for Microgateway. */ @@ -248,6 +249,7 @@ public void setTrustManagerFactory(TrustManagerFactory trustManagerFactory) { public EnvVarConfig getEnvVarConfig() { return envVarConfig; } + /** * The receiverURLGroup and the authURLGroup is preprocessed * such that to make them compatible with the binary agent. diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleAgentConfigDTO.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleAgentConfigDTO.java index 876277db14..ff8e14f5dc 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleAgentConfigDTO.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleAgentConfigDTO.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package org.wso2.micro.gateway.enforcer.dto; import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.AgentConfiguration; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleURLGroupDTO.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleURLGroupDTO.java index 049e1e6fc0..23ef43f9f3 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleURLGroupDTO.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleURLGroupDTO.java @@ -1,3 +1,21 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package org.wso2.micro.gateway.enforcer.dto; /** diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractClientPoolFactory.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractClientPoolFactory.java index 9c8ece075d..1622dd942b 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractClientPoolFactory.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractClientPoolFactory.java @@ -1,12 +1,12 @@ /* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -22,12 +22,10 @@ import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.DataPublisherUtil; - /** * The abstract class that needs to be implemented when supporting a new non-secure transport * to mainly create, validate and terminate the client to the endpoint. */ - public abstract class AbstractClientPoolFactory extends BaseKeyedPoolableObjectFactory { @Override diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractSecureClientPoolFactory.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractSecureClientPoolFactory.java index 04f14f081b..511e172441 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractSecureClientPoolFactory.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractSecureClientPoolFactory.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/ClientPool.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/ClientPool.java index 58ca0ea9d2..114bb06e18 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/ClientPool.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/ClientPool.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -23,7 +23,6 @@ /** * This class is used hold the secure/non-secure connections for an Agent. */ - public class ClientPool { private GenericKeyedObjectPool socketPool; private GenericKeyedObjectPool secureSocketPool; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpoint.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpoint.java index 60a86f9820..2f264ccc75 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpoint.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpoint.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointConnectionWorker.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointConnectionWorker.java index 0dbea618fc..b2ec0493b8 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointConnectionWorker.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointConnectionWorker.java @@ -1,20 +1,21 @@ /* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ + package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint; import org.apache.logging.log4j.LogManager; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointFailureCallback.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointFailureCallback.java index 7fc32451a7..92b325d5d3 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointFailureCallback.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointFailureCallback.java @@ -1,20 +1,21 @@ /* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ + package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint; import org.wso2.carbon.databridge.commons.Event; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointGroup.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointGroup.java index 5de63476bb..b0c39ba668 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointGroup.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointGroup.java @@ -1,20 +1,21 @@ /* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ + package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint; import com.lmax.disruptor.BlockingWaitStrategy; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/EventPublisherThreadPoolExecutor.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/EventPublisherThreadPoolExecutor.java index c857bca1ab..aee1e1c7c6 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/EventPublisherThreadPoolExecutor.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/EventPublisherThreadPoolExecutor.java @@ -1,20 +1,21 @@ /* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ + package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint; import org.wso2.carbon.databridge.commons.utils.DataBridgeThreadFactory; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryClientPoolFactory.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryClientPoolFactory.java index 4cad21b15c..cae9f58b38 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryClientPoolFactory.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryClientPoolFactory.java @@ -1,20 +1,21 @@ /* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ + package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary; import org.apache.logging.log4j.LogManager; @@ -24,7 +25,6 @@ import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.DataEndpointConfiguration; import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; - import java.io.IOException; import java.net.Socket; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryDataEndpoint.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryDataEndpoint.java index b442e9e462..bc11cdcfe5 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryDataEndpoint.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryDataEndpoint.java @@ -1,20 +1,21 @@ /* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ + package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary; import org.wso2.carbon.databridge.commons.Event; @@ -32,7 +33,6 @@ import static org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary.BinaryEventSender.sendBinaryLogoutMessage; import static org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary.BinaryEventSender.sendBinaryPublishMessage; - /** * This class is Binary transport implementation for the Data Endpoint. */ diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryEventSender.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryEventSender.java index e2d17ba12e..5da5333804 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryEventSender.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryEventSender.java @@ -1,20 +1,21 @@ /* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ + package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary; import org.wso2.carbon.databridge.commons.Event; @@ -35,7 +36,6 @@ import static org.wso2.carbon.databridge.commons.binary.BinaryMessageConverterUtil.getSize; import static org.wso2.carbon.databridge.commons.binary.BinaryMessageConverterUtil.loadData; - /** * This is a Util class which does the Binary message transformation for publish, login, logout operations. */ diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinarySecureClientPoolFactory.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinarySecureClientPoolFactory.java index 380af0bf89..3dfaa65359 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinarySecureClientPoolFactory.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinarySecureClientPoolFactory.java @@ -1,20 +1,21 @@ /* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ + package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary; import org.apache.http.conn.ssl.SSLContexts; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointAuthenticationException.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointAuthenticationException.java index 0323e37c56..617d851b59 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointAuthenticationException.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointAuthenticationException.java @@ -1,26 +1,26 @@ /* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ + package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception; /** * Exception to be thrown when connecting the Data Endpoint. */ - public class DataEndpointAuthenticationException extends Exception { private String errorMessage; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointConfigurationException.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointConfigurationException.java index 1a605a089f..1ec7f09a0e 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointConfigurationException.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointConfigurationException.java @@ -1,26 +1,26 @@ /* -* Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception; /** * Exception to be thrown When parsing the Data Endpoint configurations when initializing data publisher. */ - public class DataEndpointConfigurationException extends Exception { private String errorMessage; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointException.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointException.java index f014c664d4..1513f44458 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointException.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointException.java @@ -1,26 +1,26 @@ /* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ + package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception; /** * Exception to be thrown when communicating with DataEndpoint. */ - public class DataEndpointException extends Exception { private String errorMessage; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/EventQueueFullException.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/EventQueueFullException.java index 5b6a714a0e..0210c12bdf 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/EventQueueFullException.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/EventQueueFullException.java @@ -1,27 +1,27 @@ /* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ + package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception; /** * Exception to be thrown when the event is tried to insert into the queue * which doesn't have adequate capacity to hold. */ - public class EventQueueFullException extends Exception { private String errorMessage; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataEndpointConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataEndpointConstants.java index 096da48980..d5c0138903 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataEndpointConstants.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataEndpointConstants.java @@ -1,20 +1,21 @@ /* -* Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util; /** diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataPublisherUtil.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataPublisherUtil.java index afc9ad787a..b95325b700 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataPublisherUtil.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataPublisherUtil.java @@ -1,23 +1,22 @@ /* -* Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* WSO2 Inc. licenses this file to you under the Apache License, -* Version 2.0 (the "License"); you may not use this file except -* in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, -* software distributed under the License is distributed on an -* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -* KIND, either express or implied. See the License for the -* specific language governing permissions and limitations -* under the License. -*/ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util; - + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util; import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.DataEndpointConfiguration; import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointConfigurationException; @@ -29,14 +28,12 @@ /** * A Util class which holds all the utility processing methods in the data publisher operation. */ - public class DataPublisherUtil { /** * Making as private to avoid the instantiation of the class. */ - private DataPublisherUtil() { - } + private DataPublisherUtil() {} /** * Process and extracts the receiver Groups from the string of URL set pattern passed in. @@ -63,7 +60,6 @@ public static ArrayList getEndpointGroups(String urlSet) return endPointGroups; } - /** * Returns an object array which has first element as boolean * for specify the URLs are fail over configuration or LB configuration. @@ -102,7 +98,6 @@ private static Object[] getEndpoints(String aURLGroup) return endpoint; } - /** * Validate whether the receiverGroup and authenticationGroups are matching with pattern. * Basically if the receiver groups has been configured to be in the failover pattern, @@ -142,7 +137,6 @@ public static void validateURLs(ArrayList receiverGroups, ArrayList authGroups) } } - /** * Returns the URL set string based on the URLs provided. The first element of the array is * a boolean which indicates whether it's failover or load balancing. diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/ThrottleEventConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/ThrottleEventConstants.java index 52091db4ff..8629a2b345 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/ThrottleEventConstants.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/ThrottleEventConstants.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -19,8 +19,7 @@ package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util; /** - * This class holds the constants required to fetch the properties from the - * ThrottleEvent . + * This class holds the constants required to fetch the properties from the ThrottleEvent. */ public class ThrottleEventConstants { diff --git a/pom.xml b/pom.xml index 1389bc218f..4039fc0486 100644 --- a/pom.xml +++ b/pom.xml @@ -275,6 +275,26 @@ testng ${testng.version} + + org.wso2.carbon.analytics-common + org.wso2.carbon.databridge.commons + ${analytics.common.version} + + + org.wso2.carbon.analytics-common + org.wso2.carbon.databridge.commons.binary + ${analytics.common.version} + + + commons-pool.wso2 + commons-pool + ${apache.commons.version} + + + org.wso2.orbit.com.lmax + disruptor + ${lmax.version} + @@ -313,8 +333,8 @@ 6.11 6.0.53 0.7.2 - 6.1.45 + 6.1.45 1.5.6.wso2v1 - 3.4.2.wso2v1 + 3.4.2.wso2v1 From a604de2dc9e381906fd5cffc055dcbb806405d22 Mon Sep 17 00:00:00 2001 From: Praminda Jayawardana Date: Thu, 25 Feb 2021 14:33:24 +0530 Subject: [PATCH 04/21] xds: throttle: Push publisher config --- adapter/config/mgwtypes.go | 55 ++++++++++++++++++++++++++++++++--- adapter/pkg/xds/xds_server.go | 44 ++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 4 deletions(-) diff --git a/adapter/config/mgwtypes.go b/adapter/config/mgwtypes.go index 1e9e4b5cd6..7d4e9ddc1a 100644 --- a/adapter/config/mgwtypes.go +++ b/adapter/config/mgwtypes.go @@ -120,10 +120,11 @@ type Config struct { } Enforcer struct { - JwtTokenConfig []jwtTokenConfig - EventHub eventHub - ApimCredentials apimCredentials - AuthService authService + JwtTokenConfig []jwtTokenConfig + EventHub eventHub + ApimCredentials apimCredentials + AuthService authService + ThrottlingConfig throttlingConfig } ControlPlane controlPlane `toml:"controlPlane"` @@ -176,6 +177,52 @@ type eventHub struct { } `toml:"jmsConnectionParameters"` } +type throttlingConfig struct { + Binary binaryThrottleConfig +} + +type binaryThrottleConfig struct { + Enabled bool + Username string + Password string + URLGroup []urlGroup + Publisher binaryPublisher + Agent binaryAgent +} + +type urlGroup struct { + ReceiverURLs []string + AuthURLs []string +} + +type binaryPublisher struct { + MaxIdleDataPublishingAgents int32 + InitIdleObjectDataPublishingAgents int32 + PublisherThreadPoolCoreSize int32 + PublisherThreadPoolMaximumSize int32 + PublisherThreadPoolKeepAliveTime int32 +} + +type binaryAgent struct { + SslEnabledProtocols string + Ciphers string + QueueSize int32 + BatchSize int32 + CorePoolSize int32 + SocketTimeoutMS int32 + MaxPoolSize int32 + KeepAliveTimeInPool int32 + ReconnectionInterval int32 + MaxTransportPoolSize int32 + MaxIdleConnections int32 + EvictionTimePeriod int32 + MinIdleTimeInPool int32 + SecureMaxTransportPoolSize int32 + SecureMaxIdleConnections int32 + SecureEvictionTimePeriod int32 + SecureMinIdleTimeInPool int32 +} + // APICtlUser represents registered APICtl Users type APICtlUser struct { Username string diff --git a/adapter/pkg/xds/xds_server.go b/adapter/pkg/xds/xds_server.go index 38984a8a73..1c5cb30a36 100644 --- a/adapter/pkg/xds/xds_server.go +++ b/adapter/pkg/xds/xds_server.go @@ -308,6 +308,8 @@ func generateEnvoyResoucesForLabel(label string) ([]types.Resource, []types.Reso func generateEnforcerConfigs(config *config.Config) *enforcer.Config { issuers := []*enforcer.Issuer{} + urlGroups := []*enforcer.TMURLGroup{} + for _, issuer := range config.Enforcer.JwtTokenConfig { jwtConfig := &enforcer.Issuer{ CertificateAlias: issuer.CertificateAlias, @@ -321,6 +323,14 @@ func generateEnforcerConfigs(config *config.Config) *enforcer.Config { issuers = append(issuers, jwtConfig) } + for _, urlGroup := range config.Enforcer.ThrottlingConfig.Binary.URLGroup { + group := &enforcer.TMURLGroup{ + AuthURLs: urlGroup.AuthURLs, + ReceiverURLs: urlGroup.ReceiverURLs, + } + urlGroups = append(urlGroups, group) + } + authService := &enforcer.AuthService{ KeepAliveTime: config.Enforcer.AuthService.KeepAliveTime, MaxHeaderLimit: config.Enforcer.AuthService.MaxHeaderLimit, @@ -348,6 +358,40 @@ func generateEnforcerConfigs(config *config.Config) *enforcer.Config { "eventListeningEndpoints": config.ControlPlane.EventHub.JmsConnectionParameters.EventListeningEndpoints, }, }, + ThrottlingConfig: &enforcer.Throttling{ + Binary: &enforcer.BinaryThrottling{ + Enabled: config.Enforcer.ThrottlingConfig.Binary.Enabled, + Username: config.Enforcer.ThrottlingConfig.Binary.Username, + Password: config.Enforcer.ThrottlingConfig.Binary.Password, + UrlGroup: urlGroups, + Publisher: &enforcer.ThrottlePublisher{ + InitIdleObjectDataPublishingAgents: config.Enforcer.ThrottlingConfig.Binary.Publisher.InitIdleObjectDataPublishingAgents, + MaxIdleDataPublishingAgents: config.Enforcer.ThrottlingConfig.Binary.Publisher.MaxIdleDataPublishingAgents, + PublisherThreadPoolCoreSize: config.Enforcer.ThrottlingConfig.Binary.Publisher.PublisherThreadPoolCoreSize, + PublisherThreadPoolKeepAliveTime: config.Enforcer.ThrottlingConfig.Binary.Publisher.PublisherThreadPoolKeepAliveTime, + PublisherThreadPoolMaximumSize: config.Enforcer.ThrottlingConfig.Binary.Publisher.PublisherThreadPoolMaximumSize, + }, + Agent: &enforcer.ThrottleAgent{ + BatchSize: config.Enforcer.ThrottlingConfig.Binary.Agent.BatchSize, + Ciphers: config.Enforcer.ThrottlingConfig.Binary.Agent.Ciphers, + CorePoolSize: config.Enforcer.ThrottlingConfig.Binary.Agent.CorePoolSize, + EvictionTimePeriod: config.Enforcer.ThrottlingConfig.Binary.Agent.EvictionTimePeriod, + KeepAliveTimeInPool: config.Enforcer.ThrottlingConfig.Binary.Agent.KeepAliveTimeInPool, + MaxIdleConnections: config.Enforcer.ThrottlingConfig.Binary.Agent.MaxIdleConnections, + MaxPoolSize: config.Enforcer.ThrottlingConfig.Binary.Agent.MaxPoolSize, + MaxTransportPoolSize: config.Enforcer.ThrottlingConfig.Binary.Agent.MaxTransportPoolSize, + MinIdleTimeInPool: config.Enforcer.ThrottlingConfig.Binary.Agent.MinIdleTimeInPool, + QueueSize: config.Enforcer.ThrottlingConfig.Binary.Agent.QueueSize, + ReconnectionInterval: config.Enforcer.ThrottlingConfig.Binary.Agent.ReconnectionInterval, + SecureEvictionTimePeriod: config.Enforcer.ThrottlingConfig.Binary.Agent.SecureEvictionTimePeriod, + SecureMaxIdleConnections: config.Enforcer.ThrottlingConfig.Binary.Agent.SecureMaxIdleConnections, + SecureMaxTransportPoolSize: config.Enforcer.ThrottlingConfig.Binary.Agent.SecureMaxTransportPoolSize, + SecureMinIdleTimeInPool: config.Enforcer.ThrottlingConfig.Binary.Agent.SecureMinIdleTimeInPool, + SocketTimeoutMS: config.Enforcer.ThrottlingConfig.Binary.Agent.SocketTimeoutMS, + SslEnabledProtocols: config.Enforcer.ThrottlingConfig.Binary.Agent.SslEnabledProtocols, + }, + }, + }, } } From bf29106d489e8a5ea7c910bdbe69fe7cd5f2faa3 Mon Sep 17 00:00:00 2001 From: Praminda Jayawardana Date: Mon, 1 Mar 2021 14:15:22 +0530 Subject: [PATCH 05/21] throttle: Add urlgrp type config --- .../config/enforcer/tm_url_group.pb.go | 31 ++-- adapter/config/mgwtypes.go | 1 + adapter/pkg/xds/xds_server.go | 1 + .../config/enforcer/tm_url_group.proto | 1 + .../discovery/config/enforcer/TMURLGroup.java | 138 ++++++++++++++++++ .../config/enforcer/TMURLGroupOrBuilder.java | 12 ++ .../config/enforcer/TMURLGroupProto.java | 14 +- resources/conf/config.toml | 29 ++-- 8 files changed, 195 insertions(+), 32 deletions(-) diff --git a/adapter/api/wso2/discovery/config/enforcer/tm_url_group.pb.go b/adapter/api/wso2/discovery/config/enforcer/tm_url_group.pb.go index 8e4b144221..24aebc8b44 100644 --- a/adapter/api/wso2/discovery/config/enforcer/tm_url_group.pb.go +++ b/adapter/api/wso2/discovery/config/enforcer/tm_url_group.pb.go @@ -32,6 +32,7 @@ type TMURLGroup struct { ReceiverURLs []string `protobuf:"bytes,1,rep,name=receiverURLs,proto3" json:"receiverURLs,omitempty"` AuthURLs []string `protobuf:"bytes,2,rep,name=authURLs,proto3" json:"authURLs,omitempty"` + Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` } func (x *TMURLGroup) Reset() { @@ -80,6 +81,13 @@ func (x *TMURLGroup) GetAuthURLs() []string { return nil } +func (x *TMURLGroup) GetType() string { + if x != nil { + return x.Type + } + return "" +} + var File_wso2_discovery_config_enforcer_tm_url_group_proto protoreflect.FileDescriptor var file_wso2_discovery_config_enforcer_tm_url_group_proto_rawDesc = []byte{ @@ -88,21 +96,22 @@ var file_wso2_discovery_config_enforcer_tm_url_group_proto_rawDesc = []byte{ 0x2f, 0x74, 0x6d, 0x5f, 0x75, 0x72, 0x6c, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, - 0x63, 0x65, 0x72, 0x22, 0x4c, 0x0a, 0x0a, 0x54, 0x4d, 0x55, 0x52, 0x4c, 0x47, 0x72, 0x6f, 0x75, + 0x63, 0x65, 0x72, 0x22, 0x60, 0x0a, 0x0a, 0x54, 0x4d, 0x55, 0x52, 0x4c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x22, 0x0a, 0x0c, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x55, 0x52, 0x4c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x55, 0x52, 0x4c, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x75, 0x74, 0x68, 0x55, 0x52, 0x4c, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x61, 0x75, 0x74, 0x68, 0x55, 0x52, 0x4c, - 0x73, 0x42, 0x8f, 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x67, - 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, - 0x42, 0x0f, 0x54, 0x4d, 0x55, 0x52, 0x4c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, - 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, 0x72, - 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x42, 0x8f, 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, + 0x6f, 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, + 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, + 0x72, 0x63, 0x65, 0x72, 0x42, 0x0f, 0x54, 0x4d, 0x55, 0x52, 0x4c, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, + 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, + 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, 0x65, + 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/adapter/config/mgwtypes.go b/adapter/config/mgwtypes.go index 7d4e9ddc1a..4b81abe6e2 100644 --- a/adapter/config/mgwtypes.go +++ b/adapter/config/mgwtypes.go @@ -193,6 +193,7 @@ type binaryThrottleConfig struct { type urlGroup struct { ReceiverURLs []string AuthURLs []string + Type string } type binaryPublisher struct { diff --git a/adapter/pkg/xds/xds_server.go b/adapter/pkg/xds/xds_server.go index 1c5cb30a36..f99182de32 100644 --- a/adapter/pkg/xds/xds_server.go +++ b/adapter/pkg/xds/xds_server.go @@ -327,6 +327,7 @@ func generateEnforcerConfigs(config *config.Config) *enforcer.Config { group := &enforcer.TMURLGroup{ AuthURLs: urlGroup.AuthURLs, ReceiverURLs: urlGroup.ReceiverURLs, + Type: urlGroup.Type, } urlGroups = append(urlGroups, group) } diff --git a/api/wso2/discovery/config/enforcer/tm_url_group.proto b/api/wso2/discovery/config/enforcer/tm_url_group.proto index b7562f295e..2e88fcfab7 100644 --- a/api/wso2/discovery/config/enforcer/tm_url_group.proto +++ b/api/wso2/discovery/config/enforcer/tm_url_group.proto @@ -12,4 +12,5 @@ option java_multiple_files = true; message TMURLGroup { repeated string receiverURLs = 1; repeated string authURLs = 2; + string type = 3; } diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroup.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroup.java index cac6cf492a..09ff84cdd0 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroup.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroup.java @@ -18,6 +18,7 @@ private TMURLGroup(com.google.protobuf.GeneratedMessageV3.Builder builder) { private TMURLGroup() { receiverURLs_ = com.google.protobuf.LazyStringArrayList.EMPTY; authURLs_ = com.google.protobuf.LazyStringArrayList.EMPTY; + type_ = ""; } @java.lang.Override @@ -69,6 +70,12 @@ private TMURLGroup( authURLs_.add(s); break; } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + type_ = s; + break; + } default: { if (!parseUnknownField( input, unknownFields, extensionRegistry, tag)) { @@ -177,6 +184,44 @@ public java.lang.String getAuthURLs(int index) { return authURLs_.getByteString(index); } + public static final int TYPE_FIELD_NUMBER = 3; + private volatile java.lang.Object type_; + /** + * string type = 3; + * @return The type. + */ + @java.lang.Override + public java.lang.String getType() { + java.lang.Object ref = type_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + type_ = s; + return s; + } + } + /** + * string type = 3; + * @return The bytes for type. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getTypeBytes() { + java.lang.Object ref = type_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + private byte memoizedIsInitialized = -1; @java.lang.Override public final boolean isInitialized() { @@ -197,6 +242,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) for (int i = 0; i < authURLs_.size(); i++) { com.google.protobuf.GeneratedMessageV3.writeString(output, 2, authURLs_.getRaw(i)); } + if (!getTypeBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, type_); + } unknownFields.writeTo(output); } @@ -222,6 +270,9 @@ public int getSerializedSize() { size += dataSize; size += 1 * getAuthURLsList().size(); } + if (!getTypeBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, type_); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -241,6 +292,8 @@ public boolean equals(final java.lang.Object obj) { .equals(other.getReceiverURLsList())) return false; if (!getAuthURLsList() .equals(other.getAuthURLsList())) return false; + if (!getType() + .equals(other.getType())) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -260,6 +313,8 @@ public int hashCode() { hash = (37 * hash) + AUTHURLS_FIELD_NUMBER; hash = (53 * hash) + getAuthURLsList().hashCode(); } + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + getType().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -397,6 +452,8 @@ public Builder clear() { bitField0_ = (bitField0_ & ~0x00000001); authURLs_ = com.google.protobuf.LazyStringArrayList.EMPTY; bitField0_ = (bitField0_ & ~0x00000002); + type_ = ""; + return this; } @@ -434,6 +491,7 @@ public org.wso2.gateway.discovery.config.enforcer.TMURLGroup buildPartial() { bitField0_ = (bitField0_ & ~0x00000002); } result.authURLs_ = authURLs_; + result.type_ = type_; onBuilt(); return result; } @@ -502,6 +560,10 @@ public Builder mergeFrom(org.wso2.gateway.discovery.config.enforcer.TMURLGroup o } onChanged(); } + if (!other.getType().isEmpty()) { + type_ = other.type_; + onChanged(); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -751,6 +813,82 @@ public Builder addAuthURLsBytes( onChanged(); return this; } + + private java.lang.Object type_ = ""; + /** + * string type = 3; + * @return The type. + */ + public java.lang.String getType() { + java.lang.Object ref = type_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + type_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string type = 3; + * @return The bytes for type. + */ + public com.google.protobuf.ByteString + getTypeBytes() { + java.lang.Object ref = type_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string type = 3; + * @param value The type to set. + * @return This builder for chaining. + */ + public Builder setType( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value; + onChanged(); + return this; + } + /** + * string type = 3; + * @return This builder for chaining. + */ + public Builder clearType() { + + type_ = getDefaultInstance().getType(); + onChanged(); + return this; + } + /** + * string type = 3; + * @param value The bytes for type to set. + * @return This builder for chaining. + */ + public Builder setTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + type_ = value; + onChanged(); + return this; + } @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroupOrBuilder.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroupOrBuilder.java index ef4f140e53..9d451f798e 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroupOrBuilder.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroupOrBuilder.java @@ -56,4 +56,16 @@ public interface TMURLGroupOrBuilder extends */ com.google.protobuf.ByteString getAuthURLsBytes(int index); + + /** + * string type = 3; + * @return The type. + */ + java.lang.String getType(); + /** + * string type = 3; + * @return The bytes for type. + */ + com.google.protobuf.ByteString + getTypeBytes(); } diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroupProto.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroupProto.java index 559e247366..475af93be3 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroupProto.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/TMURLGroupProto.java @@ -30,12 +30,12 @@ public static void registerAllExtensions( java.lang.String[] descriptorData = { "\n1wso2/discovery/config/enforcer/tm_url_" + "group.proto\022\036wso2.discovery.config.enfor" + - "cer\"4\n\nTMURLGroup\022\024\n\014receiverURLs\030\001 \003(\t\022" + - "\020\n\010authURLs\030\002 \003(\tB\217\001\n*org.wso2.gateway.d" + - "iscovery.config.enforcerB\017TMURLGroupProt" + - "oP\001ZNgithub.com/envoyproxy/go-control-pl" + - "ane/wso2/discovery/config/enforcer;enfor" + - "cerb\006proto3" + "cer\"B\n\nTMURLGroup\022\024\n\014receiverURLs\030\001 \003(\t\022" + + "\020\n\010authURLs\030\002 \003(\t\022\014\n\004type\030\003 \001(\tB\217\001\n*org." + + "wso2.gateway.discovery.config.enforcerB\017" + + "TMURLGroupProtoP\001ZNgithub.com/envoyproxy" + + "/go-control-plane/wso2/discovery/config/" + + "enforcer;enforcerb\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -46,7 +46,7 @@ public static void registerAllExtensions( internal_static_wso2_discovery_config_enforcer_TMURLGroup_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_wso2_discovery_config_enforcer_TMURLGroup_descriptor, - new java.lang.String[] { "ReceiverURLs", "AuthURLs", }); + new java.lang.String[] { "ReceiverURLs", "AuthURLs", "Type", }); } // @@protoc_insertion_point(outer_class_scope) diff --git a/resources/conf/config.toml b/resources/conf/config.toml index b7c7ac9a9e..23fcaf2b1e 100644 --- a/resources/conf/config.toml +++ b/resources/conf/config.toml @@ -79,20 +79,6 @@ disableSslVerification = false username="admin" password="admin" -[controlPlane] -# Control plane's eventHub details -[controlPlane.eventHub] -enabled = false -serviceUrl = "https://localhost:9443/" -username="admin" -password="admin" -environmentLabels = ["Production and Sandbox"] -retryInterval = 5 -skipSSLVerification=true -# Message broker connection URL of the control plane -[controlPlane.eventHub.jmsConnectionParameters] -eventListeningEndpoints = "amqp://admin:admin@localhost:5672/" - # Throttling configurations related to event publishing using a binary connection [enforcer.throttlingConfig.binary] enabled = false @@ -103,6 +89,7 @@ eventListeningEndpoints = "amqp://admin:admin@localhost:5672/" [[enforcer.throttlingConfig.binary.urlGroup]] receiverURLs = ["tcp://localhost:9611"] authURLs = ["ssl://localhost:9711"] + type = "loadbalance" # Data publisher object pool configurations [enforcer.throttlingConfig.binary.publisher] maxIdleDataPublishingAgents = 1000 @@ -141,3 +128,17 @@ eventListeningEndpoints = "amqp://admin:admin@localhost:5672/" secureMaxIdleConnections = 250 secureEvictionTimePeriod = 5500 secureMinIdleTimeInPool = 5000 + +[controlPlane] +# Control plane's eventHub details +[controlPlane.eventHub] +enabled = false +serviceUrl = "https://localhost:9443/" +username="admin" +password="admin" +environmentLabels = ["Production and Sandbox"] +retryInterval = 5 +skipSSLVerification=true +# Message broker connection URL of the control plane +[controlPlane.eventHub.jmsConnectionParameters] +eventListeningEndpoints = "amqp://admin:admin@localhost:5672/" From 372f2e209324a012a4b73311858ef1b8b450c242 Mon Sep 17 00:00:00 2001 From: Praminda Jayawardana Date: Mon, 1 Mar 2021 14:16:03 +0530 Subject: [PATCH 06/21] throttle: enforcer: Receive throttle pub config --- .../micro/gateway/enforcer/api/RestAPI.java | 2 +- .../gateway/enforcer/config/ConfigHolder.java | 153 ++++++++++-------- .../enforcer/config/EnforcerConfig.java | 10 ++ 3 files changed, 100 insertions(+), 65 deletions(-) diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RestAPI.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RestAPI.java index a832e96686..b9d131725b 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RestAPI.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RestAPI.java @@ -129,7 +129,7 @@ private void initFilters() { this.filters.add(corsFilter); this.filters.add(authFilter); // enable throttle filter - if (ConfigHolder.getInstance().getThrottleAgentConfig().isEnabled()) { + if (ConfigHolder.getInstance().getConfig().getThrottleAgentConfig().isEnabled()) { ThrottleFilter throttleFilter = new ThrottleFilter(); throttleFilter.init(apiConfig); this.filters.add(throttleFilter); diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java index 6afa28ea6b..cde15407ee 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java @@ -23,9 +23,13 @@ import org.apache.logging.log4j.Logger; import org.wso2.gateway.discovery.config.enforcer.AmCredentials; import org.wso2.gateway.discovery.config.enforcer.AuthService; +import org.wso2.gateway.discovery.config.enforcer.BinaryThrottling; import org.wso2.gateway.discovery.config.enforcer.Config; import org.wso2.gateway.discovery.config.enforcer.EventHub; import org.wso2.gateway.discovery.config.enforcer.Issuer; +import org.wso2.gateway.discovery.config.enforcer.TMURLGroup; +import org.wso2.gateway.discovery.config.enforcer.ThrottleAgent; +import org.wso2.gateway.discovery.config.enforcer.ThrottlePublisher; import org.wso2.micro.gateway.enforcer.config.dto.AuthServiceConfigurationDto; import org.wso2.micro.gateway.enforcer.config.dto.CredentialDto; import org.wso2.micro.gateway.enforcer.config.dto.EventHubConfigurationDto; @@ -34,7 +38,6 @@ import org.wso2.micro.gateway.enforcer.constants.Constants; import org.wso2.micro.gateway.enforcer.discovery.ConfigDiscoveryClient; import org.wso2.micro.gateway.enforcer.dto.ThrottleAgentConfigDTO; -import org.wso2.micro.gateway.enforcer.dto.ThrottleURLGroupDTO; import org.wso2.micro.gateway.enforcer.exception.DiscoveryException; import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.AgentConfiguration; import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.publisher.PublisherConfiguration; @@ -69,11 +72,6 @@ public class ConfigHolder { private ConfigHolder() { init(); } - public ThrottleAgentConfigDTO getThrottleAgentConfig() { - return throttleAgentConfig; - } - - private ThrottleAgentConfigDTO throttleAgentConfig; public static ConfigHolder getInstance() { if (configHolder != null) { @@ -116,7 +114,7 @@ private void parseConfigs(Config config) { //Read credentials used to connect with APIM services populateAPIMCredentials(config.getApimCredentials()); - populateTMBinaryConfig(); + populateTMBinaryConfig(config.getThrottlingConfig().getBinary()); } private void populateAuthService(AuthService cdsAuth) { @@ -154,7 +152,7 @@ private void populateJWTIssuerConfiguration(List cdsIssuers) { setTrustStoreForJWT(KeyStore.getInstance(KeyStore.getDefaultType())); getTrustStoreForJWT().load(null); } catch (KeyStoreException | CertificateException | NoSuchAlgorithmException | IOException e) { - logger.error("Error while initiaing the truststore for JWT related public certificates", e); + logger.error("Error while initiating the truststore for JWT related public certificates", e); } for (Issuer jwtIssuer : cdsIssuers) { TokenIssuerDto issuerDto = new TokenIssuerDto(jwtIssuer.getIssuer()); @@ -165,7 +163,7 @@ private void populateJWTIssuerConfiguration(List cdsIssuers) { issuerDto.setJwksConfigurationDTO(jwksConfigurationDTO); String certificateAlias = jwtIssuer.getCertificateAlias(); - if (certificateAlias != null) { + if (!certificateAlias.isBlank()) { try { Certificate cert = TLSUtils.getCertificateFromFile(jwtIssuer.getCertificateFilePath()); getTrustStoreForJWT().setCertificateEntry(certificateAlias, cert); @@ -182,20 +180,47 @@ private void populateJWTIssuerConfiguration(List cdsIssuers) { } } - private void populateTMBinaryConfig() { - // TODO(amalimatharaarachchi) get binary configs from config -// throttleAgentConfig = -// configToml.getTable(Constants.TM_BINARY_THROTTLE_CONF_INSTANCE_ID) -// .to(ThrottleAgentConfigDTO.class); - AgentConfiguration agentConfiguration = throttleAgentConfig.getAgent(); - agentConfiguration.setTrustStore(trustStore); - AgentConfiguration.setInstance(agentConfiguration); - - PublisherConfiguration pubConfiguration = throttleAgentConfig.getPublisher(); - pubConfiguration.setUserName(throttleAgentConfig.getUsername()); - pubConfiguration.setPassword(throttleAgentConfig.getPassword()); - processTMPublisherURLGroup(throttleAgentConfig.getUrlGroup(), pubConfiguration); - PublisherConfiguration.setInstance(pubConfiguration); + private void populateTMBinaryConfig(BinaryThrottling binary) { + ThrottleAgent binaryAgent = binary.getAgent(); + AgentConfiguration agentConf = AgentConfiguration.getInstance(); + agentConf.setBatchSize(binaryAgent.getBatchSize()); + agentConf.setCiphers(binaryAgent.getCiphers()); + agentConf.setCorePoolSize(binaryAgent.getCorePoolSize()); + agentConf.setEvictionTimePeriod(binaryAgent.getEvictionTimePeriod()); + agentConf.setKeepAliveTimeInPool(binaryAgent.getKeepAliveTimeInPool()); + agentConf.setMaxIdleConnections(binaryAgent.getMaxIdleConnections()); + agentConf.setMaxPoolSize(binaryAgent.getMaxPoolSize()); + agentConf.setMaxTransportPoolSize(binaryAgent.getMaxTransportPoolSize()); + agentConf.setMinIdleTimeInPool(binaryAgent.getMinIdleTimeInPool()); + agentConf.setQueueSize(binaryAgent.getQueueSize()); + agentConf.setReconnectionInterval(binaryAgent.getReconnectionInterval()); + agentConf.setSecureEvictionTimePeriod(binaryAgent.getSecureEvictionTimePeriod()); + agentConf.setSecureMaxIdleConnections(binaryAgent.getSecureMaxIdleConnections()); + agentConf.setSecureMaxTransportPoolSize(binaryAgent.getSecureMaxTransportPoolSize()); + agentConf.setSecureMinIdleTimeInPool(binaryAgent.getSecureMinIdleTimeInPool()); + agentConf.setSslEnabledProtocols(binaryAgent.getSslEnabledProtocols()); + agentConf.setSocketTimeoutMS(binaryAgent.getSocketTimeoutMS()); + agentConf.setTrustStore(trustStore); + + ThrottlePublisher binaryPublisher = binary.getPublisher(); + PublisherConfiguration pubConf = PublisherConfiguration.getInstance(); + pubConf.setUserName(binary.getUsername()); + pubConf.setPassword(binary.getPassword()); + pubConf.setInitIdleObjectDataPublishingAgents(binaryPublisher.getInitIdleObjectDataPublishingAgents()); + pubConf.setMaxIdleDataPublishingAgents(binaryPublisher.getMaxIdleDataPublishingAgents()); + pubConf.setPublisherThreadPoolCoreSize(binaryPublisher.getPublisherThreadPoolCoreSize()); + pubConf.setPublisherThreadPoolKeepAliveTime(binaryPublisher.getPublisherThreadPoolKeepAliveTime()); + pubConf.setPublisherThreadPoolMaximumSize(binaryPublisher.getPublisherThreadPoolMaximumSize()); + + processTMPublisherURLGroup(binary.getUrlGroupList(), pubConf); + + ThrottleAgentConfigDTO throttleAgent = new ThrottleAgentConfigDTO(); + throttleAgent.setAgent(agentConf); + throttleAgent.setEnabled(binary.getEnabled()); + throttleAgent.setUsername(binary.getUsername()); + throttleAgent.setPassword(binary.getPassword()); + throttleAgent.setPublisher(pubConf); + config.setThrottleAgentConfig(throttleAgent); } private void loadTrustStore() { @@ -218,57 +243,26 @@ private void populateAPIMCredentials(AmCredentials cred) { config.setApimCredentials(credentialDto); } - public EnforcerConfig getConfig() { - return config; - } - - public void setConfig(EnforcerConfig config) { - this.config = config; - } - - public KeyStore getTrustStore() { - return trustStore; - } - - public KeyStore getTrustStoreForJWT() { - return trustStoreForJWT; - } - - public void setTrustStoreForJWT(KeyStore trustStoreForJWT) { - this.trustStoreForJWT = trustStoreForJWT; - } - - public TrustManagerFactory getTrustManagerFactory() { - return trustManagerFactory; - } - - public void setTrustManagerFactory(TrustManagerFactory trustManagerFactory) { - this.trustManagerFactory = trustManagerFactory; - } - - public EnvVarConfig getEnvVarConfig() { - return envVarConfig; - } /** * The receiverURLGroup and the authURLGroup is preprocessed * such that to make them compatible with the binary agent. */ - private void processTMPublisherURLGroup(List urlGroups, + private void processTMPublisherURLGroup(List urlGroups, PublisherConfiguration pubConfiguration) { StringBuilder restructuredReceiverURL = new StringBuilder(); StringBuilder restructuredAuthURL = new StringBuilder(); - for (ThrottleURLGroupDTO urlGroup : urlGroups) { - String[] receiverUrls = urlGroup.getReceiverURLs(); - String[] authUrls = urlGroup.getAuthURLs(); - if (receiverUrls.length == 1 && authUrls.length == 1) { - restructuredReceiverURL.append("{").append(receiverUrls[0]).append("},"); - restructuredAuthURL.append("{").append(authUrls[0]).append("},"); + for (TMURLGroup urlGroup : urlGroups) { + List receiverUrls = urlGroup.getReceiverURLsList(); + List authUrls = urlGroup.getAuthURLsList(); + if (receiverUrls.size() == 1 && authUrls.size() == 1) { + restructuredReceiverURL.append("{").append(receiverUrls.get(0)).append("},"); + restructuredAuthURL.append("{").append(authUrls.get(0)).append("},"); continue; } String urlType = urlGroup.getType(); - if (urlType == null || urlType.isBlank() || !(Constants.LOADBALANCE.equalsIgnoreCase(urlType) + if (urlType.isBlank() || !(Constants.LOADBALANCE.equalsIgnoreCase(urlType) || Constants.FAILOVER.equalsIgnoreCase(urlType))) { logger.warn("Type is not " + Constants.LOADBALANCE + " or " + Constants.FAILOVER + ". Hence proceeding as a " @@ -287,8 +281,7 @@ private void processTMPublisherURLGroup(List urlGroups, } } - - private String processSingleURLGroup(String[] urlArray, String urlType) { + private String processSingleURLGroup(List urlArray, String urlType) { StringBuilder concatenatedURLString = new StringBuilder("{"); for (String url : urlArray) { if (Constants.LOADBALANCE.equalsIgnoreCase(urlType)) { @@ -305,4 +298,36 @@ private String processSingleURLGroup(String[] urlArray, String urlType) { return concatenatedURLString.toString(); } + public EnforcerConfig getConfig() { + return config; + } + + public void setConfig(EnforcerConfig config) { + this.config = config; + } + + public KeyStore getTrustStore() { + return trustStore; + } + + public KeyStore getTrustStoreForJWT() { + return trustStoreForJWT; + } + + public void setTrustStoreForJWT(KeyStore trustStoreForJWT) { + this.trustStoreForJWT = trustStoreForJWT; + } + + public TrustManagerFactory getTrustManagerFactory() { + return trustManagerFactory; + } + + public void setTrustManagerFactory(TrustManagerFactory trustManagerFactory) { + this.trustManagerFactory = trustManagerFactory; + } + + public EnvVarConfig getEnvVarConfig() { + return envVarConfig; + } + } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/EnforcerConfig.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/EnforcerConfig.java index 5f51d62f99..99e269785a 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/EnforcerConfig.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/EnforcerConfig.java @@ -22,6 +22,7 @@ import org.wso2.micro.gateway.enforcer.config.dto.CredentialDto; import org.wso2.micro.gateway.enforcer.config.dto.EventHubConfigurationDto; import org.wso2.micro.gateway.enforcer.config.dto.TokenIssuerDto; +import org.wso2.micro.gateway.enforcer.dto.ThrottleAgentConfigDTO; import java.util.HashMap; import java.util.Map; @@ -35,6 +36,7 @@ public class EnforcerConfig { private EventHubConfigurationDto eventHub; private Map issuersMap = new HashMap<>(); private CredentialDto apimCredentials; + private ThrottleAgentConfigDTO throttleAgentConfig; public AuthServiceConfigurationDto getAuthService() { return authService; @@ -67,5 +69,13 @@ public CredentialDto getApimCredentials() { public void setApimCredentials(CredentialDto apimCredentials) { this.apimCredentials = apimCredentials; } + + public ThrottleAgentConfigDTO getThrottleAgentConfig() { + return throttleAgentConfig; + } + + public void setThrottleAgentConfig(ThrottleAgentConfigDTO throttleAgentConfig) { + this.throttleAgentConfig = throttleAgentConfig; + } } From cd3abef5de8a82326879e6374e07957500e4fb09 Mon Sep 17 00:00:00 2001 From: Praminda Jayawardana Date: Mon, 1 Mar 2021 19:51:28 +0530 Subject: [PATCH 07/21] throttle: enforcer: Activate publisher --- adapter/config/types.go | 8 ++++---- .../wso2/micro/gateway/enforcer/config/ConfigHolder.java | 3 ++- .../wso2/micro/gateway/enforcer/server/AuthServer.java | 5 +++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/adapter/config/types.go b/adapter/config/types.go index 1ef75cad26..2074444769 100644 --- a/adapter/config/types.go +++ b/adapter/config/types.go @@ -187,15 +187,15 @@ type binaryThrottleConfig struct { Enabled bool Username string Password string - URLGroup []urlGroup + URLGroup []urlGroup `toml:"urlGroup"` Publisher binaryPublisher Agent binaryAgent } type urlGroup struct { - ReceiverURLs []string - AuthURLs []string - Type string + ReceiverURLs []string `toml:"receiverURLs"` + AuthURLs []string `toml:"authURLs"` + Type string `toml:"type"` } type binaryPublisher struct { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java index af2545ee7f..266ddc7f61 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java @@ -47,7 +47,6 @@ import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.publisher.PublisherConfiguration; import org.wso2.micro.gateway.enforcer.util.TLSUtils; -import javax.net.ssl.TrustManagerFactory; import java.io.IOException; import java.security.KeyStore; import java.security.KeyStoreException; @@ -57,6 +56,8 @@ import java.util.List; import java.util.Properties; +import javax.net.ssl.TrustManagerFactory; + /** * Configuration holder class for Microgateway. */ diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java index 28086eae1c..654c33d5f8 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java @@ -32,6 +32,7 @@ import org.wso2.micro.gateway.enforcer.common.CacheProvider; import org.wso2.micro.gateway.enforcer.config.ConfigHolder; import org.wso2.micro.gateway.enforcer.config.dto.AuthServiceConfigurationDto; +import org.wso2.micro.gateway.enforcer.globalthrottle.ThrottleAgent; import org.wso2.micro.gateway.enforcer.grpc.ExtAuthService; import org.wso2.micro.gateway.enforcer.grpc.interceptors.AccessLogInterceptor; import org.wso2.micro.gateway.enforcer.subscription.SubscriptionDataHolder; @@ -60,6 +61,10 @@ public static void main(String[] args) { //Initialise cache objects CacheProvider.init(); + // TODO: (Praminda) do this only if throttling is enabled + // ConfigHolder.getInstance().getConfig().getThrottleAgentConfig().isEnabled() + ThrottleAgent.startThrottlePublisherPool(); + // Start the server server.start(); logger.info("Sever started Listening in port : " + 8081); From 61b051a0e2a75c48ce5ac619db8b1fabb1dbc648 Mon Sep 17 00:00:00 2001 From: Praminda Jayawardana Date: Tue, 2 Mar 2021 13:15:53 +0530 Subject: [PATCH 08/21] enf: thrt: Rename globalthrottle pkg --- .../gateway/enforcer/config/ConfigHolder.java | 4 ++-- .../enforcer/dto/ThrottleAgentConfigDTO.java | 4 ++-- .../enforcer/filters/ThrottleFilter.java | 4 ++-- .../gateway/enforcer/server/AuthServer.java | 2 +- .../ThrottleAgent.java | 4 ++-- .../databridge/agent/AgentHolder.java | 6 +++--- .../databridge/agent/DataEndpointAgent.java | 20 +++++++++---------- .../databridge/agent/DataPublisher.java | 18 ++++++++--------- .../client/AbstractClientPoolFactory.java | 8 ++++---- .../AbstractSecureClientPoolFactory.java | 2 +- .../databridge/agent/client/ClientPool.java | 2 +- .../agent/conf/AgentConfiguration.java | 4 ++-- .../agent/conf/DataEndpointConfiguration.java | 4 ++-- .../agent/endpoint/DataEndpoint.java | 10 +++++----- .../DataEndpointConnectionWorker.java | 8 ++++---- .../endpoint/DataEndpointFailureCallback.java | 2 +- .../agent/endpoint/DataEndpointGroup.java | 12 +++++------ .../EventPublisherThreadPoolExecutor.java | 2 +- .../agent/endpoint/WrappedEventFactory.java | 2 +- .../binary/BinaryClientPoolFactory.java | 10 +++++----- .../endpoint/binary/BinaryDataEndpoint.java | 16 +++++++-------- .../endpoint/binary/BinaryEventSender.java | 2 +- .../binary/BinarySecureClientPoolFactory.java | 10 +++++----- .../DataEndpointAuthenticationException.java | 2 +- .../DataEndpointConfigurationException.java | 2 +- .../exception/DataEndpointException.java | 2 +- .../exception/EventQueueFullException.java | 2 +- .../agent/util/DataEndpointConstants.java | 2 +- .../agent/util/DataPublisherUtil.java | 6 +++--- .../agent/util/ThrottleEventConstants.java | 2 +- .../DataProcessAndPublishingAgent.java | 6 +++--- .../publisher/DataPublisherConstants.java | 2 +- .../publisher/PublisherConfiguration.java | 2 +- .../publisher/ThrottleDataPublisher.java | 12 +++++------ .../publisher/ThrottleDataPublisherPool.java | 2 +- 35 files changed, 99 insertions(+), 99 deletions(-) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/ThrottleAgent.java (88%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/AgentHolder.java (85%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/DataEndpointAgent.java (77%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/DataPublisher.java (94%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/client/AbstractClientPoolFactory.java (87%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/client/AbstractSecureClientPoolFactory.java (93%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/client/ClientPool.java (97%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/conf/AgentConfiguration.java (97%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/conf/DataEndpointConfiguration.java (95%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/endpoint/DataEndpoint.java (96%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/endpoint/DataEndpointConnectionWorker.java (93%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/endpoint/DataEndpointFailureCallback.java (93%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/endpoint/DataEndpointGroup.java (96%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/endpoint/EventPublisherThreadPoolExecutor.java (96%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/endpoint/WrappedEventFactory.java (94%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/endpoint/binary/BinaryClientPoolFactory.java (83%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/endpoint/binary/BinaryDataEndpoint.java (78%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/endpoint/binary/BinaryEventSender.java (98%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/endpoint/binary/BinarySecureClientPoolFactory.java (90%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/exception/DataEndpointAuthenticationException.java (93%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/exception/DataEndpointConfigurationException.java (94%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/exception/DataEndpointException.java (93%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/exception/EventQueueFullException.java (94%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/util/DataEndpointConstants.java (94%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/util/DataPublisherUtil.java (97%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/agent/util/ThrottleEventConstants.java (95%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/publisher/DataProcessAndPublishingAgent.java (95%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/publisher/DataPublisherConstants.java (94%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/publisher/PublisherConfiguration.java (98%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/publisher/ThrottleDataPublisher.java (91%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{globalthrottle => throttle}/databridge/publisher/ThrottleDataPublisherPool.java (97%) diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java index 266ddc7f61..f47ab4c082 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java @@ -43,8 +43,8 @@ import org.wso2.micro.gateway.enforcer.discovery.ConfigDiscoveryClient; import org.wso2.micro.gateway.enforcer.dto.ThrottleAgentConfigDTO; import org.wso2.micro.gateway.enforcer.exception.DiscoveryException; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.AgentConfiguration; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.publisher.PublisherConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.AgentConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.publisher.PublisherConfiguration; import org.wso2.micro.gateway.enforcer.util.TLSUtils; import java.io.IOException; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleAgentConfigDTO.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleAgentConfigDTO.java index ff8e14f5dc..f197c1dd27 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleAgentConfigDTO.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleAgentConfigDTO.java @@ -18,8 +18,8 @@ package org.wso2.micro.gateway.enforcer.dto; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.AgentConfiguration; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.publisher.PublisherConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.AgentConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.publisher.PublisherConfiguration; import java.util.ArrayList; import java.util.List; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java index 3475500728..6950de977e 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java @@ -25,8 +25,8 @@ import org.wso2.micro.gateway.enforcer.api.config.APIConfig; import org.wso2.micro.gateway.enforcer.api.config.ResourceConfig; import org.wso2.micro.gateway.enforcer.constants.APIConstants; -import org.wso2.micro.gateway.enforcer.globalthrottle.ThrottleAgent; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.ThrottleEventConstants; +import org.wso2.micro.gateway.enforcer.throttle.ThrottleAgent; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.ThrottleEventConstants; import org.wso2.micro.gateway.enforcer.security.AuthenticationContext; import org.wso2.micro.gateway.enforcer.util.FilterUtils; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java index 654c33d5f8..9bada735c1 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java @@ -32,7 +32,7 @@ import org.wso2.micro.gateway.enforcer.common.CacheProvider; import org.wso2.micro.gateway.enforcer.config.ConfigHolder; import org.wso2.micro.gateway.enforcer.config.dto.AuthServiceConfigurationDto; -import org.wso2.micro.gateway.enforcer.globalthrottle.ThrottleAgent; +import org.wso2.micro.gateway.enforcer.throttle.ThrottleAgent; import org.wso2.micro.gateway.enforcer.grpc.ExtAuthService; import org.wso2.micro.gateway.enforcer.grpc.interceptors.AccessLogInterceptor; import org.wso2.micro.gateway.enforcer.subscription.SubscriptionDataHolder; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/ThrottleAgent.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleAgent.java similarity index 88% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/ThrottleAgent.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleAgent.java index 64dd80ad1f..d4d983701e 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/ThrottleAgent.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleAgent.java @@ -16,9 +16,9 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle; +package org.wso2.micro.gateway.enforcer.throttle; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.publisher.ThrottleDataPublisher; +import org.wso2.micro.gateway.enforcer.throttle.databridge.publisher.ThrottleDataPublisher; import java.util.Map; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/AgentHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/AgentHolder.java similarity index 85% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/AgentHolder.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/AgentHolder.java index 3fb72123e9..522e3065e7 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/AgentHolder.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/AgentHolder.java @@ -16,11 +16,11 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.AgentConfiguration; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.AgentConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; /** * The holder the created agent and this is singleton class. diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/DataEndpointAgent.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/DataEndpointAgent.java similarity index 77% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/DataEndpointAgent.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/DataEndpointAgent.java index 07abaec429..4a49316c95 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/DataEndpointAgent.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/DataEndpointAgent.java @@ -16,18 +16,18 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent; import org.apache.commons.pool.impl.GenericKeyedObjectPool; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.client.AbstractClientPoolFactory; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.client.AbstractSecureClientPoolFactory; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.client.ClientPool; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.AgentConfiguration; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.DataEndpoint; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary.BinaryClientPoolFactory; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary.BinaryDataEndpoint; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary.BinarySecureClientPoolFactory; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.client.AbstractClientPoolFactory; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.client.AbstractSecureClientPoolFactory; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.client.ClientPool; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.AgentConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.DataEndpoint; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary.BinaryClientPoolFactory; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary.BinaryDataEndpoint; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary.BinarySecureClientPoolFactory; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; import java.util.ArrayList; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/DataPublisher.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/DataPublisher.java similarity index 94% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/DataPublisher.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/DataPublisher.java index 5d05e23761..bce852a144 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/DataPublisher.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/DataPublisher.java @@ -15,20 +15,20 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.wso2.carbon.databridge.commons.Event; import org.wso2.carbon.databridge.commons.exception.TransportException; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.DataEndpointConfiguration; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.DataEndpoint; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.DataEndpointGroup; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointAuthenticationException; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointConfigurationException; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.EventQueueFullException; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.DataPublisherUtil; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.DataEndpointConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.DataEndpoint; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.DataEndpointGroup; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointAuthenticationException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointConfigurationException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.EventQueueFullException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.DataPublisherUtil; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractClientPoolFactory.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/client/AbstractClientPoolFactory.java similarity index 87% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractClientPoolFactory.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/client/AbstractClientPoolFactory.java index 1622dd942b..74b86ef3ef 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractClientPoolFactory.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/client/AbstractClientPoolFactory.java @@ -15,12 +15,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.client; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.client; import org.apache.commons.pool.BaseKeyedPoolableObjectFactory; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointConfigurationException; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.DataPublisherUtil; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointConfigurationException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.DataPublisherUtil; /** * The abstract class that needs to be implemented when supporting a new non-secure transport diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractSecureClientPoolFactory.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/client/AbstractSecureClientPoolFactory.java similarity index 93% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractSecureClientPoolFactory.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/client/AbstractSecureClientPoolFactory.java index 511e172441..7ef56a8a11 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/AbstractSecureClientPoolFactory.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/client/AbstractSecureClientPoolFactory.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.client; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.client; import java.security.KeyStore; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/ClientPool.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/client/ClientPool.java similarity index 97% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/ClientPool.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/client/ClientPool.java index 114bb06e18..3efedcf65b 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/client/ClientPool.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/client/ClientPool.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.client; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.client; import org.apache.commons.pool.impl.GenericKeyedObjectPool; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/conf/AgentConfiguration.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/conf/AgentConfiguration.java similarity index 97% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/conf/AgentConfiguration.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/conf/AgentConfiguration.java index 750a9037d4..b2736cdf10 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/conf/AgentConfiguration.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/conf/AgentConfiguration.java @@ -16,9 +16,9 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.DataEndpointConstants; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.DataEndpointConstants; import java.security.KeyStore; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/conf/DataEndpointConfiguration.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/conf/DataEndpointConfiguration.java similarity index 95% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/conf/DataEndpointConfiguration.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/conf/DataEndpointConfiguration.java index 7d8c4dbeae..4d49981f9b 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/conf/DataEndpointConfiguration.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/conf/DataEndpointConfiguration.java @@ -16,10 +16,10 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf; import org.apache.commons.pool.impl.GenericKeyedObjectPool; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.DataEndpointConstants; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.DataEndpointConstants; /** diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpoint.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpoint.java similarity index 96% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpoint.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpoint.java index 2f264ccc75..00f061b214 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpoint.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpoint.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint; import org.apache.commons.pool.impl.GenericKeyedObjectPool; import org.apache.logging.log4j.LogManager; @@ -26,10 +26,10 @@ import org.wso2.carbon.databridge.commons.exception.TransportException; import org.wso2.carbon.databridge.commons.exception.UndefinedEventTypeException; import org.wso2.carbon.databridge.commons.utils.DataBridgeThreadFactory; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.DataEndpointConfiguration; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointAuthenticationException; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.DataEndpointConstants; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.DataEndpointConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointAuthenticationException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.DataEndpointConstants; import java.util.ArrayList; import java.util.List; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointConnectionWorker.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpointConnectionWorker.java similarity index 93% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointConnectionWorker.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpointConnectionWorker.java index b2ec0493b8..9650da0176 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointConnectionWorker.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpointConnectionWorker.java @@ -16,13 +16,13 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.DataEndpointConfiguration; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointAuthenticationException; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.DataEndpointConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointAuthenticationException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; /** * DataEndpoint Connection worker class implementation. diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointFailureCallback.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpointFailureCallback.java similarity index 93% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointFailureCallback.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpointFailureCallback.java index 92b325d5d3..e2333d835b 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointFailureCallback.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpointFailureCallback.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint; import org.wso2.carbon.databridge.commons.Event; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointGroup.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpointGroup.java similarity index 96% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointGroup.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpointGroup.java index b0c39ba668..34bd96b768 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/DataEndpointGroup.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/DataEndpointGroup.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint; import com.lmax.disruptor.BlockingWaitStrategy; import com.lmax.disruptor.EventHandler; @@ -28,11 +28,11 @@ import org.apache.logging.log4j.Logger; import org.wso2.carbon.databridge.commons.Event; import org.wso2.carbon.databridge.commons.utils.DataBridgeThreadFactory; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.DataEndpointAgent; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointConfigurationException; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.EventQueueFullException; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.DataEndpointConstants; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.DataPublisherUtil; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.DataEndpointAgent; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointConfigurationException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.EventQueueFullException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.DataEndpointConstants; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.DataPublisherUtil; import java.io.IOException; import java.net.Socket; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/EventPublisherThreadPoolExecutor.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/EventPublisherThreadPoolExecutor.java similarity index 96% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/EventPublisherThreadPoolExecutor.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/EventPublisherThreadPoolExecutor.java index aee1e1c7c6..6b881d3635 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/EventPublisherThreadPoolExecutor.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/EventPublisherThreadPoolExecutor.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint; import org.wso2.carbon.databridge.commons.utils.DataBridgeThreadFactory; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/WrappedEventFactory.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/WrappedEventFactory.java similarity index 94% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/WrappedEventFactory.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/WrappedEventFactory.java index 9527389638..1b86a5c7a1 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/WrappedEventFactory.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/WrappedEventFactory.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint; import com.lmax.disruptor.EventFactory; import org.wso2.carbon.databridge.commons.Event; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryClientPoolFactory.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinaryClientPoolFactory.java similarity index 83% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryClientPoolFactory.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinaryClientPoolFactory.java index cae9f58b38..8c7b515aff 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryClientPoolFactory.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinaryClientPoolFactory.java @@ -16,14 +16,14 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.AgentHolder; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.client.AbstractClientPoolFactory; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.DataEndpointConfiguration; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.AgentHolder; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.client.AbstractClientPoolFactory; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.DataEndpointConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; import java.io.IOException; import java.net.Socket; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryDataEndpoint.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinaryDataEndpoint.java similarity index 78% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryDataEndpoint.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinaryDataEndpoint.java index bc11cdcfe5..9002d56f48 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryDataEndpoint.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinaryDataEndpoint.java @@ -16,22 +16,22 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary; import org.wso2.carbon.databridge.commons.Event; import org.wso2.carbon.databridge.commons.exception.SessionTimeoutException; import org.wso2.carbon.databridge.commons.exception.UndefinedEventTypeException; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.DataEndpoint; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointAuthenticationException; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.DataEndpoint; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointAuthenticationException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; import java.net.Socket; import java.util.List; -import static org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary.BinaryEventSender.processResponse; -import static org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary.BinaryEventSender.sendBinaryLoginMessage; -import static org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary.BinaryEventSender.sendBinaryLogoutMessage; -import static org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary.BinaryEventSender.sendBinaryPublishMessage; +import static org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary.BinaryEventSender.processResponse; +import static org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary.BinaryEventSender.sendBinaryLoginMessage; +import static org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary.BinaryEventSender.sendBinaryLogoutMessage; +import static org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary.BinaryEventSender.sendBinaryPublishMessage; /** * This class is Binary transport implementation for the Data Endpoint. diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryEventSender.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinaryEventSender.java similarity index 98% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryEventSender.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinaryEventSender.java index 5da5333804..6f83d376e1 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinaryEventSender.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinaryEventSender.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary; import org.wso2.carbon.databridge.commons.Event; import org.wso2.carbon.databridge.commons.binary.BinaryMessageConstants; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinarySecureClientPoolFactory.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinarySecureClientPoolFactory.java similarity index 90% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinarySecureClientPoolFactory.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinarySecureClientPoolFactory.java index 3dfaa65359..b18898324a 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/endpoint/binary/BinarySecureClientPoolFactory.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/endpoint/binary/BinarySecureClientPoolFactory.java @@ -16,15 +16,15 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.endpoint.binary; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.endpoint.binary; import org.apache.http.conn.ssl.SSLContexts; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.AgentHolder; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.client.AbstractSecureClientPoolFactory; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.DataEndpointConfiguration; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.AgentHolder; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.client.AbstractSecureClientPoolFactory; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.DataEndpointConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; import java.io.IOException; import java.net.Socket; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointAuthenticationException.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/DataEndpointAuthenticationException.java similarity index 93% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointAuthenticationException.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/DataEndpointAuthenticationException.java index 617d851b59..d04ad0c64a 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointAuthenticationException.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/DataEndpointAuthenticationException.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception; /** * Exception to be thrown when connecting the Data Endpoint. diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointConfigurationException.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/DataEndpointConfigurationException.java similarity index 94% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointConfigurationException.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/DataEndpointConfigurationException.java index 1ec7f09a0e..273abfdc2a 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointConfigurationException.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/DataEndpointConfigurationException.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception; /** * Exception to be thrown When parsing the Data Endpoint configurations when initializing data publisher. diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointException.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/DataEndpointException.java similarity index 93% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointException.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/DataEndpointException.java index 1513f44458..12288d7278 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/DataEndpointException.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/DataEndpointException.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception; /** * Exception to be thrown when communicating with DataEndpoint. diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/EventQueueFullException.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/EventQueueFullException.java similarity index 94% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/EventQueueFullException.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/EventQueueFullException.java index 0210c12bdf..743a8e343e 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/exception/EventQueueFullException.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/exception/EventQueueFullException.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception; /** * Exception to be thrown when the event is tried to insert into the queue diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataEndpointConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/util/DataEndpointConstants.java similarity index 94% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataEndpointConstants.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/util/DataEndpointConstants.java index d5c0138903..2386486a5b 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataEndpointConstants.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/util/DataEndpointConstants.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util; /** * Class to define the constants that are used. diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataPublisherUtil.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/util/DataPublisherUtil.java similarity index 97% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataPublisherUtil.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/util/DataPublisherUtil.java index b95325b700..faed0b2fa9 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/DataPublisherUtil.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/util/DataPublisherUtil.java @@ -16,10 +16,10 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.conf.DataEndpointConfiguration; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointConfigurationException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.DataEndpointConfiguration; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointConfigurationException; import java.util.ArrayList; import java.util.regex.Matcher; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/ThrottleEventConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/util/ThrottleEventConstants.java similarity index 95% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/ThrottleEventConstants.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/util/ThrottleEventConstants.java index 8629a2b345..7c33314964 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/agent/util/ThrottleEventConstants.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/agent/util/ThrottleEventConstants.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util; +package org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util; /** * This class holds the constants required to fetch the properties from the ThrottleEvent. diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/DataProcessAndPublishingAgent.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/DataProcessAndPublishingAgent.java similarity index 95% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/DataProcessAndPublishingAgent.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/DataProcessAndPublishingAgent.java index b755a68038..f414384747 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/DataProcessAndPublishingAgent.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/DataProcessAndPublishingAgent.java @@ -16,13 +16,13 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.publisher; +package org.wso2.micro.gateway.enforcer.throttle.databridge.publisher; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.wso2.carbon.databridge.commons.Event; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.DataPublisher; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.ThrottleEventConstants; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.DataPublisher; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.ThrottleEventConstants; import java.util.Map; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/DataPublisherConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/DataPublisherConstants.java similarity index 94% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/DataPublisherConstants.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/DataPublisherConstants.java index ea794942e5..cb08c1afa9 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/DataPublisherConstants.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/DataPublisherConstants.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.publisher; +package org.wso2.micro.gateway.enforcer.throttle.databridge.publisher; /** * Class to define the constants for Data Agent. diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/PublisherConfiguration.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/PublisherConfiguration.java similarity index 98% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/PublisherConfiguration.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/PublisherConfiguration.java index a3e05a2325..6519173a16 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/PublisherConfiguration.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/PublisherConfiguration.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.publisher; +package org.wso2.micro.gateway.enforcer.throttle.databridge.publisher; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/ThrottleDataPublisher.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/ThrottleDataPublisher.java similarity index 91% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/ThrottleDataPublisher.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/ThrottleDataPublisher.java index f01acd5da6..13b7f15ef5 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/ThrottleDataPublisher.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/ThrottleDataPublisher.java @@ -16,16 +16,16 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.publisher; +package org.wso2.micro.gateway.enforcer.throttle.databridge.publisher; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.wso2.carbon.databridge.commons.exception.TransportException; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.DataPublisher; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointAuthenticationException; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointConfigurationException; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.exception.DataEndpointException; -import org.wso2.micro.gateway.enforcer.globalthrottle.databridge.agent.util.ThrottleEventConstants; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.DataPublisher; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointAuthenticationException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointConfigurationException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.exception.DataEndpointException; +import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.ThrottleEventConstants; import java.text.SimpleDateFormat; import java.util.Date; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/ThrottleDataPublisherPool.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/ThrottleDataPublisherPool.java similarity index 97% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/ThrottleDataPublisherPool.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/ThrottleDataPublisherPool.java index 68cbfc3052..a8257ac946 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/globalthrottle/databridge/publisher/ThrottleDataPublisherPool.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/databridge/publisher/ThrottleDataPublisherPool.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.globalthrottle.databridge.publisher; +package org.wso2.micro.gateway.enforcer.throttle.databridge.publisher; import org.apache.commons.pool.BasePoolableObjectFactory; import org.apache.commons.pool.ObjectPool; From cec8e6f3c1bbe0001196a284ab618745f3e79011 Mon Sep 17 00:00:00 2001 From: Praminda Jayawardana Date: Thu, 4 Mar 2021 10:55:04 +0530 Subject: [PATCH 09/21] thrtl: enf: Add dummy throttle listener --- .../security/jwt/JWTAuthenticator.java | 6 +- .../gateway/enforcer/server/AuthServer.java | 4 +- .../throttle/ThrottleEventListener.java | 137 ++++++++++++++++++ 3 files changed, 142 insertions(+), 5 deletions(-) create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTAuthenticator.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTAuthenticator.java index 1b647a2ceb..3000fe10e7 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTAuthenticator.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/jwt/JWTAuthenticator.java @@ -118,11 +118,9 @@ public AuthenticationContext authenticate(RequestContext requestContext) throws } - JWTValidationInfo validationInfo = - getJwtValidationInfo(signedJWTInfo, jwtTokenIdentifier); + JWTValidationInfo validationInfo = getJwtValidationInfo(signedJWTInfo, jwtTokenIdentifier); if (validationInfo != null) { if (validationInfo.isValid()) { - // Validate subscriptions APIKeyValidationInfoDTO apiKeyValidationInfoDTO = null; EnforcerConfig configuration = ConfigHolder.getInstance().getConfig(); @@ -162,7 +160,7 @@ public AuthenticationContext authenticate(RequestContext requestContext) throws try { // Set public certificate jwtConfigurationDto.setPublicCert(TLSUtils.getCertificate()); - //Set private key + // Set private key jwtConfigurationDto.setPrivateKey(JWTUtil.getPrivateKey()); } catch (MGWException | CertificateException | IOException e) { throw new APISecurityException(APIConstants.StatusCodes.UNAUTHENTICATED.getCode(), diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java index 9bada735c1..386dcc3085 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java @@ -32,10 +32,11 @@ import org.wso2.micro.gateway.enforcer.common.CacheProvider; import org.wso2.micro.gateway.enforcer.config.ConfigHolder; import org.wso2.micro.gateway.enforcer.config.dto.AuthServiceConfigurationDto; -import org.wso2.micro.gateway.enforcer.throttle.ThrottleAgent; import org.wso2.micro.gateway.enforcer.grpc.ExtAuthService; import org.wso2.micro.gateway.enforcer.grpc.interceptors.AccessLogInterceptor; import org.wso2.micro.gateway.enforcer.subscription.SubscriptionDataHolder; +import org.wso2.micro.gateway.enforcer.throttle.ThrottleAgent; +import org.wso2.micro.gateway.enforcer.throttle.ThrottleEventListener; import java.io.File; import java.io.IOException; @@ -64,6 +65,7 @@ public static void main(String[] args) { // TODO: (Praminda) do this only if throttling is enabled // ConfigHolder.getInstance().getConfig().getThrottleAgentConfig().isEnabled() ThrottleAgent.startThrottlePublisherPool(); + ThrottleEventListener.init(); // Start the server server.start(); diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java new file mode 100644 index 0000000000..fa98f17900 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.throttle; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.micro.gateway.enforcer.constants.APIConstants; + +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import javax.jms.JMSException; +import javax.jms.MapMessage; +import javax.jms.Message; +import javax.jms.MessageListener; +import javax.jms.Topic; +import javax.jms.TopicConnection; +import javax.jms.TopicConnectionFactory; +import javax.jms.TopicSession; +import javax.jms.TopicSubscriber; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; + +/** + * JMS event listener for throttle data. + */ +public class ThrottleEventListener implements MessageListener { + private static final Log log = LogFactory.getLog(ThrottleEventListener.class); + + private ThrottleEventListener() {} + + public static void init() { + String initialContextFactory = "org.wso2.andes.jndi.PropertiesFileInitialContextFactory"; + String connectionFactoryNamePrefix = "connectionfactory."; + String connectionFactoryName = "qpidConnectionfactory"; + String eventReceiverURL = "amqp://admin:admin@clientid/carbon?brokerlist='tcp://localhost:5672'"; + Runnable runnable = () -> { + try { + TopicConnection topicConnection; + TopicSession topicSession; + Properties properties = new Properties(); + properties.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory); + properties.put(connectionFactoryNamePrefix + connectionFactoryName, eventReceiverURL); + InitialContext context = new InitialContext(properties); + TopicConnectionFactory connFactory = (TopicConnectionFactory) context.lookup(connectionFactoryName); + topicConnection = connFactory.createTopicConnection(); + topicConnection.start(); + topicSession = topicConnection.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE); + Topic gatewayJmsTopic = topicSession.createTopic("throttleData"); + TopicSubscriber listener = topicSession.createSubscriber(gatewayJmsTopic); + listener.setMessageListener(new ThrottleEventListener()); + } catch (NamingException | JMSException e) { + log.error("Error while initiating jms connection...", e); + } + }; + Thread jmsThread = new Thread(runnable); + jmsThread.start(); + } + + @Override + public void onMessage(Message message) { + if (message == null) { + log.warn("Dropping the empty/null event received through jms receiver"); + return; + } else if (!(message instanceof MapMessage)) { + log.warn("Event dropped due to unsupported message type " + message.getClass()); + return; + } + + if (log.isDebugEnabled()) { + log.debug("Event received in JMS Event Receiver - " + message); + } + + try { + Topic jmsDestination = (Topic) message.getJMSDestination(); + MapMessage mapMessage = (MapMessage) message; + Map map = new HashMap(); + Enumeration enumeration = mapMessage.getMapNames(); + while (enumeration.hasMoreElements()) { + String key = (String) enumeration.nextElement(); + map.put(key, mapMessage.getObject(key)); + } + + if (APIConstants.TopicNames.TOPIC_THROTTLE_DATA.equalsIgnoreCase(jmsDestination.getTopicName())) { + if (map.get(APIConstants.THROTTLE_KEY) != null) { + /* + * This message contains throttle data in map which contains Keys + * throttleKey - Key of particular throttling level + * isThrottled - Whether message has throttled or not + * expiryTimeStamp - When the throttling time window will expires + */ + + log.info("Event THROTTLE_KEY received in JMS Event Receiver - " + message); +// handleThrottleUpdateMessage(map); + } else if (map.get(APIConstants.BLOCKING_CONDITION_KEY) != null) { + /* + * This message contains blocking condition data + * blockingCondition - Blocking condition type + * conditionValue - blocking condition value + * state - State whether blocking condition is enabled or not + */ + log.info("Event BLOCKING_CONDITION_KEY received in JMS Event Receiver - " + message); +// handleBlockingMessage(map); + } else if (map.get(APIConstants.POLICY_TEMPLATE_KEY) != null) { + /* + * This message contains key template data + * keyTemplateValue - Value of key template + * keyTemplateState - whether key template active or not + */ + log.info("Event POLICY_TEMPLATE_KEY received in JMS Event Receiver - " + message); +// handleKeyTemplateMessage(map); + } + } + } catch (JMSException e) { + log.error("Error occurred when processing the received message ", e); + } + } +} From c747727424b782321b82bae5abbfc1713607a2c1 Mon Sep 17 00:00:00 2001 From: Praminda Jayawardana Date: Fri, 5 Mar 2021 11:51:36 +0530 Subject: [PATCH 10/21] thrtl: Listen and store throttle data Listen to throttle data messages and populate the required DTOs for throttling. --- .../enforcer/constants/APIConstants.java | 14 +- .../enforcer/throttle/APICondition.java | 40 ++++ .../enforcer/throttle/PolicyConstants.java | 30 +++ .../enforcer/throttle/ThrottleCondition.java | 205 ++++++++++++++++++ .../enforcer/throttle/ThrottleDataHolder.java | 108 +++++++++ .../throttle/ThrottleEventListener.java | 100 +++++++-- .../enforcer/throttle/ThrottleUtils.java | 125 +++++++++++ 7 files changed, 597 insertions(+), 25 deletions(-) create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/APICondition.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/PolicyConstants.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleCondition.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleDataHolder.java create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleUtils.java diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java index e8fbe8e9a0..2b96693afc 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java @@ -35,7 +35,6 @@ public class APIConstants { public static final String GW_VERSION_PARAM = "version"; public static final String GW_API_NAME_PARAM = "name"; - public static final String GATEWAY_SIGNED_JWT_CACHE = "SignedJWTParseCache"; public static final String GATEWAY_PUBLIC_CERTIFICATE_ALIAS = "wso2carbon"; public static final String HTTPS_PROTOCOL = "https"; @@ -69,6 +68,8 @@ public class APIConstants { public static final String APPLICATION_JSON = "application/json"; public static final String API_TRACE_KEY = "X-TRACE-KEY"; + public static final String THROTTLE_KEY = "throttleKey"; + /** * Holds the common set of constants related to the output status codes of the security validations. */ @@ -248,4 +249,15 @@ public int getCode() { return this.code; } } + + /** + * Advanced Throttling related constants. + */ + public static class AdvancedThrottleConstants { + public static final String IS_THROTTLED = "isThrottled"; + public static final String THROTTLE_KEY = "throttleKey"; + public static final String EXPIRY_TIMESTAMP = "expiryTimeStamp"; + public static final String EVALUATED_CONDITIONS = "evaluatedConditions"; + public static final String TRUE = "true"; + } } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/APICondition.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/APICondition.java new file mode 100644 index 0000000000..9c5a5f37bd --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/APICondition.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.throttle; + +/** + * DTO of parameters defining a throttle condition. + */ +public class APICondition { + private final String resourceKey; + private final String name; + + public APICondition(String resourceKey, String name) { + this.resourceKey = resourceKey; + this.name = name; + } + + public String getResourceKey() { + return resourceKey; + } + + public String getName() { + return name; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/PolicyConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/PolicyConstants.java new file mode 100644 index 0000000000..388f3dfccd --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/PolicyConstants.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.throttle; + +/** + * Throttle policy constants. + */ +public class PolicyConstants { + public static final String IP_RANGE_TYPE = "IPRange"; + public static final String IP_SPECIFIC_TYPE = "IPSpecific"; + public static final String HEADER_TYPE = "Header"; + public static final String JWT_CLAIMS_TYPE = "JWTClaims"; + public static final String QUERY_PARAMETER_TYPE = "QueryParameterType"; +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleCondition.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleCondition.java new file mode 100644 index 0000000000..1e21b7d14b --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleCondition.java @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.throttle; + +import java.math.BigInteger; +import java.util.HashMap; +import java.util.Map; + +/** + * Defines the applicable conditions and the types of conditions for a conditional throttle policy. + */ +public class ThrottleCondition { + private IPCondition ipCondition; + private IPCondition ipRangeCondition; + private HeaderConditions headerConditions; + private QueryParamConditions queryParameterConditions; + private JWTClaimConditions jwtClaimConditions; + + public IPCondition getIpCondition() { + return ipCondition; + } + + public void setIpCondition(IPCondition ipCondition) { + this.ipCondition = ipCondition; + } + + public IPCondition getIpRangeCondition() { + return ipRangeCondition; + } + + public void setIpRangeCondition(IPCondition ipRangeCondition) { + this.ipRangeCondition = ipRangeCondition; + } + + public HeaderConditions getHeaderConditions() { + return headerConditions; + } + + public void setHeaderConditions(HeaderConditions headerConditions) { + this.headerConditions = headerConditions; + } + + public QueryParamConditions getQueryParameterConditions() { + return queryParameterConditions; + } + + public void setQueryParameterConditions(QueryParamConditions queryParameterConditions) { + this.queryParameterConditions = queryParameterConditions; + } + + public JWTClaimConditions getJwtClaimConditions() { + return jwtClaimConditions; + } + + public void setJwtClaimConditions(JWTClaimConditions jwtClaimConditions) { + this.jwtClaimConditions = jwtClaimConditions; + } + + /** + * Throttle condition based on request headers. + */ + public static class HeaderConditions { + private Map values = new HashMap<>(); + private boolean invert; + + public Map getValues() { + return values; + } + + public void setValues(Map values) { + this.values = values; + } + + public boolean isInvert() { + return invert; + } + + public void setInvert(boolean invert) { + this.invert = invert; + } + } + + /** + * Throttle condition based on request query parameters. + */ + public static class QueryParamConditions { + private Map values = new HashMap<>(); + private boolean invert; + + public Map getValues() { + return values; + } + + public void setValues(Map values) { + this.values = values; + } + + public boolean isInvert() { + return invert; + } + + public void setInvert(boolean invert) { + this.invert = invert; + } + } + + /** + * Throttle condition based on jwt claim conditions. + */ + public static class JWTClaimConditions { + private Map values = new HashMap<>(); + private boolean invert; + + public Map getValues() { + return values; + } + + public void setValues(Map values) { + this.values = values; + } + + public boolean isInvert() { + return invert; + } + + public void setInvert(boolean invert) { + this.invert = invert; + } + } + + /** + * Throttle condition based on request IP address. + */ + public static class IPCondition { + private BigInteger specificIp; + private BigInteger startingIp; + private BigInteger endingIp; + private boolean invert; + + public IPCondition() { + + } + + public IPCondition(BigInteger specificIp, boolean invert) { + + this.specificIp = specificIp; + this.invert = invert; + } + + public IPCondition(BigInteger startingIp, BigInteger endingIp, boolean invert) { + + this.startingIp = startingIp; + this.endingIp = endingIp; + this.invert = invert; + } + + public BigInteger getSpecificIp() { + return specificIp; + } + + public void setSpecificIp(BigInteger specificIp) { + this.specificIp = specificIp; + } + + public BigInteger getStartingIp() { + return startingIp; + } + + public void setStartingIp(BigInteger startingIp) { + this.startingIp = startingIp; + } + + public BigInteger getEndingIp() { + return endingIp; + } + + public void setEndingIp(BigInteger endingIp) { + this.endingIp = endingIp; + } + + public boolean isInvert() { + return invert; + } + + public void setInvert(boolean invert) { + this.invert = invert; + } + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleDataHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleDataHolder.java new file mode 100644 index 0000000000..263a53987c --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleDataHolder.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.throttle; + + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * This class holds throttle data per given node. In addition to holding throttle data if provides + * required methods to evaluate throttle state of a given throttling key. + */ +public class ThrottleDataHolder { + private static final Log log = LogFactory.getLog(ThrottleDataHolder.class); + + private final Map throttleDataMap; + private static ThrottleDataHolder instance; + private final Map>> conditionDtoMap = new ConcurrentHashMap<>(); + + private ThrottleDataHolder() { + throttleDataMap = new ConcurrentHashMap(); + } + + public static ThrottleDataHolder getInstance() { + if (instance == null) { + instance = new ThrottleDataHolder(); + } + + return instance; + } + + /** + * Add throttle conditions to the Throttle Conditions map. + * + * @param key throttle key + * @param conditionKey condition key + * @param conditionValue conditions to be added to the map + */ + public void addThrottledConditions(String key, String conditionKey, List conditionValue) { + + Map> conditionMap; + if (conditionDtoMap.containsKey(key)) { + conditionMap = conditionDtoMap.get(key); + } else { + conditionMap = new ConcurrentHashMap<>(); + conditionDtoMap.put(key, conditionMap); + } + if (!conditionMap.containsKey(conditionKey)) { + conditionMap.put(conditionKey, conditionValue); + } + } + + /** + * Remove throttle conditions from the Throttle Conditions map. + * + * @param key throttle key + * @param conditionKey condition key to be removed + */ + public void removeThrottledConditions(String key, String conditionKey) { + if (conditionDtoMap.containsKey(key)) { + Map> conditionMap = conditionDtoMap.get(key); + conditionMap.remove(conditionKey); + if (conditionMap.isEmpty()) { + conditionDtoMap.remove(key); + } + } + } + + /** + * Add new throttle data item to the throttle data map. + * + * @param key throttle key to be added + * @param timestamp throttle timestamp + */ + public void addThrottleData(String key, Long timestamp) { + throttleDataMap.put(key, timestamp); + } + + /** + * Remove throttle data item from the throttle data map. + * + * @param key throttle key to be removed + */ + public void removeThrottleData(String key) { + throttleDataMap.remove(key); + } + +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java index fa98f17900..f80ab3a06b 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java @@ -22,10 +22,14 @@ import org.apache.commons.logging.LogFactory; import org.wso2.micro.gateway.enforcer.constants.APIConstants; +import java.util.Date; import java.util.Enumeration; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.jms.JMSException; import javax.jms.MapMessage; @@ -46,6 +50,15 @@ public class ThrottleEventListener implements MessageListener { private static final Log log = LogFactory.getLog(ThrottleEventListener.class); + // These patterns will be used to determine for which type of keys the throttling condition has occurred. + private final Pattern apiPattern = Pattern.compile("/.*/(.*):\\1_(condition_(\\d*)|default)"); + private static final int API_PATTERN_GROUPS = 3; + private static final int API_PATTERN_CONDITION_INDEX = 2; + + private final Pattern resourcePattern = Pattern.compile("/.*/(.*)/\\1(.*)?:[A-Z]{0,7}_(condition_(\\d*)|default)"); + public static final int RESOURCE_PATTERN_GROUPS = 4; + public static final int RESOURCE_PATTERN_CONDITION_INDEX = 3; + private ThrottleEventListener() {} public static void init() { @@ -86,14 +99,10 @@ public void onMessage(Message message) { return; } - if (log.isDebugEnabled()) { - log.debug("Event received in JMS Event Receiver - " + message); - } - try { Topic jmsDestination = (Topic) message.getJMSDestination(); MapMessage mapMessage = (MapMessage) message; - Map map = new HashMap(); + Map map = new HashMap<>(); Enumeration enumeration = mapMessage.getMapNames(); while (enumeration.hasMoreElements()) { String key = (String) enumeration.nextElement(); @@ -109,29 +118,72 @@ public void onMessage(Message message) { * expiryTimeStamp - When the throttling time window will expires */ - log.info("Event THROTTLE_KEY received in JMS Event Receiver - " + message); -// handleThrottleUpdateMessage(map); - } else if (map.get(APIConstants.BLOCKING_CONDITION_KEY) != null) { - /* - * This message contains blocking condition data - * blockingCondition - Blocking condition type - * conditionValue - blocking condition value - * state - State whether blocking condition is enabled or not - */ - log.info("Event BLOCKING_CONDITION_KEY received in JMS Event Receiver - " + message); -// handleBlockingMessage(map); - } else if (map.get(APIConstants.POLICY_TEMPLATE_KEY) != null) { - /* - * This message contains key template data - * keyTemplateValue - Value of key template - * keyTemplateState - whether key template active or not - */ - log.info("Event POLICY_TEMPLATE_KEY received in JMS Event Receiver - " + message); -// handleKeyTemplateMessage(map); + handleThrottleUpdateMessage(map); } } } catch (JMSException e) { log.error("Error occurred when processing the received message ", e); } } + + private void handleThrottleUpdateMessage(Map map) { + String throttleKey = map.get(APIConstants.AdvancedThrottleConstants.THROTTLE_KEY).toString(); + String throttleState = map.get(APIConstants.AdvancedThrottleConstants.IS_THROTTLED).toString(); + long timeStamp = Long.parseLong(map.get(APIConstants.AdvancedThrottleConstants.EXPIRY_TIMESTAMP).toString()); + Object evaluatedConditionObject = map.get(APIConstants.AdvancedThrottleConstants.EVALUATED_CONDITIONS); + ThrottleDataHolder dataHolder = ThrottleDataHolder.getInstance(); + + if (log.isDebugEnabled()) { + log.debug("Received event - throttleKey : " + throttleKey + ", isThrottled: " + + throttleState + ", expiryTime: " + new Date(timeStamp).toString()); + } + + if (APIConstants.AdvancedThrottleConstants.TRUE.equalsIgnoreCase(throttleState)) { + dataHolder.addThrottleData(throttleKey, timeStamp); + APICondition extractedKey = extractAPIorResourceKey(throttleKey); + if (log.isDebugEnabled()) { + log.debug("Adding throttling key : " + extractedKey); + } + + if (extractedKey != null) { + if (evaluatedConditionObject != null) { + String conditionStr = (String) evaluatedConditionObject; + List conditions = ThrottleUtils.extractThrottleCondition(conditionStr); + dataHolder.addThrottledConditions(extractedKey.getResourceKey(), extractedKey.getName(), + conditions); + } + } + } else { + dataHolder.removeThrottleData(throttleKey); + APICondition extractedKey = extractAPIorResourceKey(throttleKey); + if (extractedKey != null) { + if (log.isDebugEnabled()) { + log.debug("Removing throttling key : " + extractedKey.getResourceKey()); + } + + dataHolder.removeThrottledConditions(extractedKey.getResourceKey(), extractedKey.getName()); + } + } + } + + private APICondition extractAPIorResourceKey(String throttleKey) { + Matcher m = resourcePattern.matcher(throttleKey); + if (m.matches()) { + if (m.groupCount() == RESOURCE_PATTERN_GROUPS) { + String condition = m.group(RESOURCE_PATTERN_CONDITION_INDEX); + String resourceKey = throttleKey.substring(0, throttleKey.indexOf("_" + condition)); + return new APICondition(resourceKey, condition); + } + } else { + m = apiPattern.matcher(throttleKey); + if (m.matches()) { + if (m.groupCount() == API_PATTERN_GROUPS) { + String condition = m.group(API_PATTERN_CONDITION_INDEX); + String resourceKey = throttleKey.substring(0, throttleKey.indexOf("_" + condition)); + return new APICondition(resourceKey, condition); + } + } + } + return null; + } } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleUtils.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleUtils.java new file mode 100644 index 0000000000..f3172eb07f --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleUtils.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.throttle; + +import com.google.gson.Gson; +import org.apache.commons.codec.binary.Base64; +import org.json.JSONArray; +import org.json.JSONObject; +import org.json.JSONTokener; + +import java.util.ArrayList; +import java.util.List; + +/** + * Utilities related to throttling. + */ +public class ThrottleUtils { + + /** + * Extract a {@code ThrottleCondition} from a provided compatible base64 encoded string. + * + * @param base64EncodedString base64 encoded string containing a json in compatible format + * @return list of extracted {@code ThrottleCondition}s + */ + public static List extractThrottleCondition(String base64EncodedString) { + + List conditionDtoList = new ArrayList<>(); + String base64Decoded = new String(Base64.decodeBase64(base64EncodedString)); + JSONTokener tokener = new JSONTokener(base64Decoded); + JSONArray conditionJsonArray = new JSONArray(tokener); + for (Object conditionJson : conditionJsonArray) { + ThrottleCondition conditionDto = new ThrottleCondition(); + JSONObject conditionJsonObject = (JSONObject) conditionJson; + if (conditionJsonObject.has(PolicyConstants.IP_SPECIFIC_TYPE.toLowerCase())) { + JSONObject ipSpecificCondition = (JSONObject) conditionJsonObject.get(PolicyConstants.IP_SPECIFIC_TYPE + .toLowerCase()); + ThrottleCondition.IPCondition ipCondition = new Gson().fromJson(ipSpecificCondition.toString(), + ThrottleCondition.IPCondition.class); + conditionDto.setIpCondition(ipCondition); + } else if (conditionJsonObject.has(PolicyConstants.IP_RANGE_TYPE.toLowerCase())) { + JSONObject ipRangeCondition = (JSONObject) conditionJsonObject.get(PolicyConstants.IP_RANGE_TYPE + .toLowerCase()); + ThrottleCondition.IPCondition ipCondition = new Gson().fromJson(ipRangeCondition.toString(), + ThrottleCondition.IPCondition.class); + conditionDto.setIpRangeCondition(ipCondition); + } + if (conditionJsonObject.has(PolicyConstants.JWT_CLAIMS_TYPE.toLowerCase())) { + JSONObject jwtClaimConditions = (JSONObject) conditionJsonObject.get(PolicyConstants.JWT_CLAIMS_TYPE + .toLowerCase()); + ThrottleCondition.JWTClaimConditions jwtClaimCondition = new Gson().fromJson(jwtClaimConditions + .toString(), ThrottleCondition.JWTClaimConditions.class); + conditionDto.setJwtClaimConditions(jwtClaimCondition); + } + if (conditionJsonObject.has(PolicyConstants.HEADER_TYPE.toLowerCase())) { + JSONObject headerConditionJson = (JSONObject) conditionJsonObject.get(PolicyConstants.HEADER_TYPE + .toLowerCase()); + ThrottleCondition.HeaderConditions headerConditions = new Gson().fromJson(headerConditionJson + .toString(), ThrottleCondition.HeaderConditions.class); + conditionDto.setHeaderConditions(headerConditions); + } + + if (conditionJsonObject.has(PolicyConstants.QUERY_PARAMETER_TYPE.toLowerCase())) { + JSONObject queryParamConditionJson = (JSONObject) conditionJsonObject.get(PolicyConstants + .QUERY_PARAMETER_TYPE.toLowerCase()); + ThrottleCondition.QueryParamConditions queryParamCondition = new Gson().fromJson(queryParamConditionJson + .toString(), ThrottleCondition.QueryParamConditions.class); + conditionDto.setQueryParameterConditions(queryParamCondition); + } + conditionDtoList.add(conditionDto); + } + conditionDtoList.sort((o1, o2) -> { + + if (o1.getIpCondition() != null && o2.getIpCondition() == null) { + return -1; + } else if (o1.getIpCondition() == null && o2.getIpCondition() != null) { + return 1; + } else { + if (o1.getIpRangeCondition() != null && o2.getIpRangeCondition() == null) { + return -1; + } else if (o1.getIpRangeCondition() == null && o2.getIpRangeCondition() != null) { + return 1; + } else { + if (o1.getHeaderConditions() != null && o2.getHeaderConditions() == null) { + return -1; + } else if (o1.getHeaderConditions() == null && o2.getHeaderConditions() != null) { + return 1; + } else { + if (o1.getQueryParameterConditions() != null && o2.getQueryParameterConditions() == null) { + return -1; + } else if (o1.getQueryParameterConditions() == null && o2.getQueryParameterConditions() + != null) { + return 1; + } else { + if (o1.getJwtClaimConditions() != null && o2.getJwtClaimConditions() == null) { + return -1; + } else if (o1.getJwtClaimConditions() == null && o2.getJwtClaimConditions() != null) { + return 1; + } + } + } + } + } + return 0; + }); + + return conditionDtoList; + } + +} From 1af1b668afd407c3571bc1e26c9275a0e29b0e5e Mon Sep 17 00:00:00 2001 From: Praminda Jayawardana Date: Wed, 10 Mar 2021 09:28:20 +0530 Subject: [PATCH 11/21] throttle: enf: Add basic sub/app throttling inSecure scenario is not handled yet --- .../enforcer/constants/APIConstants.java | 4 +- .../constants/APISecurityConstants.java | 13 -- .../enforcer/filters/ThrottleFilter.java | 135 ++++++++++++++++-- .../gateway/enforcer/server/AuthServer.java | 7 +- .../enforcer/throttle/APICondition.java | 5 + .../enforcer/throttle/ThrottleConstants.java | 46 ++++++ .../enforcer/throttle/ThrottleDataHolder.java | 29 +++- .../throttle/ThrottleEventListener.java | 11 +- 8 files changed, 211 insertions(+), 39 deletions(-) create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleConstants.java diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java index 2b96693afc..0e9cf4cb39 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java @@ -69,6 +69,7 @@ public class APIConstants { public static final String API_TRACE_KEY = "X-TRACE-KEY"; public static final String THROTTLE_KEY = "throttleKey"; + public static final String THROTTLE_OUT_REASON = "THROTTLED_OUT_REASON"; /** * Holds the common set of constants related to the output status codes of the security validations. @@ -232,7 +233,8 @@ public enum StatusCodes { OK("200", 200), UNAUTHENTICATED("401", 401), UNAUTHORIZED("403", 403), - NOTFOUND("404", 404); + NOTFOUND("404", 404), + THROTTLED("429", 429); private String value; private int code; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APISecurityConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APISecurityConstants.java index 0347a9699e..635c3121e3 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APISecurityConstants.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APISecurityConstants.java @@ -69,19 +69,6 @@ public class APISecurityConstants { public static final int API_AUTH_MISSING_OPEN_API_DEF = 900911; public static final String API_AUTH_MISSING_OPEN_API_DEF_ERROR_MESSAGE = "Internal Server Error"; - public static final int GRAPHQL_QUERY_TOO_DEEP = 900912; - public static final String GRAPHQL_QUERY_TOO_DEEP_MESSAGE = "QUERY TOO DEEP"; - - public static final int GRAPHQL_QUERY_TOO_COMPLEX = 900913; - public static final String GRAPHQL_QUERY_TOO_COMPLEX_MESSAGE = "QUERY TOO COMPLEX"; - - public static final int GRAPHQL_INVALID_QUERY = 900422; - public static final String GRAPHQL_API_FAILURE_HANDLER = "_graphql_failure_handler"; - public static final String GRAPHQL_INVALID_QUERY_MESSAGE = "INVALID QUERY"; - - public static final int OAUTH_TEMPORARY_SERVER_ERROR = 900424; - public static final String OAUTH_TEMPORARY_SERVER_ERROR_MESSAGE = "Temporary Server Error"; - // We have added this because we need to add an additional description to the original one and we need to // separate the 2 messages public static final String DESCRIPTION_SEPARATOR = ". "; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java index 6950de977e..cf5067dd67 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java @@ -24,10 +24,13 @@ import org.wso2.micro.gateway.enforcer.api.RequestContext; import org.wso2.micro.gateway.enforcer.api.config.APIConfig; import org.wso2.micro.gateway.enforcer.api.config.ResourceConfig; +import org.wso2.micro.gateway.enforcer.config.ConfigHolder; import org.wso2.micro.gateway.enforcer.constants.APIConstants; +import org.wso2.micro.gateway.enforcer.security.AuthenticationContext; import org.wso2.micro.gateway.enforcer.throttle.ThrottleAgent; +import org.wso2.micro.gateway.enforcer.throttle.ThrottleConstants; +import org.wso2.micro.gateway.enforcer.throttle.ThrottleDataHolder; import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.util.ThrottleEventConstants; -import org.wso2.micro.gateway.enforcer.security.AuthenticationContext; import org.wso2.micro.gateway.enforcer.util.FilterUtils; import java.net.Inet4Address; @@ -42,20 +45,108 @@ */ public class ThrottleFilter implements Filter { private static final Logger log = LogManager.getLogger(ThrottleFilter.class); - private APIConfig apiConfig; - @Override - public void init(APIConfig apiConfig) { - this.apiConfig = apiConfig; + private final boolean isGlobalThrottlingEnabled; + private final ThrottleDataHolder dataHolder; + + public ThrottleFilter() { + this.dataHolder = ThrottleDataHolder.getInstance(); + this.isGlobalThrottlingEnabled = ConfigHolder.getInstance().getConfig().getThrottleAgentConfig().isEnabled(); } + @Override + public void init(APIConfig apiConfig) {} + @Override public boolean handleRequest(RequestContext requestContext) { - log.info("handle request called"); + log.debug("Throttle filter received the request"); + + if (doThrottle(requestContext)) { + // breaking filter chain since request is throttled + return false; + } + + // publish throttle event and continue the filter chain ThrottleAgent.publishNonThrottledEvent(getThrottleEventMap(requestContext)); return true; } + /** + * Evaluate the throttle policies to find out if the request is throttled at any supported throttling level. + * + * @param reqContext request context with all request related details, + * including the authentication details + * @return {@code true} if the request is throttled, otherwise {@code false} + */ + private boolean doThrottle(RequestContext reqContext) { + AuthenticationContext authContext = reqContext.getAuthenticationContext(); + + // TODO: (Praminda) Handle unauthenticated + subscription validation false scenarios + if (reqContext.getAuthenticationContext() != null) { + log.debug("Found AuthenticationContext for the request"); + APIConfig api = reqContext.getMathedAPI().getAPIConfig(); + String apiContext = api.getBasePath(); + String apiVersion = api.getVersion(); + String appId = authContext.getApplicationId(); + String apiTier = authContext.getApiTier(); + String apiThrottleKey = getApiThrottleKey(apiContext, apiVersion); + String resourceTier = getResourceTier(reqContext.getMatchedResourcePath()); + String resourceThrottleKey = getResourceThrottleKey(reqContext, apiContext, apiVersion); + String subTier = authContext.getTier(); + String appTier = authContext.getApplicationTier(); + + String subThrottleKey = getSubscriptionThrottleKey(appId, apiContext, apiVersion); + boolean isSubscriptionThrottled = isSubscriptionLevelThrottled(subThrottleKey, subTier); + if (isSubscriptionThrottled) { + if (authContext.isStopOnQuotaReach()) { + log.debug("Setting subscription throttle out response"); + reqContext.getProperties().put(APIConstants.MessageFormat.ERROR_CODE, + ThrottleConstants.SUBSCRIPTION_THROTTLE_OUT_ERROR_CODE); + reqContext.getProperties().put(APIConstants.MessageFormat.STATUS_CODE, + APIConstants.StatusCodes.THROTTLED.getCode()); + reqContext.getProperties().put(APIConstants.MessageFormat.ERROR_MESSAGE, + ThrottleConstants.THROTTLE_OUT_MESSAGE); + reqContext.getProperties().put(APIConstants.MessageFormat.ERROR_DESCRIPTION, + ThrottleConstants.THROTTLE_OUT_DESCRIPTION); + reqContext.getProperties().put(APIConstants.THROTTLE_OUT_REASON, + ThrottleConstants.THROTTLE_OUT_REASON_SUBSCRIPTION_LIMIT_EXCEEDED); + return true; + } + log.debug("Proceeding since stopOnQuotaReach is false"); + } + + String appThrottleKey = appId + ':' + authContext.getUsername(); + boolean isAppThrottled = isAppLevelThrottled(appThrottleKey, appTier); + if (isAppThrottled) { + log.debug("Setting application throttle out response"); + reqContext.getProperties().put(APIConstants.MessageFormat.ERROR_CODE, + ThrottleConstants.APPLICATION_THROTTLE_OUT_ERROR_CODE); + reqContext.getProperties().put(APIConstants.MessageFormat.STATUS_CODE, + APIConstants.StatusCodes.THROTTLED.getCode()); + reqContext.getProperties().put(APIConstants.MessageFormat.ERROR_MESSAGE, + ThrottleConstants.THROTTLE_OUT_MESSAGE); + reqContext.getProperties().put(APIConstants.MessageFormat.ERROR_DESCRIPTION, + ThrottleConstants.THROTTLE_OUT_DESCRIPTION); + reqContext.getProperties().put(APIConstants.THROTTLE_OUT_REASON, + ThrottleConstants.THROTTLE_OUT_REASON_APPLICATION_LIMIT_EXCEEDED); + return true; + } + } + return false; + } + + private boolean isSubscriptionLevelThrottled(String throttleKey, String tier) { + boolean isThrottled = dataHolder.isThrottled(throttleKey); + log.debug("Subscription Level throttle decision is {} for key:tier {}:{}", isThrottled, throttleKey, tier); + return isThrottled; + } + + private boolean isAppLevelThrottled(String throttleKey, String tier) { + boolean isThrottled = dataHolder.isThrottled(throttleKey); + log.debug("Application Level throttle decision is {} for key:tier {}:{}", isThrottled, throttleKey, tier); + return isThrottled; + } + //TODO (amaliMatharaarachchi) Add default values to keys. // Handle fault invocations. // Test all flows. @@ -72,7 +163,7 @@ private Map getThrottleEventMap(RequestContext requestContext) { String basePath = requestContext.getMathedAPI().getAPIConfig().getBasePath(); String apiVersion = requestContext.getMathedAPI().getAPIConfig().getVersion(); - String apiContext = basePath + ":" + apiVersion; + String apiContext = basePath + ':' + apiVersion; String apiName = requestContext.getMathedAPI().getAPIConfig().getName(); String tenantDomain = FilterUtils.getTenantDomainFromRequestURL(apiContext); if (tenantDomain == null) { @@ -93,12 +184,12 @@ private Map getThrottleEventMap(RequestContext requestContext) { throttleEvent.put(ThrottleEventConstants.MESSAGE_ID, requestContext.getRequestID()); - throttleEvent.put(ThrottleEventConstants.APP_KEY, authenticationContext.getApplicationId() + ":" + + throttleEvent.put(ThrottleEventConstants.APP_KEY, authenticationContext.getApplicationId() + ':' + authenticationContext.getUsername()); throttleEvent.put(ThrottleEventConstants.APP_TIER, authenticationContext.getApplicationTier()); throttleEvent.put(ThrottleEventConstants.API_KEY, apiContext); throttleEvent.put(ThrottleEventConstants.API_TIER, authenticationContext.getApiTier()); - throttleEvent.put(ThrottleEventConstants.SUBSCRIPTION_KEY, authenticationContext.getApplicationId() + ":" + + throttleEvent.put(ThrottleEventConstants.SUBSCRIPTION_KEY, authenticationContext.getApplicationId() + ':' + apiContext); throttleEvent.put(ThrottleEventConstants.SUBSCRIPTION_TIER, authenticationContext.getTier()); throttleEvent.put(ThrottleEventConstants.RESOURCE_KEY, resourceKey); @@ -115,13 +206,29 @@ private Map getThrottleEventMap(RequestContext requestContext) { } private String getResourceThrottleKey(RequestContext requestContext, String apiContext, String apiVersion) { - String resourceLevelThrottleKey = apiContext; + String resourceThrottleKey = apiContext; if (!apiVersion.isBlank()) { - resourceLevelThrottleKey += "/" + apiVersion; + resourceThrottleKey += "/" + apiVersion; } - resourceLevelThrottleKey += requestContext.getMatchedResourcePath().getPath() + ":" + + resourceThrottleKey += requestContext.getMatchedResourcePath().getPath() + ':' + requestContext.getRequestMethod(); - return resourceLevelThrottleKey; + return resourceThrottleKey; + } + + private String getApiThrottleKey(String apiContext, String apiVersion) { + String apiThrottleKey = apiContext; + if (!apiVersion.isBlank()) { + apiThrottleKey += ':' + apiVersion; + } + return apiThrottleKey; + } + + private String getSubscriptionThrottleKey(String appId, String apiContext, String apiVersion) { + String subThrottleKey = appId + ':' + apiContext; + if (!apiVersion.isBlank()) { + subThrottleKey += ':' + apiVersion; + } + return subThrottleKey; } private String getResourceTier(ResourceConfig resourceConfig) { @@ -147,7 +254,7 @@ private JSONObject getProperties(RequestContext requestContext) { } } catch (UnknownHostException e) { //send empty value as ip - log.error("Error while parsing host IP " + remoteIP, e); + log.error("Error while parsing host IP {}", remoteIP, e); jsonObMap.put(APIConstants.IPV6, 0); jsonObMap.put(APIConstants.IP, 0); } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java index 386dcc3085..08e35cf491 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java @@ -63,9 +63,10 @@ public static void main(String[] args) { CacheProvider.init(); // TODO: (Praminda) do this only if throttling is enabled - // ConfigHolder.getInstance().getConfig().getThrottleAgentConfig().isEnabled() - ThrottleAgent.startThrottlePublisherPool(); - ThrottleEventListener.init(); + if (ConfigHolder.getInstance().getConfig().getThrottleAgentConfig().isEnabled()) { + ThrottleAgent.startThrottlePublisherPool(); + ThrottleEventListener.init(); + } // Start the server server.start(); diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/APICondition.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/APICondition.java index 9c5a5f37bd..6282a460d6 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/APICondition.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/APICondition.java @@ -37,4 +37,9 @@ public String getResourceKey() { public String getName() { return name; } + + @Override + public String toString() { + return "resourceKey='" + resourceKey + "', name='" + name + '\''; + } } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleConstants.java new file mode 100644 index 0000000000..2dc35ace4b --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleConstants.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.throttle; + +/** + * Constants related to Throttling + */ +public class ThrottleConstants { + public static final int API_THROTTLE_OUT_ERROR_CODE = 900800; + public static final int HARD_LIMIT_EXCEEDED_ERROR_CODE = 900801; + public static final int RESOURCE_THROTTLE_OUT_ERROR_CODE = 900802; + public static final int APPLICATION_THROTTLE_OUT_ERROR_CODE = 900803; + public static final int SUBSCRIPTION_THROTTLE_OUT_ERROR_CODE = 900804; + public static final int SUBSCRIPTION_BURST_THROTTLE_OUT_ERROR_CODE = 900807; + public static final int BLOCKED_ERROR_CODE = 900805; + public static final int CUSTOM_POLICY_THROTTLE_OUT_ERROR_CODE = 900806; + public static final int CONNECTIONS_COUNT_THROTTLE_OUT_ERROR_CODE = 900808; + public static final int EVENTS_COUNT_THROTTLE_OUT_ERROR_CODE = 900808; + + public static final String THROTTLE_OUT_MESSAGE = "Message throttled out"; + public static final String THROTTLE_OUT_DESCRIPTION = "You have exceeded your quota"; + public static final String BLOCKING_MESSAGE = "Message blocked"; + public static final String BLOCKING_DESCRIPTION = "You have been blocked from accesing the resource"; + + public static final String THROTTLE_OUT_REASON_API_LIMIT_EXCEEDED = "API_LIMIT_EXCEEDED"; + public static final String THROTTLE_OUT_REASON_RESOURCE_LIMIT_EXCEEDED = "RESOURCE_LIMIT_EXCEEDED"; + public static final String THROTTLE_OUT_REASON_SUBSCRIPTION_LIMIT_EXCEEDED = "SUBSCRIPTION_LIMIT_EXCEEDED"; + public static final String THROTTLE_OUT_REASON_APPLICATION_LIMIT_EXCEEDED = "APPLICATION_LIMIT_EXCEEDED"; + public static final String POLICY_NOT_FOUND_DESCRIPTION = "POLICY ENFORCEMENT ERROR"; +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleDataHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleDataHolder.java index 263a53987c..936cb8bf91 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleDataHolder.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleDataHolder.java @@ -38,7 +38,7 @@ public class ThrottleDataHolder { private final Map>> conditionDtoMap = new ConcurrentHashMap<>(); private ThrottleDataHolder() { - throttleDataMap = new ConcurrentHashMap(); + throttleDataMap = new ConcurrentHashMap<>(); } public static ThrottleDataHolder getInstance() { @@ -57,8 +57,8 @@ public static ThrottleDataHolder getInstance() { * @param conditionValue conditions to be added to the map */ public void addThrottledConditions(String key, String conditionKey, List conditionValue) { - Map> conditionMap; + if (conditionDtoMap.containsKey(key)) { conditionMap = conditionDtoMap.get(key); } else { @@ -105,4 +105,29 @@ public void removeThrottleData(String key) { throttleDataMap.remove(key); } + /** + * This method will check given key in throttle data Map. A key is considered throttled if, + *
    + *
  1. A values for the given @{code key} exists in the throttle data map
  2. + *
  3. Validity timestamp for the provided key is not passed already
  4. + *
+ * + * @param key throttle key + * @return {@code true} if event is throttled {@code false} if event is not throttled. + */ + public boolean isThrottled(String key) { + boolean isThrottled = this.throttleDataMap.containsKey(key); + + if (isThrottled) { + long currentTime = System.currentTimeMillis(); + long timestamp = this.throttleDataMap.get(key); + if (timestamp < currentTime) { + this.throttleDataMap.remove(key); + isThrottled = false; + } + } + + return isThrottled; + } + } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java index f80ab3a06b..8208a50861 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java @@ -18,8 +18,8 @@ package org.wso2.micro.gateway.enforcer.throttle; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.wso2.micro.gateway.enforcer.constants.APIConstants; import java.util.Date; @@ -48,7 +48,7 @@ * JMS event listener for throttle data. */ public class ThrottleEventListener implements MessageListener { - private static final Log log = LogFactory.getLog(ThrottleEventListener.class); + private static final Logger log = LogManager.getLogger(ThrottleEventListener.class); // These patterns will be used to determine for which type of keys the throttling condition has occurred. private final Pattern apiPattern = Pattern.compile("/.*/(.*):\\1_(condition_(\\d*)|default)"); @@ -139,11 +139,10 @@ private void handleThrottleUpdateMessage(Map map) { } if (APIConstants.AdvancedThrottleConstants.TRUE.equalsIgnoreCase(throttleState)) { + dataHolder.addThrottleData(throttleKey, timeStamp); APICondition extractedKey = extractAPIorResourceKey(throttleKey); - if (log.isDebugEnabled()) { - log.debug("Adding throttling key : " + extractedKey); - } + log.debug("Adding throttling key : {}", extractedKey); if (extractedKey != null) { if (evaluatedConditionObject != null) { From d4b0593347fccdc9fdda5cd3b69f2a01361a6e2e Mon Sep 17 00:00:00 2001 From: Praminda Jayawardana Date: Wed, 10 Mar 2021 11:13:33 +0530 Subject: [PATCH 12/21] throttle: enf: Move config dtos to correct pkg --- .../dto/ThrottleAgentConfigDto.java} | 12 ++++++------ .../dto/ThrottleURLGroupDto.java} | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{dto/ThrottleAgentConfigDTO.java => config/dto/ThrottleAgentConfigDto.java} (86%) rename enforcer/src/main/java/org/wso2/micro/gateway/enforcer/{dto/ThrottleURLGroupDTO.java => config/dto/ThrottleURLGroupDto.java} (90%) diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleAgentConfigDTO.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleAgentConfigDto.java similarity index 86% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleAgentConfigDTO.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleAgentConfigDto.java index f197c1dd27..c24425d0b6 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleAgentConfigDTO.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleAgentConfigDto.java @@ -6,7 +6,7 @@ * in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.dto; +package org.wso2.micro.gateway.enforcer.config.dto; import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.AgentConfiguration; import org.wso2.micro.gateway.enforcer.throttle.databridge.publisher.PublisherConfiguration; @@ -27,11 +27,11 @@ /** * This contains throttle configurations. */ -public class ThrottleAgentConfigDTO { +public class ThrottleAgentConfigDto { boolean enabled = false; String username; String password; - List urlGroup = new ArrayList<>(); + List urlGroup = new ArrayList<>(); PublisherConfiguration publisher; AgentConfiguration agent; @@ -59,11 +59,11 @@ public void setPassword(String password) { this.password = password; } - public List getUrlGroup() { + public List getUrlGroup() { return urlGroup; } - public void setUrlGroup(List urlGroup) { + public void setUrlGroup(List urlGroup) { this.urlGroup = urlGroup; } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleURLGroupDTO.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleURLGroupDto.java similarity index 90% rename from enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleURLGroupDTO.java rename to enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleURLGroupDto.java index 23ef43f9f3..ef33fc715b 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/dto/ThrottleURLGroupDTO.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleURLGroupDto.java @@ -6,7 +6,7 @@ * in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an @@ -16,12 +16,12 @@ * under the License. */ -package org.wso2.micro.gateway.enforcer.dto; +package org.wso2.micro.gateway.enforcer.config.dto; /** * Throttle URL groups configurations. */ -public class ThrottleURLGroupDTO { +public class ThrottleURLGroupDto { String[] receiverURLs; String[] authURLs; String type; From c8c6cd7ca4b55e0ca2a8b6d1c1ddd0907471452b Mon Sep 17 00:00:00 2001 From: Praminda Jayawardana Date: Wed, 10 Mar 2021 12:56:03 +0530 Subject: [PATCH 13/21] throttle: enf: Add configs to protos --- .../config/enforcer/am_credentials.pb.go | 9 +- .../config/enforcer/auth_service.pb.go | 9 +- .../config/enforcer/binary_throttling.pb.go | 76 +- .../discovery/config/enforcer/cache.pb.go | 9 +- .../wso2/discovery/config/enforcer/cert.pb.go | 9 +- .../discovery/config/enforcer/config.pb.go | 9 +- .../discovery/config/enforcer/event_hub.pb.go | 9 +- .../discovery/config/enforcer/issuer.pb.go | 9 +- .../enforcer/jms_connection_params.pb.go | 9 +- .../config/enforcer/jwt_generator.pb.go | 9 +- .../config/enforcer/thread_pool.pb.go | 9 +- .../config/enforcer/throttle_agent.pb.go | 10 +- .../config/enforcer/throttle_publisher.pb.go | 10 +- .../config/enforcer/throttling.pb.go | 139 ++- .../config/enforcer/tm_url_group.pb.go | 9 +- .../config/enforcer/binary_throttling.proto | 1 - .../config/enforcer/throttle_agent.proto | 1 + .../config/enforcer/throttle_publisher.proto | 1 + .../config/enforcer/throttling.proto | 10 +- .../config/enforcer/BinaryThrottling.java | 65 -- .../enforcer/BinaryThrottlingOrBuilder.java | 6 - .../enforcer/BinaryThrottlingProto.java | 24 +- .../config/enforcer/ThrottleAgent.java | 8 + .../config/enforcer/ThrottlePublisher.java | 8 + .../discovery/config/enforcer/Throttling.java | 844 +++++++++++++++++- .../config/enforcer/ThrottlingOrBuilder.java | 78 +- .../config/enforcer/ThrottlingProto.java | 23 +- 27 files changed, 1206 insertions(+), 197 deletions(-) diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/am_credentials.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/am_credentials.pb.go index cd15559f22..e4f66de00b 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/am_credentials.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/am_credentials.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.25.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/am_credentials.proto package enforcer import ( + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -20,6 +21,10 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + // APIM Credentials model type AmCredentials struct { state protoimpl.MessageState diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/auth_service.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/auth_service.pb.go index 5c9318c0a9..409ef94ff2 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/auth_service.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/auth_service.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.25.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/auth_service.proto package enforcer import ( + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -20,6 +21,10 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + // Auth service model type AuthService struct { state protoimpl.MessageState diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/binary_throttling.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/binary_throttling.pb.go index f311018833..71d59f4e98 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/binary_throttling.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/binary_throttling.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.25.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/binary_throttling.proto package enforcer import ( + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -20,12 +21,15 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + type BinaryThrottling struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` UrlGroup []*TMURLGroup `protobuf:"bytes,4,rep,name=urlGroup,proto3" json:"urlGroup,omitempty"` @@ -65,13 +69,6 @@ func (*BinaryThrottling) Descriptor() ([]byte, []int) { return file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDescGZIP(), []int{0} } -func (x *BinaryThrottling) GetEnabled() bool { - if x != nil { - return x.Enabled - } - return false -} - func (x *BinaryThrottling) GetUsername() string { if x != nil { return x.Username @@ -125,37 +122,36 @@ var file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDesc = []byte 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x33, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2f, 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x65, 0x5f, 0x61, 0x67, - 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc2, 0x02, 0x0a, 0x10, 0x42, 0x69, - 0x6e, 0x61, 0x72, 0x79, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x12, 0x18, - 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, - 0x12, 0x46, 0x0a, 0x08, 0x75, 0x72, 0x6c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x04, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, - 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, - 0x63, 0x65, 0x72, 0x2e, 0x54, 0x4d, 0x55, 0x52, 0x4c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x08, - 0x75, 0x72, 0x6c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x4f, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, - 0x69, 0x73, 0x68, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x77, 0x73, - 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x54, 0x68, 0x72, - 0x6f, 0x74, 0x74, 0x6c, 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x52, 0x09, - 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x12, 0x43, 0x0a, 0x05, 0x61, 0x67, 0x65, - 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, + 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa8, 0x02, 0x0a, 0x10, 0x42, 0x69, + 0x6e, 0x61, 0x72, 0x79, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x12, 0x1a, + 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, + 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, + 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x46, 0x0a, 0x08, 0x75, 0x72, 0x6c, 0x47, 0x72, 0x6f, + 0x75, 0x70, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, - 0x6c, 0x65, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x42, 0x95, - 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, - 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, 0x15, 0x42, - 0x69, 0x6e, 0x61, 0x72, 0x79, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, - 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, - 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, - 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x54, 0x4d, 0x55, 0x52, 0x4c, 0x47, + 0x72, 0x6f, 0x75, 0x70, 0x52, 0x08, 0x75, 0x72, 0x6c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x4f, + 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x31, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, + 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, + 0x65, 0x72, 0x2e, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, + 0x73, 0x68, 0x65, 0x72, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x12, + 0x43, 0x0a, 0x05, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, + 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, + 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x65, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x61, + 0x67, 0x65, 0x6e, 0x74, 0x42, 0x95, 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, + 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, + 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, + 0x63, 0x65, 0x72, 0x42, 0x15, 0x42, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x54, 0x68, 0x72, 0x6f, 0x74, + 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, + 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, + 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, + 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, + 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/cache.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/cache.pb.go index 8363f44739..9080ab0c7b 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/cache.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/cache.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.25.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/cache.proto package enforcer import ( + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -20,6 +21,10 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + // JWT Generator model type Cache struct { state protoimpl.MessageState diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/cert.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/cert.pb.go index 5bf897b200..44f6bbc0a2 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/cert.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/cert.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.25.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/cert.proto package enforcer import ( + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -20,6 +21,10 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + // Listener and client certificate store model type CertStore struct { state protoimpl.MessageState diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/config.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/config.pb.go index c2e2e3f3ec..35b942ccfa 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/config.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/config.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.25.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/config.proto package enforcer import ( + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -20,6 +21,10 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + // Enforcer config model type Config struct { state protoimpl.MessageState diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/event_hub.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/event_hub.pb.go index afcf182f45..b936919b15 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/event_hub.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/event_hub.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.25.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/event_hub.proto package enforcer import ( + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -20,6 +21,10 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + // Event hub configuration model type EventHub struct { state protoimpl.MessageState diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/issuer.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/issuer.pb.go index 6a2ee727a6..4a6cdd6d73 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/issuer.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/issuer.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.25.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/issuer.proto package enforcer import ( + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -20,6 +21,10 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + // Token issuer model type Issuer struct { state protoimpl.MessageState diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jms_connection_params.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jms_connection_params.pb.go index 0f7bfd6808..706e43b6d2 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jms_connection_params.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jms_connection_params.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.25.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/jms_connection_params.proto package enforcer import ( + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -20,6 +21,10 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + // JMS connection parameter model type JmsConnectionParameters struct { state protoimpl.MessageState diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jwt_generator.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jwt_generator.pb.go index 229b1d9b46..a6cda5f5f5 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jwt_generator.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/jwt_generator.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.25.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/jwt_generator.proto package enforcer import ( + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -20,6 +21,10 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + // JWT Generator model type JWTGenerator struct { state protoimpl.MessageState diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/thread_pool.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/thread_pool.pb.go index bf05e19a08..dafa3bfb34 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/thread_pool.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/thread_pool.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.25.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/thread_pool.proto package enforcer import ( + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -20,6 +21,10 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + // ThreadPool model type ThreadPool struct { state protoimpl.MessageState diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_agent.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_agent.pb.go index 570f6650fb..e667ea2896 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_agent.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_agent.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.25.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/throttle_agent.proto package enforcer import ( + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -20,6 +21,11 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +// Throttle Agent configuration model type ThrottleAgent struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_publisher.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_publisher.pb.go index fbade38e62..87a27afac4 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_publisher.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_publisher.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.25.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/throttle_publisher.proto package enforcer import ( + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -20,6 +21,11 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +// Throttle Publisher configuration model type ThrottlePublisher struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttling.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttling.pb.go index 41610f6e64..196c13cc00 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttling.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttling.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.25.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/throttling.proto package enforcer import ( + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -20,13 +21,25 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + // Throttling model type Throttling struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Binary *BinaryThrottling `protobuf:"bytes,1,opt,name=binary,proto3" json:"binary,omitempty"` + EnableGlobalEventPublishing bool `protobuf:"varint,1,opt,name=enable_global_event_publishing,json=enableGlobalEventPublishing,proto3" json:"enable_global_event_publishing,omitempty"` + EnableHeaderConditions bool `protobuf:"varint,2,opt,name=enable_header_conditions,json=enableHeaderConditions,proto3" json:"enable_header_conditions,omitempty"` + EnableQueryParamConditions bool `protobuf:"varint,3,opt,name=enable_query_param_conditions,json=enableQueryParamConditions,proto3" json:"enable_query_param_conditions,omitempty"` + EnableJwtClaimConditions bool `protobuf:"varint,4,opt,name=enable_jwt_claim_conditions,json=enableJwtClaimConditions,proto3" json:"enable_jwt_claim_conditions,omitempty"` + JmsConnectionInitialContextFactory string `protobuf:"bytes,5,opt,name=jms_connection_initial_context_factory,json=jmsConnectionInitialContextFactory,proto3" json:"jms_connection_initial_context_factory,omitempty"` + JmsConnectionProviderUrl string `protobuf:"bytes,6,opt,name=jms_connection_provider_url,json=jmsConnectionProviderUrl,proto3" json:"jms_connection_provider_url,omitempty"` + JmsConnectionUsername string `protobuf:"bytes,7,opt,name=jms_connection_username,json=jmsConnectionUsername,proto3" json:"jms_connection_username,omitempty"` + JmsConnectionPassword string `protobuf:"bytes,8,opt,name=jms_connection_password,json=jmsConnectionPassword,proto3" json:"jms_connection_password,omitempty"` + Binary *BinaryThrottling `protobuf:"bytes,9,opt,name=binary,proto3" json:"binary,omitempty"` } func (x *Throttling) Reset() { @@ -61,6 +74,62 @@ func (*Throttling) Descriptor() ([]byte, []int) { return file_wso2_discovery_config_enforcer_throttling_proto_rawDescGZIP(), []int{0} } +func (x *Throttling) GetEnableGlobalEventPublishing() bool { + if x != nil { + return x.EnableGlobalEventPublishing + } + return false +} + +func (x *Throttling) GetEnableHeaderConditions() bool { + if x != nil { + return x.EnableHeaderConditions + } + return false +} + +func (x *Throttling) GetEnableQueryParamConditions() bool { + if x != nil { + return x.EnableQueryParamConditions + } + return false +} + +func (x *Throttling) GetEnableJwtClaimConditions() bool { + if x != nil { + return x.EnableJwtClaimConditions + } + return false +} + +func (x *Throttling) GetJmsConnectionInitialContextFactory() string { + if x != nil { + return x.JmsConnectionInitialContextFactory + } + return "" +} + +func (x *Throttling) GetJmsConnectionProviderUrl() string { + if x != nil { + return x.JmsConnectionProviderUrl + } + return "" +} + +func (x *Throttling) GetJmsConnectionUsername() string { + if x != nil { + return x.JmsConnectionUsername + } + return "" +} + +func (x *Throttling) GetJmsConnectionPassword() string { + if x != nil { + return x.JmsConnectionPassword + } + return "" +} + func (x *Throttling) GetBinary() *BinaryThrottling { if x != nil { return x.Binary @@ -79,22 +148,54 @@ var file_wso2_discovery_config_enforcer_throttling_proto_rawDesc = []byte{ 0x72, 0x1a, 0x36, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x5f, 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, - 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x56, 0x0a, 0x0a, 0x54, 0x68, 0x72, - 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x12, 0x48, 0x0a, 0x06, 0x62, 0x69, 0x6e, 0x61, 0x72, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, - 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, - 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x42, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x54, - 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x52, 0x06, 0x62, 0x69, 0x6e, 0x61, 0x72, - 0x79, 0x42, 0x8f, 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x67, - 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, - 0x42, 0x0f, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, - 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, 0x72, - 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xda, 0x04, 0x0a, 0x0a, 0x54, 0x68, + 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x12, 0x43, 0x0a, 0x1e, 0x65, 0x6e, 0x61, 0x62, + 0x6c, 0x65, 0x5f, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, + 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x1b, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x45, 0x76, + 0x65, 0x6e, 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x38, 0x0a, + 0x18, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x63, + 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x16, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, + 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x41, 0x0a, 0x1d, 0x65, 0x6e, 0x61, 0x62, 0x6c, + 0x65, 0x5f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x5f, 0x63, 0x6f, + 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1a, + 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, + 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x3d, 0x0a, 0x1b, 0x65, 0x6e, + 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6a, 0x77, 0x74, 0x5f, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x5f, 0x63, + 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x18, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x4a, 0x77, 0x74, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x43, + 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x52, 0x0a, 0x26, 0x6a, 0x6d, 0x73, + 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, 0x69, 0x74, + 0x69, 0x61, 0x6c, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x5f, 0x66, 0x61, 0x63, 0x74, + 0x6f, 0x72, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x22, 0x6a, 0x6d, 0x73, 0x43, 0x6f, + 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x43, + 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x3d, 0x0a, + 0x1b, 0x6a, 0x6d, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x18, 0x6a, 0x6d, 0x73, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x55, 0x72, 0x6c, 0x12, 0x36, 0x0a, 0x17, + 0x6a, 0x6d, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x75, + 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x6a, + 0x6d, 0x73, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x73, 0x65, 0x72, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x36, 0x0a, 0x17, 0x6a, 0x6d, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, + 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x6a, 0x6d, 0x73, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x48, 0x0a, 0x06, + 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x77, + 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x42, 0x69, + 0x6e, 0x61, 0x72, 0x79, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x52, 0x06, + 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x42, 0x8f, 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, 0x2e, 0x77, + 0x73, 0x6f, 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, 0x73, 0x63, + 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, + 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, 0x0f, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, + 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, + 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, + 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, + 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/tm_url_group.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/tm_url_group.pb.go index 63d75fe6d2..730e24a6d3 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/tm_url_group.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/tm_url_group.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel -// protoc v3.14.0 +// protoc-gen-go v1.25.0 +// protoc v3.15.5 // source: wso2/discovery/config/enforcer/tm_url_group.proto package enforcer import ( + proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -20,6 +21,10 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + type TMURLGroup struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/api/wso2/discovery/config/enforcer/binary_throttling.proto b/api/wso2/discovery/config/enforcer/binary_throttling.proto index 26db289fee..1c45a7f4db 100644 --- a/api/wso2/discovery/config/enforcer/binary_throttling.proto +++ b/api/wso2/discovery/config/enforcer/binary_throttling.proto @@ -14,7 +14,6 @@ option java_multiple_files = true; // [#protodoc-title: BinaryThrottling] message BinaryThrottling { - bool enabled = 1; string username = 2; string password = 3; repeated TMURLGroup urlGroup = 4; diff --git a/api/wso2/discovery/config/enforcer/throttle_agent.proto b/api/wso2/discovery/config/enforcer/throttle_agent.proto index bd130981e0..fd7a766972 100644 --- a/api/wso2/discovery/config/enforcer/throttle_agent.proto +++ b/api/wso2/discovery/config/enforcer/throttle_agent.proto @@ -9,6 +9,7 @@ option java_multiple_files = true; // [#protodoc-title: ThrottleAgent] +// Throttle Agent configuration model message ThrottleAgent { string sslEnabledProtocols = 1; string ciphers = 2; diff --git a/api/wso2/discovery/config/enforcer/throttle_publisher.proto b/api/wso2/discovery/config/enforcer/throttle_publisher.proto index a308b6da66..9b4c24a641 100644 --- a/api/wso2/discovery/config/enforcer/throttle_publisher.proto +++ b/api/wso2/discovery/config/enforcer/throttle_publisher.proto @@ -9,6 +9,7 @@ option java_multiple_files = true; // [#protodoc-title: ThrottlePublisher] +// Throttle Publisher configuration model message ThrottlePublisher { int32 maxIdleDataPublishingAgents = 1; int32 initIdleObjectDataPublishingAgents = 2; diff --git a/api/wso2/discovery/config/enforcer/throttling.proto b/api/wso2/discovery/config/enforcer/throttling.proto index 479051f6e5..02f14f5e15 100644 --- a/api/wso2/discovery/config/enforcer/throttling.proto +++ b/api/wso2/discovery/config/enforcer/throttling.proto @@ -13,5 +13,13 @@ option java_multiple_files = true; // Throttling model message Throttling { - BinaryThrottling binary = 1; + bool enable_global_event_publishing = 1; + bool enable_header_conditions = 2; + bool enable_query_param_conditions = 3; + bool enable_jwt_claim_conditions = 4; + string jms_connection_initial_context_factory = 5; + string jms_connection_provider_url = 6; + string jms_connection_username = 7; + string jms_connection_password = 8; + BinaryThrottling binary = 9; } diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottling.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottling.java index b954666618..de053208b0 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottling.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottling.java @@ -52,11 +52,6 @@ private BinaryThrottling( case 0: done = true; break; - case 8: { - - enabled_ = input.readBool(); - break; - } case 18: { java.lang.String s = input.readStringRequireUtf8(); @@ -139,17 +134,6 @@ private BinaryThrottling( org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.class, org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.Builder.class); } - public static final int ENABLED_FIELD_NUMBER = 1; - private boolean enabled_; - /** - * bool enabled = 1; - * @return The enabled. - */ - @java.lang.Override - public boolean getEnabled() { - return enabled_; - } - public static final int USERNAME_FIELD_NUMBER = 2; private volatile java.lang.Object username_; /** @@ -332,9 +316,6 @@ public final boolean isInitialized() { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (enabled_ != false) { - output.writeBool(1, enabled_); - } if (!getUsernameBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 2, username_); } @@ -359,10 +340,6 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; - if (enabled_ != false) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize(1, enabled_); - } if (!getUsernameBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, username_); } @@ -396,8 +373,6 @@ public boolean equals(final java.lang.Object obj) { } org.wso2.gateway.discovery.config.enforcer.BinaryThrottling other = (org.wso2.gateway.discovery.config.enforcer.BinaryThrottling) obj; - if (getEnabled() - != other.getEnabled()) return false; if (!getUsername() .equals(other.getUsername())) return false; if (!getPassword() @@ -425,9 +400,6 @@ public int hashCode() { } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + ENABLED_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( - getEnabled()); hash = (37 * hash) + USERNAME_FIELD_NUMBER; hash = (53 * hash) + getUsername().hashCode(); hash = (37 * hash) + PASSWORD_FIELD_NUMBER; @@ -578,8 +550,6 @@ private void maybeForceBuilderInitialization() { @java.lang.Override public Builder clear() { super.clear(); - enabled_ = false; - username_ = ""; password_ = ""; @@ -629,7 +599,6 @@ public org.wso2.gateway.discovery.config.enforcer.BinaryThrottling build() { public org.wso2.gateway.discovery.config.enforcer.BinaryThrottling buildPartial() { org.wso2.gateway.discovery.config.enforcer.BinaryThrottling result = new org.wso2.gateway.discovery.config.enforcer.BinaryThrottling(this); int from_bitField0_ = bitField0_; - result.enabled_ = enabled_; result.username_ = username_; result.password_ = password_; if (urlGroupBuilder_ == null) { @@ -699,9 +668,6 @@ public Builder mergeFrom(com.google.protobuf.Message other) { public Builder mergeFrom(org.wso2.gateway.discovery.config.enforcer.BinaryThrottling other) { if (other == org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.getDefaultInstance()) return this; - if (other.getEnabled() != false) { - setEnabled(other.getEnabled()); - } if (!other.getUsername().isEmpty()) { username_ = other.username_; onChanged(); @@ -772,37 +738,6 @@ public Builder mergeFrom( } private int bitField0_; - private boolean enabled_ ; - /** - * bool enabled = 1; - * @return The enabled. - */ - @java.lang.Override - public boolean getEnabled() { - return enabled_; - } - /** - * bool enabled = 1; - * @param value The enabled to set. - * @return This builder for chaining. - */ - public Builder setEnabled(boolean value) { - - enabled_ = value; - onChanged(); - return this; - } - /** - * bool enabled = 1; - * @return This builder for chaining. - */ - public Builder clearEnabled() { - - enabled_ = false; - onChanged(); - return this; - } - private java.lang.Object username_ = ""; /** * string username = 2; diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottlingOrBuilder.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottlingOrBuilder.java index 38c0c6ba41..26ba771704 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottlingOrBuilder.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottlingOrBuilder.java @@ -7,12 +7,6 @@ public interface BinaryThrottlingOrBuilder extends // @@protoc_insertion_point(interface_extends:wso2.discovery.config.enforcer.BinaryThrottling) com.google.protobuf.MessageOrBuilder { - /** - * bool enabled = 1; - * @return The enabled. - */ - boolean getEnabled(); - /** * string username = 2; * @return The username. diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottlingProto.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottlingProto.java index f5f4be689d..c737602d4b 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottlingProto.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryThrottlingProto.java @@ -34,17 +34,17 @@ public static void registerAllExtensions( "/tm_url_group.proto\0327wso2/discovery/conf" + "ig/enforcer/throttle_publisher.proto\0323ws" + "o2/discovery/config/enforcer/throttle_ag" + - "ent.proto\"\211\002\n\020BinaryThrottling\022\017\n\007enable" + - "d\030\001 \001(\010\022\020\n\010username\030\002 \001(\t\022\020\n\010password\030\003 " + - "\001(\t\022<\n\010urlGroup\030\004 \003(\0132*.wso2.discovery.c" + - "onfig.enforcer.TMURLGroup\022D\n\tpublisher\030\005" + - " \001(\01321.wso2.discovery.config.enforcer.Th" + - "rottlePublisher\022<\n\005agent\030\006 \001(\0132-.wso2.di" + - "scovery.config.enforcer.ThrottleAgentB\225\001" + - "\n*org.wso2.gateway.discovery.config.enfo" + - "rcerB\025BinaryThrottlingProtoP\001ZNgithub.co" + - "m/envoyproxy/go-control-plane/wso2/disco" + - "very/config/enforcer;enforcerb\006proto3" + "ent.proto\"\370\001\n\020BinaryThrottling\022\020\n\010userna" + + "me\030\002 \001(\t\022\020\n\010password\030\003 \001(\t\022<\n\010urlGroup\030\004" + + " \003(\0132*.wso2.discovery.config.enforcer.TM" + + "URLGroup\022D\n\tpublisher\030\005 \001(\01321.wso2.disco" + + "very.config.enforcer.ThrottlePublisher\022<" + + "\n\005agent\030\006 \001(\0132-.wso2.discovery.config.en" + + "forcer.ThrottleAgentB\225\001\n*org.wso2.gatewa" + + "y.discovery.config.enforcerB\025BinaryThrot" + + "tlingProtoP\001ZNgithub.com/envoyproxy/go-c" + + "ontrol-plane/wso2/discovery/config/enfor" + + "cer;enforcerb\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -58,7 +58,7 @@ public static void registerAllExtensions( internal_static_wso2_discovery_config_enforcer_BinaryThrottling_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_wso2_discovery_config_enforcer_BinaryThrottling_descriptor, - new java.lang.String[] { "Enabled", "Username", "Password", "UrlGroup", "Publisher", "Agent", }); + new java.lang.String[] { "Username", "Password", "UrlGroup", "Publisher", "Agent", }); org.wso2.gateway.discovery.config.enforcer.TMURLGroupProto.getDescriptor(); org.wso2.gateway.discovery.config.enforcer.ThrottlePublishergProto.getDescriptor(); org.wso2.gateway.discovery.config.enforcer.ThrottleAgentProto.getDescriptor(); diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottleAgent.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottleAgent.java index 07c5e0974d..c0dfc92865 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottleAgent.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottleAgent.java @@ -4,6 +4,10 @@ package org.wso2.gateway.discovery.config.enforcer; /** + *
+ * Throttle Agent configuration model
+ * 
+ * * Protobuf type {@code wso2.discovery.config.enforcer.ThrottleAgent} */ public final class ThrottleAgent extends @@ -740,6 +744,10 @@ protected Builder newBuilderForType( return builder; } /** + *
+   * Throttle Agent configuration model
+   * 
+ * * Protobuf type {@code wso2.discovery.config.enforcer.ThrottleAgent} */ public static final class Builder extends diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlePublisher.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlePublisher.java index 7aa75bfb7a..aa9d880e02 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlePublisher.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlePublisher.java @@ -4,6 +4,10 @@ package org.wso2.gateway.discovery.config.enforcer; /** + *
+ * Throttle Publisher configuration model
+ * 
+ * * Protobuf type {@code wso2.discovery.config.enforcer.ThrottlePublisher} */ public final class ThrottlePublisher extends @@ -360,6 +364,10 @@ protected Builder newBuilderForType( return builder; } /** + *
+   * Throttle Publisher configuration model
+   * 
+ * * Protobuf type {@code wso2.discovery.config.enforcer.ThrottlePublisher} */ public static final class Builder extends diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/Throttling.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/Throttling.java index 9bb4ef40c0..527c84d709 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/Throttling.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/Throttling.java @@ -20,6 +20,10 @@ private Throttling(com.google.protobuf.GeneratedMessageV3.Builder builder) { super(builder); } private Throttling() { + jmsConnectionInitialContextFactory_ = ""; + jmsConnectionProviderUrl_ = ""; + jmsConnectionUsername_ = ""; + jmsConnectionPassword_ = ""; } @java.lang.Override @@ -52,7 +56,51 @@ private Throttling( case 0: done = true; break; - case 10: { + case 8: { + + enableGlobalEventPublishing_ = input.readBool(); + break; + } + case 16: { + + enableHeaderConditions_ = input.readBool(); + break; + } + case 24: { + + enableQueryParamConditions_ = input.readBool(); + break; + } + case 32: { + + enableJwtClaimConditions_ = input.readBool(); + break; + } + case 42: { + java.lang.String s = input.readStringRequireUtf8(); + + jmsConnectionInitialContextFactory_ = s; + break; + } + case 50: { + java.lang.String s = input.readStringRequireUtf8(); + + jmsConnectionProviderUrl_ = s; + break; + } + case 58: { + java.lang.String s = input.readStringRequireUtf8(); + + jmsConnectionUsername_ = s; + break; + } + case 66: { + java.lang.String s = input.readStringRequireUtf8(); + + jmsConnectionPassword_ = s; + break; + } + case 74: { org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.Builder subBuilder = null; if (binary_ != null) { subBuilder = binary_.toBuilder(); @@ -97,10 +145,206 @@ private Throttling( org.wso2.gateway.discovery.config.enforcer.Throttling.class, org.wso2.gateway.discovery.config.enforcer.Throttling.Builder.class); } - public static final int BINARY_FIELD_NUMBER = 1; + public static final int ENABLE_GLOBAL_EVENT_PUBLISHING_FIELD_NUMBER = 1; + private boolean enableGlobalEventPublishing_; + /** + * bool enable_global_event_publishing = 1; + * @return The enableGlobalEventPublishing. + */ + @java.lang.Override + public boolean getEnableGlobalEventPublishing() { + return enableGlobalEventPublishing_; + } + + public static final int ENABLE_HEADER_CONDITIONS_FIELD_NUMBER = 2; + private boolean enableHeaderConditions_; + /** + * bool enable_header_conditions = 2; + * @return The enableHeaderConditions. + */ + @java.lang.Override + public boolean getEnableHeaderConditions() { + return enableHeaderConditions_; + } + + public static final int ENABLE_QUERY_PARAM_CONDITIONS_FIELD_NUMBER = 3; + private boolean enableQueryParamConditions_; + /** + * bool enable_query_param_conditions = 3; + * @return The enableQueryParamConditions. + */ + @java.lang.Override + public boolean getEnableQueryParamConditions() { + return enableQueryParamConditions_; + } + + public static final int ENABLE_JWT_CLAIM_CONDITIONS_FIELD_NUMBER = 4; + private boolean enableJwtClaimConditions_; + /** + * bool enable_jwt_claim_conditions = 4; + * @return The enableJwtClaimConditions. + */ + @java.lang.Override + public boolean getEnableJwtClaimConditions() { + return enableJwtClaimConditions_; + } + + public static final int JMS_CONNECTION_INITIAL_CONTEXT_FACTORY_FIELD_NUMBER = 5; + private volatile java.lang.Object jmsConnectionInitialContextFactory_; + /** + * string jms_connection_initial_context_factory = 5; + * @return The jmsConnectionInitialContextFactory. + */ + @java.lang.Override + public java.lang.String getJmsConnectionInitialContextFactory() { + java.lang.Object ref = jmsConnectionInitialContextFactory_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + jmsConnectionInitialContextFactory_ = s; + return s; + } + } + /** + * string jms_connection_initial_context_factory = 5; + * @return The bytes for jmsConnectionInitialContextFactory. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getJmsConnectionInitialContextFactoryBytes() { + java.lang.Object ref = jmsConnectionInitialContextFactory_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + jmsConnectionInitialContextFactory_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int JMS_CONNECTION_PROVIDER_URL_FIELD_NUMBER = 6; + private volatile java.lang.Object jmsConnectionProviderUrl_; + /** + * string jms_connection_provider_url = 6; + * @return The jmsConnectionProviderUrl. + */ + @java.lang.Override + public java.lang.String getJmsConnectionProviderUrl() { + java.lang.Object ref = jmsConnectionProviderUrl_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + jmsConnectionProviderUrl_ = s; + return s; + } + } + /** + * string jms_connection_provider_url = 6; + * @return The bytes for jmsConnectionProviderUrl. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getJmsConnectionProviderUrlBytes() { + java.lang.Object ref = jmsConnectionProviderUrl_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + jmsConnectionProviderUrl_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int JMS_CONNECTION_USERNAME_FIELD_NUMBER = 7; + private volatile java.lang.Object jmsConnectionUsername_; + /** + * string jms_connection_username = 7; + * @return The jmsConnectionUsername. + */ + @java.lang.Override + public java.lang.String getJmsConnectionUsername() { + java.lang.Object ref = jmsConnectionUsername_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + jmsConnectionUsername_ = s; + return s; + } + } + /** + * string jms_connection_username = 7; + * @return The bytes for jmsConnectionUsername. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getJmsConnectionUsernameBytes() { + java.lang.Object ref = jmsConnectionUsername_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + jmsConnectionUsername_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int JMS_CONNECTION_PASSWORD_FIELD_NUMBER = 8; + private volatile java.lang.Object jmsConnectionPassword_; + /** + * string jms_connection_password = 8; + * @return The jmsConnectionPassword. + */ + @java.lang.Override + public java.lang.String getJmsConnectionPassword() { + java.lang.Object ref = jmsConnectionPassword_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + jmsConnectionPassword_ = s; + return s; + } + } + /** + * string jms_connection_password = 8; + * @return The bytes for jmsConnectionPassword. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getJmsConnectionPasswordBytes() { + java.lang.Object ref = jmsConnectionPassword_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + jmsConnectionPassword_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int BINARY_FIELD_NUMBER = 9; private org.wso2.gateway.discovery.config.enforcer.BinaryThrottling binary_; /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; * @return Whether the binary field is set. */ @java.lang.Override @@ -108,7 +352,7 @@ public boolean hasBinary() { return binary_ != null; } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; * @return The binary. */ @java.lang.Override @@ -116,7 +360,7 @@ public org.wso2.gateway.discovery.config.enforcer.BinaryThrottling getBinary() { return binary_ == null ? org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.getDefaultInstance() : binary_; } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; */ @java.lang.Override public org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingOrBuilder getBinaryOrBuilder() { @@ -137,8 +381,32 @@ public final boolean isInitialized() { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (enableGlobalEventPublishing_ != false) { + output.writeBool(1, enableGlobalEventPublishing_); + } + if (enableHeaderConditions_ != false) { + output.writeBool(2, enableHeaderConditions_); + } + if (enableQueryParamConditions_ != false) { + output.writeBool(3, enableQueryParamConditions_); + } + if (enableJwtClaimConditions_ != false) { + output.writeBool(4, enableJwtClaimConditions_); + } + if (!getJmsConnectionInitialContextFactoryBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, jmsConnectionInitialContextFactory_); + } + if (!getJmsConnectionProviderUrlBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, jmsConnectionProviderUrl_); + } + if (!getJmsConnectionUsernameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 7, jmsConnectionUsername_); + } + if (!getJmsConnectionPasswordBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, jmsConnectionPassword_); + } if (binary_ != null) { - output.writeMessage(1, getBinary()); + output.writeMessage(9, getBinary()); } unknownFields.writeTo(output); } @@ -149,9 +417,37 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; + if (enableGlobalEventPublishing_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(1, enableGlobalEventPublishing_); + } + if (enableHeaderConditions_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(2, enableHeaderConditions_); + } + if (enableQueryParamConditions_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(3, enableQueryParamConditions_); + } + if (enableJwtClaimConditions_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(4, enableJwtClaimConditions_); + } + if (!getJmsConnectionInitialContextFactoryBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, jmsConnectionInitialContextFactory_); + } + if (!getJmsConnectionProviderUrlBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, jmsConnectionProviderUrl_); + } + if (!getJmsConnectionUsernameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, jmsConnectionUsername_); + } + if (!getJmsConnectionPasswordBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, jmsConnectionPassword_); + } if (binary_ != null) { size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, getBinary()); + .computeMessageSize(9, getBinary()); } size += unknownFields.getSerializedSize(); memoizedSize = size; @@ -168,6 +464,22 @@ public boolean equals(final java.lang.Object obj) { } org.wso2.gateway.discovery.config.enforcer.Throttling other = (org.wso2.gateway.discovery.config.enforcer.Throttling) obj; + if (getEnableGlobalEventPublishing() + != other.getEnableGlobalEventPublishing()) return false; + if (getEnableHeaderConditions() + != other.getEnableHeaderConditions()) return false; + if (getEnableQueryParamConditions() + != other.getEnableQueryParamConditions()) return false; + if (getEnableJwtClaimConditions() + != other.getEnableJwtClaimConditions()) return false; + if (!getJmsConnectionInitialContextFactory() + .equals(other.getJmsConnectionInitialContextFactory())) return false; + if (!getJmsConnectionProviderUrl() + .equals(other.getJmsConnectionProviderUrl())) return false; + if (!getJmsConnectionUsername() + .equals(other.getJmsConnectionUsername())) return false; + if (!getJmsConnectionPassword() + .equals(other.getJmsConnectionPassword())) return false; if (hasBinary() != other.hasBinary()) return false; if (hasBinary()) { if (!getBinary() @@ -184,6 +496,26 @@ public int hashCode() { } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ENABLE_GLOBAL_EVENT_PUBLISHING_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getEnableGlobalEventPublishing()); + hash = (37 * hash) + ENABLE_HEADER_CONDITIONS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getEnableHeaderConditions()); + hash = (37 * hash) + ENABLE_QUERY_PARAM_CONDITIONS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getEnableQueryParamConditions()); + hash = (37 * hash) + ENABLE_JWT_CLAIM_CONDITIONS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getEnableJwtClaimConditions()); + hash = (37 * hash) + JMS_CONNECTION_INITIAL_CONTEXT_FACTORY_FIELD_NUMBER; + hash = (53 * hash) + getJmsConnectionInitialContextFactory().hashCode(); + hash = (37 * hash) + JMS_CONNECTION_PROVIDER_URL_FIELD_NUMBER; + hash = (53 * hash) + getJmsConnectionProviderUrl().hashCode(); + hash = (37 * hash) + JMS_CONNECTION_USERNAME_FIELD_NUMBER; + hash = (53 * hash) + getJmsConnectionUsername().hashCode(); + hash = (37 * hash) + JMS_CONNECTION_PASSWORD_FIELD_NUMBER; + hash = (53 * hash) + getJmsConnectionPassword().hashCode(); if (hasBinary()) { hash = (37 * hash) + BINARY_FIELD_NUMBER; hash = (53 * hash) + getBinary().hashCode(); @@ -325,6 +657,22 @@ private void maybeForceBuilderInitialization() { @java.lang.Override public Builder clear() { super.clear(); + enableGlobalEventPublishing_ = false; + + enableHeaderConditions_ = false; + + enableQueryParamConditions_ = false; + + enableJwtClaimConditions_ = false; + + jmsConnectionInitialContextFactory_ = ""; + + jmsConnectionProviderUrl_ = ""; + + jmsConnectionUsername_ = ""; + + jmsConnectionPassword_ = ""; + if (binaryBuilder_ == null) { binary_ = null; } else { @@ -357,6 +705,14 @@ public org.wso2.gateway.discovery.config.enforcer.Throttling build() { @java.lang.Override public org.wso2.gateway.discovery.config.enforcer.Throttling buildPartial() { org.wso2.gateway.discovery.config.enforcer.Throttling result = new org.wso2.gateway.discovery.config.enforcer.Throttling(this); + result.enableGlobalEventPublishing_ = enableGlobalEventPublishing_; + result.enableHeaderConditions_ = enableHeaderConditions_; + result.enableQueryParamConditions_ = enableQueryParamConditions_; + result.enableJwtClaimConditions_ = enableJwtClaimConditions_; + result.jmsConnectionInitialContextFactory_ = jmsConnectionInitialContextFactory_; + result.jmsConnectionProviderUrl_ = jmsConnectionProviderUrl_; + result.jmsConnectionUsername_ = jmsConnectionUsername_; + result.jmsConnectionPassword_ = jmsConnectionPassword_; if (binaryBuilder_ == null) { result.binary_ = binary_; } else { @@ -410,6 +766,34 @@ public Builder mergeFrom(com.google.protobuf.Message other) { public Builder mergeFrom(org.wso2.gateway.discovery.config.enforcer.Throttling other) { if (other == org.wso2.gateway.discovery.config.enforcer.Throttling.getDefaultInstance()) return this; + if (other.getEnableGlobalEventPublishing() != false) { + setEnableGlobalEventPublishing(other.getEnableGlobalEventPublishing()); + } + if (other.getEnableHeaderConditions() != false) { + setEnableHeaderConditions(other.getEnableHeaderConditions()); + } + if (other.getEnableQueryParamConditions() != false) { + setEnableQueryParamConditions(other.getEnableQueryParamConditions()); + } + if (other.getEnableJwtClaimConditions() != false) { + setEnableJwtClaimConditions(other.getEnableJwtClaimConditions()); + } + if (!other.getJmsConnectionInitialContextFactory().isEmpty()) { + jmsConnectionInitialContextFactory_ = other.jmsConnectionInitialContextFactory_; + onChanged(); + } + if (!other.getJmsConnectionProviderUrl().isEmpty()) { + jmsConnectionProviderUrl_ = other.jmsConnectionProviderUrl_; + onChanged(); + } + if (!other.getJmsConnectionUsername().isEmpty()) { + jmsConnectionUsername_ = other.jmsConnectionUsername_; + onChanged(); + } + if (!other.getJmsConnectionPassword().isEmpty()) { + jmsConnectionPassword_ = other.jmsConnectionPassword_; + onChanged(); + } if (other.hasBinary()) { mergeBinary(other.getBinary()); } @@ -442,18 +826,446 @@ public Builder mergeFrom( return this; } + private boolean enableGlobalEventPublishing_ ; + /** + * bool enable_global_event_publishing = 1; + * @return The enableGlobalEventPublishing. + */ + @java.lang.Override + public boolean getEnableGlobalEventPublishing() { + return enableGlobalEventPublishing_; + } + /** + * bool enable_global_event_publishing = 1; + * @param value The enableGlobalEventPublishing to set. + * @return This builder for chaining. + */ + public Builder setEnableGlobalEventPublishing(boolean value) { + + enableGlobalEventPublishing_ = value; + onChanged(); + return this; + } + /** + * bool enable_global_event_publishing = 1; + * @return This builder for chaining. + */ + public Builder clearEnableGlobalEventPublishing() { + + enableGlobalEventPublishing_ = false; + onChanged(); + return this; + } + + private boolean enableHeaderConditions_ ; + /** + * bool enable_header_conditions = 2; + * @return The enableHeaderConditions. + */ + @java.lang.Override + public boolean getEnableHeaderConditions() { + return enableHeaderConditions_; + } + /** + * bool enable_header_conditions = 2; + * @param value The enableHeaderConditions to set. + * @return This builder for chaining. + */ + public Builder setEnableHeaderConditions(boolean value) { + + enableHeaderConditions_ = value; + onChanged(); + return this; + } + /** + * bool enable_header_conditions = 2; + * @return This builder for chaining. + */ + public Builder clearEnableHeaderConditions() { + + enableHeaderConditions_ = false; + onChanged(); + return this; + } + + private boolean enableQueryParamConditions_ ; + /** + * bool enable_query_param_conditions = 3; + * @return The enableQueryParamConditions. + */ + @java.lang.Override + public boolean getEnableQueryParamConditions() { + return enableQueryParamConditions_; + } + /** + * bool enable_query_param_conditions = 3; + * @param value The enableQueryParamConditions to set. + * @return This builder for chaining. + */ + public Builder setEnableQueryParamConditions(boolean value) { + + enableQueryParamConditions_ = value; + onChanged(); + return this; + } + /** + * bool enable_query_param_conditions = 3; + * @return This builder for chaining. + */ + public Builder clearEnableQueryParamConditions() { + + enableQueryParamConditions_ = false; + onChanged(); + return this; + } + + private boolean enableJwtClaimConditions_ ; + /** + * bool enable_jwt_claim_conditions = 4; + * @return The enableJwtClaimConditions. + */ + @java.lang.Override + public boolean getEnableJwtClaimConditions() { + return enableJwtClaimConditions_; + } + /** + * bool enable_jwt_claim_conditions = 4; + * @param value The enableJwtClaimConditions to set. + * @return This builder for chaining. + */ + public Builder setEnableJwtClaimConditions(boolean value) { + + enableJwtClaimConditions_ = value; + onChanged(); + return this; + } + /** + * bool enable_jwt_claim_conditions = 4; + * @return This builder for chaining. + */ + public Builder clearEnableJwtClaimConditions() { + + enableJwtClaimConditions_ = false; + onChanged(); + return this; + } + + private java.lang.Object jmsConnectionInitialContextFactory_ = ""; + /** + * string jms_connection_initial_context_factory = 5; + * @return The jmsConnectionInitialContextFactory. + */ + public java.lang.String getJmsConnectionInitialContextFactory() { + java.lang.Object ref = jmsConnectionInitialContextFactory_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + jmsConnectionInitialContextFactory_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string jms_connection_initial_context_factory = 5; + * @return The bytes for jmsConnectionInitialContextFactory. + */ + public com.google.protobuf.ByteString + getJmsConnectionInitialContextFactoryBytes() { + java.lang.Object ref = jmsConnectionInitialContextFactory_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + jmsConnectionInitialContextFactory_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string jms_connection_initial_context_factory = 5; + * @param value The jmsConnectionInitialContextFactory to set. + * @return This builder for chaining. + */ + public Builder setJmsConnectionInitialContextFactory( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + jmsConnectionInitialContextFactory_ = value; + onChanged(); + return this; + } + /** + * string jms_connection_initial_context_factory = 5; + * @return This builder for chaining. + */ + public Builder clearJmsConnectionInitialContextFactory() { + + jmsConnectionInitialContextFactory_ = getDefaultInstance().getJmsConnectionInitialContextFactory(); + onChanged(); + return this; + } + /** + * string jms_connection_initial_context_factory = 5; + * @param value The bytes for jmsConnectionInitialContextFactory to set. + * @return This builder for chaining. + */ + public Builder setJmsConnectionInitialContextFactoryBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + jmsConnectionInitialContextFactory_ = value; + onChanged(); + return this; + } + + private java.lang.Object jmsConnectionProviderUrl_ = ""; + /** + * string jms_connection_provider_url = 6; + * @return The jmsConnectionProviderUrl. + */ + public java.lang.String getJmsConnectionProviderUrl() { + java.lang.Object ref = jmsConnectionProviderUrl_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + jmsConnectionProviderUrl_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string jms_connection_provider_url = 6; + * @return The bytes for jmsConnectionProviderUrl. + */ + public com.google.protobuf.ByteString + getJmsConnectionProviderUrlBytes() { + java.lang.Object ref = jmsConnectionProviderUrl_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + jmsConnectionProviderUrl_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string jms_connection_provider_url = 6; + * @param value The jmsConnectionProviderUrl to set. + * @return This builder for chaining. + */ + public Builder setJmsConnectionProviderUrl( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + jmsConnectionProviderUrl_ = value; + onChanged(); + return this; + } + /** + * string jms_connection_provider_url = 6; + * @return This builder for chaining. + */ + public Builder clearJmsConnectionProviderUrl() { + + jmsConnectionProviderUrl_ = getDefaultInstance().getJmsConnectionProviderUrl(); + onChanged(); + return this; + } + /** + * string jms_connection_provider_url = 6; + * @param value The bytes for jmsConnectionProviderUrl to set. + * @return This builder for chaining. + */ + public Builder setJmsConnectionProviderUrlBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + jmsConnectionProviderUrl_ = value; + onChanged(); + return this; + } + + private java.lang.Object jmsConnectionUsername_ = ""; + /** + * string jms_connection_username = 7; + * @return The jmsConnectionUsername. + */ + public java.lang.String getJmsConnectionUsername() { + java.lang.Object ref = jmsConnectionUsername_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + jmsConnectionUsername_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string jms_connection_username = 7; + * @return The bytes for jmsConnectionUsername. + */ + public com.google.protobuf.ByteString + getJmsConnectionUsernameBytes() { + java.lang.Object ref = jmsConnectionUsername_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + jmsConnectionUsername_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string jms_connection_username = 7; + * @param value The jmsConnectionUsername to set. + * @return This builder for chaining. + */ + public Builder setJmsConnectionUsername( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + jmsConnectionUsername_ = value; + onChanged(); + return this; + } + /** + * string jms_connection_username = 7; + * @return This builder for chaining. + */ + public Builder clearJmsConnectionUsername() { + + jmsConnectionUsername_ = getDefaultInstance().getJmsConnectionUsername(); + onChanged(); + return this; + } + /** + * string jms_connection_username = 7; + * @param value The bytes for jmsConnectionUsername to set. + * @return This builder for chaining. + */ + public Builder setJmsConnectionUsernameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + jmsConnectionUsername_ = value; + onChanged(); + return this; + } + + private java.lang.Object jmsConnectionPassword_ = ""; + /** + * string jms_connection_password = 8; + * @return The jmsConnectionPassword. + */ + public java.lang.String getJmsConnectionPassword() { + java.lang.Object ref = jmsConnectionPassword_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + jmsConnectionPassword_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string jms_connection_password = 8; + * @return The bytes for jmsConnectionPassword. + */ + public com.google.protobuf.ByteString + getJmsConnectionPasswordBytes() { + java.lang.Object ref = jmsConnectionPassword_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + jmsConnectionPassword_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string jms_connection_password = 8; + * @param value The jmsConnectionPassword to set. + * @return This builder for chaining. + */ + public Builder setJmsConnectionPassword( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + jmsConnectionPassword_ = value; + onChanged(); + return this; + } + /** + * string jms_connection_password = 8; + * @return This builder for chaining. + */ + public Builder clearJmsConnectionPassword() { + + jmsConnectionPassword_ = getDefaultInstance().getJmsConnectionPassword(); + onChanged(); + return this; + } + /** + * string jms_connection_password = 8; + * @param value The bytes for jmsConnectionPassword to set. + * @return This builder for chaining. + */ + public Builder setJmsConnectionPasswordBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + jmsConnectionPassword_ = value; + onChanged(); + return this; + } + private org.wso2.gateway.discovery.config.enforcer.BinaryThrottling binary_; private com.google.protobuf.SingleFieldBuilderV3< org.wso2.gateway.discovery.config.enforcer.BinaryThrottling, org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.Builder, org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingOrBuilder> binaryBuilder_; /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; * @return Whether the binary field is set. */ public boolean hasBinary() { return binaryBuilder_ != null || binary_ != null; } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; * @return The binary. */ public org.wso2.gateway.discovery.config.enforcer.BinaryThrottling getBinary() { @@ -464,7 +1276,7 @@ public org.wso2.gateway.discovery.config.enforcer.BinaryThrottling getBinary() { } } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; */ public Builder setBinary(org.wso2.gateway.discovery.config.enforcer.BinaryThrottling value) { if (binaryBuilder_ == null) { @@ -480,7 +1292,7 @@ public Builder setBinary(org.wso2.gateway.discovery.config.enforcer.BinaryThrott return this; } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; */ public Builder setBinary( org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.Builder builderForValue) { @@ -494,7 +1306,7 @@ public Builder setBinary( return this; } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; */ public Builder mergeBinary(org.wso2.gateway.discovery.config.enforcer.BinaryThrottling value) { if (binaryBuilder_ == null) { @@ -512,7 +1324,7 @@ public Builder mergeBinary(org.wso2.gateway.discovery.config.enforcer.BinaryThro return this; } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; */ public Builder clearBinary() { if (binaryBuilder_ == null) { @@ -526,7 +1338,7 @@ public Builder clearBinary() { return this; } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; */ public org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.Builder getBinaryBuilder() { @@ -534,7 +1346,7 @@ public org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.Builder getBi return getBinaryFieldBuilder().getBuilder(); } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; */ public org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingOrBuilder getBinaryOrBuilder() { if (binaryBuilder_ != null) { @@ -545,7 +1357,7 @@ public org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingOrBuilder getB } } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; */ private com.google.protobuf.SingleFieldBuilderV3< org.wso2.gateway.discovery.config.enforcer.BinaryThrottling, org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.Builder, org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingOrBuilder> diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingOrBuilder.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingOrBuilder.java index 1ea806dc93..ac522e82bd 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingOrBuilder.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingOrBuilder.java @@ -8,17 +8,89 @@ public interface ThrottlingOrBuilder extends com.google.protobuf.MessageOrBuilder { /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * bool enable_global_event_publishing = 1; + * @return The enableGlobalEventPublishing. + */ + boolean getEnableGlobalEventPublishing(); + + /** + * bool enable_header_conditions = 2; + * @return The enableHeaderConditions. + */ + boolean getEnableHeaderConditions(); + + /** + * bool enable_query_param_conditions = 3; + * @return The enableQueryParamConditions. + */ + boolean getEnableQueryParamConditions(); + + /** + * bool enable_jwt_claim_conditions = 4; + * @return The enableJwtClaimConditions. + */ + boolean getEnableJwtClaimConditions(); + + /** + * string jms_connection_initial_context_factory = 5; + * @return The jmsConnectionInitialContextFactory. + */ + java.lang.String getJmsConnectionInitialContextFactory(); + /** + * string jms_connection_initial_context_factory = 5; + * @return The bytes for jmsConnectionInitialContextFactory. + */ + com.google.protobuf.ByteString + getJmsConnectionInitialContextFactoryBytes(); + + /** + * string jms_connection_provider_url = 6; + * @return The jmsConnectionProviderUrl. + */ + java.lang.String getJmsConnectionProviderUrl(); + /** + * string jms_connection_provider_url = 6; + * @return The bytes for jmsConnectionProviderUrl. + */ + com.google.protobuf.ByteString + getJmsConnectionProviderUrlBytes(); + + /** + * string jms_connection_username = 7; + * @return The jmsConnectionUsername. + */ + java.lang.String getJmsConnectionUsername(); + /** + * string jms_connection_username = 7; + * @return The bytes for jmsConnectionUsername. + */ + com.google.protobuf.ByteString + getJmsConnectionUsernameBytes(); + + /** + * string jms_connection_password = 8; + * @return The jmsConnectionPassword. + */ + java.lang.String getJmsConnectionPassword(); + /** + * string jms_connection_password = 8; + * @return The bytes for jmsConnectionPassword. + */ + com.google.protobuf.ByteString + getJmsConnectionPasswordBytes(); + + /** + * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; * @return Whether the binary field is set. */ boolean hasBinary(); /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; * @return The binary. */ org.wso2.gateway.discovery.config.enforcer.BinaryThrottling getBinary(); /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 1; + * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; */ org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingOrBuilder getBinaryOrBuilder(); } diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingProto.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingProto.java index 5658b5fcd6..e1c253d3e7 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingProto.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingProto.java @@ -31,13 +31,20 @@ public static void registerAllExtensions( "\n/wso2/discovery/config/enforcer/throttl" + "ing.proto\022\036wso2.discovery.config.enforce" + "r\0326wso2/discovery/config/enforcer/binary" + - "_throttling.proto\"N\n\nThrottling\022@\n\006binar" + - "y\030\001 \001(\01320.wso2.discovery.config.enforcer" + - ".BinaryThrottlingB\217\001\n*org.wso2.gateway.d" + - "iscovery.config.enforcerB\017ThrottlingProt" + - "oP\001ZNgithub.com/envoyproxy/go-control-pl" + - "ane/wso2/discovery/config/enforcer;enfor" + - "cerb\006proto3" + "_throttling.proto\"\373\002\n\nThrottling\022&\n\036enab" + + "le_global_event_publishing\030\001 \001(\010\022 \n\030enab" + + "le_header_conditions\030\002 \001(\010\022%\n\035enable_que" + + "ry_param_conditions\030\003 \001(\010\022#\n\033enable_jwt_" + + "claim_conditions\030\004 \001(\010\022.\n&jms_connection" + + "_initial_context_factory\030\005 \001(\t\022#\n\033jms_co" + + "nnection_provider_url\030\006 \001(\t\022\037\n\027jms_conne" + + "ction_username\030\007 \001(\t\022\037\n\027jms_connection_p" + + "assword\030\010 \001(\t\022@\n\006binary\030\t \001(\01320.wso2.dis" + + "covery.config.enforcer.BinaryThrottlingB" + + "\217\001\n*org.wso2.gateway.discovery.config.en" + + "forcerB\017ThrottlingProtoP\001ZNgithub.com/en" + + "voyproxy/go-control-plane/wso2/discovery" + + "/config/enforcer;enforcerb\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -49,7 +56,7 @@ public static void registerAllExtensions( internal_static_wso2_discovery_config_enforcer_Throttling_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_wso2_discovery_config_enforcer_Throttling_descriptor, - new java.lang.String[] { "Binary", }); + new java.lang.String[] { "EnableGlobalEventPublishing", "EnableHeaderConditions", "EnableQueryParamConditions", "EnableJwtClaimConditions", "JmsConnectionInitialContextFactory", "JmsConnectionProviderUrl", "JmsConnectionUsername", "JmsConnectionPassword", "Binary", }); org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingProto.getDescriptor(); } From 2c47c247ab98124af0ee6dd9c09f20993d56582a Mon Sep 17 00:00:00 2001 From: Praminda Jayawardana Date: Wed, 10 Mar 2021 13:23:09 +0530 Subject: [PATCH 14/21] throttle: enf: Use config values --- adapter/config/types.go | 11 +- adapter/internal/discovery/xds/marshaller.go | 9 +- .../micro/gateway/enforcer/api/RestAPI.java | 2 +- .../gateway/enforcer/config/ConfigHolder.java | 25 +++- .../enforcer/config/EnforcerConfig.java | 12 +- .../config/dto/ThrottleAgentConfigDto.java | 9 -- .../config/dto/ThrottleConfigDto.java | 106 ++++++++++++++++ .../enforcer/filters/ThrottleFilter.java | 3 +- .../gateway/enforcer/server/AuthServer.java | 3 +- .../throttle/ThrottleEventListener.java | 7 +- resources/conf/config.toml | 115 ++++++++++-------- 11 files changed, 224 insertions(+), 78 deletions(-) create mode 100644 enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleConfigDto.java diff --git a/adapter/config/types.go b/adapter/config/types.go index 2074444769..97e2f35332 100644 --- a/adapter/config/types.go +++ b/adapter/config/types.go @@ -180,11 +180,18 @@ type eventHub struct { } type throttlingConfig struct { - Binary binaryThrottleConfig + EnableGlobalEventPublishing bool `toml:"enableGlobalEventPublishing"` + EnableHeaderConditions bool `toml:"enableHeaderConditions"` + EnableQueryParamConditions bool `toml:"enableQueryParamConditions"` + EnableJwtClaimConditions bool `toml:"enableJwtClaimConditions"` + JmsConnectioninitialContextFactory string `toml:"jmsConnectioninitialContextFactory"` + JmsConnectionProviderURL string `toml:"jmsConnectionProviderUrl"` + JmsConnectionUsername string `toml:"jmsConnectionUsername"` + JmsConnectionPassword string `toml:"jmsConnectionPassword"` + Binary binaryThrottleConfig } type binaryThrottleConfig struct { - Enabled bool Username string Password string URLGroup []urlGroup `toml:"urlGroup"` diff --git a/adapter/internal/discovery/xds/marshaller.go b/adapter/internal/discovery/xds/marshaller.go index 81a0c5c63a..0b6d53a20d 100644 --- a/adapter/internal/discovery/xds/marshaller.go +++ b/adapter/internal/discovery/xds/marshaller.go @@ -86,8 +86,15 @@ func MarshalConfig(config *config.Config) *enforcer.Config { }, }, ThrottlingConfig: &enforcer.Throttling{ + EnableGlobalEventPublishing: config.Enforcer.ThrottlingConfig.EnableGlobalEventPublishing, + EnableHeaderConditions: config.Enforcer.ThrottlingConfig.EnableHeaderConditions, + EnableQueryParamConditions: config.Enforcer.ThrottlingConfig.EnableQueryParamConditions, + EnableJwtClaimConditions: config.Enforcer.ThrottlingConfig.EnableJwtClaimConditions, + JmsConnectionInitialContextFactory: config.Enforcer.ThrottlingConfig.JmsConnectioninitialContextFactory, + JmsConnectionProviderUrl: config.Enforcer.ThrottlingConfig.JmsConnectionProviderURL, + JmsConnectionUsername: config.Enforcer.ThrottlingConfig.JmsConnectionUsername, + JmsConnectionPassword: config.Enforcer.ThrottlingConfig.JmsConnectionPassword, Binary: &enforcer.BinaryThrottling{ - Enabled: config.Enforcer.ThrottlingConfig.Binary.Enabled, Username: config.Enforcer.ThrottlingConfig.Binary.Username, Password: config.Enforcer.ThrottlingConfig.Binary.Password, UrlGroup: urlGroups, diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RestAPI.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RestAPI.java index b9d131725b..0fddb87b2b 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RestAPI.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RestAPI.java @@ -129,7 +129,7 @@ private void initFilters() { this.filters.add(corsFilter); this.filters.add(authFilter); // enable throttle filter - if (ConfigHolder.getInstance().getConfig().getThrottleAgentConfig().isEnabled()) { + if (ConfigHolder.getInstance().getConfig().getThrottleConfig().isGlobalPublishingEnabled()) { ThrottleFilter throttleFilter = new ThrottleFilter(); throttleFilter.init(apiConfig); this.filters.add(throttleFilter); diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java index f47ab4c082..9a2616c449 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java @@ -33,15 +33,17 @@ import org.wso2.gateway.discovery.config.enforcer.TMURLGroup; import org.wso2.gateway.discovery.config.enforcer.ThrottleAgent; import org.wso2.gateway.discovery.config.enforcer.ThrottlePublisher; +import org.wso2.gateway.discovery.config.enforcer.Throttling; import org.wso2.micro.gateway.enforcer.config.dto.AuthServiceConfigurationDto; import org.wso2.micro.gateway.enforcer.config.dto.CacheDto; import org.wso2.micro.gateway.enforcer.config.dto.CredentialDto; import org.wso2.micro.gateway.enforcer.config.dto.EventHubConfigurationDto; import org.wso2.micro.gateway.enforcer.config.dto.JWKSConfigurationDTO; +import org.wso2.micro.gateway.enforcer.config.dto.ThrottleAgentConfigDto; +import org.wso2.micro.gateway.enforcer.config.dto.ThrottleConfigDto; import org.wso2.micro.gateway.enforcer.config.dto.TokenIssuerDto; import org.wso2.micro.gateway.enforcer.constants.Constants; import org.wso2.micro.gateway.enforcer.discovery.ConfigDiscoveryClient; -import org.wso2.micro.gateway.enforcer.dto.ThrottleAgentConfigDTO; import org.wso2.micro.gateway.enforcer.exception.DiscoveryException; import org.wso2.micro.gateway.enforcer.throttle.databridge.agent.conf.AgentConfiguration; import org.wso2.micro.gateway.enforcer.throttle.databridge.publisher.PublisherConfiguration; @@ -120,7 +122,7 @@ private void parseConfigs(Config config) { populateAPIMCredentials(config.getApimCredentials()); // Read throttle publisher configurations - populateTMBinaryConfig(config.getThrottlingConfig().getBinary()); + populateThrottlingConfig(config.getThrottlingConfig()); // Read backend jwt generation configurations populateJWTGeneratorConfigurations(config.getJwtGenerator()); @@ -193,6 +195,20 @@ private void populateJWTIssuerConfiguration(List cdsIssuers) { } } + private void populateThrottlingConfig(Throttling throttling) { + ThrottleConfigDto throttleConfig = new ThrottleConfigDto(); + throttleConfig.setGlobalPublishingEnabled(throttling.getEnableGlobalEventPublishing()); + throttleConfig.setHeaderConditionsEnabled(throttling.getEnableHeaderConditions()); + throttleConfig.setQueryConditionsEnabled(throttling.getEnableQueryParamConditions()); + throttleConfig.setJwtClaimConditionsEnabled(throttling.getEnableJwtClaimConditions()); + throttleConfig.setJmsConnectionInitialContextFactory(throttling.getJmsConnectionInitialContextFactory()); + throttleConfig.setJmsConnectionProviderUrl(throttling.getJmsConnectionProviderUrl()); + throttleConfig.setJmsConnectionUsername(throttling.getJmsConnectionUsername()); + throttleConfig.setJmsConnectionPassword(throttling.getJmsConnectionPassword()); + config.setThrottleConfig(throttleConfig); + populateTMBinaryConfig(throttling.getBinary()); + } + private void populateTMBinaryConfig(BinaryThrottling binary) { ThrottleAgent binaryAgent = binary.getAgent(); AgentConfiguration agentConf = AgentConfiguration.getInstance(); @@ -227,13 +243,12 @@ private void populateTMBinaryConfig(BinaryThrottling binary) { processTMPublisherURLGroup(binary.getUrlGroupList(), pubConf); - ThrottleAgentConfigDTO throttleAgent = new ThrottleAgentConfigDTO(); + ThrottleAgentConfigDto throttleAgent = new ThrottleAgentConfigDto(); throttleAgent.setAgent(agentConf); - throttleAgent.setEnabled(binary.getEnabled()); throttleAgent.setUsername(binary.getUsername()); throttleAgent.setPassword(binary.getPassword()); throttleAgent.setPublisher(pubConf); - config.setThrottleAgentConfig(throttleAgent); + config.getThrottleConfig().setThrottleAgent(throttleAgent); } private void loadTrustStore() { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/EnforcerConfig.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/EnforcerConfig.java index e8e673036d..8eb81fff07 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/EnforcerConfig.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/EnforcerConfig.java @@ -23,8 +23,8 @@ import org.wso2.micro.gateway.enforcer.config.dto.CacheDto; import org.wso2.micro.gateway.enforcer.config.dto.CredentialDto; import org.wso2.micro.gateway.enforcer.config.dto.EventHubConfigurationDto; +import org.wso2.micro.gateway.enforcer.config.dto.ThrottleConfigDto; import org.wso2.micro.gateway.enforcer.config.dto.TokenIssuerDto; -import org.wso2.micro.gateway.enforcer.dto.ThrottleAgentConfigDTO; import java.util.HashMap; import java.util.Map; @@ -38,7 +38,7 @@ public class EnforcerConfig { private EventHubConfigurationDto eventHub; private Map issuersMap = new HashMap<>(); private CredentialDto apimCredentials; - private ThrottleAgentConfigDTO throttleAgentConfig; + private ThrottleConfigDto throttleConfig; private JWTConfigurationDto jwtConfigurationDto; private CacheDto cacheDto; private String publicCertificatePath = ""; @@ -76,12 +76,12 @@ public void setApimCredentials(CredentialDto apimCredentials) { this.apimCredentials = apimCredentials; } - public ThrottleAgentConfigDTO getThrottleAgentConfig() { - return throttleAgentConfig; + public ThrottleConfigDto getThrottleConfig() { + return throttleConfig; } - public void setThrottleAgentConfig(ThrottleAgentConfigDTO throttleAgentConfig) { - this.throttleAgentConfig = throttleAgentConfig; + public void setThrottleConfig(ThrottleConfigDto throttleConfig) { + this.throttleConfig = throttleConfig; } public void setJwtConfigurationDto(JWTConfigurationDto jwtConfigurationDto) { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleAgentConfigDto.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleAgentConfigDto.java index c24425d0b6..0b54b82441 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleAgentConfigDto.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleAgentConfigDto.java @@ -28,21 +28,12 @@ * This contains throttle configurations. */ public class ThrottleAgentConfigDto { - boolean enabled = false; String username; String password; List urlGroup = new ArrayList<>(); PublisherConfiguration publisher; AgentConfiguration agent; - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - public String getUsername() { return username; } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleConfigDto.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleConfigDto.java new file mode 100644 index 0000000000..eda2d46460 --- /dev/null +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleConfigDto.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.micro.gateway.enforcer.config.dto; + +/** + * Throttling configuration model. + */ +public class ThrottleConfigDto { + private boolean isGlobalPublishingEnabled; + private boolean isHeaderConditionsEnabled; + private boolean isQueryConditionsEnabled; + private boolean isJwtClaimConditionsEnabled; + private String jmsConnectionInitialContextFactory; + private String jmsConnectionProviderUrl; + private String jmsConnectionUsername; + private String jmsConnectionPassword; + private ThrottleAgentConfigDto throttleAgent; + + public boolean isGlobalPublishingEnabled() { + return isGlobalPublishingEnabled; + } + + public void setGlobalPublishingEnabled(boolean globalPublishingEnabled) { + isGlobalPublishingEnabled = globalPublishingEnabled; + } + + public boolean isHeaderConditionsEnabled() { + return isHeaderConditionsEnabled; + } + + public void setHeaderConditionsEnabled(boolean headerConditionsEnabled) { + isHeaderConditionsEnabled = headerConditionsEnabled; + } + + public boolean isQueryConditionsEnabled() { + return isQueryConditionsEnabled; + } + + public void setQueryConditionsEnabled(boolean queryConditionsEnabled) { + isQueryConditionsEnabled = queryConditionsEnabled; + } + + public boolean isJwtClaimConditionsEnabled() { + return isJwtClaimConditionsEnabled; + } + + public void setJwtClaimConditionsEnabled(boolean jwtClaimConditionsEnabled) { + isJwtClaimConditionsEnabled = jwtClaimConditionsEnabled; + } + + public String getJmsConnectionInitialContextFactory() { + return jmsConnectionInitialContextFactory; + } + + public void setJmsConnectionInitialContextFactory(String jmsConnectionInitialContextFactory) { + this.jmsConnectionInitialContextFactory = jmsConnectionInitialContextFactory; + } + + public String getJmsConnectionProviderUrl() { + return jmsConnectionProviderUrl; + } + + public void setJmsConnectionProviderUrl(String jmsConnectionProviderUrl) { + this.jmsConnectionProviderUrl = jmsConnectionProviderUrl; + } + + public String getJmsConnectionUsername() { + return jmsConnectionUsername; + } + + public void setJmsConnectionUsername(String jmsConnectionUsername) { + this.jmsConnectionUsername = jmsConnectionUsername; + } + + public String getJmsConnectionPassword() { + return jmsConnectionPassword; + } + + public void setJmsConnectionPassword(String jmsConnectionPassword) { + this.jmsConnectionPassword = jmsConnectionPassword; + } + + public ThrottleAgentConfigDto getThrottleAgent() { + return throttleAgent; + } + + public void setThrottleAgent(ThrottleAgentConfigDto throttleAgent) { + this.throttleAgent = throttleAgent; + } +} diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java index cf5067dd67..6ccb5aa2cc 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java @@ -51,7 +51,8 @@ public class ThrottleFilter implements Filter { public ThrottleFilter() { this.dataHolder = ThrottleDataHolder.getInstance(); - this.isGlobalThrottlingEnabled = ConfigHolder.getInstance().getConfig().getThrottleAgentConfig().isEnabled(); + this.isGlobalThrottlingEnabled = ConfigHolder.getInstance().getConfig().getThrottleConfig() + .isGlobalPublishingEnabled(); } @Override diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java index 08e35cf491..fab733d867 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/server/AuthServer.java @@ -62,8 +62,7 @@ public static void main(String[] args) { //Initialise cache objects CacheProvider.init(); - // TODO: (Praminda) do this only if throttling is enabled - if (ConfigHolder.getInstance().getConfig().getThrottleAgentConfig().isEnabled()) { + if (ConfigHolder.getInstance().getConfig().getThrottleConfig().isGlobalPublishingEnabled()) { ThrottleAgent.startThrottlePublisherPool(); ThrottleEventListener.init(); } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java index 8208a50861..a368cc1276 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java @@ -20,6 +20,8 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.wso2.micro.gateway.enforcer.config.ConfigHolder; +import org.wso2.micro.gateway.enforcer.config.dto.ThrottleConfigDto; import org.wso2.micro.gateway.enforcer.constants.APIConstants; import java.util.Date; @@ -62,10 +64,11 @@ public class ThrottleEventListener implements MessageListener { private ThrottleEventListener() {} public static void init() { - String initialContextFactory = "org.wso2.andes.jndi.PropertiesFileInitialContextFactory"; + ThrottleConfigDto throttleConf = ConfigHolder.getInstance().getConfig().getThrottleConfig(); + String initialContextFactory = throttleConf.getJmsConnectionInitialContextFactory(); String connectionFactoryNamePrefix = "connectionfactory."; String connectionFactoryName = "qpidConnectionfactory"; - String eventReceiverURL = "amqp://admin:admin@clientid/carbon?brokerlist='tcp://localhost:5672'"; + String eventReceiverURL = throttleConf.getJmsConnectionProviderUrl(); Runnable runnable = () -> { try { TopicConnection topicConnection; diff --git a/resources/conf/config.toml b/resources/conf/config.toml index 6ef320ca23..dcc09bd0d4 100644 --- a/resources/conf/config.toml +++ b/resources/conf/config.toml @@ -97,55 +97,72 @@ disableSslVerification = false publicCertificatePath = "/home/wso2/security/truststore/mg.pem" privateKeyPath = "/home/wso2/security/keystore/mg.key" -# Throttling configurations related to event publishing using a binary connection -[enforcer.throttlingConfig.binary] - enabled = false - # Credentials required to establish connection between Traffic Manager - username = "admin" - password = "admin" - # Receiver URL and the authentication URL of the Traffic manager node/nodes - [[enforcer.throttlingConfig.binary.urlGroup]] - receiverURLs = ["tcp://localhost:9611"] - authURLs = ["ssl://localhost:9711"] - type = "loadbalance" - # Data publisher object pool configurations - [enforcer.throttlingConfig.binary.publisher] - maxIdleDataPublishingAgents = 1000 - initIdleObjectDataPublishingAgents = 200 - # Data publisher thread pool configurations - publisherThreadPoolCoreSize = 200 - publisherThreadPoolMaximumSize = 1000 - publisherThreadPoolKeepAliveTime = 200 - [enforcer.throttlingConfig.binary.agent] - # SSL Protocols - sslEnabledProtocols = "TLSv1,TLSv1.1,TLSv1.2" - # ciphers - ciphers="TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA,TLS_ECDH_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 ,TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 ,TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA,TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA,TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA,SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA,TLS_EMPTY_RENEGOTIATION_INFO_SCSV" - # The size of the queue event disruptor which handles events before they are published. - # The value specified should always be the result of an exponent with 2 as the base. - queueSize = 32768 - # The maximum number of events in a batch sent to the queue event disruptor at a given time - batchSize = 200 - # The number of threads that will be reserved to handle events at the time you start - corePoolSize = 1 - # Socket timeout - socketTimeoutMS = 30000 - # The maximum number of threads that should be reserved at any given time to handle events - maxPoolSize = 1 - # The amount of time which threads in excess of the core pool size may remain idle before being terminated. - keepAliveTimeInPool = 20 - # The time interval between reconnection - reconnectionInterval = 30 - # TCP connection pool configurations (for data publishing) - maxTransportPoolSize = 250 - maxIdleConnections = 250 - evictionTimePeriod = 5500 - minIdleTimeInPool = 5000 - # SSL connection pool configurations (for authentication) - secureMaxTransportPoolSize = 250 - secureMaxIdleConnections = 250 - secureEvictionTimePeriod = 5500 - secureMinIdleTimeInPool = 5000 +# Throttling configurations +[enforcer.throttlingConfig] + # Connect with the central traffic manager + enableGlobalEventPublishing = false + # Enable global advanced throttling based on request header conditions + enableHeaderConditions = false + # Enable global advanced throttling based on request query parameter conditions + enableQueryParamConditions = false + # Enable global advanced throttling based on jwt claim conditions + enableJwtClaimConditions = false + # The message broker context factory + jmsConnectioninitialContextFactory = "org.wso2.andes.jndi.PropertiesFileInitialContextFactory" + # The message broker connection URL + jmsConnectionProviderUrl = "amqp://admin:admin@carbon/carbon?brokerlist='tcp://localhost:5672'" + # The username used to establish the message broker connection + jmsConnectionUsername = "" + # The password used to establish the message broker connection + jmsConnectionPassword = "" + # Throttling configurations related to event publishing using a binary connection + [enforcer.throttlingConfig.binary] + # Credentials required to establish connection between Traffic Manager + username = "admin" + password = "admin" + # Receiver URL and the authentication URL of the Traffic manager node/nodes + [[enforcer.throttlingConfig.binary.urlGroup]] + receiverURLs = ["tcp://localhost:9611"] + authURLs = ["ssl://localhost:9711"] + type = "loadbalance" + # Data publisher object pool configurations + [enforcer.throttlingConfig.binary.publisher] + maxIdleDataPublishingAgents = 1000 + initIdleObjectDataPublishingAgents = 200 + # Data publisher thread pool configurations + publisherThreadPoolCoreSize = 200 + publisherThreadPoolMaximumSize = 1000 + publisherThreadPoolKeepAliveTime = 200 + [enforcer.throttlingConfig.binary.agent] + # SSL Protocols + sslEnabledProtocols = "TLSv1,TLSv1.1,TLSv1.2" + # ciphers + ciphers="TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA,TLS_ECDH_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 ,TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 ,TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA,TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA,TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA,SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA,TLS_EMPTY_RENEGOTIATION_INFO_SCSV" + # The size of the queue event disruptor which handles events before they are published. + # The value specified should always be the result of an exponent with 2 as the base. + queueSize = 32768 + # The maximum number of events in a batch sent to the queue event disruptor at a given time + batchSize = 200 + # The number of threads that will be reserved to handle events at the time you start + corePoolSize = 1 + # Socket timeout + socketTimeoutMS = 30000 + # The maximum number of threads that should be reserved at any given time to handle events + maxPoolSize = 1 + # The amount of time which threads in excess of the core pool size may remain idle before being terminated. + keepAliveTimeInPool = 20 + # The time interval between reconnection + reconnectionInterval = 30 + # TCP connection pool configurations (for data publishing) + maxTransportPoolSize = 250 + maxIdleConnections = 250 + evictionTimePeriod = 5500 + minIdleTimeInPool = 5000 + # SSL connection pool configurations (for authentication) + secureMaxTransportPoolSize = 250 + secureMaxIdleConnections = 250 + secureEvictionTimePeriod = 5500 + secureMinIdleTimeInPool = 5000 [controlPlane] # Control plane's eventHub details From a1beae1db22b7073df7a5c2d187b9f75cc7d9443 Mon Sep 17 00:00:00 2001 From: Praminda Jayawardana Date: Wed, 10 Mar 2021 14:56:53 +0530 Subject: [PATCH 15/21] throttle: enf: Add common method to set errors --- .../enforcer/filters/ThrottleFilter.java | 37 ++++++++++++------- .../gateway/enforcer/util/FilterUtils.java | 17 +++++++++ 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java index 6ccb5aa2cc..3c73c4e185 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java @@ -96,18 +96,31 @@ private boolean doThrottle(RequestContext reqContext) { String subTier = authContext.getTier(); String appTier = authContext.getApplicationTier(); + if (isAPILevelThrottled(apiThrottleKey, apiTier)) { + FilterUtils.setThrottleErrorToContext(reqContext, + ThrottleConstants.API_THROTTLE_OUT_ERROR_CODE, + ThrottleConstants.THROTTLE_OUT_MESSAGE, + ThrottleConstants.THROTTLE_OUT_DESCRIPTION); + reqContext.getProperties().put(APIConstants.THROTTLE_OUT_REASON, + ThrottleConstants.THROTTLE_OUT_REASON_API_LIMIT_EXCEEDED); + return true; + } else if (isResourceLevelThrottled(resourceThrottleKey, resourceTier)) { + FilterUtils.setThrottleErrorToContext(reqContext, + ThrottleConstants.RESOURCE_THROTTLE_OUT_ERROR_CODE, + ThrottleConstants.THROTTLE_OUT_MESSAGE, + ThrottleConstants.THROTTLE_OUT_DESCRIPTION); + reqContext.getProperties().put(APIConstants.THROTTLE_OUT_REASON, + ThrottleConstants.THROTTLE_OUT_REASON_RESOURCE_LIMIT_EXCEEDED); + return true; + } String subThrottleKey = getSubscriptionThrottleKey(appId, apiContext, apiVersion); boolean isSubscriptionThrottled = isSubscriptionLevelThrottled(subThrottleKey, subTier); if (isSubscriptionThrottled) { if (authContext.isStopOnQuotaReach()) { log.debug("Setting subscription throttle out response"); - reqContext.getProperties().put(APIConstants.MessageFormat.ERROR_CODE, - ThrottleConstants.SUBSCRIPTION_THROTTLE_OUT_ERROR_CODE); - reqContext.getProperties().put(APIConstants.MessageFormat.STATUS_CODE, - APIConstants.StatusCodes.THROTTLED.getCode()); - reqContext.getProperties().put(APIConstants.MessageFormat.ERROR_MESSAGE, - ThrottleConstants.THROTTLE_OUT_MESSAGE); - reqContext.getProperties().put(APIConstants.MessageFormat.ERROR_DESCRIPTION, + FilterUtils.setThrottleErrorToContext(reqContext, + ThrottleConstants.SUBSCRIPTION_THROTTLE_OUT_ERROR_CODE, + ThrottleConstants.THROTTLE_OUT_MESSAGE, ThrottleConstants.THROTTLE_OUT_DESCRIPTION); reqContext.getProperties().put(APIConstants.THROTTLE_OUT_REASON, ThrottleConstants.THROTTLE_OUT_REASON_SUBSCRIPTION_LIMIT_EXCEEDED); @@ -120,13 +133,9 @@ private boolean doThrottle(RequestContext reqContext) { boolean isAppThrottled = isAppLevelThrottled(appThrottleKey, appTier); if (isAppThrottled) { log.debug("Setting application throttle out response"); - reqContext.getProperties().put(APIConstants.MessageFormat.ERROR_CODE, - ThrottleConstants.APPLICATION_THROTTLE_OUT_ERROR_CODE); - reqContext.getProperties().put(APIConstants.MessageFormat.STATUS_CODE, - APIConstants.StatusCodes.THROTTLED.getCode()); - reqContext.getProperties().put(APIConstants.MessageFormat.ERROR_MESSAGE, - ThrottleConstants.THROTTLE_OUT_MESSAGE); - reqContext.getProperties().put(APIConstants.MessageFormat.ERROR_DESCRIPTION, + FilterUtils.setThrottleErrorToContext(reqContext, + ThrottleConstants.APPLICATION_THROTTLE_OUT_ERROR_CODE, + ThrottleConstants.THROTTLE_OUT_MESSAGE, ThrottleConstants.THROTTLE_OUT_DESCRIPTION); reqContext.getProperties().put(APIConstants.THROTTLE_OUT_REASON, ThrottleConstants.THROTTLE_OUT_REASON_APPLICATION_LIMIT_EXCEEDED); diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/util/FilterUtils.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/util/FilterUtils.java index c4ff3b3319..cb76ed1fc7 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/util/FilterUtils.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/util/FilterUtils.java @@ -43,6 +43,7 @@ import org.wso2.micro.gateway.enforcer.exception.APISecurityException; import org.wso2.micro.gateway.enforcer.exception.MGWException; import org.wso2.micro.gateway.enforcer.security.AuthenticationContext; +import org.wso2.micro.gateway.enforcer.throttle.ThrottleConstants; import java.math.BigInteger; import java.net.InetAddress; @@ -341,4 +342,20 @@ public static void setUnauthenticatedErrorToContext(RequestContext requestContex APISecurityConstants.API_AUTH_INVALID_CREDENTIALS_DESCRIPTION); } + /** + * Set the throttle error related details to the {@code RequestContext}. + * + * @param context request context object to set the details. + * @param errorCode internal wso2 throttle error code. + * @param msg wso2 throttle error message. + * @param desc description of throttle decision. + */ + public static void setThrottleErrorToContext(RequestContext context, int errorCode, String msg, String desc) { + context.getProperties().put(APIConstants.MessageFormat.ERROR_CODE, errorCode); + context.getProperties().put(APIConstants.MessageFormat.STATUS_CODE, + APIConstants.StatusCodes.THROTTLED.getCode()); + context.getProperties().put(APIConstants.MessageFormat.ERROR_MESSAGE, msg); + context.getProperties().put(APIConstants.MessageFormat.ERROR_DESCRIPTION, desc); + } + } From 30f8aef25800657a18173830e1da45324871e0d2 Mon Sep 17 00:00:00 2001 From: Praminda Jayawardana Date: Thu, 11 Mar 2021 13:48:26 +0530 Subject: [PATCH 16/21] throttle: Update config format simplified the throttle publisher and receiver config structure --- adapter/config/types.go | 36 +- .../config/enforcer/binary_publisher.pb.go | 226 +++ .../config/enforcer/binary_throttling.pb.go | 227 --- .../discovery/config/enforcer/config.pb.go | 63 +- .../config/enforcer/throttle_publisher.pb.go | 214 --- .../enforcer/throttle_publisher_pool.pb.go | 214 +++ .../config/enforcer/throttling.pb.go | 136 +- adapter/internal/discovery/xds/marshaller.go | 70 +- ...hrottling.proto => binary_publisher.proto} | 10 +- .../discovery/config/enforcer/config.proto | 2 +- ...er.proto => throttle_publisher_pool.proto} | 8 +- .../config/enforcer/throttling.proto | 6 +- .../config/enforcer/BinaryPublisher.java | 1422 +++++++++++++++++ .../enforcer/BinaryPublisherOrBuilder.java | 87 + .../config/enforcer/BinaryPublisherProto.java | 68 + .../discovery/config/enforcer/Config.java | 180 +-- .../config/enforcer/ConfigOrBuilder.java | 16 +- .../config/enforcer/ConfigProto.java | 19 +- .../config/enforcer/PublisherPool.java | 747 +++++++++ .../enforcer/PublisherPoolOrBuilder.java | 39 + .../config/enforcer/PublisherPoolProto.java | 57 + .../discovery/config/enforcer/Throttling.java | 464 ++---- .../config/enforcer/ThrottlingOrBuilder.java | 40 +- .../config/enforcer/ThrottlingProto.java | 35 +- .../gateway/enforcer/config/ConfigHolder.java | 24 +- .../config/dto/ThrottleConfigDto.java | 18 - .../gateway/enforcer/util/FilterUtils.java | 1 - resources/conf/config.toml | 14 +- 28 files changed, 3253 insertions(+), 1190 deletions(-) create mode 100644 adapter/internal/discovery/api/wso2/discovery/config/enforcer/binary_publisher.pb.go delete mode 100644 adapter/internal/discovery/api/wso2/discovery/config/enforcer/binary_throttling.pb.go delete mode 100644 adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_publisher.pb.go create mode 100644 adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_publisher_pool.pb.go rename api/wso2/discovery/config/enforcer/{binary_throttling.proto => binary_publisher.proto} (69%) rename api/wso2/discovery/config/enforcer/{throttle_publisher.proto => throttle_publisher_pool.proto} (74%) create mode 100644 enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisher.java create mode 100644 enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisherOrBuilder.java create mode 100644 enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisherProto.java create mode 100644 enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPool.java create mode 100644 enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPoolOrBuilder.java create mode 100644 enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPoolProto.java diff --git a/adapter/config/types.go b/adapter/config/types.go index 97e2f35332..1d6e4d7427 100644 --- a/adapter/config/types.go +++ b/adapter/config/types.go @@ -105,7 +105,7 @@ type Config struct { KeyStore keystore ListenerTLSEnabled bool - // Envoy Upstream Related Connfigurations + // Envoy Upstream Related Configurations Upstream struct { //UpstreamTLS related Configuration TLS struct { @@ -120,13 +120,13 @@ type Config struct { } Enforcer struct { - JwtTokenConfig []jwtTokenConfig - EventHub eventHub - ApimCredentials apimCredentials - AuthService authService - JwtGenerator jwtGenerator - Cache cache - ThrottlingConfig throttlingConfig + JwtTokenConfig []jwtTokenConfig + EventHub eventHub + ApimCredentials apimCredentials + AuthService authService + JwtGenerator jwtGenerator + Cache cache + Throttling throttlingConfig } ControlPlane controlPlane `toml:"controlPlane"` @@ -184,19 +184,17 @@ type throttlingConfig struct { EnableHeaderConditions bool `toml:"enableHeaderConditions"` EnableQueryParamConditions bool `toml:"enableQueryParamConditions"` EnableJwtClaimConditions bool `toml:"enableJwtClaimConditions"` - JmsConnectioninitialContextFactory string `toml:"jmsConnectioninitialContextFactory"` + JmsConnectionInitialContextFactory string `toml:"jmsConnectioninitialContextFactory"` JmsConnectionProviderURL string `toml:"jmsConnectionProviderUrl"` - JmsConnectionUsername string `toml:"jmsConnectionUsername"` - JmsConnectionPassword string `toml:"jmsConnectionPassword"` - Binary binaryThrottleConfig + Publisher binaryPublisher } -type binaryThrottleConfig struct { - Username string - Password string - URLGroup []urlGroup `toml:"urlGroup"` - Publisher binaryPublisher - Agent binaryAgent +type binaryPublisher struct { + Username string + Password string + URLGroup []urlGroup `toml:"urlGroup"` + Pool publisherPool + Agent binaryAgent } type urlGroup struct { @@ -205,7 +203,7 @@ type urlGroup struct { Type string `toml:"type"` } -type binaryPublisher struct { +type publisherPool struct { MaxIdleDataPublishingAgents int32 InitIdleObjectDataPublishingAgents int32 PublisherThreadPoolCoreSize int32 diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/binary_publisher.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/binary_publisher.pb.go new file mode 100644 index 0000000000..49f214a69b --- /dev/null +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/binary_publisher.pb.go @@ -0,0 +1,226 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.15.5 +// source: wso2/discovery/config/enforcer/binary_publisher.proto + +package enforcer + +import ( + proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +type BinaryPublisher struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` + Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` + UrlGroup []*TMURLGroup `protobuf:"bytes,4,rep,name=urlGroup,proto3" json:"urlGroup,omitempty"` + Pool *PublisherPool `protobuf:"bytes,5,opt,name=pool,proto3" json:"pool,omitempty"` + Agent *ThrottleAgent `protobuf:"bytes,6,opt,name=agent,proto3" json:"agent,omitempty"` +} + +func (x *BinaryPublisher) Reset() { + *x = BinaryPublisher{} + if protoimpl.UnsafeEnabled { + mi := &file_wso2_discovery_config_enforcer_binary_publisher_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BinaryPublisher) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BinaryPublisher) ProtoMessage() {} + +func (x *BinaryPublisher) ProtoReflect() protoreflect.Message { + mi := &file_wso2_discovery_config_enforcer_binary_publisher_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BinaryPublisher.ProtoReflect.Descriptor instead. +func (*BinaryPublisher) Descriptor() ([]byte, []int) { + return file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDescGZIP(), []int{0} +} + +func (x *BinaryPublisher) GetUsername() string { + if x != nil { + return x.Username + } + return "" +} + +func (x *BinaryPublisher) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +func (x *BinaryPublisher) GetUrlGroup() []*TMURLGroup { + if x != nil { + return x.UrlGroup + } + return nil +} + +func (x *BinaryPublisher) GetPool() *PublisherPool { + if x != nil { + return x.Pool + } + return nil +} + +func (x *BinaryPublisher) GetAgent() *ThrottleAgent { + if x != nil { + return x.Agent + } + return nil +} + +var File_wso2_discovery_config_enforcer_binary_publisher_proto protoreflect.FileDescriptor + +var file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDesc = []byte{ + 0x0a, 0x35, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, + 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, + 0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, + 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, + 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, + 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x1a, 0x31, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, + 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, + 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2f, 0x74, 0x6d, 0x5f, 0x75, 0x72, 0x6c, 0x5f, 0x67, + 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x3c, 0x77, 0x73, 0x6f, 0x32, + 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2f, 0x74, 0x68, 0x72, 0x6f, 0x74, + 0x74, 0x6c, 0x65, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x5f, 0x70, 0x6f, + 0x6f, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x33, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, + 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, + 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2f, 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, + 0x65, 0x5f, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x99, 0x02, + 0x0a, 0x0f, 0x42, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, + 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, + 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x46, 0x0a, 0x08, 0x75, 0x72, 0x6c, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x77, 0x73, + 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x54, 0x4d, 0x55, + 0x52, 0x4c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x08, 0x75, 0x72, 0x6c, 0x47, 0x72, 0x6f, 0x75, + 0x70, 0x12, 0x41, 0x0a, 0x04, 0x70, 0x6f, 0x6f, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x2d, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, + 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, + 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x50, 0x6f, 0x6f, 0x6c, 0x52, 0x04, + 0x70, 0x6f, 0x6f, 0x6c, 0x12, 0x43, 0x0a, 0x05, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, + 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, + 0x72, 0x63, 0x65, 0x72, 0x2e, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x65, 0x41, 0x67, 0x65, + 0x6e, 0x74, 0x52, 0x05, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x42, 0x94, 0x01, 0x0a, 0x2a, 0x6f, 0x72, + 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x64, + 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, + 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, 0x14, 0x42, 0x69, 0x6e, 0x61, 0x72, 0x79, + 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, + 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, + 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, + 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, + 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDescOnce sync.Once + file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDescData = file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDesc +) + +func file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDescGZIP() []byte { + file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDescOnce.Do(func() { + file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDescData) + }) + return file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDescData +} + +var file_wso2_discovery_config_enforcer_binary_publisher_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_wso2_discovery_config_enforcer_binary_publisher_proto_goTypes = []interface{}{ + (*BinaryPublisher)(nil), // 0: wso2.discovery.config.enforcer.BinaryPublisher + (*TMURLGroup)(nil), // 1: wso2.discovery.config.enforcer.TMURLGroup + (*PublisherPool)(nil), // 2: wso2.discovery.config.enforcer.PublisherPool + (*ThrottleAgent)(nil), // 3: wso2.discovery.config.enforcer.ThrottleAgent +} +var file_wso2_discovery_config_enforcer_binary_publisher_proto_depIdxs = []int32{ + 1, // 0: wso2.discovery.config.enforcer.BinaryPublisher.urlGroup:type_name -> wso2.discovery.config.enforcer.TMURLGroup + 2, // 1: wso2.discovery.config.enforcer.BinaryPublisher.pool:type_name -> wso2.discovery.config.enforcer.PublisherPool + 3, // 2: wso2.discovery.config.enforcer.BinaryPublisher.agent:type_name -> wso2.discovery.config.enforcer.ThrottleAgent + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_wso2_discovery_config_enforcer_binary_publisher_proto_init() } +func file_wso2_discovery_config_enforcer_binary_publisher_proto_init() { + if File_wso2_discovery_config_enforcer_binary_publisher_proto != nil { + return + } + file_wso2_discovery_config_enforcer_tm_url_group_proto_init() + file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_init() + file_wso2_discovery_config_enforcer_throttle_agent_proto_init() + if !protoimpl.UnsafeEnabled { + file_wso2_discovery_config_enforcer_binary_publisher_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BinaryPublisher); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_wso2_discovery_config_enforcer_binary_publisher_proto_goTypes, + DependencyIndexes: file_wso2_discovery_config_enforcer_binary_publisher_proto_depIdxs, + MessageInfos: file_wso2_discovery_config_enforcer_binary_publisher_proto_msgTypes, + }.Build() + File_wso2_discovery_config_enforcer_binary_publisher_proto = out.File + file_wso2_discovery_config_enforcer_binary_publisher_proto_rawDesc = nil + file_wso2_discovery_config_enforcer_binary_publisher_proto_goTypes = nil + file_wso2_discovery_config_enforcer_binary_publisher_proto_depIdxs = nil +} diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/binary_throttling.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/binary_throttling.pb.go deleted file mode 100644 index 71d59f4e98..0000000000 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/binary_throttling.pb.go +++ /dev/null @@ -1,227 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0 -// protoc v3.15.5 -// source: wso2/discovery/config/enforcer/binary_throttling.proto - -package enforcer - -import ( - proto "github.com/golang/protobuf/proto" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - -type BinaryThrottling struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` - Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` - UrlGroup []*TMURLGroup `protobuf:"bytes,4,rep,name=urlGroup,proto3" json:"urlGroup,omitempty"` - Publisher *ThrottlePublisher `protobuf:"bytes,5,opt,name=publisher,proto3" json:"publisher,omitempty"` - Agent *ThrottleAgent `protobuf:"bytes,6,opt,name=agent,proto3" json:"agent,omitempty"` -} - -func (x *BinaryThrottling) Reset() { - *x = BinaryThrottling{} - if protoimpl.UnsafeEnabled { - mi := &file_wso2_discovery_config_enforcer_binary_throttling_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *BinaryThrottling) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*BinaryThrottling) ProtoMessage() {} - -func (x *BinaryThrottling) ProtoReflect() protoreflect.Message { - mi := &file_wso2_discovery_config_enforcer_binary_throttling_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use BinaryThrottling.ProtoReflect.Descriptor instead. -func (*BinaryThrottling) Descriptor() ([]byte, []int) { - return file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDescGZIP(), []int{0} -} - -func (x *BinaryThrottling) GetUsername() string { - if x != nil { - return x.Username - } - return "" -} - -func (x *BinaryThrottling) GetPassword() string { - if x != nil { - return x.Password - } - return "" -} - -func (x *BinaryThrottling) GetUrlGroup() []*TMURLGroup { - if x != nil { - return x.UrlGroup - } - return nil -} - -func (x *BinaryThrottling) GetPublisher() *ThrottlePublisher { - if x != nil { - return x.Publisher - } - return nil -} - -func (x *BinaryThrottling) GetAgent() *ThrottleAgent { - if x != nil { - return x.Agent - } - return nil -} - -var File_wso2_discovery_config_enforcer_binary_throttling_proto protoreflect.FileDescriptor - -var file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDesc = []byte{ - 0x0a, 0x36, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, - 0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x5f, 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, - 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, - 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, - 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x1a, 0x31, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, - 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, - 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2f, 0x74, 0x6d, 0x5f, 0x75, 0x72, 0x6c, 0x5f, - 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x37, 0x77, 0x73, 0x6f, - 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2f, 0x74, 0x68, 0x72, 0x6f, - 0x74, 0x74, 0x6c, 0x65, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x33, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, - 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, - 0x72, 0x63, 0x65, 0x72, 0x2f, 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x65, 0x5f, 0x61, 0x67, - 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa8, 0x02, 0x0a, 0x10, 0x42, 0x69, - 0x6e, 0x61, 0x72, 0x79, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x12, 0x1a, - 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, - 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, - 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x46, 0x0a, 0x08, 0x75, 0x72, 0x6c, 0x47, 0x72, 0x6f, - 0x75, 0x70, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, - 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x54, 0x4d, 0x55, 0x52, 0x4c, 0x47, - 0x72, 0x6f, 0x75, 0x70, 0x52, 0x08, 0x75, 0x72, 0x6c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x4f, - 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x31, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, - 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, - 0x65, 0x72, 0x2e, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, - 0x73, 0x68, 0x65, 0x72, 0x52, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x12, - 0x43, 0x0a, 0x05, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, - 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, - 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x65, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x61, - 0x67, 0x65, 0x6e, 0x74, 0x42, 0x95, 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, - 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, - 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, - 0x63, 0x65, 0x72, 0x42, 0x15, 0x42, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x54, 0x68, 0x72, 0x6f, 0x74, - 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, - 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, - 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, - 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, - 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDescOnce sync.Once - file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDescData = file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDesc -) - -func file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDescGZIP() []byte { - file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDescOnce.Do(func() { - file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDescData) - }) - return file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDescData -} - -var file_wso2_discovery_config_enforcer_binary_throttling_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_wso2_discovery_config_enforcer_binary_throttling_proto_goTypes = []interface{}{ - (*BinaryThrottling)(nil), // 0: wso2.discovery.config.enforcer.BinaryThrottling - (*TMURLGroup)(nil), // 1: wso2.discovery.config.enforcer.TMURLGroup - (*ThrottlePublisher)(nil), // 2: wso2.discovery.config.enforcer.ThrottlePublisher - (*ThrottleAgent)(nil), // 3: wso2.discovery.config.enforcer.ThrottleAgent -} -var file_wso2_discovery_config_enforcer_binary_throttling_proto_depIdxs = []int32{ - 1, // 0: wso2.discovery.config.enforcer.BinaryThrottling.urlGroup:type_name -> wso2.discovery.config.enforcer.TMURLGroup - 2, // 1: wso2.discovery.config.enforcer.BinaryThrottling.publisher:type_name -> wso2.discovery.config.enforcer.ThrottlePublisher - 3, // 2: wso2.discovery.config.enforcer.BinaryThrottling.agent:type_name -> wso2.discovery.config.enforcer.ThrottleAgent - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name -} - -func init() { file_wso2_discovery_config_enforcer_binary_throttling_proto_init() } -func file_wso2_discovery_config_enforcer_binary_throttling_proto_init() { - if File_wso2_discovery_config_enforcer_binary_throttling_proto != nil { - return - } - file_wso2_discovery_config_enforcer_tm_url_group_proto_init() - file_wso2_discovery_config_enforcer_throttle_publisher_proto_init() - file_wso2_discovery_config_enforcer_throttle_agent_proto_init() - if !protoimpl.UnsafeEnabled { - file_wso2_discovery_config_enforcer_binary_throttling_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BinaryThrottling); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_wso2_discovery_config_enforcer_binary_throttling_proto_goTypes, - DependencyIndexes: file_wso2_discovery_config_enforcer_binary_throttling_proto_depIdxs, - MessageInfos: file_wso2_discovery_config_enforcer_binary_throttling_proto_msgTypes, - }.Build() - File_wso2_discovery_config_enforcer_binary_throttling_proto = out.File - file_wso2_discovery_config_enforcer_binary_throttling_proto_rawDesc = nil - file_wso2_discovery_config_enforcer_binary_throttling_proto_goTypes = nil - file_wso2_discovery_config_enforcer_binary_throttling_proto_depIdxs = nil -} diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/config.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/config.pb.go index 35b942ccfa..7ab76dd192 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/config.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/config.pb.go @@ -31,15 +31,15 @@ type Config struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - JwtTokenConfig []*Issuer `protobuf:"bytes,1,rep,name=jwtTokenConfig,proto3" json:"jwtTokenConfig,omitempty"` - Keystore *CertStore `protobuf:"bytes,2,opt,name=keystore,proto3" json:"keystore,omitempty"` - Truststore *CertStore `protobuf:"bytes,3,opt,name=truststore,proto3" json:"truststore,omitempty"` - Eventhub *EventHub `protobuf:"bytes,4,opt,name=eventhub,proto3" json:"eventhub,omitempty"` - AuthService *AuthService `protobuf:"bytes,5,opt,name=authService,proto3" json:"authService,omitempty"` - ApimCredentials *AmCredentials `protobuf:"bytes,6,opt,name=apimCredentials,proto3" json:"apimCredentials,omitempty"` - JwtGenerator *JWTGenerator `protobuf:"bytes,7,opt,name=jwtGenerator,proto3" json:"jwtGenerator,omitempty"` - ThrottlingConfig *Throttling `protobuf:"bytes,8,opt,name=throttlingConfig,proto3" json:"throttlingConfig,omitempty"` - Cache *Cache `protobuf:"bytes,9,opt,name=cache,proto3" json:"cache,omitempty"` + JwtTokenConfig []*Issuer `protobuf:"bytes,1,rep,name=jwtTokenConfig,proto3" json:"jwtTokenConfig,omitempty"` + Keystore *CertStore `protobuf:"bytes,2,opt,name=keystore,proto3" json:"keystore,omitempty"` + Truststore *CertStore `protobuf:"bytes,3,opt,name=truststore,proto3" json:"truststore,omitempty"` + Eventhub *EventHub `protobuf:"bytes,4,opt,name=eventhub,proto3" json:"eventhub,omitempty"` + AuthService *AuthService `protobuf:"bytes,5,opt,name=authService,proto3" json:"authService,omitempty"` + ApimCredentials *AmCredentials `protobuf:"bytes,6,opt,name=apimCredentials,proto3" json:"apimCredentials,omitempty"` + JwtGenerator *JWTGenerator `protobuf:"bytes,7,opt,name=jwtGenerator,proto3" json:"jwtGenerator,omitempty"` + Throttling *Throttling `protobuf:"bytes,8,opt,name=throttling,proto3" json:"throttling,omitempty"` + Cache *Cache `protobuf:"bytes,9,opt,name=cache,proto3" json:"cache,omitempty"` } func (x *Config) Reset() { @@ -123,9 +123,9 @@ func (x *Config) GetJwtGenerator() *JWTGenerator { return nil } -func (x *Config) GetThrottlingConfig() *Throttling { +func (x *Config) GetThrottling() *Throttling { if x != nil { - return x.ThrottlingConfig + return x.Throttling } return nil } @@ -168,7 +168,7 @@ var file_wso2_discovery_config_enforcer_config_proto_rawDesc = []byte{ 0x72, 0x2f, 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, - 0x65, 0x72, 0x2f, 0x63, 0x61, 0x63, 0x68, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbf, + 0x65, 0x72, 0x2f, 0x63, 0x61, 0x63, 0x68, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb3, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4e, 0x0a, 0x0e, 0x6a, 0x77, 0x74, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, @@ -203,26 +203,25 @@ var file_wso2_discovery_config_enforcer_config_proto_rawDesc = []byte{ 0x2c, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x4a, 0x57, 0x54, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x0c, 0x6a, - 0x77, 0x74, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x56, 0x0a, 0x10, 0x74, - 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, - 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, - 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, - 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, - 0x67, 0x52, 0x10, 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x12, 0x3b, 0x0a, 0x05, 0x63, 0x61, 0x63, 0x68, 0x65, 0x18, 0x09, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, + 0x77, 0x74, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x4a, 0x0a, 0x0a, 0x74, + 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x2a, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, + 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, + 0x2e, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x52, 0x0a, 0x74, 0x68, 0x72, + 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x12, 0x3b, 0x0a, 0x05, 0x63, 0x61, 0x63, 0x68, 0x65, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, + 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, + 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x05, 0x63, + 0x61, 0x63, 0x68, 0x65, 0x42, 0x8b, 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, + 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, - 0x63, 0x65, 0x72, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x05, 0x63, 0x61, 0x63, 0x68, 0x65, - 0x42, 0x8b, 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x67, 0x61, - 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, - 0x0b, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, - 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, - 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, - 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x65, 0x72, 0x42, 0x0b, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, + 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, + 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, + 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, + 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -257,7 +256,7 @@ var file_wso2_discovery_config_enforcer_config_proto_depIdxs = []int32{ 4, // 4: wso2.discovery.config.enforcer.Config.authService:type_name -> wso2.discovery.config.enforcer.AuthService 5, // 5: wso2.discovery.config.enforcer.Config.apimCredentials:type_name -> wso2.discovery.config.enforcer.AmCredentials 6, // 6: wso2.discovery.config.enforcer.Config.jwtGenerator:type_name -> wso2.discovery.config.enforcer.JWTGenerator - 7, // 7: wso2.discovery.config.enforcer.Config.throttlingConfig:type_name -> wso2.discovery.config.enforcer.Throttling + 7, // 7: wso2.discovery.config.enforcer.Config.throttling:type_name -> wso2.discovery.config.enforcer.Throttling 8, // 8: wso2.discovery.config.enforcer.Config.cache:type_name -> wso2.discovery.config.enforcer.Cache 9, // [9:9] is the sub-list for method output_type 9, // [9:9] is the sub-list for method input_type diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_publisher.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_publisher.pb.go deleted file mode 100644 index 87a27afac4..0000000000 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_publisher.pb.go +++ /dev/null @@ -1,214 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0 -// protoc v3.15.5 -// source: wso2/discovery/config/enforcer/throttle_publisher.proto - -package enforcer - -import ( - proto "github.com/golang/protobuf/proto" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - -// Throttle Publisher configuration model -type ThrottlePublisher struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - MaxIdleDataPublishingAgents int32 `protobuf:"varint,1,opt,name=maxIdleDataPublishingAgents,proto3" json:"maxIdleDataPublishingAgents,omitempty"` - InitIdleObjectDataPublishingAgents int32 `protobuf:"varint,2,opt,name=initIdleObjectDataPublishingAgents,proto3" json:"initIdleObjectDataPublishingAgents,omitempty"` - PublisherThreadPoolCoreSize int32 `protobuf:"varint,3,opt,name=publisherThreadPoolCoreSize,proto3" json:"publisherThreadPoolCoreSize,omitempty"` - PublisherThreadPoolMaximumSize int32 `protobuf:"varint,4,opt,name=publisherThreadPoolMaximumSize,proto3" json:"publisherThreadPoolMaximumSize,omitempty"` - PublisherThreadPoolKeepAliveTime int32 `protobuf:"varint,5,opt,name=publisherThreadPoolKeepAliveTime,proto3" json:"publisherThreadPoolKeepAliveTime,omitempty"` -} - -func (x *ThrottlePublisher) Reset() { - *x = ThrottlePublisher{} - if protoimpl.UnsafeEnabled { - mi := &file_wso2_discovery_config_enforcer_throttle_publisher_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ThrottlePublisher) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ThrottlePublisher) ProtoMessage() {} - -func (x *ThrottlePublisher) ProtoReflect() protoreflect.Message { - mi := &file_wso2_discovery_config_enforcer_throttle_publisher_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ThrottlePublisher.ProtoReflect.Descriptor instead. -func (*ThrottlePublisher) Descriptor() ([]byte, []int) { - return file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDescGZIP(), []int{0} -} - -func (x *ThrottlePublisher) GetMaxIdleDataPublishingAgents() int32 { - if x != nil { - return x.MaxIdleDataPublishingAgents - } - return 0 -} - -func (x *ThrottlePublisher) GetInitIdleObjectDataPublishingAgents() int32 { - if x != nil { - return x.InitIdleObjectDataPublishingAgents - } - return 0 -} - -func (x *ThrottlePublisher) GetPublisherThreadPoolCoreSize() int32 { - if x != nil { - return x.PublisherThreadPoolCoreSize - } - return 0 -} - -func (x *ThrottlePublisher) GetPublisherThreadPoolMaximumSize() int32 { - if x != nil { - return x.PublisherThreadPoolMaximumSize - } - return 0 -} - -func (x *ThrottlePublisher) GetPublisherThreadPoolKeepAliveTime() int32 { - if x != nil { - return x.PublisherThreadPoolKeepAliveTime - } - return 0 -} - -var File_wso2_discovery_config_enforcer_throttle_publisher_proto protoreflect.FileDescriptor - -var file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDesc = []byte{ - 0x0a, 0x37, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, - 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, - 0x2f, 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x65, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, - 0x68, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1e, 0x77, 0x73, 0x6f, 0x32, 0x2e, - 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x22, 0xfb, 0x02, 0x0a, 0x11, 0x54, 0x68, - 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x12, - 0x40, 0x0a, 0x1b, 0x6d, 0x61, 0x78, 0x49, 0x64, 0x6c, 0x65, 0x44, 0x61, 0x74, 0x61, 0x50, 0x75, - 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x1b, 0x6d, 0x61, 0x78, 0x49, 0x64, 0x6c, 0x65, 0x44, 0x61, 0x74, - 0x61, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x41, 0x67, 0x65, 0x6e, 0x74, - 0x73, 0x12, 0x4e, 0x0a, 0x22, 0x69, 0x6e, 0x69, 0x74, 0x49, 0x64, 0x6c, 0x65, 0x4f, 0x62, 0x6a, - 0x65, 0x63, 0x74, 0x44, 0x61, 0x74, 0x61, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, - 0x67, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x22, 0x69, - 0x6e, 0x69, 0x74, 0x49, 0x64, 0x6c, 0x65, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x44, 0x61, 0x74, - 0x61, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x41, 0x67, 0x65, 0x6e, 0x74, - 0x73, 0x12, 0x40, 0x0a, 0x1b, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x54, 0x68, - 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, 0x6c, 0x43, 0x6f, 0x72, 0x65, 0x53, 0x69, 0x7a, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x1b, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, - 0x72, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, 0x6c, 0x43, 0x6f, 0x72, 0x65, 0x53, - 0x69, 0x7a, 0x65, 0x12, 0x46, 0x0a, 0x1e, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, - 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, 0x6c, 0x4d, 0x61, 0x78, 0x69, 0x6d, 0x75, - 0x6d, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x1e, 0x70, 0x75, 0x62, - 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, 0x6c, - 0x4d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x4a, 0x0a, 0x20, 0x70, - 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, - 0x6f, 0x6c, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x20, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, - 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, 0x6c, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, - 0x69, 0x76, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x42, 0x97, 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, 0x2e, - 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, 0x73, - 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, - 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, 0x17, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x65, - 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, - 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, - 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, - 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, - 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, - 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDescOnce sync.Once - file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDescData = file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDesc -) - -func file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDescGZIP() []byte { - file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDescOnce.Do(func() { - file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDescData) - }) - return file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDescData -} - -var file_wso2_discovery_config_enforcer_throttle_publisher_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_wso2_discovery_config_enforcer_throttle_publisher_proto_goTypes = []interface{}{ - (*ThrottlePublisher)(nil), // 0: wso2.discovery.config.enforcer.ThrottlePublisher -} -var file_wso2_discovery_config_enforcer_throttle_publisher_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_wso2_discovery_config_enforcer_throttle_publisher_proto_init() } -func file_wso2_discovery_config_enforcer_throttle_publisher_proto_init() { - if File_wso2_discovery_config_enforcer_throttle_publisher_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_wso2_discovery_config_enforcer_throttle_publisher_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ThrottlePublisher); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_wso2_discovery_config_enforcer_throttle_publisher_proto_goTypes, - DependencyIndexes: file_wso2_discovery_config_enforcer_throttle_publisher_proto_depIdxs, - MessageInfos: file_wso2_discovery_config_enforcer_throttle_publisher_proto_msgTypes, - }.Build() - File_wso2_discovery_config_enforcer_throttle_publisher_proto = out.File - file_wso2_discovery_config_enforcer_throttle_publisher_proto_rawDesc = nil - file_wso2_discovery_config_enforcer_throttle_publisher_proto_goTypes = nil - file_wso2_discovery_config_enforcer_throttle_publisher_proto_depIdxs = nil -} diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_publisher_pool.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_publisher_pool.pb.go new file mode 100644 index 0000000000..c5c922b792 --- /dev/null +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttle_publisher_pool.pb.go @@ -0,0 +1,214 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.25.0 +// protoc v3.15.5 +// source: wso2/discovery/config/enforcer/throttle_publisher_pool.proto + +package enforcer + +import ( + proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// This is a compile-time assertion that a sufficiently up-to-date version +// of the legacy proto package is being used. +const _ = proto.ProtoPackageIsVersion4 + +// Throttle Publisher pool configuration model +type PublisherPool struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + MaxIdleDataPublishingAgents int32 `protobuf:"varint,1,opt,name=maxIdleDataPublishingAgents,proto3" json:"maxIdleDataPublishingAgents,omitempty"` + InitIdleObjectDataPublishingAgents int32 `protobuf:"varint,2,opt,name=initIdleObjectDataPublishingAgents,proto3" json:"initIdleObjectDataPublishingAgents,omitempty"` + PublisherThreadPoolCoreSize int32 `protobuf:"varint,3,opt,name=publisherThreadPoolCoreSize,proto3" json:"publisherThreadPoolCoreSize,omitempty"` + PublisherThreadPoolMaximumSize int32 `protobuf:"varint,4,opt,name=publisherThreadPoolMaximumSize,proto3" json:"publisherThreadPoolMaximumSize,omitempty"` + PublisherThreadPoolKeepAliveTime int32 `protobuf:"varint,5,opt,name=publisherThreadPoolKeepAliveTime,proto3" json:"publisherThreadPoolKeepAliveTime,omitempty"` +} + +func (x *PublisherPool) Reset() { + *x = PublisherPool{} + if protoimpl.UnsafeEnabled { + mi := &file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PublisherPool) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PublisherPool) ProtoMessage() {} + +func (x *PublisherPool) ProtoReflect() protoreflect.Message { + mi := &file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PublisherPool.ProtoReflect.Descriptor instead. +func (*PublisherPool) Descriptor() ([]byte, []int) { + return file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDescGZIP(), []int{0} +} + +func (x *PublisherPool) GetMaxIdleDataPublishingAgents() int32 { + if x != nil { + return x.MaxIdleDataPublishingAgents + } + return 0 +} + +func (x *PublisherPool) GetInitIdleObjectDataPublishingAgents() int32 { + if x != nil { + return x.InitIdleObjectDataPublishingAgents + } + return 0 +} + +func (x *PublisherPool) GetPublisherThreadPoolCoreSize() int32 { + if x != nil { + return x.PublisherThreadPoolCoreSize + } + return 0 +} + +func (x *PublisherPool) GetPublisherThreadPoolMaximumSize() int32 { + if x != nil { + return x.PublisherThreadPoolMaximumSize + } + return 0 +} + +func (x *PublisherPool) GetPublisherThreadPoolKeepAliveTime() int32 { + if x != nil { + return x.PublisherThreadPoolKeepAliveTime + } + return 0 +} + +var File_wso2_discovery_config_enforcer_throttle_publisher_pool_proto protoreflect.FileDescriptor + +var file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDesc = []byte{ + 0x0a, 0x3c, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, + 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, + 0x2f, 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x65, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, + 0x68, 0x65, 0x72, 0x5f, 0x70, 0x6f, 0x6f, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1e, + 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x22, 0xf7, + 0x02, 0x0a, 0x0d, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x50, 0x6f, 0x6f, 0x6c, + 0x12, 0x40, 0x0a, 0x1b, 0x6d, 0x61, 0x78, 0x49, 0x64, 0x6c, 0x65, 0x44, 0x61, 0x74, 0x61, 0x50, + 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x73, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x1b, 0x6d, 0x61, 0x78, 0x49, 0x64, 0x6c, 0x65, 0x44, 0x61, + 0x74, 0x61, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x41, 0x67, 0x65, 0x6e, + 0x74, 0x73, 0x12, 0x4e, 0x0a, 0x22, 0x69, 0x6e, 0x69, 0x74, 0x49, 0x64, 0x6c, 0x65, 0x4f, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x44, 0x61, 0x74, 0x61, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, + 0x6e, 0x67, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x22, + 0x69, 0x6e, 0x69, 0x74, 0x49, 0x64, 0x6c, 0x65, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x44, 0x61, + 0x74, 0x61, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x41, 0x67, 0x65, 0x6e, + 0x74, 0x73, 0x12, 0x40, 0x0a, 0x1b, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x54, + 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, 0x6c, 0x43, 0x6f, 0x72, 0x65, 0x53, 0x69, 0x7a, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x1b, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, + 0x65, 0x72, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, 0x6c, 0x43, 0x6f, 0x72, 0x65, + 0x53, 0x69, 0x7a, 0x65, 0x12, 0x46, 0x0a, 0x1e, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, + 0x72, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, 0x6c, 0x4d, 0x61, 0x78, 0x69, 0x6d, + 0x75, 0x6d, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x1e, 0x70, 0x75, + 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, + 0x6c, 0x4d, 0x61, 0x78, 0x69, 0x6d, 0x75, 0x6d, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x4a, 0x0a, 0x20, + 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, + 0x6f, 0x6f, 0x6c, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x54, 0x69, 0x6d, 0x65, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x20, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, + 0x72, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x50, 0x6f, 0x6f, 0x6c, 0x4b, 0x65, 0x65, 0x70, 0x41, + 0x6c, 0x69, 0x76, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x42, 0x92, 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, + 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, + 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, + 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, 0x12, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, + 0x65, 0x72, 0x50, 0x6f, 0x6f, 0x6c, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, + 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, + 0x70, 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, + 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, + 0x72, 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDescOnce sync.Once + file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDescData = file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDesc +) + +func file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDescGZIP() []byte { + file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDescOnce.Do(func() { + file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDescData = protoimpl.X.CompressGZIP(file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDescData) + }) + return file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDescData +} + +var file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_goTypes = []interface{}{ + (*PublisherPool)(nil), // 0: wso2.discovery.config.enforcer.PublisherPool +} +var file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_init() } +func file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_init() { + if File_wso2_discovery_config_enforcer_throttle_publisher_pool_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PublisherPool); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_goTypes, + DependencyIndexes: file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_depIdxs, + MessageInfos: file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_msgTypes, + }.Build() + File_wso2_discovery_config_enforcer_throttle_publisher_pool_proto = out.File + file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_rawDesc = nil + file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_goTypes = nil + file_wso2_discovery_config_enforcer_throttle_publisher_pool_proto_depIdxs = nil +} diff --git a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttling.pb.go b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttling.pb.go index 196c13cc00..1f27a2b29c 100644 --- a/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttling.pb.go +++ b/adapter/internal/discovery/api/wso2/discovery/config/enforcer/throttling.pb.go @@ -31,15 +31,13 @@ type Throttling struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - EnableGlobalEventPublishing bool `protobuf:"varint,1,opt,name=enable_global_event_publishing,json=enableGlobalEventPublishing,proto3" json:"enable_global_event_publishing,omitempty"` - EnableHeaderConditions bool `protobuf:"varint,2,opt,name=enable_header_conditions,json=enableHeaderConditions,proto3" json:"enable_header_conditions,omitempty"` - EnableQueryParamConditions bool `protobuf:"varint,3,opt,name=enable_query_param_conditions,json=enableQueryParamConditions,proto3" json:"enable_query_param_conditions,omitempty"` - EnableJwtClaimConditions bool `protobuf:"varint,4,opt,name=enable_jwt_claim_conditions,json=enableJwtClaimConditions,proto3" json:"enable_jwt_claim_conditions,omitempty"` - JmsConnectionInitialContextFactory string `protobuf:"bytes,5,opt,name=jms_connection_initial_context_factory,json=jmsConnectionInitialContextFactory,proto3" json:"jms_connection_initial_context_factory,omitempty"` - JmsConnectionProviderUrl string `protobuf:"bytes,6,opt,name=jms_connection_provider_url,json=jmsConnectionProviderUrl,proto3" json:"jms_connection_provider_url,omitempty"` - JmsConnectionUsername string `protobuf:"bytes,7,opt,name=jms_connection_username,json=jmsConnectionUsername,proto3" json:"jms_connection_username,omitempty"` - JmsConnectionPassword string `protobuf:"bytes,8,opt,name=jms_connection_password,json=jmsConnectionPassword,proto3" json:"jms_connection_password,omitempty"` - Binary *BinaryThrottling `protobuf:"bytes,9,opt,name=binary,proto3" json:"binary,omitempty"` + EnableGlobalEventPublishing bool `protobuf:"varint,1,opt,name=enable_global_event_publishing,json=enableGlobalEventPublishing,proto3" json:"enable_global_event_publishing,omitempty"` + EnableHeaderConditions bool `protobuf:"varint,2,opt,name=enable_header_conditions,json=enableHeaderConditions,proto3" json:"enable_header_conditions,omitempty"` + EnableQueryParamConditions bool `protobuf:"varint,3,opt,name=enable_query_param_conditions,json=enableQueryParamConditions,proto3" json:"enable_query_param_conditions,omitempty"` + EnableJwtClaimConditions bool `protobuf:"varint,4,opt,name=enable_jwt_claim_conditions,json=enableJwtClaimConditions,proto3" json:"enable_jwt_claim_conditions,omitempty"` + JmsConnectionInitialContextFactory string `protobuf:"bytes,5,opt,name=jms_connection_initial_context_factory,json=jmsConnectionInitialContextFactory,proto3" json:"jms_connection_initial_context_factory,omitempty"` + JmsConnectionProviderUrl string `protobuf:"bytes,6,opt,name=jms_connection_provider_url,json=jmsConnectionProviderUrl,proto3" json:"jms_connection_provider_url,omitempty"` + Publisher *BinaryPublisher `protobuf:"bytes,7,opt,name=publisher,proto3" json:"publisher,omitempty"` } func (x *Throttling) Reset() { @@ -116,23 +114,9 @@ func (x *Throttling) GetJmsConnectionProviderUrl() string { return "" } -func (x *Throttling) GetJmsConnectionUsername() string { +func (x *Throttling) GetPublisher() *BinaryPublisher { if x != nil { - return x.JmsConnectionUsername - } - return "" -} - -func (x *Throttling) GetJmsConnectionPassword() string { - if x != nil { - return x.JmsConnectionPassword - } - return "" -} - -func (x *Throttling) GetBinary() *BinaryThrottling { - if x != nil { - return x.Binary + return x.Publisher } return nil } @@ -145,57 +129,51 @@ var file_wso2_discovery_config_enforcer_throttling_proto_rawDesc = []byte{ 0x2f, 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, - 0x72, 0x1a, 0x36, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, + 0x72, 0x1a, 0x35, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, - 0x72, 0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x5f, 0x74, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, - 0x69, 0x6e, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xda, 0x04, 0x0a, 0x0a, 0x54, 0x68, - 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x12, 0x43, 0x0a, 0x1e, 0x65, 0x6e, 0x61, 0x62, - 0x6c, 0x65, 0x5f, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, - 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x1b, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x45, 0x76, - 0x65, 0x6e, 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x38, 0x0a, - 0x18, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x63, - 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x16, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, - 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x41, 0x0a, 0x1d, 0x65, 0x6e, 0x61, 0x62, 0x6c, - 0x65, 0x5f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x5f, 0x63, 0x6f, - 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1a, - 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x3d, 0x0a, 0x1b, 0x65, 0x6e, - 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6a, 0x77, 0x74, 0x5f, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x5f, 0x63, - 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x18, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x4a, 0x77, 0x74, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x43, - 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x52, 0x0a, 0x26, 0x6a, 0x6d, 0x73, - 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, 0x69, 0x74, - 0x69, 0x61, 0x6c, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x5f, 0x66, 0x61, 0x63, 0x74, - 0x6f, 0x72, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x22, 0x6a, 0x6d, 0x73, 0x43, 0x6f, - 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x43, - 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x3d, 0x0a, - 0x1b, 0x6a, 0x6d, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, - 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x18, 0x6a, 0x6d, 0x73, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x55, 0x72, 0x6c, 0x12, 0x36, 0x0a, 0x17, - 0x6a, 0x6d, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x75, - 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x6a, - 0x6d, 0x73, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x73, 0x65, 0x72, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x36, 0x0a, 0x17, 0x6a, 0x6d, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, - 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x6a, 0x6d, 0x73, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x48, 0x0a, 0x06, - 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x77, - 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, 0x42, 0x69, - 0x6e, 0x61, 0x72, 0x79, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x52, 0x06, - 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x42, 0x8f, 0x01, 0x0a, 0x2a, 0x6f, 0x72, 0x67, 0x2e, 0x77, - 0x73, 0x6f, 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, 0x64, 0x69, 0x73, 0x63, - 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, - 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, 0x0f, 0x54, 0x68, 0x72, 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, - 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, - 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, 0x6c, 0x61, 0x6e, 0x65, - 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2f, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x3b, - 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, + 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xef, 0x03, 0x0a, 0x0a, 0x54, 0x68, 0x72, + 0x6f, 0x74, 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x12, 0x43, 0x0a, 0x1e, 0x65, 0x6e, 0x61, 0x62, 0x6c, + 0x65, 0x5f, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x70, + 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x1b, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x12, 0x38, 0x0a, 0x18, + 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x63, 0x6f, + 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, + 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x64, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x41, 0x0a, 0x1d, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, + 0x5f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x5f, 0x63, 0x6f, 0x6e, + 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1a, 0x65, + 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x43, + 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x3d, 0x0a, 0x1b, 0x65, 0x6e, 0x61, + 0x62, 0x6c, 0x65, 0x5f, 0x6a, 0x77, 0x74, 0x5f, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x5f, 0x63, 0x6f, + 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x18, + 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x4a, 0x77, 0x74, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x43, 0x6f, + 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x52, 0x0a, 0x26, 0x6a, 0x6d, 0x73, 0x5f, + 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x6e, 0x69, 0x74, 0x69, + 0x61, 0x6c, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, + 0x72, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x22, 0x6a, 0x6d, 0x73, 0x43, 0x6f, 0x6e, + 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x43, 0x6f, + 0x6e, 0x74, 0x65, 0x78, 0x74, 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x3d, 0x0a, 0x1b, + 0x6a, 0x6d, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x18, 0x6a, 0x6d, 0x73, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x55, 0x72, 0x6c, 0x12, 0x4d, 0x0a, 0x09, 0x70, + 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, + 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x2e, + 0x42, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x52, + 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x72, 0x42, 0x8f, 0x01, 0x0a, 0x2a, 0x6f, + 0x72, 0x67, 0x2e, 0x77, 0x73, 0x6f, 0x32, 0x2e, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x2e, + 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x2e, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x42, 0x0f, 0x54, 0x68, 0x72, 0x6f, 0x74, + 0x74, 0x6c, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4e, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x65, 0x6e, 0x76, 0x6f, 0x79, 0x70, 0x72, + 0x6f, 0x78, 0x79, 0x2f, 0x67, 0x6f, 0x2d, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2d, 0x70, + 0x6c, 0x61, 0x6e, 0x65, 0x2f, 0x77, 0x73, 0x6f, 0x32, 0x2f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, + 0x65, 0x72, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x66, 0x6f, 0x72, + 0x63, 0x65, 0x72, 0x3b, 0x65, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -212,11 +190,11 @@ func file_wso2_discovery_config_enforcer_throttling_proto_rawDescGZIP() []byte { var file_wso2_discovery_config_enforcer_throttling_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_wso2_discovery_config_enforcer_throttling_proto_goTypes = []interface{}{ - (*Throttling)(nil), // 0: wso2.discovery.config.enforcer.Throttling - (*BinaryThrottling)(nil), // 1: wso2.discovery.config.enforcer.BinaryThrottling + (*Throttling)(nil), // 0: wso2.discovery.config.enforcer.Throttling + (*BinaryPublisher)(nil), // 1: wso2.discovery.config.enforcer.BinaryPublisher } var file_wso2_discovery_config_enforcer_throttling_proto_depIdxs = []int32{ - 1, // 0: wso2.discovery.config.enforcer.Throttling.binary:type_name -> wso2.discovery.config.enforcer.BinaryThrottling + 1, // 0: wso2.discovery.config.enforcer.Throttling.publisher:type_name -> wso2.discovery.config.enforcer.BinaryPublisher 1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name @@ -229,7 +207,7 @@ func file_wso2_discovery_config_enforcer_throttling_proto_init() { if File_wso2_discovery_config_enforcer_throttling_proto != nil { return } - file_wso2_discovery_config_enforcer_binary_throttling_proto_init() + file_wso2_discovery_config_enforcer_binary_publisher_proto_init() if !protoimpl.UnsafeEnabled { file_wso2_discovery_config_enforcer_throttling_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Throttling); i { diff --git a/adapter/internal/discovery/xds/marshaller.go b/adapter/internal/discovery/xds/marshaller.go index 0b6d53a20d..0fb18fe993 100644 --- a/adapter/internal/discovery/xds/marshaller.go +++ b/adapter/internal/discovery/xds/marshaller.go @@ -29,7 +29,7 @@ func MarshalConfig(config *config.Config) *enforcer.Config { issuers = append(issuers, jwtConfig) } - for _, urlGroup := range config.Enforcer.ThrottlingConfig.Binary.URLGroup { + for _, urlGroup := range config.Enforcer.Throttling.Publisher.URLGroup { group := &enforcer.TMURLGroup{ AuthURLs: urlGroup.AuthURLs, ReceiverURLs: urlGroup.ReceiverURLs, @@ -85,44 +85,42 @@ func MarshalConfig(config *config.Config) *enforcer.Config { EventListeningEndpoints: config.ControlPlane.EventHub.JmsConnectionParameters.EventListeningEndpoints, }, }, - ThrottlingConfig: &enforcer.Throttling{ - EnableGlobalEventPublishing: config.Enforcer.ThrottlingConfig.EnableGlobalEventPublishing, - EnableHeaderConditions: config.Enforcer.ThrottlingConfig.EnableHeaderConditions, - EnableQueryParamConditions: config.Enforcer.ThrottlingConfig.EnableQueryParamConditions, - EnableJwtClaimConditions: config.Enforcer.ThrottlingConfig.EnableJwtClaimConditions, - JmsConnectionInitialContextFactory: config.Enforcer.ThrottlingConfig.JmsConnectioninitialContextFactory, - JmsConnectionProviderUrl: config.Enforcer.ThrottlingConfig.JmsConnectionProviderURL, - JmsConnectionUsername: config.Enforcer.ThrottlingConfig.JmsConnectionUsername, - JmsConnectionPassword: config.Enforcer.ThrottlingConfig.JmsConnectionPassword, - Binary: &enforcer.BinaryThrottling{ - Username: config.Enforcer.ThrottlingConfig.Binary.Username, - Password: config.Enforcer.ThrottlingConfig.Binary.Password, + Throttling: &enforcer.Throttling{ + EnableGlobalEventPublishing: config.Enforcer.Throttling.EnableGlobalEventPublishing, + EnableHeaderConditions: config.Enforcer.Throttling.EnableHeaderConditions, + EnableQueryParamConditions: config.Enforcer.Throttling.EnableQueryParamConditions, + EnableJwtClaimConditions: config.Enforcer.Throttling.EnableJwtClaimConditions, + JmsConnectionInitialContextFactory: config.Enforcer.Throttling.JmsConnectionInitialContextFactory, + JmsConnectionProviderUrl: config.Enforcer.Throttling.JmsConnectionProviderURL, + Publisher: &enforcer.BinaryPublisher{ + Username: config.Enforcer.Throttling.Publisher.Username, + Password: config.Enforcer.Throttling.Publisher.Password, UrlGroup: urlGroups, - Publisher: &enforcer.ThrottlePublisher{ - InitIdleObjectDataPublishingAgents: config.Enforcer.ThrottlingConfig.Binary.Publisher.InitIdleObjectDataPublishingAgents, - MaxIdleDataPublishingAgents: config.Enforcer.ThrottlingConfig.Binary.Publisher.MaxIdleDataPublishingAgents, - PublisherThreadPoolCoreSize: config.Enforcer.ThrottlingConfig.Binary.Publisher.PublisherThreadPoolCoreSize, - PublisherThreadPoolKeepAliveTime: config.Enforcer.ThrottlingConfig.Binary.Publisher.PublisherThreadPoolKeepAliveTime, - PublisherThreadPoolMaximumSize: config.Enforcer.ThrottlingConfig.Binary.Publisher.PublisherThreadPoolMaximumSize, + Pool: &enforcer.PublisherPool{ + InitIdleObjectDataPublishingAgents: config.Enforcer.Throttling.Publisher.Pool.InitIdleObjectDataPublishingAgents, + MaxIdleDataPublishingAgents: config.Enforcer.Throttling.Publisher.Pool.MaxIdleDataPublishingAgents, + PublisherThreadPoolCoreSize: config.Enforcer.Throttling.Publisher.Pool.PublisherThreadPoolCoreSize, + PublisherThreadPoolKeepAliveTime: config.Enforcer.Throttling.Publisher.Pool.PublisherThreadPoolKeepAliveTime, + PublisherThreadPoolMaximumSize: config.Enforcer.Throttling.Publisher.Pool.PublisherThreadPoolMaximumSize, }, Agent: &enforcer.ThrottleAgent{ - BatchSize: config.Enforcer.ThrottlingConfig.Binary.Agent.BatchSize, - Ciphers: config.Enforcer.ThrottlingConfig.Binary.Agent.Ciphers, - CorePoolSize: config.Enforcer.ThrottlingConfig.Binary.Agent.CorePoolSize, - EvictionTimePeriod: config.Enforcer.ThrottlingConfig.Binary.Agent.EvictionTimePeriod, - KeepAliveTimeInPool: config.Enforcer.ThrottlingConfig.Binary.Agent.KeepAliveTimeInPool, - MaxIdleConnections: config.Enforcer.ThrottlingConfig.Binary.Agent.MaxIdleConnections, - MaxPoolSize: config.Enforcer.ThrottlingConfig.Binary.Agent.MaxPoolSize, - MaxTransportPoolSize: config.Enforcer.ThrottlingConfig.Binary.Agent.MaxTransportPoolSize, - MinIdleTimeInPool: config.Enforcer.ThrottlingConfig.Binary.Agent.MinIdleTimeInPool, - QueueSize: config.Enforcer.ThrottlingConfig.Binary.Agent.QueueSize, - ReconnectionInterval: config.Enforcer.ThrottlingConfig.Binary.Agent.ReconnectionInterval, - SecureEvictionTimePeriod: config.Enforcer.ThrottlingConfig.Binary.Agent.SecureEvictionTimePeriod, - SecureMaxIdleConnections: config.Enforcer.ThrottlingConfig.Binary.Agent.SecureMaxIdleConnections, - SecureMaxTransportPoolSize: config.Enforcer.ThrottlingConfig.Binary.Agent.SecureMaxTransportPoolSize, - SecureMinIdleTimeInPool: config.Enforcer.ThrottlingConfig.Binary.Agent.SecureMinIdleTimeInPool, - SocketTimeoutMS: config.Enforcer.ThrottlingConfig.Binary.Agent.SocketTimeoutMS, - SslEnabledProtocols: config.Enforcer.ThrottlingConfig.Binary.Agent.SslEnabledProtocols, + BatchSize: config.Enforcer.Throttling.Publisher.Agent.BatchSize, + Ciphers: config.Enforcer.Throttling.Publisher.Agent.Ciphers, + CorePoolSize: config.Enforcer.Throttling.Publisher.Agent.CorePoolSize, + EvictionTimePeriod: config.Enforcer.Throttling.Publisher.Agent.EvictionTimePeriod, + KeepAliveTimeInPool: config.Enforcer.Throttling.Publisher.Agent.KeepAliveTimeInPool, + MaxIdleConnections: config.Enforcer.Throttling.Publisher.Agent.MaxIdleConnections, + MaxPoolSize: config.Enforcer.Throttling.Publisher.Agent.MaxPoolSize, + MaxTransportPoolSize: config.Enforcer.Throttling.Publisher.Agent.MaxTransportPoolSize, + MinIdleTimeInPool: config.Enforcer.Throttling.Publisher.Agent.MinIdleTimeInPool, + QueueSize: config.Enforcer.Throttling.Publisher.Agent.QueueSize, + ReconnectionInterval: config.Enforcer.Throttling.Publisher.Agent.ReconnectionInterval, + SecureEvictionTimePeriod: config.Enforcer.Throttling.Publisher.Agent.SecureEvictionTimePeriod, + SecureMaxIdleConnections: config.Enforcer.Throttling.Publisher.Agent.SecureMaxIdleConnections, + SecureMaxTransportPoolSize: config.Enforcer.Throttling.Publisher.Agent.SecureMaxTransportPoolSize, + SecureMinIdleTimeInPool: config.Enforcer.Throttling.Publisher.Agent.SecureMinIdleTimeInPool, + SocketTimeoutMS: config.Enforcer.Throttling.Publisher.Agent.SocketTimeoutMS, + SslEnabledProtocols: config.Enforcer.Throttling.Publisher.Agent.SslEnabledProtocols, }, }, }, diff --git a/api/wso2/discovery/config/enforcer/binary_throttling.proto b/api/wso2/discovery/config/enforcer/binary_publisher.proto similarity index 69% rename from api/wso2/discovery/config/enforcer/binary_throttling.proto rename to api/wso2/discovery/config/enforcer/binary_publisher.proto index 1c45a7f4db..d7ef6c6464 100644 --- a/api/wso2/discovery/config/enforcer/binary_throttling.proto +++ b/api/wso2/discovery/config/enforcer/binary_publisher.proto @@ -3,20 +3,20 @@ syntax = "proto3"; package wso2.discovery.config.enforcer; import "wso2/discovery/config/enforcer/tm_url_group.proto"; -import "wso2/discovery/config/enforcer/throttle_publisher.proto"; +import "wso2/discovery/config/enforcer/throttle_publisher_pool.proto"; import "wso2/discovery/config/enforcer/throttle_agent.proto"; option go_package = "github.com/envoyproxy/go-control-plane/wso2/discovery/config/enforcer;enforcer"; option java_package = "org.wso2.gateway.discovery.config.enforcer"; -option java_outer_classname = "BinaryThrottlingProto"; +option java_outer_classname = "BinaryPublisherProto"; option java_multiple_files = true; -// [#protodoc-title: BinaryThrottling] +// [#protodoc-title: BinaryPublisher] -message BinaryThrottling { +message BinaryPublisher { string username = 2; string password = 3; repeated TMURLGroup urlGroup = 4; - ThrottlePublisher publisher = 5; + PublisherPool pool = 5; ThrottleAgent agent = 6; } diff --git a/api/wso2/discovery/config/enforcer/config.proto b/api/wso2/discovery/config/enforcer/config.proto index d4351deb44..4abc41b553 100644 --- a/api/wso2/discovery/config/enforcer/config.proto +++ b/api/wso2/discovery/config/enforcer/config.proto @@ -34,7 +34,7 @@ message Config { JWTGenerator jwtGenerator = 7; - Throttling throttlingConfig = 8; + Throttling throttling = 8; Cache cache = 9; } diff --git a/api/wso2/discovery/config/enforcer/throttle_publisher.proto b/api/wso2/discovery/config/enforcer/throttle_publisher_pool.proto similarity index 74% rename from api/wso2/discovery/config/enforcer/throttle_publisher.proto rename to api/wso2/discovery/config/enforcer/throttle_publisher_pool.proto index 9b4c24a641..bca84252cb 100644 --- a/api/wso2/discovery/config/enforcer/throttle_publisher.proto +++ b/api/wso2/discovery/config/enforcer/throttle_publisher_pool.proto @@ -4,13 +4,13 @@ package wso2.discovery.config.enforcer; option go_package = "github.com/envoyproxy/go-control-plane/wso2/discovery/config/enforcer;enforcer"; option java_package = "org.wso2.gateway.discovery.config.enforcer"; -option java_outer_classname = "ThrottlePublishergProto"; +option java_outer_classname = "PublisherPoolProto"; option java_multiple_files = true; -// [#protodoc-title: ThrottlePublisher] +// [#protodoc-title: PublisherPool] -// Throttle Publisher configuration model -message ThrottlePublisher { +// Throttle Publisher pool configuration model +message PublisherPool { int32 maxIdleDataPublishingAgents = 1; int32 initIdleObjectDataPublishingAgents = 2; int32 publisherThreadPoolCoreSize = 3; diff --git a/api/wso2/discovery/config/enforcer/throttling.proto b/api/wso2/discovery/config/enforcer/throttling.proto index 02f14f5e15..2628ae3dfb 100644 --- a/api/wso2/discovery/config/enforcer/throttling.proto +++ b/api/wso2/discovery/config/enforcer/throttling.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package wso2.discovery.config.enforcer; -import "wso2/discovery/config/enforcer/binary_throttling.proto"; +import "wso2/discovery/config/enforcer/binary_publisher.proto"; option go_package = "github.com/envoyproxy/go-control-plane/wso2/discovery/config/enforcer;enforcer"; option java_package = "org.wso2.gateway.discovery.config.enforcer"; @@ -19,7 +19,5 @@ message Throttling { bool enable_jwt_claim_conditions = 4; string jms_connection_initial_context_factory = 5; string jms_connection_provider_url = 6; - string jms_connection_username = 7; - string jms_connection_password = 8; - BinaryThrottling binary = 9; + BinaryPublisher publisher = 7; } diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisher.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisher.java new file mode 100644 index 0000000000..b571717c8c --- /dev/null +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisher.java @@ -0,0 +1,1422 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/config/enforcer/binary_publisher.proto + +package org.wso2.gateway.discovery.config.enforcer; + +/** + * Protobuf type {@code wso2.discovery.config.enforcer.BinaryPublisher} + */ +public final class BinaryPublisher extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:wso2.discovery.config.enforcer.BinaryPublisher) + BinaryPublisherOrBuilder { +private static final long serialVersionUID = 0L; + // Use BinaryPublisher.newBuilder() to construct. + private BinaryPublisher(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BinaryPublisher() { + username_ = ""; + password_ = ""; + urlGroup_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new BinaryPublisher(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BinaryPublisher( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + username_ = s; + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); + + password_ = s; + break; + } + case 34: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + urlGroup_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + urlGroup_.add( + input.readMessage(org.wso2.gateway.discovery.config.enforcer.TMURLGroup.parser(), extensionRegistry)); + break; + } + case 42: { + org.wso2.gateway.discovery.config.enforcer.PublisherPool.Builder subBuilder = null; + if (pool_ != null) { + subBuilder = pool_.toBuilder(); + } + pool_ = input.readMessage(org.wso2.gateway.discovery.config.enforcer.PublisherPool.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(pool_); + pool_ = subBuilder.buildPartial(); + } + + break; + } + case 50: { + org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.Builder subBuilder = null; + if (agent_ != null) { + subBuilder = agent_.toBuilder(); + } + agent_ = input.readMessage(org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(agent_); + agent_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + urlGroup_ = java.util.Collections.unmodifiableList(urlGroup_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.gateway.discovery.config.enforcer.BinaryPublisherProto.internal_static_wso2_discovery_config_enforcer_BinaryPublisher_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.gateway.discovery.config.enforcer.BinaryPublisherProto.internal_static_wso2_discovery_config_enforcer_BinaryPublisher_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.class, org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.Builder.class); + } + + public static final int USERNAME_FIELD_NUMBER = 2; + private volatile java.lang.Object username_; + /** + * string username = 2; + * @return The username. + */ + @java.lang.Override + public java.lang.String getUsername() { + java.lang.Object ref = username_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + username_ = s; + return s; + } + } + /** + * string username = 2; + * @return The bytes for username. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getUsernameBytes() { + java.lang.Object ref = username_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + username_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PASSWORD_FIELD_NUMBER = 3; + private volatile java.lang.Object password_; + /** + * string password = 3; + * @return The password. + */ + @java.lang.Override + public java.lang.String getPassword() { + java.lang.Object ref = password_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + password_ = s; + return s; + } + } + /** + * string password = 3; + * @return The bytes for password. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getPasswordBytes() { + java.lang.Object ref = password_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + password_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int URLGROUP_FIELD_NUMBER = 4; + private java.util.List urlGroup_; + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + @java.lang.Override + public java.util.List getUrlGroupList() { + return urlGroup_; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + @java.lang.Override + public java.util.List + getUrlGroupOrBuilderList() { + return urlGroup_; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + @java.lang.Override + public int getUrlGroupCount() { + return urlGroup_.size(); + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.TMURLGroup getUrlGroup(int index) { + return urlGroup_.get(index); + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.TMURLGroupOrBuilder getUrlGroupOrBuilder( + int index) { + return urlGroup_.get(index); + } + + public static final int POOL_FIELD_NUMBER = 5; + private org.wso2.gateway.discovery.config.enforcer.PublisherPool pool_; + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + * @return Whether the pool field is set. + */ + @java.lang.Override + public boolean hasPool() { + return pool_ != null; + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + * @return The pool. + */ + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.PublisherPool getPool() { + return pool_ == null ? org.wso2.gateway.discovery.config.enforcer.PublisherPool.getDefaultInstance() : pool_; + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + */ + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.PublisherPoolOrBuilder getPoolOrBuilder() { + return getPool(); + } + + public static final int AGENT_FIELD_NUMBER = 6; + private org.wso2.gateway.discovery.config.enforcer.ThrottleAgent agent_; + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + * @return Whether the agent field is set. + */ + @java.lang.Override + public boolean hasAgent() { + return agent_ != null; + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + * @return The agent. + */ + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.ThrottleAgent getAgent() { + return agent_ == null ? org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.getDefaultInstance() : agent_; + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + */ + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.ThrottleAgentOrBuilder getAgentOrBuilder() { + return getAgent(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getUsernameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, username_); + } + if (!getPasswordBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, password_); + } + for (int i = 0; i < urlGroup_.size(); i++) { + output.writeMessage(4, urlGroup_.get(i)); + } + if (pool_ != null) { + output.writeMessage(5, getPool()); + } + if (agent_ != null) { + output.writeMessage(6, getAgent()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getUsernameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, username_); + } + if (!getPasswordBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, password_); + } + for (int i = 0; i < urlGroup_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, urlGroup_.get(i)); + } + if (pool_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, getPool()); + } + if (agent_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(6, getAgent()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.wso2.gateway.discovery.config.enforcer.BinaryPublisher)) { + return super.equals(obj); + } + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher other = (org.wso2.gateway.discovery.config.enforcer.BinaryPublisher) obj; + + if (!getUsername() + .equals(other.getUsername())) return false; + if (!getPassword() + .equals(other.getPassword())) return false; + if (!getUrlGroupList() + .equals(other.getUrlGroupList())) return false; + if (hasPool() != other.hasPool()) return false; + if (hasPool()) { + if (!getPool() + .equals(other.getPool())) return false; + } + if (hasAgent() != other.hasAgent()) return false; + if (hasAgent()) { + if (!getAgent() + .equals(other.getAgent())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + USERNAME_FIELD_NUMBER; + hash = (53 * hash) + getUsername().hashCode(); + hash = (37 * hash) + PASSWORD_FIELD_NUMBER; + hash = (53 * hash) + getPassword().hashCode(); + if (getUrlGroupCount() > 0) { + hash = (37 * hash) + URLGROUP_FIELD_NUMBER; + hash = (53 * hash) + getUrlGroupList().hashCode(); + } + if (hasPool()) { + hash = (37 * hash) + POOL_FIELD_NUMBER; + hash = (53 * hash) + getPool().hashCode(); + } + if (hasAgent()) { + hash = (37 * hash) + AGENT_FIELD_NUMBER; + hash = (53 * hash) + getAgent().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.wso2.gateway.discovery.config.enforcer.BinaryPublisher prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code wso2.discovery.config.enforcer.BinaryPublisher} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:wso2.discovery.config.enforcer.BinaryPublisher) + org.wso2.gateway.discovery.config.enforcer.BinaryPublisherOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.gateway.discovery.config.enforcer.BinaryPublisherProto.internal_static_wso2_discovery_config_enforcer_BinaryPublisher_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.gateway.discovery.config.enforcer.BinaryPublisherProto.internal_static_wso2_discovery_config_enforcer_BinaryPublisher_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.class, org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.Builder.class); + } + + // Construct using org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getUrlGroupFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + username_ = ""; + + password_ = ""; + + if (urlGroupBuilder_ == null) { + urlGroup_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + urlGroupBuilder_.clear(); + } + if (poolBuilder_ == null) { + pool_ = null; + } else { + pool_ = null; + poolBuilder_ = null; + } + if (agentBuilder_ == null) { + agent_ = null; + } else { + agent_ = null; + agentBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.wso2.gateway.discovery.config.enforcer.BinaryPublisherProto.internal_static_wso2_discovery_config_enforcer_BinaryPublisher_descriptor; + } + + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.BinaryPublisher getDefaultInstanceForType() { + return org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.getDefaultInstance(); + } + + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.BinaryPublisher build() { + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.BinaryPublisher buildPartial() { + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher result = new org.wso2.gateway.discovery.config.enforcer.BinaryPublisher(this); + int from_bitField0_ = bitField0_; + result.username_ = username_; + result.password_ = password_; + if (urlGroupBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + urlGroup_ = java.util.Collections.unmodifiableList(urlGroup_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.urlGroup_ = urlGroup_; + } else { + result.urlGroup_ = urlGroupBuilder_.build(); + } + if (poolBuilder_ == null) { + result.pool_ = pool_; + } else { + result.pool_ = poolBuilder_.build(); + } + if (agentBuilder_ == null) { + result.agent_ = agent_; + } else { + result.agent_ = agentBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.wso2.gateway.discovery.config.enforcer.BinaryPublisher) { + return mergeFrom((org.wso2.gateway.discovery.config.enforcer.BinaryPublisher)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.wso2.gateway.discovery.config.enforcer.BinaryPublisher other) { + if (other == org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.getDefaultInstance()) return this; + if (!other.getUsername().isEmpty()) { + username_ = other.username_; + onChanged(); + } + if (!other.getPassword().isEmpty()) { + password_ = other.password_; + onChanged(); + } + if (urlGroupBuilder_ == null) { + if (!other.urlGroup_.isEmpty()) { + if (urlGroup_.isEmpty()) { + urlGroup_ = other.urlGroup_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureUrlGroupIsMutable(); + urlGroup_.addAll(other.urlGroup_); + } + onChanged(); + } + } else { + if (!other.urlGroup_.isEmpty()) { + if (urlGroupBuilder_.isEmpty()) { + urlGroupBuilder_.dispose(); + urlGroupBuilder_ = null; + urlGroup_ = other.urlGroup_; + bitField0_ = (bitField0_ & ~0x00000001); + urlGroupBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getUrlGroupFieldBuilder() : null; + } else { + urlGroupBuilder_.addAllMessages(other.urlGroup_); + } + } + } + if (other.hasPool()) { + mergePool(other.getPool()); + } + if (other.hasAgent()) { + mergeAgent(other.getAgent()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.wso2.gateway.discovery.config.enforcer.BinaryPublisher) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.lang.Object username_ = ""; + /** + * string username = 2; + * @return The username. + */ + public java.lang.String getUsername() { + java.lang.Object ref = username_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + username_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string username = 2; + * @return The bytes for username. + */ + public com.google.protobuf.ByteString + getUsernameBytes() { + java.lang.Object ref = username_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + username_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string username = 2; + * @param value The username to set. + * @return This builder for chaining. + */ + public Builder setUsername( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + username_ = value; + onChanged(); + return this; + } + /** + * string username = 2; + * @return This builder for chaining. + */ + public Builder clearUsername() { + + username_ = getDefaultInstance().getUsername(); + onChanged(); + return this; + } + /** + * string username = 2; + * @param value The bytes for username to set. + * @return This builder for chaining. + */ + public Builder setUsernameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + username_ = value; + onChanged(); + return this; + } + + private java.lang.Object password_ = ""; + /** + * string password = 3; + * @return The password. + */ + public java.lang.String getPassword() { + java.lang.Object ref = password_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + password_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string password = 3; + * @return The bytes for password. + */ + public com.google.protobuf.ByteString + getPasswordBytes() { + java.lang.Object ref = password_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + password_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string password = 3; + * @param value The password to set. + * @return This builder for chaining. + */ + public Builder setPassword( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + password_ = value; + onChanged(); + return this; + } + /** + * string password = 3; + * @return This builder for chaining. + */ + public Builder clearPassword() { + + password_ = getDefaultInstance().getPassword(); + onChanged(); + return this; + } + /** + * string password = 3; + * @param value The bytes for password to set. + * @return This builder for chaining. + */ + public Builder setPasswordBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + password_ = value; + onChanged(); + return this; + } + + private java.util.List urlGroup_ = + java.util.Collections.emptyList(); + private void ensureUrlGroupIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + urlGroup_ = new java.util.ArrayList(urlGroup_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.TMURLGroup, org.wso2.gateway.discovery.config.enforcer.TMURLGroup.Builder, org.wso2.gateway.discovery.config.enforcer.TMURLGroupOrBuilder> urlGroupBuilder_; + + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public java.util.List getUrlGroupList() { + if (urlGroupBuilder_ == null) { + return java.util.Collections.unmodifiableList(urlGroup_); + } else { + return urlGroupBuilder_.getMessageList(); + } + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public int getUrlGroupCount() { + if (urlGroupBuilder_ == null) { + return urlGroup_.size(); + } else { + return urlGroupBuilder_.getCount(); + } + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public org.wso2.gateway.discovery.config.enforcer.TMURLGroup getUrlGroup(int index) { + if (urlGroupBuilder_ == null) { + return urlGroup_.get(index); + } else { + return urlGroupBuilder_.getMessage(index); + } + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public Builder setUrlGroup( + int index, org.wso2.gateway.discovery.config.enforcer.TMURLGroup value) { + if (urlGroupBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureUrlGroupIsMutable(); + urlGroup_.set(index, value); + onChanged(); + } else { + urlGroupBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public Builder setUrlGroup( + int index, org.wso2.gateway.discovery.config.enforcer.TMURLGroup.Builder builderForValue) { + if (urlGroupBuilder_ == null) { + ensureUrlGroupIsMutable(); + urlGroup_.set(index, builderForValue.build()); + onChanged(); + } else { + urlGroupBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public Builder addUrlGroup(org.wso2.gateway.discovery.config.enforcer.TMURLGroup value) { + if (urlGroupBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureUrlGroupIsMutable(); + urlGroup_.add(value); + onChanged(); + } else { + urlGroupBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public Builder addUrlGroup( + int index, org.wso2.gateway.discovery.config.enforcer.TMURLGroup value) { + if (urlGroupBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureUrlGroupIsMutable(); + urlGroup_.add(index, value); + onChanged(); + } else { + urlGroupBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public Builder addUrlGroup( + org.wso2.gateway.discovery.config.enforcer.TMURLGroup.Builder builderForValue) { + if (urlGroupBuilder_ == null) { + ensureUrlGroupIsMutable(); + urlGroup_.add(builderForValue.build()); + onChanged(); + } else { + urlGroupBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public Builder addUrlGroup( + int index, org.wso2.gateway.discovery.config.enforcer.TMURLGroup.Builder builderForValue) { + if (urlGroupBuilder_ == null) { + ensureUrlGroupIsMutable(); + urlGroup_.add(index, builderForValue.build()); + onChanged(); + } else { + urlGroupBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public Builder addAllUrlGroup( + java.lang.Iterable values) { + if (urlGroupBuilder_ == null) { + ensureUrlGroupIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, urlGroup_); + onChanged(); + } else { + urlGroupBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public Builder clearUrlGroup() { + if (urlGroupBuilder_ == null) { + urlGroup_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + urlGroupBuilder_.clear(); + } + return this; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public Builder removeUrlGroup(int index) { + if (urlGroupBuilder_ == null) { + ensureUrlGroupIsMutable(); + urlGroup_.remove(index); + onChanged(); + } else { + urlGroupBuilder_.remove(index); + } + return this; + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public org.wso2.gateway.discovery.config.enforcer.TMURLGroup.Builder getUrlGroupBuilder( + int index) { + return getUrlGroupFieldBuilder().getBuilder(index); + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public org.wso2.gateway.discovery.config.enforcer.TMURLGroupOrBuilder getUrlGroupOrBuilder( + int index) { + if (urlGroupBuilder_ == null) { + return urlGroup_.get(index); } else { + return urlGroupBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public java.util.List + getUrlGroupOrBuilderList() { + if (urlGroupBuilder_ != null) { + return urlGroupBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(urlGroup_); + } + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public org.wso2.gateway.discovery.config.enforcer.TMURLGroup.Builder addUrlGroupBuilder() { + return getUrlGroupFieldBuilder().addBuilder( + org.wso2.gateway.discovery.config.enforcer.TMURLGroup.getDefaultInstance()); + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public org.wso2.gateway.discovery.config.enforcer.TMURLGroup.Builder addUrlGroupBuilder( + int index) { + return getUrlGroupFieldBuilder().addBuilder( + index, org.wso2.gateway.discovery.config.enforcer.TMURLGroup.getDefaultInstance()); + } + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + public java.util.List + getUrlGroupBuilderList() { + return getUrlGroupFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.TMURLGroup, org.wso2.gateway.discovery.config.enforcer.TMURLGroup.Builder, org.wso2.gateway.discovery.config.enforcer.TMURLGroupOrBuilder> + getUrlGroupFieldBuilder() { + if (urlGroupBuilder_ == null) { + urlGroupBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.TMURLGroup, org.wso2.gateway.discovery.config.enforcer.TMURLGroup.Builder, org.wso2.gateway.discovery.config.enforcer.TMURLGroupOrBuilder>( + urlGroup_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + urlGroup_ = null; + } + return urlGroupBuilder_; + } + + private org.wso2.gateway.discovery.config.enforcer.PublisherPool pool_; + private com.google.protobuf.SingleFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.PublisherPool, org.wso2.gateway.discovery.config.enforcer.PublisherPool.Builder, org.wso2.gateway.discovery.config.enforcer.PublisherPoolOrBuilder> poolBuilder_; + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + * @return Whether the pool field is set. + */ + public boolean hasPool() { + return poolBuilder_ != null || pool_ != null; + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + * @return The pool. + */ + public org.wso2.gateway.discovery.config.enforcer.PublisherPool getPool() { + if (poolBuilder_ == null) { + return pool_ == null ? org.wso2.gateway.discovery.config.enforcer.PublisherPool.getDefaultInstance() : pool_; + } else { + return poolBuilder_.getMessage(); + } + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + */ + public Builder setPool(org.wso2.gateway.discovery.config.enforcer.PublisherPool value) { + if (poolBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + pool_ = value; + onChanged(); + } else { + poolBuilder_.setMessage(value); + } + + return this; + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + */ + public Builder setPool( + org.wso2.gateway.discovery.config.enforcer.PublisherPool.Builder builderForValue) { + if (poolBuilder_ == null) { + pool_ = builderForValue.build(); + onChanged(); + } else { + poolBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + */ + public Builder mergePool(org.wso2.gateway.discovery.config.enforcer.PublisherPool value) { + if (poolBuilder_ == null) { + if (pool_ != null) { + pool_ = + org.wso2.gateway.discovery.config.enforcer.PublisherPool.newBuilder(pool_).mergeFrom(value).buildPartial(); + } else { + pool_ = value; + } + onChanged(); + } else { + poolBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + */ + public Builder clearPool() { + if (poolBuilder_ == null) { + pool_ = null; + onChanged(); + } else { + pool_ = null; + poolBuilder_ = null; + } + + return this; + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + */ + public org.wso2.gateway.discovery.config.enforcer.PublisherPool.Builder getPoolBuilder() { + + onChanged(); + return getPoolFieldBuilder().getBuilder(); + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + */ + public org.wso2.gateway.discovery.config.enforcer.PublisherPoolOrBuilder getPoolOrBuilder() { + if (poolBuilder_ != null) { + return poolBuilder_.getMessageOrBuilder(); + } else { + return pool_ == null ? + org.wso2.gateway.discovery.config.enforcer.PublisherPool.getDefaultInstance() : pool_; + } + } + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.PublisherPool, org.wso2.gateway.discovery.config.enforcer.PublisherPool.Builder, org.wso2.gateway.discovery.config.enforcer.PublisherPoolOrBuilder> + getPoolFieldBuilder() { + if (poolBuilder_ == null) { + poolBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.PublisherPool, org.wso2.gateway.discovery.config.enforcer.PublisherPool.Builder, org.wso2.gateway.discovery.config.enforcer.PublisherPoolOrBuilder>( + getPool(), + getParentForChildren(), + isClean()); + pool_ = null; + } + return poolBuilder_; + } + + private org.wso2.gateway.discovery.config.enforcer.ThrottleAgent agent_; + private com.google.protobuf.SingleFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.ThrottleAgent, org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.Builder, org.wso2.gateway.discovery.config.enforcer.ThrottleAgentOrBuilder> agentBuilder_; + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + * @return Whether the agent field is set. + */ + public boolean hasAgent() { + return agentBuilder_ != null || agent_ != null; + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + * @return The agent. + */ + public org.wso2.gateway.discovery.config.enforcer.ThrottleAgent getAgent() { + if (agentBuilder_ == null) { + return agent_ == null ? org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.getDefaultInstance() : agent_; + } else { + return agentBuilder_.getMessage(); + } + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + */ + public Builder setAgent(org.wso2.gateway.discovery.config.enforcer.ThrottleAgent value) { + if (agentBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + agent_ = value; + onChanged(); + } else { + agentBuilder_.setMessage(value); + } + + return this; + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + */ + public Builder setAgent( + org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.Builder builderForValue) { + if (agentBuilder_ == null) { + agent_ = builderForValue.build(); + onChanged(); + } else { + agentBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + */ + public Builder mergeAgent(org.wso2.gateway.discovery.config.enforcer.ThrottleAgent value) { + if (agentBuilder_ == null) { + if (agent_ != null) { + agent_ = + org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.newBuilder(agent_).mergeFrom(value).buildPartial(); + } else { + agent_ = value; + } + onChanged(); + } else { + agentBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + */ + public Builder clearAgent() { + if (agentBuilder_ == null) { + agent_ = null; + onChanged(); + } else { + agent_ = null; + agentBuilder_ = null; + } + + return this; + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + */ + public org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.Builder getAgentBuilder() { + + onChanged(); + return getAgentFieldBuilder().getBuilder(); + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + */ + public org.wso2.gateway.discovery.config.enforcer.ThrottleAgentOrBuilder getAgentOrBuilder() { + if (agentBuilder_ != null) { + return agentBuilder_.getMessageOrBuilder(); + } else { + return agent_ == null ? + org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.getDefaultInstance() : agent_; + } + } + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + */ + private com.google.protobuf.SingleFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.ThrottleAgent, org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.Builder, org.wso2.gateway.discovery.config.enforcer.ThrottleAgentOrBuilder> + getAgentFieldBuilder() { + if (agentBuilder_ == null) { + agentBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.ThrottleAgent, org.wso2.gateway.discovery.config.enforcer.ThrottleAgent.Builder, org.wso2.gateway.discovery.config.enforcer.ThrottleAgentOrBuilder>( + getAgent(), + getParentForChildren(), + isClean()); + agent_ = null; + } + return agentBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:wso2.discovery.config.enforcer.BinaryPublisher) + } + + // @@protoc_insertion_point(class_scope:wso2.discovery.config.enforcer.BinaryPublisher) + private static final org.wso2.gateway.discovery.config.enforcer.BinaryPublisher DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.wso2.gateway.discovery.config.enforcer.BinaryPublisher(); + } + + public static org.wso2.gateway.discovery.config.enforcer.BinaryPublisher getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BinaryPublisher parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BinaryPublisher(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.BinaryPublisher getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisherOrBuilder.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisherOrBuilder.java new file mode 100644 index 0000000000..042a6257a3 --- /dev/null +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisherOrBuilder.java @@ -0,0 +1,87 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/config/enforcer/binary_publisher.proto + +package org.wso2.gateway.discovery.config.enforcer; + +public interface BinaryPublisherOrBuilder extends + // @@protoc_insertion_point(interface_extends:wso2.discovery.config.enforcer.BinaryPublisher) + com.google.protobuf.MessageOrBuilder { + + /** + * string username = 2; + * @return The username. + */ + java.lang.String getUsername(); + /** + * string username = 2; + * @return The bytes for username. + */ + com.google.protobuf.ByteString + getUsernameBytes(); + + /** + * string password = 3; + * @return The password. + */ + java.lang.String getPassword(); + /** + * string password = 3; + * @return The bytes for password. + */ + com.google.protobuf.ByteString + getPasswordBytes(); + + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + java.util.List + getUrlGroupList(); + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + org.wso2.gateway.discovery.config.enforcer.TMURLGroup getUrlGroup(int index); + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + int getUrlGroupCount(); + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + java.util.List + getUrlGroupOrBuilderList(); + /** + * repeated .wso2.discovery.config.enforcer.TMURLGroup urlGroup = 4; + */ + org.wso2.gateway.discovery.config.enforcer.TMURLGroupOrBuilder getUrlGroupOrBuilder( + int index); + + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + * @return Whether the pool field is set. + */ + boolean hasPool(); + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + * @return The pool. + */ + org.wso2.gateway.discovery.config.enforcer.PublisherPool getPool(); + /** + * .wso2.discovery.config.enforcer.PublisherPool pool = 5; + */ + org.wso2.gateway.discovery.config.enforcer.PublisherPoolOrBuilder getPoolOrBuilder(); + + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + * @return Whether the agent field is set. + */ + boolean hasAgent(); + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + * @return The agent. + */ + org.wso2.gateway.discovery.config.enforcer.ThrottleAgent getAgent(); + /** + * .wso2.discovery.config.enforcer.ThrottleAgent agent = 6; + */ + org.wso2.gateway.discovery.config.enforcer.ThrottleAgentOrBuilder getAgentOrBuilder(); +} diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisherProto.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisherProto.java new file mode 100644 index 0000000000..0357c5cec4 --- /dev/null +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/BinaryPublisherProto.java @@ -0,0 +1,68 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/config/enforcer/binary_publisher.proto + +package org.wso2.gateway.discovery.config.enforcer; + +public final class BinaryPublisherProto { + private BinaryPublisherProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + static final com.google.protobuf.Descriptors.Descriptor + internal_static_wso2_discovery_config_enforcer_BinaryPublisher_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_wso2_discovery_config_enforcer_BinaryPublisher_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n5wso2/discovery/config/enforcer/binary_" + + "publisher.proto\022\036wso2.discovery.config.e" + + "nforcer\0321wso2/discovery/config/enforcer/" + + "tm_url_group.proto\032.wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; - * @return Whether the throttlingConfig field is set. + * .wso2.discovery.config.enforcer.Throttling throttling = 8; + * @return Whether the throttling field is set. */ @java.lang.Override - public boolean hasThrottlingConfig() { - return throttlingConfig_ != null; + public boolean hasThrottling() { + return throttling_ != null; } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; - * @return The throttlingConfig. + * .wso2.discovery.config.enforcer.Throttling throttling = 8; + * @return The throttling. */ @java.lang.Override - public org.wso2.gateway.discovery.config.enforcer.Throttling getThrottlingConfig() { - return throttlingConfig_ == null ? org.wso2.gateway.discovery.config.enforcer.Throttling.getDefaultInstance() : throttlingConfig_; + public org.wso2.gateway.discovery.config.enforcer.Throttling getThrottling() { + return throttling_ == null ? org.wso2.gateway.discovery.config.enforcer.Throttling.getDefaultInstance() : throttling_; } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; + * .wso2.discovery.config.enforcer.Throttling throttling = 8; */ @java.lang.Override - public org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder getThrottlingConfigOrBuilder() { - return getThrottlingConfig(); + public org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder getThrottlingOrBuilder() { + return getThrottling(); } public static final int CACHE_FIELD_NUMBER = 9; @@ -485,8 +485,8 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (jwtGenerator_ != null) { output.writeMessage(7, getJwtGenerator()); } - if (throttlingConfig_ != null) { - output.writeMessage(8, getThrottlingConfig()); + if (throttling_ != null) { + output.writeMessage(8, getThrottling()); } if (cache_ != null) { output.writeMessage(9, getCache()); @@ -528,9 +528,9 @@ public int getSerializedSize() { size += com.google.protobuf.CodedOutputStream .computeMessageSize(7, getJwtGenerator()); } - if (throttlingConfig_ != null) { + if (throttling_ != null) { size += com.google.protobuf.CodedOutputStream - .computeMessageSize(8, getThrottlingConfig()); + .computeMessageSize(8, getThrottling()); } if (cache_ != null) { size += com.google.protobuf.CodedOutputStream @@ -583,10 +583,10 @@ public boolean equals(final java.lang.Object obj) { if (!getJwtGenerator() .equals(other.getJwtGenerator())) return false; } - if (hasThrottlingConfig() != other.hasThrottlingConfig()) return false; - if (hasThrottlingConfig()) { - if (!getThrottlingConfig() - .equals(other.getThrottlingConfig())) return false; + if (hasThrottling() != other.hasThrottling()) return false; + if (hasThrottling()) { + if (!getThrottling() + .equals(other.getThrottling())) return false; } if (hasCache() != other.hasCache()) return false; if (hasCache()) { @@ -632,9 +632,9 @@ public int hashCode() { hash = (37 * hash) + JWTGENERATOR_FIELD_NUMBER; hash = (53 * hash) + getJwtGenerator().hashCode(); } - if (hasThrottlingConfig()) { - hash = (37 * hash) + THROTTLINGCONFIG_FIELD_NUMBER; - hash = (53 * hash) + getThrottlingConfig().hashCode(); + if (hasThrottling()) { + hash = (37 * hash) + THROTTLING_FIELD_NUMBER; + hash = (53 * hash) + getThrottling().hashCode(); } if (hasCache()) { hash = (37 * hash) + CACHE_FIELD_NUMBER; @@ -820,11 +820,11 @@ public Builder clear() { jwtGenerator_ = null; jwtGeneratorBuilder_ = null; } - if (throttlingConfigBuilder_ == null) { - throttlingConfig_ = null; + if (throttlingBuilder_ == null) { + throttling_ = null; } else { - throttlingConfig_ = null; - throttlingConfigBuilder_ = null; + throttling_ = null; + throttlingBuilder_ = null; } if (cacheBuilder_ == null) { cache_ = null; @@ -898,10 +898,10 @@ public org.wso2.gateway.discovery.config.enforcer.Config buildPartial() { } else { result.jwtGenerator_ = jwtGeneratorBuilder_.build(); } - if (throttlingConfigBuilder_ == null) { - result.throttlingConfig_ = throttlingConfig_; + if (throttlingBuilder_ == null) { + result.throttling_ = throttling_; } else { - result.throttlingConfig_ = throttlingConfigBuilder_.build(); + result.throttling_ = throttlingBuilder_.build(); } if (cacheBuilder_ == null) { result.cache_ = cache_; @@ -1000,8 +1000,8 @@ public Builder mergeFrom(org.wso2.gateway.discovery.config.enforcer.Config other if (other.hasJwtGenerator()) { mergeJwtGenerator(other.getJwtGenerator()); } - if (other.hasThrottlingConfig()) { - mergeThrottlingConfig(other.getThrottlingConfig()); + if (other.hasThrottling()) { + mergeThrottling(other.getThrottling()); } if (other.hasCache()) { mergeCache(other.getCache()); @@ -1990,123 +1990,123 @@ public org.wso2.gateway.discovery.config.enforcer.JWTGeneratorOrBuilder getJwtGe return jwtGeneratorBuilder_; } - private org.wso2.gateway.discovery.config.enforcer.Throttling throttlingConfig_; + private org.wso2.gateway.discovery.config.enforcer.Throttling throttling_; private com.google.protobuf.SingleFieldBuilderV3< - org.wso2.gateway.discovery.config.enforcer.Throttling, org.wso2.gateway.discovery.config.enforcer.Throttling.Builder, org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder> throttlingConfigBuilder_; + org.wso2.gateway.discovery.config.enforcer.Throttling, org.wso2.gateway.discovery.config.enforcer.Throttling.Builder, org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder> throttlingBuilder_; /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; - * @return Whether the throttlingConfig field is set. + * .wso2.discovery.config.enforcer.Throttling throttling = 8; + * @return Whether the throttling field is set. */ - public boolean hasThrottlingConfig() { - return throttlingConfigBuilder_ != null || throttlingConfig_ != null; + public boolean hasThrottling() { + return throttlingBuilder_ != null || throttling_ != null; } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; - * @return The throttlingConfig. + * .wso2.discovery.config.enforcer.Throttling throttling = 8; + * @return The throttling. */ - public org.wso2.gateway.discovery.config.enforcer.Throttling getThrottlingConfig() { - if (throttlingConfigBuilder_ == null) { - return throttlingConfig_ == null ? org.wso2.gateway.discovery.config.enforcer.Throttling.getDefaultInstance() : throttlingConfig_; + public org.wso2.gateway.discovery.config.enforcer.Throttling getThrottling() { + if (throttlingBuilder_ == null) { + return throttling_ == null ? org.wso2.gateway.discovery.config.enforcer.Throttling.getDefaultInstance() : throttling_; } else { - return throttlingConfigBuilder_.getMessage(); + return throttlingBuilder_.getMessage(); } } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; + * .wso2.discovery.config.enforcer.Throttling throttling = 8; */ - public Builder setThrottlingConfig(org.wso2.gateway.discovery.config.enforcer.Throttling value) { - if (throttlingConfigBuilder_ == null) { + public Builder setThrottling(org.wso2.gateway.discovery.config.enforcer.Throttling value) { + if (throttlingBuilder_ == null) { if (value == null) { throw new NullPointerException(); } - throttlingConfig_ = value; + throttling_ = value; onChanged(); } else { - throttlingConfigBuilder_.setMessage(value); + throttlingBuilder_.setMessage(value); } return this; } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; + * .wso2.discovery.config.enforcer.Throttling throttling = 8; */ - public Builder setThrottlingConfig( + public Builder setThrottling( org.wso2.gateway.discovery.config.enforcer.Throttling.Builder builderForValue) { - if (throttlingConfigBuilder_ == null) { - throttlingConfig_ = builderForValue.build(); + if (throttlingBuilder_ == null) { + throttling_ = builderForValue.build(); onChanged(); } else { - throttlingConfigBuilder_.setMessage(builderForValue.build()); + throttlingBuilder_.setMessage(builderForValue.build()); } return this; } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; + * .wso2.discovery.config.enforcer.Throttling throttling = 8; */ - public Builder mergeThrottlingConfig(org.wso2.gateway.discovery.config.enforcer.Throttling value) { - if (throttlingConfigBuilder_ == null) { - if (throttlingConfig_ != null) { - throttlingConfig_ = - org.wso2.gateway.discovery.config.enforcer.Throttling.newBuilder(throttlingConfig_).mergeFrom(value).buildPartial(); + public Builder mergeThrottling(org.wso2.gateway.discovery.config.enforcer.Throttling value) { + if (throttlingBuilder_ == null) { + if (throttling_ != null) { + throttling_ = + org.wso2.gateway.discovery.config.enforcer.Throttling.newBuilder(throttling_).mergeFrom(value).buildPartial(); } else { - throttlingConfig_ = value; + throttling_ = value; } onChanged(); } else { - throttlingConfigBuilder_.mergeFrom(value); + throttlingBuilder_.mergeFrom(value); } return this; } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; + * .wso2.discovery.config.enforcer.Throttling throttling = 8; */ - public Builder clearThrottlingConfig() { - if (throttlingConfigBuilder_ == null) { - throttlingConfig_ = null; + public Builder clearThrottling() { + if (throttlingBuilder_ == null) { + throttling_ = null; onChanged(); } else { - throttlingConfig_ = null; - throttlingConfigBuilder_ = null; + throttling_ = null; + throttlingBuilder_ = null; } return this; } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; + * .wso2.discovery.config.enforcer.Throttling throttling = 8; */ - public org.wso2.gateway.discovery.config.enforcer.Throttling.Builder getThrottlingConfigBuilder() { + public org.wso2.gateway.discovery.config.enforcer.Throttling.Builder getThrottlingBuilder() { onChanged(); - return getThrottlingConfigFieldBuilder().getBuilder(); + return getThrottlingFieldBuilder().getBuilder(); } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; + * .wso2.discovery.config.enforcer.Throttling throttling = 8; */ - public org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder getThrottlingConfigOrBuilder() { - if (throttlingConfigBuilder_ != null) { - return throttlingConfigBuilder_.getMessageOrBuilder(); + public org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder getThrottlingOrBuilder() { + if (throttlingBuilder_ != null) { + return throttlingBuilder_.getMessageOrBuilder(); } else { - return throttlingConfig_ == null ? - org.wso2.gateway.discovery.config.enforcer.Throttling.getDefaultInstance() : throttlingConfig_; + return throttling_ == null ? + org.wso2.gateway.discovery.config.enforcer.Throttling.getDefaultInstance() : throttling_; } } /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; + * .wso2.discovery.config.enforcer.Throttling throttling = 8; */ private com.google.protobuf.SingleFieldBuilderV3< org.wso2.gateway.discovery.config.enforcer.Throttling, org.wso2.gateway.discovery.config.enforcer.Throttling.Builder, org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder> - getThrottlingConfigFieldBuilder() { - if (throttlingConfigBuilder_ == null) { - throttlingConfigBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + getThrottlingFieldBuilder() { + if (throttlingBuilder_ == null) { + throttlingBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< org.wso2.gateway.discovery.config.enforcer.Throttling, org.wso2.gateway.discovery.config.enforcer.Throttling.Builder, org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder>( - getThrottlingConfig(), + getThrottling(), getParentForChildren(), isClean()); - throttlingConfig_ = null; + throttling_ = null; } - return throttlingConfigBuilder_; + return throttlingBuilder_; } private org.wso2.gateway.discovery.config.enforcer.Cache cache_; diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ConfigOrBuilder.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ConfigOrBuilder.java index 7f04a4fbbd..80f7643491 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ConfigOrBuilder.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ConfigOrBuilder.java @@ -122,19 +122,19 @@ org.wso2.gateway.discovery.config.enforcer.IssuerOrBuilder getJwtTokenConfigOrBu org.wso2.gateway.discovery.config.enforcer.JWTGeneratorOrBuilder getJwtGeneratorOrBuilder(); /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; - * @return Whether the throttlingConfig field is set. + * .wso2.discovery.config.enforcer.Throttling throttling = 8; + * @return Whether the throttling field is set. */ - boolean hasThrottlingConfig(); + boolean hasThrottling(); /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; - * @return The throttlingConfig. + * .wso2.discovery.config.enforcer.Throttling throttling = 8; + * @return The throttling. */ - org.wso2.gateway.discovery.config.enforcer.Throttling getThrottlingConfig(); + org.wso2.gateway.discovery.config.enforcer.Throttling getThrottling(); /** - * .wso2.discovery.config.enforcer.Throttling throttlingConfig = 8; + * .wso2.discovery.config.enforcer.Throttling throttling = 8; */ - org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder getThrottlingConfigOrBuilder(); + org.wso2.gateway.discovery.config.enforcer.ThrottlingOrBuilder getThrottlingOrBuilder(); /** * .wso2.discovery.config.enforcer.Cache cache = 9; diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ConfigProto.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ConfigProto.java index 5c2c177ede..b15eb73b29 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ConfigProto.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ConfigProto.java @@ -39,7 +39,7 @@ public static void registerAllExtensions( "so2/discovery/config/enforcer/jwt_genera" + "tor.proto\032/wso2/discovery/config/enforce" + "r/throttling.proto\032*wso2/discovery/confi" + - "g/enforcer/cache.proto\"\312\004\n\006Config\022>\n\016jwt" + + "g/enforcer/cache.proto\"\304\004\n\006Config\022>\n\016jwt" + "TokenConfig\030\001 \003(\0132&.wso2.discovery.confi" + "g.enforcer.Issuer\022;\n\010keystore\030\002 \001(\0132).ws" + "o2.discovery.config.enforcer.CertStore\022=" + @@ -51,14 +51,13 @@ public static void registerAllExtensions( "ntials\030\006 \001(\0132-.wso2.discovery.config.enf" + "orcer.AmCredentials\022B\n\014jwtGenerator\030\007 \001(" + "\0132,.wso2.discovery.config.enforcer.JWTGe" + - "nerator\022D\n\020throttlingConfig\030\010 \001(\0132*.wso2" + - ".discovery.config.enforcer.Throttling\0224\n" + - "\005cache\030\t \001(\0132%.wso2.discovery.config.enf" + - "orcer.CacheB\213\001\n*org.wso2.gateway.discove" + - "ry.config.enforcerB\013ConfigProtoP\001ZNgithu" + - "b.com/envoyproxy/go-control-plane/wso2/d" + - "iscovery/config/enforcer;enforcerb\006proto" + - "3" + "nerator\022>\n\nthrottling\030\010 \001(\0132*.wso2.disco" + + "very.config.enforcer.Throttling\0224\n\005cache" + + "\030\t \001(\0132%.wso2.discovery.config.enforcer." + + "CacheB\213\001\n*org.wso2.gateway.discovery.con" + + "fig.enforcerB\013ConfigProtoP\001ZNgithub.com/" + + "envoyproxy/go-control-plane/wso2/discove" + + "ry/config/enforcer;enforcerb\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -77,7 +76,7 @@ public static void registerAllExtensions( internal_static_wso2_discovery_config_enforcer_Config_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_wso2_discovery_config_enforcer_Config_descriptor, - new java.lang.String[] { "JwtTokenConfig", "Keystore", "Truststore", "Eventhub", "AuthService", "ApimCredentials", "JwtGenerator", "ThrottlingConfig", "Cache", }); + new java.lang.String[] { "JwtTokenConfig", "Keystore", "Truststore", "Eventhub", "AuthService", "ApimCredentials", "JwtGenerator", "Throttling", "Cache", }); org.wso2.gateway.discovery.config.enforcer.CertStoreProto.getDescriptor(); org.wso2.gateway.discovery.config.enforcer.IssuerProto.getDescriptor(); org.wso2.gateway.discovery.config.enforcer.EventHubProto.getDescriptor(); diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPool.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPool.java new file mode 100644 index 0000000000..20ee1d8f25 --- /dev/null +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPool.java @@ -0,0 +1,747 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/config/enforcer/throttle_publisher_pool.proto + +package org.wso2.gateway.discovery.config.enforcer; + +/** + *
+ * Throttle Publisher pool configuration model
+ * 
+ * + * Protobuf type {@code wso2.discovery.config.enforcer.PublisherPool} + */ +public final class PublisherPool extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:wso2.discovery.config.enforcer.PublisherPool) + PublisherPoolOrBuilder { +private static final long serialVersionUID = 0L; + // Use PublisherPool.newBuilder() to construct. + private PublisherPool(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private PublisherPool() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new PublisherPool(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private PublisherPool( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + + maxIdleDataPublishingAgents_ = input.readInt32(); + break; + } + case 16: { + + initIdleObjectDataPublishingAgents_ = input.readInt32(); + break; + } + case 24: { + + publisherThreadPoolCoreSize_ = input.readInt32(); + break; + } + case 32: { + + publisherThreadPoolMaximumSize_ = input.readInt32(); + break; + } + case 40: { + + publisherThreadPoolKeepAliveTime_ = input.readInt32(); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.gateway.discovery.config.enforcer.PublisherPoolProto.internal_static_wso2_discovery_config_enforcer_PublisherPool_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.gateway.discovery.config.enforcer.PublisherPoolProto.internal_static_wso2_discovery_config_enforcer_PublisherPool_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.gateway.discovery.config.enforcer.PublisherPool.class, org.wso2.gateway.discovery.config.enforcer.PublisherPool.Builder.class); + } + + public static final int MAXIDLEDATAPUBLISHINGAGENTS_FIELD_NUMBER = 1; + private int maxIdleDataPublishingAgents_; + /** + * int32 maxIdleDataPublishingAgents = 1; + * @return The maxIdleDataPublishingAgents. + */ + @java.lang.Override + public int getMaxIdleDataPublishingAgents() { + return maxIdleDataPublishingAgents_; + } + + public static final int INITIDLEOBJECTDATAPUBLISHINGAGENTS_FIELD_NUMBER = 2; + private int initIdleObjectDataPublishingAgents_; + /** + * int32 initIdleObjectDataPublishingAgents = 2; + * @return The initIdleObjectDataPublishingAgents. + */ + @java.lang.Override + public int getInitIdleObjectDataPublishingAgents() { + return initIdleObjectDataPublishingAgents_; + } + + public static final int PUBLISHERTHREADPOOLCORESIZE_FIELD_NUMBER = 3; + private int publisherThreadPoolCoreSize_; + /** + * int32 publisherThreadPoolCoreSize = 3; + * @return The publisherThreadPoolCoreSize. + */ + @java.lang.Override + public int getPublisherThreadPoolCoreSize() { + return publisherThreadPoolCoreSize_; + } + + public static final int PUBLISHERTHREADPOOLMAXIMUMSIZE_FIELD_NUMBER = 4; + private int publisherThreadPoolMaximumSize_; + /** + * int32 publisherThreadPoolMaximumSize = 4; + * @return The publisherThreadPoolMaximumSize. + */ + @java.lang.Override + public int getPublisherThreadPoolMaximumSize() { + return publisherThreadPoolMaximumSize_; + } + + public static final int PUBLISHERTHREADPOOLKEEPALIVETIME_FIELD_NUMBER = 5; + private int publisherThreadPoolKeepAliveTime_; + /** + * int32 publisherThreadPoolKeepAliveTime = 5; + * @return The publisherThreadPoolKeepAliveTime. + */ + @java.lang.Override + public int getPublisherThreadPoolKeepAliveTime() { + return publisherThreadPoolKeepAliveTime_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (maxIdleDataPublishingAgents_ != 0) { + output.writeInt32(1, maxIdleDataPublishingAgents_); + } + if (initIdleObjectDataPublishingAgents_ != 0) { + output.writeInt32(2, initIdleObjectDataPublishingAgents_); + } + if (publisherThreadPoolCoreSize_ != 0) { + output.writeInt32(3, publisherThreadPoolCoreSize_); + } + if (publisherThreadPoolMaximumSize_ != 0) { + output.writeInt32(4, publisherThreadPoolMaximumSize_); + } + if (publisherThreadPoolKeepAliveTime_ != 0) { + output.writeInt32(5, publisherThreadPoolKeepAliveTime_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (maxIdleDataPublishingAgents_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, maxIdleDataPublishingAgents_); + } + if (initIdleObjectDataPublishingAgents_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, initIdleObjectDataPublishingAgents_); + } + if (publisherThreadPoolCoreSize_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, publisherThreadPoolCoreSize_); + } + if (publisherThreadPoolMaximumSize_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(4, publisherThreadPoolMaximumSize_); + } + if (publisherThreadPoolKeepAliveTime_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(5, publisherThreadPoolKeepAliveTime_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.wso2.gateway.discovery.config.enforcer.PublisherPool)) { + return super.equals(obj); + } + org.wso2.gateway.discovery.config.enforcer.PublisherPool other = (org.wso2.gateway.discovery.config.enforcer.PublisherPool) obj; + + if (getMaxIdleDataPublishingAgents() + != other.getMaxIdleDataPublishingAgents()) return false; + if (getInitIdleObjectDataPublishingAgents() + != other.getInitIdleObjectDataPublishingAgents()) return false; + if (getPublisherThreadPoolCoreSize() + != other.getPublisherThreadPoolCoreSize()) return false; + if (getPublisherThreadPoolMaximumSize() + != other.getPublisherThreadPoolMaximumSize()) return false; + if (getPublisherThreadPoolKeepAliveTime() + != other.getPublisherThreadPoolKeepAliveTime()) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + MAXIDLEDATAPUBLISHINGAGENTS_FIELD_NUMBER; + hash = (53 * hash) + getMaxIdleDataPublishingAgents(); + hash = (37 * hash) + INITIDLEOBJECTDATAPUBLISHINGAGENTS_FIELD_NUMBER; + hash = (53 * hash) + getInitIdleObjectDataPublishingAgents(); + hash = (37 * hash) + PUBLISHERTHREADPOOLCORESIZE_FIELD_NUMBER; + hash = (53 * hash) + getPublisherThreadPoolCoreSize(); + hash = (37 * hash) + PUBLISHERTHREADPOOLMAXIMUMSIZE_FIELD_NUMBER; + hash = (53 * hash) + getPublisherThreadPoolMaximumSize(); + hash = (37 * hash) + PUBLISHERTHREADPOOLKEEPALIVETIME_FIELD_NUMBER; + hash = (53 * hash) + getPublisherThreadPoolKeepAliveTime(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.wso2.gateway.discovery.config.enforcer.PublisherPool prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+   * Throttle Publisher pool configuration model
+   * 
+ * + * Protobuf type {@code wso2.discovery.config.enforcer.PublisherPool} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:wso2.discovery.config.enforcer.PublisherPool) + org.wso2.gateway.discovery.config.enforcer.PublisherPoolOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.wso2.gateway.discovery.config.enforcer.PublisherPoolProto.internal_static_wso2_discovery_config_enforcer_PublisherPool_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.wso2.gateway.discovery.config.enforcer.PublisherPoolProto.internal_static_wso2_discovery_config_enforcer_PublisherPool_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.wso2.gateway.discovery.config.enforcer.PublisherPool.class, org.wso2.gateway.discovery.config.enforcer.PublisherPool.Builder.class); + } + + // Construct using org.wso2.gateway.discovery.config.enforcer.PublisherPool.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + maxIdleDataPublishingAgents_ = 0; + + initIdleObjectDataPublishingAgents_ = 0; + + publisherThreadPoolCoreSize_ = 0; + + publisherThreadPoolMaximumSize_ = 0; + + publisherThreadPoolKeepAliveTime_ = 0; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.wso2.gateway.discovery.config.enforcer.PublisherPoolProto.internal_static_wso2_discovery_config_enforcer_PublisherPool_descriptor; + } + + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.PublisherPool getDefaultInstanceForType() { + return org.wso2.gateway.discovery.config.enforcer.PublisherPool.getDefaultInstance(); + } + + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.PublisherPool build() { + org.wso2.gateway.discovery.config.enforcer.PublisherPool result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.PublisherPool buildPartial() { + org.wso2.gateway.discovery.config.enforcer.PublisherPool result = new org.wso2.gateway.discovery.config.enforcer.PublisherPool(this); + result.maxIdleDataPublishingAgents_ = maxIdleDataPublishingAgents_; + result.initIdleObjectDataPublishingAgents_ = initIdleObjectDataPublishingAgents_; + result.publisherThreadPoolCoreSize_ = publisherThreadPoolCoreSize_; + result.publisherThreadPoolMaximumSize_ = publisherThreadPoolMaximumSize_; + result.publisherThreadPoolKeepAliveTime_ = publisherThreadPoolKeepAliveTime_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.wso2.gateway.discovery.config.enforcer.PublisherPool) { + return mergeFrom((org.wso2.gateway.discovery.config.enforcer.PublisherPool)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.wso2.gateway.discovery.config.enforcer.PublisherPool other) { + if (other == org.wso2.gateway.discovery.config.enforcer.PublisherPool.getDefaultInstance()) return this; + if (other.getMaxIdleDataPublishingAgents() != 0) { + setMaxIdleDataPublishingAgents(other.getMaxIdleDataPublishingAgents()); + } + if (other.getInitIdleObjectDataPublishingAgents() != 0) { + setInitIdleObjectDataPublishingAgents(other.getInitIdleObjectDataPublishingAgents()); + } + if (other.getPublisherThreadPoolCoreSize() != 0) { + setPublisherThreadPoolCoreSize(other.getPublisherThreadPoolCoreSize()); + } + if (other.getPublisherThreadPoolMaximumSize() != 0) { + setPublisherThreadPoolMaximumSize(other.getPublisherThreadPoolMaximumSize()); + } + if (other.getPublisherThreadPoolKeepAliveTime() != 0) { + setPublisherThreadPoolKeepAliveTime(other.getPublisherThreadPoolKeepAliveTime()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.wso2.gateway.discovery.config.enforcer.PublisherPool parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.wso2.gateway.discovery.config.enforcer.PublisherPool) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int maxIdleDataPublishingAgents_ ; + /** + * int32 maxIdleDataPublishingAgents = 1; + * @return The maxIdleDataPublishingAgents. + */ + @java.lang.Override + public int getMaxIdleDataPublishingAgents() { + return maxIdleDataPublishingAgents_; + } + /** + * int32 maxIdleDataPublishingAgents = 1; + * @param value The maxIdleDataPublishingAgents to set. + * @return This builder for chaining. + */ + public Builder setMaxIdleDataPublishingAgents(int value) { + + maxIdleDataPublishingAgents_ = value; + onChanged(); + return this; + } + /** + * int32 maxIdleDataPublishingAgents = 1; + * @return This builder for chaining. + */ + public Builder clearMaxIdleDataPublishingAgents() { + + maxIdleDataPublishingAgents_ = 0; + onChanged(); + return this; + } + + private int initIdleObjectDataPublishingAgents_ ; + /** + * int32 initIdleObjectDataPublishingAgents = 2; + * @return The initIdleObjectDataPublishingAgents. + */ + @java.lang.Override + public int getInitIdleObjectDataPublishingAgents() { + return initIdleObjectDataPublishingAgents_; + } + /** + * int32 initIdleObjectDataPublishingAgents = 2; + * @param value The initIdleObjectDataPublishingAgents to set. + * @return This builder for chaining. + */ + public Builder setInitIdleObjectDataPublishingAgents(int value) { + + initIdleObjectDataPublishingAgents_ = value; + onChanged(); + return this; + } + /** + * int32 initIdleObjectDataPublishingAgents = 2; + * @return This builder for chaining. + */ + public Builder clearInitIdleObjectDataPublishingAgents() { + + initIdleObjectDataPublishingAgents_ = 0; + onChanged(); + return this; + } + + private int publisherThreadPoolCoreSize_ ; + /** + * int32 publisherThreadPoolCoreSize = 3; + * @return The publisherThreadPoolCoreSize. + */ + @java.lang.Override + public int getPublisherThreadPoolCoreSize() { + return publisherThreadPoolCoreSize_; + } + /** + * int32 publisherThreadPoolCoreSize = 3; + * @param value The publisherThreadPoolCoreSize to set. + * @return This builder for chaining. + */ + public Builder setPublisherThreadPoolCoreSize(int value) { + + publisherThreadPoolCoreSize_ = value; + onChanged(); + return this; + } + /** + * int32 publisherThreadPoolCoreSize = 3; + * @return This builder for chaining. + */ + public Builder clearPublisherThreadPoolCoreSize() { + + publisherThreadPoolCoreSize_ = 0; + onChanged(); + return this; + } + + private int publisherThreadPoolMaximumSize_ ; + /** + * int32 publisherThreadPoolMaximumSize = 4; + * @return The publisherThreadPoolMaximumSize. + */ + @java.lang.Override + public int getPublisherThreadPoolMaximumSize() { + return publisherThreadPoolMaximumSize_; + } + /** + * int32 publisherThreadPoolMaximumSize = 4; + * @param value The publisherThreadPoolMaximumSize to set. + * @return This builder for chaining. + */ + public Builder setPublisherThreadPoolMaximumSize(int value) { + + publisherThreadPoolMaximumSize_ = value; + onChanged(); + return this; + } + /** + * int32 publisherThreadPoolMaximumSize = 4; + * @return This builder for chaining. + */ + public Builder clearPublisherThreadPoolMaximumSize() { + + publisherThreadPoolMaximumSize_ = 0; + onChanged(); + return this; + } + + private int publisherThreadPoolKeepAliveTime_ ; + /** + * int32 publisherThreadPoolKeepAliveTime = 5; + * @return The publisherThreadPoolKeepAliveTime. + */ + @java.lang.Override + public int getPublisherThreadPoolKeepAliveTime() { + return publisherThreadPoolKeepAliveTime_; + } + /** + * int32 publisherThreadPoolKeepAliveTime = 5; + * @param value The publisherThreadPoolKeepAliveTime to set. + * @return This builder for chaining. + */ + public Builder setPublisherThreadPoolKeepAliveTime(int value) { + + publisherThreadPoolKeepAliveTime_ = value; + onChanged(); + return this; + } + /** + * int32 publisherThreadPoolKeepAliveTime = 5; + * @return This builder for chaining. + */ + public Builder clearPublisherThreadPoolKeepAliveTime() { + + publisherThreadPoolKeepAliveTime_ = 0; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:wso2.discovery.config.enforcer.PublisherPool) + } + + // @@protoc_insertion_point(class_scope:wso2.discovery.config.enforcer.PublisherPool) + private static final org.wso2.gateway.discovery.config.enforcer.PublisherPool DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.wso2.gateway.discovery.config.enforcer.PublisherPool(); + } + + public static org.wso2.gateway.discovery.config.enforcer.PublisherPool getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PublisherPool parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PublisherPool(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public org.wso2.gateway.discovery.config.enforcer.PublisherPool getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPoolOrBuilder.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPoolOrBuilder.java new file mode 100644 index 0000000000..4b582b9dae --- /dev/null +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPoolOrBuilder.java @@ -0,0 +1,39 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/config/enforcer/throttle_publisher_pool.proto + +package org.wso2.gateway.discovery.config.enforcer; + +public interface PublisherPoolOrBuilder extends + // @@protoc_insertion_point(interface_extends:wso2.discovery.config.enforcer.PublisherPool) + com.google.protobuf.MessageOrBuilder { + + /** + * int32 maxIdleDataPublishingAgents = 1; + * @return The maxIdleDataPublishingAgents. + */ + int getMaxIdleDataPublishingAgents(); + + /** + * int32 initIdleObjectDataPublishingAgents = 2; + * @return The initIdleObjectDataPublishingAgents. + */ + int getInitIdleObjectDataPublishingAgents(); + + /** + * int32 publisherThreadPoolCoreSize = 3; + * @return The publisherThreadPoolCoreSize. + */ + int getPublisherThreadPoolCoreSize(); + + /** + * int32 publisherThreadPoolMaximumSize = 4; + * @return The publisherThreadPoolMaximumSize. + */ + int getPublisherThreadPoolMaximumSize(); + + /** + * int32 publisherThreadPoolKeepAliveTime = 5; + * @return The publisherThreadPoolKeepAliveTime. + */ + int getPublisherThreadPoolKeepAliveTime(); +} diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPoolProto.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPoolProto.java new file mode 100644 index 0000000000..2ed1db3fce --- /dev/null +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/PublisherPoolProto.java @@ -0,0 +1,57 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: wso2/discovery/config/enforcer/throttle_publisher_pool.proto + +package org.wso2.gateway.discovery.config.enforcer; + +public final class PublisherPoolProto { + private PublisherPoolProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + static final com.google.protobuf.Descriptors.Descriptor + internal_static_wso2_discovery_config_enforcer_PublisherPool_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_wso2_discovery_config_enforcer_PublisherPool_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n builder) { private Throttling() { jmsConnectionInitialContextFactory_ = ""; jmsConnectionProviderUrl_ = ""; - jmsConnectionUsername_ = ""; - jmsConnectionPassword_ = ""; } @java.lang.Override @@ -89,26 +87,14 @@ private Throttling( break; } case 58: { - java.lang.String s = input.readStringRequireUtf8(); - - jmsConnectionUsername_ = s; - break; - } - case 66: { - java.lang.String s = input.readStringRequireUtf8(); - - jmsConnectionPassword_ = s; - break; - } - case 74: { - org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.Builder subBuilder = null; - if (binary_ != null) { - subBuilder = binary_.toBuilder(); + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.Builder subBuilder = null; + if (publisher_ != null) { + subBuilder = publisher_.toBuilder(); } - binary_ = input.readMessage(org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.parser(), extensionRegistry); + publisher_ = input.readMessage(org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.parser(), extensionRegistry); if (subBuilder != null) { - subBuilder.mergeFrom(binary_); - binary_ = subBuilder.buildPartial(); + subBuilder.mergeFrom(publisher_); + publisher_ = subBuilder.buildPartial(); } break; @@ -265,106 +251,30 @@ public java.lang.String getJmsConnectionProviderUrl() { } } - public static final int JMS_CONNECTION_USERNAME_FIELD_NUMBER = 7; - private volatile java.lang.Object jmsConnectionUsername_; + public static final int PUBLISHER_FIELD_NUMBER = 7; + private org.wso2.gateway.discovery.config.enforcer.BinaryPublisher publisher_; /** - * string jms_connection_username = 7; - * @return The jmsConnectionUsername. + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; + * @return Whether the publisher field is set. */ @java.lang.Override - public java.lang.String getJmsConnectionUsername() { - java.lang.Object ref = jmsConnectionUsername_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - jmsConnectionUsername_ = s; - return s; - } + public boolean hasPublisher() { + return publisher_ != null; } /** - * string jms_connection_username = 7; - * @return The bytes for jmsConnectionUsername. + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; + * @return The publisher. */ @java.lang.Override - public com.google.protobuf.ByteString - getJmsConnectionUsernameBytes() { - java.lang.Object ref = jmsConnectionUsername_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - jmsConnectionUsername_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + public org.wso2.gateway.discovery.config.enforcer.BinaryPublisher getPublisher() { + return publisher_ == null ? org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.getDefaultInstance() : publisher_; } - - public static final int JMS_CONNECTION_PASSWORD_FIELD_NUMBER = 8; - private volatile java.lang.Object jmsConnectionPassword_; /** - * string jms_connection_password = 8; - * @return The jmsConnectionPassword. + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; */ @java.lang.Override - public java.lang.String getJmsConnectionPassword() { - java.lang.Object ref = jmsConnectionPassword_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - jmsConnectionPassword_ = s; - return s; - } - } - /** - * string jms_connection_password = 8; - * @return The bytes for jmsConnectionPassword. - */ - @java.lang.Override - public com.google.protobuf.ByteString - getJmsConnectionPasswordBytes() { - java.lang.Object ref = jmsConnectionPassword_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - jmsConnectionPassword_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int BINARY_FIELD_NUMBER = 9; - private org.wso2.gateway.discovery.config.enforcer.BinaryThrottling binary_; - /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; - * @return Whether the binary field is set. - */ - @java.lang.Override - public boolean hasBinary() { - return binary_ != null; - } - /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; - * @return The binary. - */ - @java.lang.Override - public org.wso2.gateway.discovery.config.enforcer.BinaryThrottling getBinary() { - return binary_ == null ? org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.getDefaultInstance() : binary_; - } - /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; - */ - @java.lang.Override - public org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingOrBuilder getBinaryOrBuilder() { - return getBinary(); + public org.wso2.gateway.discovery.config.enforcer.BinaryPublisherOrBuilder getPublisherOrBuilder() { + return getPublisher(); } private byte memoizedIsInitialized = -1; @@ -399,14 +309,8 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (!getJmsConnectionProviderUrlBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 6, jmsConnectionProviderUrl_); } - if (!getJmsConnectionUsernameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 7, jmsConnectionUsername_); - } - if (!getJmsConnectionPasswordBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 8, jmsConnectionPassword_); - } - if (binary_ != null) { - output.writeMessage(9, getBinary()); + if (publisher_ != null) { + output.writeMessage(7, getPublisher()); } unknownFields.writeTo(output); } @@ -439,15 +343,9 @@ public int getSerializedSize() { if (!getJmsConnectionProviderUrlBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, jmsConnectionProviderUrl_); } - if (!getJmsConnectionUsernameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, jmsConnectionUsername_); - } - if (!getJmsConnectionPasswordBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, jmsConnectionPassword_); - } - if (binary_ != null) { + if (publisher_ != null) { size += com.google.protobuf.CodedOutputStream - .computeMessageSize(9, getBinary()); + .computeMessageSize(7, getPublisher()); } size += unknownFields.getSerializedSize(); memoizedSize = size; @@ -476,14 +374,10 @@ public boolean equals(final java.lang.Object obj) { .equals(other.getJmsConnectionInitialContextFactory())) return false; if (!getJmsConnectionProviderUrl() .equals(other.getJmsConnectionProviderUrl())) return false; - if (!getJmsConnectionUsername() - .equals(other.getJmsConnectionUsername())) return false; - if (!getJmsConnectionPassword() - .equals(other.getJmsConnectionPassword())) return false; - if (hasBinary() != other.hasBinary()) return false; - if (hasBinary()) { - if (!getBinary() - .equals(other.getBinary())) return false; + if (hasPublisher() != other.hasPublisher()) return false; + if (hasPublisher()) { + if (!getPublisher() + .equals(other.getPublisher())) return false; } if (!unknownFields.equals(other.unknownFields)) return false; return true; @@ -512,13 +406,9 @@ public int hashCode() { hash = (53 * hash) + getJmsConnectionInitialContextFactory().hashCode(); hash = (37 * hash) + JMS_CONNECTION_PROVIDER_URL_FIELD_NUMBER; hash = (53 * hash) + getJmsConnectionProviderUrl().hashCode(); - hash = (37 * hash) + JMS_CONNECTION_USERNAME_FIELD_NUMBER; - hash = (53 * hash) + getJmsConnectionUsername().hashCode(); - hash = (37 * hash) + JMS_CONNECTION_PASSWORD_FIELD_NUMBER; - hash = (53 * hash) + getJmsConnectionPassword().hashCode(); - if (hasBinary()) { - hash = (37 * hash) + BINARY_FIELD_NUMBER; - hash = (53 * hash) + getBinary().hashCode(); + if (hasPublisher()) { + hash = (37 * hash) + PUBLISHER_FIELD_NUMBER; + hash = (53 * hash) + getPublisher().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; @@ -669,15 +559,11 @@ public Builder clear() { jmsConnectionProviderUrl_ = ""; - jmsConnectionUsername_ = ""; - - jmsConnectionPassword_ = ""; - - if (binaryBuilder_ == null) { - binary_ = null; + if (publisherBuilder_ == null) { + publisher_ = null; } else { - binary_ = null; - binaryBuilder_ = null; + publisher_ = null; + publisherBuilder_ = null; } return this; } @@ -711,12 +597,10 @@ public org.wso2.gateway.discovery.config.enforcer.Throttling buildPartial() { result.enableJwtClaimConditions_ = enableJwtClaimConditions_; result.jmsConnectionInitialContextFactory_ = jmsConnectionInitialContextFactory_; result.jmsConnectionProviderUrl_ = jmsConnectionProviderUrl_; - result.jmsConnectionUsername_ = jmsConnectionUsername_; - result.jmsConnectionPassword_ = jmsConnectionPassword_; - if (binaryBuilder_ == null) { - result.binary_ = binary_; + if (publisherBuilder_ == null) { + result.publisher_ = publisher_; } else { - result.binary_ = binaryBuilder_.build(); + result.publisher_ = publisherBuilder_.build(); } onBuilt(); return result; @@ -786,16 +670,8 @@ public Builder mergeFrom(org.wso2.gateway.discovery.config.enforcer.Throttling o jmsConnectionProviderUrl_ = other.jmsConnectionProviderUrl_; onChanged(); } - if (!other.getJmsConnectionUsername().isEmpty()) { - jmsConnectionUsername_ = other.jmsConnectionUsername_; - onChanged(); - } - if (!other.getJmsConnectionPassword().isEmpty()) { - jmsConnectionPassword_ = other.jmsConnectionPassword_; - onChanged(); - } - if (other.hasBinary()) { - mergeBinary(other.getBinary()); + if (other.hasPublisher()) { + mergePublisher(other.getPublisher()); } this.mergeUnknownFields(other.unknownFields); onChanged(); @@ -1102,275 +978,123 @@ public Builder setJmsConnectionProviderUrlBytes( return this; } - private java.lang.Object jmsConnectionUsername_ = ""; - /** - * string jms_connection_username = 7; - * @return The jmsConnectionUsername. - */ - public java.lang.String getJmsConnectionUsername() { - java.lang.Object ref = jmsConnectionUsername_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - jmsConnectionUsername_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string jms_connection_username = 7; - * @return The bytes for jmsConnectionUsername. - */ - public com.google.protobuf.ByteString - getJmsConnectionUsernameBytes() { - java.lang.Object ref = jmsConnectionUsername_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - jmsConnectionUsername_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string jms_connection_username = 7; - * @param value The jmsConnectionUsername to set. - * @return This builder for chaining. - */ - public Builder setJmsConnectionUsername( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - jmsConnectionUsername_ = value; - onChanged(); - return this; - } - /** - * string jms_connection_username = 7; - * @return This builder for chaining. - */ - public Builder clearJmsConnectionUsername() { - - jmsConnectionUsername_ = getDefaultInstance().getJmsConnectionUsername(); - onChanged(); - return this; - } - /** - * string jms_connection_username = 7; - * @param value The bytes for jmsConnectionUsername to set. - * @return This builder for chaining. - */ - public Builder setJmsConnectionUsernameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - jmsConnectionUsername_ = value; - onChanged(); - return this; - } - - private java.lang.Object jmsConnectionPassword_ = ""; - /** - * string jms_connection_password = 8; - * @return The jmsConnectionPassword. - */ - public java.lang.String getJmsConnectionPassword() { - java.lang.Object ref = jmsConnectionPassword_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - jmsConnectionPassword_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string jms_connection_password = 8; - * @return The bytes for jmsConnectionPassword. - */ - public com.google.protobuf.ByteString - getJmsConnectionPasswordBytes() { - java.lang.Object ref = jmsConnectionPassword_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - jmsConnectionPassword_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string jms_connection_password = 8; - * @param value The jmsConnectionPassword to set. - * @return This builder for chaining. - */ - public Builder setJmsConnectionPassword( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - jmsConnectionPassword_ = value; - onChanged(); - return this; - } - /** - * string jms_connection_password = 8; - * @return This builder for chaining. - */ - public Builder clearJmsConnectionPassword() { - - jmsConnectionPassword_ = getDefaultInstance().getJmsConnectionPassword(); - onChanged(); - return this; - } - /** - * string jms_connection_password = 8; - * @param value The bytes for jmsConnectionPassword to set. - * @return This builder for chaining. - */ - public Builder setJmsConnectionPasswordBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - jmsConnectionPassword_ = value; - onChanged(); - return this; - } - - private org.wso2.gateway.discovery.config.enforcer.BinaryThrottling binary_; + private org.wso2.gateway.discovery.config.enforcer.BinaryPublisher publisher_; private com.google.protobuf.SingleFieldBuilderV3< - org.wso2.gateway.discovery.config.enforcer.BinaryThrottling, org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.Builder, org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingOrBuilder> binaryBuilder_; + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher, org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.Builder, org.wso2.gateway.discovery.config.enforcer.BinaryPublisherOrBuilder> publisherBuilder_; /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; - * @return Whether the binary field is set. + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; + * @return Whether the publisher field is set. */ - public boolean hasBinary() { - return binaryBuilder_ != null || binary_ != null; + public boolean hasPublisher() { + return publisherBuilder_ != null || publisher_ != null; } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; - * @return The binary. + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; + * @return The publisher. */ - public org.wso2.gateway.discovery.config.enforcer.BinaryThrottling getBinary() { - if (binaryBuilder_ == null) { - return binary_ == null ? org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.getDefaultInstance() : binary_; + public org.wso2.gateway.discovery.config.enforcer.BinaryPublisher getPublisher() { + if (publisherBuilder_ == null) { + return publisher_ == null ? org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.getDefaultInstance() : publisher_; } else { - return binaryBuilder_.getMessage(); + return publisherBuilder_.getMessage(); } } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; */ - public Builder setBinary(org.wso2.gateway.discovery.config.enforcer.BinaryThrottling value) { - if (binaryBuilder_ == null) { + public Builder setPublisher(org.wso2.gateway.discovery.config.enforcer.BinaryPublisher value) { + if (publisherBuilder_ == null) { if (value == null) { throw new NullPointerException(); } - binary_ = value; + publisher_ = value; onChanged(); } else { - binaryBuilder_.setMessage(value); + publisherBuilder_.setMessage(value); } return this; } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; */ - public Builder setBinary( - org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.Builder builderForValue) { - if (binaryBuilder_ == null) { - binary_ = builderForValue.build(); + public Builder setPublisher( + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.Builder builderForValue) { + if (publisherBuilder_ == null) { + publisher_ = builderForValue.build(); onChanged(); } else { - binaryBuilder_.setMessage(builderForValue.build()); + publisherBuilder_.setMessage(builderForValue.build()); } return this; } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; */ - public Builder mergeBinary(org.wso2.gateway.discovery.config.enforcer.BinaryThrottling value) { - if (binaryBuilder_ == null) { - if (binary_ != null) { - binary_ = - org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.newBuilder(binary_).mergeFrom(value).buildPartial(); + public Builder mergePublisher(org.wso2.gateway.discovery.config.enforcer.BinaryPublisher value) { + if (publisherBuilder_ == null) { + if (publisher_ != null) { + publisher_ = + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.newBuilder(publisher_).mergeFrom(value).buildPartial(); } else { - binary_ = value; + publisher_ = value; } onChanged(); } else { - binaryBuilder_.mergeFrom(value); + publisherBuilder_.mergeFrom(value); } return this; } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; */ - public Builder clearBinary() { - if (binaryBuilder_ == null) { - binary_ = null; + public Builder clearPublisher() { + if (publisherBuilder_ == null) { + publisher_ = null; onChanged(); } else { - binary_ = null; - binaryBuilder_ = null; + publisher_ = null; + publisherBuilder_ = null; } return this; } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; */ - public org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.Builder getBinaryBuilder() { + public org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.Builder getPublisherBuilder() { onChanged(); - return getBinaryFieldBuilder().getBuilder(); + return getPublisherFieldBuilder().getBuilder(); } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; */ - public org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingOrBuilder getBinaryOrBuilder() { - if (binaryBuilder_ != null) { - return binaryBuilder_.getMessageOrBuilder(); + public org.wso2.gateway.discovery.config.enforcer.BinaryPublisherOrBuilder getPublisherOrBuilder() { + if (publisherBuilder_ != null) { + return publisherBuilder_.getMessageOrBuilder(); } else { - return binary_ == null ? - org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.getDefaultInstance() : binary_; + return publisher_ == null ? + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.getDefaultInstance() : publisher_; } } /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; */ private com.google.protobuf.SingleFieldBuilderV3< - org.wso2.gateway.discovery.config.enforcer.BinaryThrottling, org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.Builder, org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingOrBuilder> - getBinaryFieldBuilder() { - if (binaryBuilder_ == null) { - binaryBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - org.wso2.gateway.discovery.config.enforcer.BinaryThrottling, org.wso2.gateway.discovery.config.enforcer.BinaryThrottling.Builder, org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingOrBuilder>( - getBinary(), + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher, org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.Builder, org.wso2.gateway.discovery.config.enforcer.BinaryPublisherOrBuilder> + getPublisherFieldBuilder() { + if (publisherBuilder_ == null) { + publisherBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher, org.wso2.gateway.discovery.config.enforcer.BinaryPublisher.Builder, org.wso2.gateway.discovery.config.enforcer.BinaryPublisherOrBuilder>( + getPublisher(), getParentForChildren(), isClean()); - binary_ = null; + publisher_ = null; } - return binaryBuilder_; + return publisherBuilder_; } @java.lang.Override public final Builder setUnknownFields( diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingOrBuilder.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingOrBuilder.java index ac522e82bd..47fefc7606 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingOrBuilder.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingOrBuilder.java @@ -56,41 +56,17 @@ public interface ThrottlingOrBuilder extends getJmsConnectionProviderUrlBytes(); /** - * string jms_connection_username = 7; - * @return The jmsConnectionUsername. + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; + * @return Whether the publisher field is set. */ - java.lang.String getJmsConnectionUsername(); + boolean hasPublisher(); /** - * string jms_connection_username = 7; - * @return The bytes for jmsConnectionUsername. + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; + * @return The publisher. */ - com.google.protobuf.ByteString - getJmsConnectionUsernameBytes(); - - /** - * string jms_connection_password = 8; - * @return The jmsConnectionPassword. - */ - java.lang.String getJmsConnectionPassword(); - /** - * string jms_connection_password = 8; - * @return The bytes for jmsConnectionPassword. - */ - com.google.protobuf.ByteString - getJmsConnectionPasswordBytes(); - - /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; - * @return Whether the binary field is set. - */ - boolean hasBinary(); - /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; - * @return The binary. - */ - org.wso2.gateway.discovery.config.enforcer.BinaryThrottling getBinary(); + org.wso2.gateway.discovery.config.enforcer.BinaryPublisher getPublisher(); /** - * .wso2.discovery.config.enforcer.BinaryThrottling binary = 9; + * .wso2.discovery.config.enforcer.BinaryPublisher publisher = 7; */ - org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingOrBuilder getBinaryOrBuilder(); + org.wso2.gateway.discovery.config.enforcer.BinaryPublisherOrBuilder getPublisherOrBuilder(); } diff --git a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingProto.java b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingProto.java index e1c253d3e7..7fc683d5fe 100644 --- a/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingProto.java +++ b/enforcer/src/main/gen/org/wso2/gateway/discovery/config/enforcer/ThrottlingProto.java @@ -30,34 +30,33 @@ public static void registerAllExtensions( java.lang.String[] descriptorData = { "\n/wso2/discovery/config/enforcer/throttl" + "ing.proto\022\036wso2.discovery.config.enforce" + - "r\0326wso2/discovery/config/enforcer/binary" + - "_throttling.proto\"\373\002\n\nThrottling\022&\n\036enab" + - "le_global_event_publishing\030\001 \001(\010\022 \n\030enab" + - "le_header_conditions\030\002 \001(\010\022%\n\035enable_que" + - "ry_param_conditions\030\003 \001(\010\022#\n\033enable_jwt_" + - "claim_conditions\030\004 \001(\010\022.\n&jms_connection" + - "_initial_context_factory\030\005 \001(\t\022#\n\033jms_co" + - "nnection_provider_url\030\006 \001(\t\022\037\n\027jms_conne" + - "ction_username\030\007 \001(\t\022\037\n\027jms_connection_p" + - "assword\030\010 \001(\t\022@\n\006binary\030\t \001(\01320.wso2.dis" + - "covery.config.enforcer.BinaryThrottlingB" + - "\217\001\n*org.wso2.gateway.discovery.config.en" + - "forcerB\017ThrottlingProtoP\001ZNgithub.com/en" + - "voyproxy/go-control-plane/wso2/discovery" + - "/config/enforcer;enforcerb\006proto3" + "r\0325wso2/discovery/config/enforcer/binary" + + "_publisher.proto\"\273\002\n\nThrottling\022&\n\036enabl" + + "e_global_event_publishing\030\001 \001(\010\022 \n\030enabl" + + "e_header_conditions\030\002 \001(\010\022%\n\035enable_quer" + + "y_param_conditions\030\003 \001(\010\022#\n\033enable_jwt_c" + + "laim_conditions\030\004 \001(\010\022.\n&jms_connection_" + + "initial_context_factory\030\005 \001(\t\022#\n\033jms_con" + + "nection_provider_url\030\006 \001(\t\022B\n\tpublisher\030" + + "\007 \001(\0132/.wso2.discovery.config.enforcer.B" + + "inaryPublisherB\217\001\n*org.wso2.gateway.disc" + + "overy.config.enforcerB\017ThrottlingProtoP\001" + + "ZNgithub.com/envoyproxy/go-control-plane" + + "/wso2/discovery/config/enforcer;enforcer" + + "b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { - org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingProto.getDescriptor(), + org.wso2.gateway.discovery.config.enforcer.BinaryPublisherProto.getDescriptor(), }); internal_static_wso2_discovery_config_enforcer_Throttling_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_wso2_discovery_config_enforcer_Throttling_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_wso2_discovery_config_enforcer_Throttling_descriptor, - new java.lang.String[] { "EnableGlobalEventPublishing", "EnableHeaderConditions", "EnableQueryParamConditions", "EnableJwtClaimConditions", "JmsConnectionInitialContextFactory", "JmsConnectionProviderUrl", "JmsConnectionUsername", "JmsConnectionPassword", "Binary", }); - org.wso2.gateway.discovery.config.enforcer.BinaryThrottlingProto.getDescriptor(); + new java.lang.String[] { "EnableGlobalEventPublishing", "EnableHeaderConditions", "EnableQueryParamConditions", "EnableJwtClaimConditions", "JmsConnectionInitialContextFactory", "JmsConnectionProviderUrl", "Publisher", }); + org.wso2.gateway.discovery.config.enforcer.BinaryPublisherProto.getDescriptor(); } // @@protoc_insertion_point(outer_class_scope) diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java index 9a2616c449..e91ac5dc98 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java @@ -24,15 +24,15 @@ import org.wso2.carbon.apimgt.common.gateway.dto.JWTConfigurationDto; import org.wso2.gateway.discovery.config.enforcer.AmCredentials; import org.wso2.gateway.discovery.config.enforcer.AuthService; -import org.wso2.gateway.discovery.config.enforcer.BinaryThrottling; +import org.wso2.gateway.discovery.config.enforcer.BinaryPublisher; import org.wso2.gateway.discovery.config.enforcer.Cache; import org.wso2.gateway.discovery.config.enforcer.Config; import org.wso2.gateway.discovery.config.enforcer.EventHub; import org.wso2.gateway.discovery.config.enforcer.Issuer; import org.wso2.gateway.discovery.config.enforcer.JWTGenerator; +import org.wso2.gateway.discovery.config.enforcer.PublisherPool; import org.wso2.gateway.discovery.config.enforcer.TMURLGroup; import org.wso2.gateway.discovery.config.enforcer.ThrottleAgent; -import org.wso2.gateway.discovery.config.enforcer.ThrottlePublisher; import org.wso2.gateway.discovery.config.enforcer.Throttling; import org.wso2.micro.gateway.enforcer.config.dto.AuthServiceConfigurationDto; import org.wso2.micro.gateway.enforcer.config.dto.CacheDto; @@ -122,7 +122,7 @@ private void parseConfigs(Config config) { populateAPIMCredentials(config.getApimCredentials()); // Read throttle publisher configurations - populateThrottlingConfig(config.getThrottlingConfig()); + populateThrottlingConfig(config.getThrottling()); // Read backend jwt generation configurations populateJWTGeneratorConfigurations(config.getJwtGenerator()); @@ -203,13 +203,11 @@ private void populateThrottlingConfig(Throttling throttling) { throttleConfig.setJwtClaimConditionsEnabled(throttling.getEnableJwtClaimConditions()); throttleConfig.setJmsConnectionInitialContextFactory(throttling.getJmsConnectionInitialContextFactory()); throttleConfig.setJmsConnectionProviderUrl(throttling.getJmsConnectionProviderUrl()); - throttleConfig.setJmsConnectionUsername(throttling.getJmsConnectionUsername()); - throttleConfig.setJmsConnectionPassword(throttling.getJmsConnectionPassword()); config.setThrottleConfig(throttleConfig); - populateTMBinaryConfig(throttling.getBinary()); + populateTMBinaryConfig(throttling.getPublisher()); } - private void populateTMBinaryConfig(BinaryThrottling binary) { + private void populateTMBinaryConfig(BinaryPublisher binary) { ThrottleAgent binaryAgent = binary.getAgent(); AgentConfiguration agentConf = AgentConfiguration.getInstance(); agentConf.setBatchSize(binaryAgent.getBatchSize()); @@ -231,15 +229,15 @@ private void populateTMBinaryConfig(BinaryThrottling binary) { agentConf.setSocketTimeoutMS(binaryAgent.getSocketTimeoutMS()); agentConf.setTrustStore(trustStore); - ThrottlePublisher binaryPublisher = binary.getPublisher(); + PublisherPool pool = binary.getPool(); PublisherConfiguration pubConf = PublisherConfiguration.getInstance(); pubConf.setUserName(binary.getUsername()); pubConf.setPassword(binary.getPassword()); - pubConf.setInitIdleObjectDataPublishingAgents(binaryPublisher.getInitIdleObjectDataPublishingAgents()); - pubConf.setMaxIdleDataPublishingAgents(binaryPublisher.getMaxIdleDataPublishingAgents()); - pubConf.setPublisherThreadPoolCoreSize(binaryPublisher.getPublisherThreadPoolCoreSize()); - pubConf.setPublisherThreadPoolKeepAliveTime(binaryPublisher.getPublisherThreadPoolKeepAliveTime()); - pubConf.setPublisherThreadPoolMaximumSize(binaryPublisher.getPublisherThreadPoolMaximumSize()); + pubConf.setInitIdleObjectDataPublishingAgents(pool.getInitIdleObjectDataPublishingAgents()); + pubConf.setMaxIdleDataPublishingAgents(pool.getMaxIdleDataPublishingAgents()); + pubConf.setPublisherThreadPoolCoreSize(pool.getPublisherThreadPoolCoreSize()); + pubConf.setPublisherThreadPoolKeepAliveTime(pool.getPublisherThreadPoolKeepAliveTime()); + pubConf.setPublisherThreadPoolMaximumSize(pool.getPublisherThreadPoolMaximumSize()); processTMPublisherURLGroup(binary.getUrlGroupList(), pubConf); diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleConfigDto.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleConfigDto.java index eda2d46460..cf1b619f0d 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleConfigDto.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/dto/ThrottleConfigDto.java @@ -28,8 +28,6 @@ public class ThrottleConfigDto { private boolean isJwtClaimConditionsEnabled; private String jmsConnectionInitialContextFactory; private String jmsConnectionProviderUrl; - private String jmsConnectionUsername; - private String jmsConnectionPassword; private ThrottleAgentConfigDto throttleAgent; public boolean isGlobalPublishingEnabled() { @@ -80,22 +78,6 @@ public void setJmsConnectionProviderUrl(String jmsConnectionProviderUrl) { this.jmsConnectionProviderUrl = jmsConnectionProviderUrl; } - public String getJmsConnectionUsername() { - return jmsConnectionUsername; - } - - public void setJmsConnectionUsername(String jmsConnectionUsername) { - this.jmsConnectionUsername = jmsConnectionUsername; - } - - public String getJmsConnectionPassword() { - return jmsConnectionPassword; - } - - public void setJmsConnectionPassword(String jmsConnectionPassword) { - this.jmsConnectionPassword = jmsConnectionPassword; - } - public ThrottleAgentConfigDto getThrottleAgent() { return throttleAgent; } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/util/FilterUtils.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/util/FilterUtils.java index cb76ed1fc7..07966a9dd6 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/util/FilterUtils.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/util/FilterUtils.java @@ -43,7 +43,6 @@ import org.wso2.micro.gateway.enforcer.exception.APISecurityException; import org.wso2.micro.gateway.enforcer.exception.MGWException; import org.wso2.micro.gateway.enforcer.security.AuthenticationContext; -import org.wso2.micro.gateway.enforcer.throttle.ThrottleConstants; import java.math.BigInteger; import java.net.InetAddress; diff --git a/resources/conf/config.toml b/resources/conf/config.toml index dcc09bd0d4..6bb8b1ee24 100644 --- a/resources/conf/config.toml +++ b/resources/conf/config.toml @@ -98,7 +98,7 @@ disableSslVerification = false privateKeyPath = "/home/wso2/security/keystore/mg.key" # Throttling configurations -[enforcer.throttlingConfig] +[enforcer.throttling] # Connect with the central traffic manager enableGlobalEventPublishing = false # Enable global advanced throttling based on request header conditions @@ -111,29 +111,25 @@ disableSslVerification = false jmsConnectioninitialContextFactory = "org.wso2.andes.jndi.PropertiesFileInitialContextFactory" # The message broker connection URL jmsConnectionProviderUrl = "amqp://admin:admin@carbon/carbon?brokerlist='tcp://localhost:5672'" - # The username used to establish the message broker connection - jmsConnectionUsername = "" - # The password used to establish the message broker connection - jmsConnectionPassword = "" # Throttling configurations related to event publishing using a binary connection - [enforcer.throttlingConfig.binary] + [enforcer.throttling.publisher] # Credentials required to establish connection between Traffic Manager username = "admin" password = "admin" # Receiver URL and the authentication URL of the Traffic manager node/nodes - [[enforcer.throttlingConfig.binary.urlGroup]] + [[enforcer.throttling.publisher.urlGroup]] receiverURLs = ["tcp://localhost:9611"] authURLs = ["ssl://localhost:9711"] type = "loadbalance" # Data publisher object pool configurations - [enforcer.throttlingConfig.binary.publisher] + [enforcer.throttling.publisher.pool] maxIdleDataPublishingAgents = 1000 initIdleObjectDataPublishingAgents = 200 # Data publisher thread pool configurations publisherThreadPoolCoreSize = 200 publisherThreadPoolMaximumSize = 1000 publisherThreadPoolKeepAliveTime = 200 - [enforcer.throttlingConfig.binary.agent] + [enforcer.throttling.publisher.agent] # SSL Protocols sslEnabledProtocols = "TLSv1,TLSv1.1,TLSv1.2" # ciphers From b7f827e78a5a9e5b2994f6c24badc3c2e5384a23 Mon Sep 17 00:00:00 2001 From: Praminda Jayawardana Date: Thu, 11 Mar 2021 14:07:03 +0530 Subject: [PATCH 17/21] throttle: enf: Remove urlGrp type config this config is not required and not recommended. Used only in rare use cases where we don't want to publicly announce the support ATM. --- .../org/wso2/micro/gateway/enforcer/config/ConfigHolder.java | 2 +- resources/conf/config.toml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java index e91ac5dc98..525f39eaec 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/config/ConfigHolder.java @@ -296,8 +296,8 @@ private void processTMPublisherURLGroup(List urlGroups, } restructuredReceiverURL.append(processSingleURLGroup(receiverUrls, urlType)).append(","); restructuredAuthURL.append(processSingleURLGroup(authUrls, urlType)).append(","); - } + //to remove the final ',' in the URLs and set to publisher config if (!restructuredReceiverURL.toString().isBlank() && !restructuredAuthURL.toString().isBlank()) { pubConfiguration.setReceiverUrlGroup(restructuredReceiverURL.substring(0, diff --git a/resources/conf/config.toml b/resources/conf/config.toml index 6bb8b1ee24..aaded6aed5 100644 --- a/resources/conf/config.toml +++ b/resources/conf/config.toml @@ -120,7 +120,6 @@ disableSslVerification = false [[enforcer.throttling.publisher.urlGroup]] receiverURLs = ["tcp://localhost:9611"] authURLs = ["ssl://localhost:9711"] - type = "loadbalance" # Data publisher object pool configurations [enforcer.throttling.publisher.pool] maxIdleDataPublishingAgents = 1000 From 3ea0e134a3e4786f881610ac0a563fd89fff4228 Mon Sep 17 00:00:00 2001 From: Praminda Jayawardana Date: Thu, 11 Mar 2021 14:12:51 +0530 Subject: [PATCH 18/21] throttle: Remove unrecommended TLS versions --- resources/conf/config.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/conf/config.toml b/resources/conf/config.toml index aaded6aed5..61cfc48ac4 100644 --- a/resources/conf/config.toml +++ b/resources/conf/config.toml @@ -130,7 +130,7 @@ disableSslVerification = false publisherThreadPoolKeepAliveTime = 200 [enforcer.throttling.publisher.agent] # SSL Protocols - sslEnabledProtocols = "TLSv1,TLSv1.1,TLSv1.2" + sslEnabledProtocols = "TLSv1.2" # ciphers ciphers="TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA,TLS_ECDH_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 ,TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 ,TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA,TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA,TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA,SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA,TLS_EMPTY_RENEGOTIATION_INFO_SCSV" # The size of the queue event disruptor which handles events before they are published. From 3455cd500736c6b22cefc719fc0a1ef12f554e9e Mon Sep 17 00:00:00 2001 From: Praminda Jayawardana Date: Fri, 12 Mar 2021 06:42:09 +0530 Subject: [PATCH 19/21] throttle: enf: Move constants to one class --- .../enforcer/api/config/APIConfig.java | 6 ++-- .../enforcer/api/config/ResourceConfig.java | 4 +-- .../enforcer/constants/APIConstants.java | 30 ------------------- .../enforcer/filters/ThrottleFilter.java | 25 ++++++++-------- .../enforcer/throttle/ThrottleConstants.java | 22 +++++++++++++- .../throttle/ThrottleEventListener.java | 18 +++++------ 6 files changed, 47 insertions(+), 58 deletions(-) diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/APIConfig.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/APIConfig.java index 586369d73c..0f9222d124 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/APIConfig.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/APIConfig.java @@ -17,7 +17,7 @@ */ package org.wso2.micro.gateway.enforcer.api.config; -import org.wso2.micro.gateway.enforcer.constants.APIConstants; +import org.wso2.micro.gateway.enforcer.throttle.ThrottleConstants; import java.util.ArrayList; import java.util.List; @@ -31,7 +31,7 @@ public class APIConfig { private String basePath; private List securitySchemas = new ArrayList<>(); - private String tier = APIConstants.UNLIMITED_TIER; + private String tier = ThrottleConstants.UNLIMITED_TIER; private List resources = new ArrayList<>(); /** @@ -44,7 +44,7 @@ public static class Builder { private String basePath; private List securitySchemas = new ArrayList<>(); - private String tier = APIConstants.UNLIMITED_TIER; + private String tier = ThrottleConstants.UNLIMITED_TIER; private List resources = new ArrayList<>(); public Builder(String name) { diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/ResourceConfig.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/ResourceConfig.java index 11f3477831..bf94ed5886 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/ResourceConfig.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/config/ResourceConfig.java @@ -17,7 +17,7 @@ */ package org.wso2.micro.gateway.enforcer.api.config; -import org.wso2.micro.gateway.enforcer.constants.APIConstants; +import org.wso2.micro.gateway.enforcer.throttle.ThrottleConstants; import java.util.HashMap; import java.util.List; @@ -32,7 +32,7 @@ public class ResourceConfig { private String path; private HttpMethods method; private Map> securitySchemas = new HashMap(); - private String tier = APIConstants.UNLIMITED_TIER; + private String tier = ThrottleConstants.UNLIMITED_TIER; public String getPath() { return path; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java index 0e9cf4cb39..e08de590bd 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/APIConstants.java @@ -22,10 +22,6 @@ */ public class APIConstants { - public static final String UNLIMITED_TIER = "Unlimited"; - public static final String IP = "ip"; - public static final String IPV6 = "ipv6"; - //open API extensions public static final String X_WSO2_BASE_PATH = "x-wso2-basepath"; @@ -68,9 +64,6 @@ public class APIConstants { public static final String APPLICATION_JSON = "application/json"; public static final String API_TRACE_KEY = "X-TRACE-KEY"; - public static final String THROTTLE_KEY = "throttleKey"; - public static final String THROTTLE_OUT_REASON = "THROTTLED_OUT_REASON"; - /** * Holds the common set of constants related to the output status codes of the security validations. */ @@ -202,19 +195,6 @@ public enum PolicyType { SUBSCRIPTION } - /** - * Topic Names. - */ - public static class TopicNames { - - //APIM default topic names - public static final String TOPIC_THROTTLE_DATA = "throttleData"; - public static final String TOPIC_TOKEN_REVOCATION = "tokenRevocation"; - public static final String TOPIC_CACHE_INVALIDATION = "cacheInvalidation"; - public static final String TOPIC_KEY_MANAGER = "keyManager"; - public static final String TOPIC_NOTIFICATION = "notification"; - } - /** * Holds the constants related to attributes to be sent in the response in case of an error * scenario raised within the enforcer. @@ -252,14 +232,4 @@ public int getCode() { } } - /** - * Advanced Throttling related constants. - */ - public static class AdvancedThrottleConstants { - public static final String IS_THROTTLED = "isThrottled"; - public static final String THROTTLE_KEY = "throttleKey"; - public static final String EXPIRY_TIMESTAMP = "expiryTimeStamp"; - public static final String EVALUATED_CONDITIONS = "evaluatedConditions"; - public static final String TRUE = "true"; - } } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java index 3c73c4e185..2cc37cc6c4 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java @@ -101,7 +101,7 @@ private boolean doThrottle(RequestContext reqContext) { ThrottleConstants.API_THROTTLE_OUT_ERROR_CODE, ThrottleConstants.THROTTLE_OUT_MESSAGE, ThrottleConstants.THROTTLE_OUT_DESCRIPTION); - reqContext.getProperties().put(APIConstants.THROTTLE_OUT_REASON, + reqContext.getProperties().put(ThrottleConstants.THROTTLE_OUT_REASON, ThrottleConstants.THROTTLE_OUT_REASON_API_LIMIT_EXCEEDED); return true; } else if (isResourceLevelThrottled(resourceThrottleKey, resourceTier)) { @@ -109,7 +109,7 @@ private boolean doThrottle(RequestContext reqContext) { ThrottleConstants.RESOURCE_THROTTLE_OUT_ERROR_CODE, ThrottleConstants.THROTTLE_OUT_MESSAGE, ThrottleConstants.THROTTLE_OUT_DESCRIPTION); - reqContext.getProperties().put(APIConstants.THROTTLE_OUT_REASON, + reqContext.getProperties().put(ThrottleConstants.THROTTLE_OUT_REASON, ThrottleConstants.THROTTLE_OUT_REASON_RESOURCE_LIMIT_EXCEEDED); return true; } @@ -122,7 +122,7 @@ private boolean doThrottle(RequestContext reqContext) { ThrottleConstants.SUBSCRIPTION_THROTTLE_OUT_ERROR_CODE, ThrottleConstants.THROTTLE_OUT_MESSAGE, ThrottleConstants.THROTTLE_OUT_DESCRIPTION); - reqContext.getProperties().put(APIConstants.THROTTLE_OUT_REASON, + reqContext.getProperties().put(ThrottleConstants.THROTTLE_OUT_REASON, ThrottleConstants.THROTTLE_OUT_REASON_SUBSCRIPTION_LIMIT_EXCEEDED); return true; } @@ -137,7 +137,7 @@ private boolean doThrottle(RequestContext reqContext) { ThrottleConstants.APPLICATION_THROTTLE_OUT_ERROR_CODE, ThrottleConstants.THROTTLE_OUT_MESSAGE, ThrottleConstants.THROTTLE_OUT_DESCRIPTION); - reqContext.getProperties().put(APIConstants.THROTTLE_OUT_REASON, + reqContext.getProperties().put(ThrottleConstants.THROTTLE_OUT_REASON, ThrottleConstants.THROTTLE_OUT_REASON_APPLICATION_LIMIT_EXCEEDED); return true; } @@ -182,7 +182,7 @@ private Map getThrottleEventMap(RequestContext requestContext) { String resourceTier; String resourceKey; - if (!APIConstants.UNLIMITED_TIER.equals(authenticationContext.getApiTier()) && + if (!ThrottleConstants.UNLIMITED_TIER.equals(authenticationContext.getApiTier()) && authenticationContext.getApiTier() != null && !authenticationContext.getApiTier().isBlank()) { resourceTier = authenticationContext.getApiTier(); @@ -192,7 +192,6 @@ private Map getThrottleEventMap(RequestContext requestContext) { resourceKey = getResourceThrottleKey(requestContext, apiContext, apiVersion); } - throttleEvent.put(ThrottleEventConstants.MESSAGE_ID, requestContext.getRequestID()); throttleEvent.put(ThrottleEventConstants.APP_KEY, authenticationContext.getApplicationId() + ':' + authenticationContext.getUsername()); @@ -245,7 +244,7 @@ private String getResourceTier(ResourceConfig resourceConfig) { if (!resourceConfig.getTier().isBlank()) { return resourceConfig.getTier(); } - return APIConstants.UNLIMITED_TIER; + return ThrottleConstants.UNLIMITED_TIER; } @@ -256,17 +255,17 @@ private JSONObject getProperties(RequestContext requestContext) { try { InetAddress address = InetAddress.getByName(remoteIP); if (address instanceof Inet4Address) { - jsonObMap.put(APIConstants.IP, FilterUtils.ipToLong(remoteIP)); - jsonObMap.put(APIConstants.IPV6, 0); + jsonObMap.put(ThrottleConstants.IP, FilterUtils.ipToLong(remoteIP)); + jsonObMap.put(ThrottleConstants.IPV6, 0); } else if (address instanceof Inet6Address) { - jsonObMap.put(APIConstants.IPV6, FilterUtils.ipToBigInteger(remoteIP)); - jsonObMap.put(APIConstants.IP, 0); + jsonObMap.put(ThrottleConstants.IPV6, FilterUtils.ipToBigInteger(remoteIP)); + jsonObMap.put(ThrottleConstants.IP, 0); } } catch (UnknownHostException e) { //send empty value as ip log.error("Error while parsing host IP {}", remoteIP, e); - jsonObMap.put(APIConstants.IPV6, 0); - jsonObMap.put(APIConstants.IP, 0); + jsonObMap.put(ThrottleConstants.IPV6, 0); + jsonObMap.put(ThrottleConstants.IP, 0); } } // TODO(amaliMatharaarachchi) Add advance throttling data to additional properties. diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleConstants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleConstants.java index 2dc35ace4b..76a27baccb 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleConstants.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleConstants.java @@ -36,11 +36,31 @@ public class ThrottleConstants { public static final String THROTTLE_OUT_MESSAGE = "Message throttled out"; public static final String THROTTLE_OUT_DESCRIPTION = "You have exceeded your quota"; public static final String BLOCKING_MESSAGE = "Message blocked"; - public static final String BLOCKING_DESCRIPTION = "You have been blocked from accesing the resource"; + public static final String BLOCKING_DESCRIPTION = "You have been blocked from accessing the resource"; public static final String THROTTLE_OUT_REASON_API_LIMIT_EXCEEDED = "API_LIMIT_EXCEEDED"; public static final String THROTTLE_OUT_REASON_RESOURCE_LIMIT_EXCEEDED = "RESOURCE_LIMIT_EXCEEDED"; public static final String THROTTLE_OUT_REASON_SUBSCRIPTION_LIMIT_EXCEEDED = "SUBSCRIPTION_LIMIT_EXCEEDED"; public static final String THROTTLE_OUT_REASON_APPLICATION_LIMIT_EXCEEDED = "APPLICATION_LIMIT_EXCEEDED"; public static final String POLICY_NOT_FOUND_DESCRIPTION = "POLICY ENFORCEMENT ERROR"; + + public static final String UNLIMITED_TIER = "Unlimited"; + public static final String IP = "ip"; + public static final String IPV6 = "ipv6"; + public static final String BLOCKING_CONDITION_KEY = "blockingCondition"; + public static final String POLICY_TEMPLATE_KEY = "keyTemplateValue"; + public static final String THROTTLE_KEY = "throttleKey"; + public static final String THROTTLE_OUT_REASON = "THROTTLED_OUT_REASON"; + public static final String TOPIC_THROTTLE_DATA = "throttleData"; + + /** + * Advanced Throttling related constants. + */ + public static class AdvancedThrottleConstants { + public static final String IS_THROTTLED = "isThrottled"; + public static final String THROTTLE_KEY = "throttleKey"; + public static final String EXPIRY_TIMESTAMP = "expiryTimeStamp"; + public static final String EVALUATED_CONDITIONS = "evaluatedConditions"; + public static final String TRUE = "true"; + } } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java index a368cc1276..2e72ac0b20 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java @@ -81,7 +81,7 @@ public static void init() { topicConnection = connFactory.createTopicConnection(); topicConnection.start(); topicSession = topicConnection.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE); - Topic gatewayJmsTopic = topicSession.createTopic("throttleData"); + Topic gatewayJmsTopic = topicSession.createTopic(ThrottleConstants.TOPIC_THROTTLE_DATA); TopicSubscriber listener = topicSession.createSubscriber(gatewayJmsTopic); listener.setMessageListener(new ThrottleEventListener()); } catch (NamingException | JMSException e) { @@ -112,8 +112,8 @@ public void onMessage(Message message) { map.put(key, mapMessage.getObject(key)); } - if (APIConstants.TopicNames.TOPIC_THROTTLE_DATA.equalsIgnoreCase(jmsDestination.getTopicName())) { - if (map.get(APIConstants.THROTTLE_KEY) != null) { + if (ThrottleConstants.TOPIC_THROTTLE_DATA.equalsIgnoreCase(jmsDestination.getTopicName())) { + if (map.get(ThrottleConstants.THROTTLE_KEY) != null) { /* * This message contains throttle data in map which contains Keys * throttleKey - Key of particular throttling level @@ -130,10 +130,11 @@ public void onMessage(Message message) { } private void handleThrottleUpdateMessage(Map map) { - String throttleKey = map.get(APIConstants.AdvancedThrottleConstants.THROTTLE_KEY).toString(); - String throttleState = map.get(APIConstants.AdvancedThrottleConstants.IS_THROTTLED).toString(); - long timeStamp = Long.parseLong(map.get(APIConstants.AdvancedThrottleConstants.EXPIRY_TIMESTAMP).toString()); - Object evaluatedConditionObject = map.get(APIConstants.AdvancedThrottleConstants.EVALUATED_CONDITIONS); + String throttleKey = map.get(ThrottleConstants.AdvancedThrottleConstants.THROTTLE_KEY).toString(); + String throttleState = map.get(ThrottleConstants.AdvancedThrottleConstants.IS_THROTTLED).toString(); + long timeStamp = Long.parseLong(map.get(ThrottleConstants. + AdvancedThrottleConstants.EXPIRY_TIMESTAMP).toString()); + Object evaluatedConditionObject = map.get(ThrottleConstants.AdvancedThrottleConstants.EVALUATED_CONDITIONS); ThrottleDataHolder dataHolder = ThrottleDataHolder.getInstance(); if (log.isDebugEnabled()) { @@ -141,8 +142,7 @@ private void handleThrottleUpdateMessage(Map map) { throttleState + ", expiryTime: " + new Date(timeStamp).toString()); } - if (APIConstants.AdvancedThrottleConstants.TRUE.equalsIgnoreCase(throttleState)) { - + if (ThrottleConstants.AdvancedThrottleConstants.TRUE.equalsIgnoreCase(throttleState)) { dataHolder.addThrottleData(throttleKey, timeStamp); APICondition extractedKey = extractAPIorResourceKey(throttleKey); log.debug("Adding throttling key : {}", extractedKey); From 1aada8fdd1d950888044ebd0bc13a70b1a48030d Mon Sep 17 00:00:00 2001 From: Praminda Jayawardana Date: Fri, 12 Mar 2021 08:21:35 +0530 Subject: [PATCH 20/21] throttle: enf: Set default throttle values --- .../discovery/subscription/url_mapping.proto | 2 +- .../gateway/enforcer/api/RequestContext.java | 2 +- .../gateway/enforcer/constants/Constants.java | 3 ++- .../enforcer/security/AuthenticationContext.java | 16 ++++++++++++++++ .../enforcer/throttle/ThrottleEventListener.java | 1 - 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/api/wso2/discovery/subscription/url_mapping.proto b/api/wso2/discovery/subscription/url_mapping.proto index 6e4c45bf5f..6e0d7cb40e 100644 --- a/api/wso2/discovery/subscription/url_mapping.proto +++ b/api/wso2/discovery/subscription/url_mapping.proto @@ -11,7 +11,7 @@ option java_multiple_files = true; // URLMapping data model message URLMapping { - string authScheme = 1; + string authScheme = 1; string httpMethod = 2; string urlPattern = 3; repeated string scopes = 4; diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RequestContext.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RequestContext.java index eaaa8f4432..f549dee513 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RequestContext.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/api/RequestContext.java @@ -37,7 +37,7 @@ public class RequestContext { private ResourceConfig matchedResourcePath; private Map headers; private Map properties = new HashMap(); - private AuthenticationContext authenticationContext = new AuthenticationContext(); + private AuthenticationContext authenticationContext; private String requestID; private String address; // Denotes the cluster header name for each environment. Both properties can be null if diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/Constants.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/Constants.java index 9e3559b3ce..d16a7a1e90 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/Constants.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/constants/Constants.java @@ -44,9 +44,10 @@ public class Constants { public static final String END_OF_PRIVATE_KEY = "-----END PRIVATE KEY-----"; public static final String RSA = "RSA"; - //Throttle config constants public static final String LOADBALANCE = "loadbalance"; public static final String FAILOVER = "failover"; public static final String TM_BINARY_LOADBALANCE_SEPARATOR = ","; public static final String TM_BINARY_FAILOVER_SEPARATOR = "|"; + + public static final String UNKNOWN_VALUE = "__unknown__"; } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/AuthenticationContext.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/AuthenticationContext.java index 11dd83f20d..aaf0b82ebb 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/AuthenticationContext.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/security/AuthenticationContext.java @@ -18,6 +18,9 @@ package org.wso2.micro.gateway.enforcer.security; +import org.wso2.micro.gateway.enforcer.constants.Constants; +import org.wso2.micro.gateway.enforcer.throttle.ThrottleConstants; + import java.util.List; /** @@ -50,6 +53,19 @@ public class AuthenticationContext { private String apiPublisher; private String apiVersion; + public AuthenticationContext() { + this.applicationId = Constants.UNKNOWN_VALUE; + this.apiPublisher = Constants.UNKNOWN_VALUE; + this.apiTier = ""; + this.applicationId = Constants.UNKNOWN_VALUE; + this.applicationName = Constants.UNKNOWN_VALUE; + this.applicationTier = ThrottleConstants.UNLIMITED_TIER; + this.consumerKey = Constants.UNKNOWN_VALUE; + this.spikeArrestUnit = ""; + this.subscriber = Constants.UNKNOWN_VALUE; + this.subscriberTenantDomain = Constants.UNKNOWN_VALUE; + } + public List getThrottlingDataList() { return throttlingDataList; } diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java index 2e72ac0b20..8939b7e151 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/throttle/ThrottleEventListener.java @@ -22,7 +22,6 @@ import org.apache.logging.log4j.Logger; import org.wso2.micro.gateway.enforcer.config.ConfigHolder; import org.wso2.micro.gateway.enforcer.config.dto.ThrottleConfigDto; -import org.wso2.micro.gateway.enforcer.constants.APIConstants; import java.util.Date; import java.util.Enumeration; From a3a4047eb1167502823dea94770f2e2a1908859b Mon Sep 17 00:00:00 2001 From: Praminda Jayawardana Date: Fri, 12 Mar 2021 08:22:19 +0530 Subject: [PATCH 21/21] throttle: enf: Add basic API throttling --- .../enforcer/filters/ThrottleFilter.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java index 2cc37cc6c4..6df84a39b8 100644 --- a/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java +++ b/enforcer/src/main/java/org/wso2/micro/gateway/enforcer/filters/ThrottleFilter.java @@ -157,10 +157,48 @@ private boolean isAppLevelThrottled(String throttleKey, String tier) { return isThrottled; } + private boolean isAPILevelThrottled(String throttleKey, String tier) { + log.debug("Checking if request is throttled at API level for tier: {}", tier); + + if (ThrottleConstants.UNLIMITED_TIER.equals(tier)) { + return false; + } + + if (isGlobalThrottlingEnabled) { + // TODO: (Praminda) Check conditional throttling decisions + boolean isThrottled; + throttleKey += "_default"; + + isThrottled = dataHolder.isThrottled(throttleKey); + log.debug("API Level throttle decision: {}", isThrottled); + return isThrottled; + } + return false; + } + + private boolean isResourceLevelThrottled(String throttleKey, String tier) { + log.debug("Checking if request is throttled at resource level for tier: " + tier); + + if (ThrottleConstants.UNLIMITED_TIER.equals(tier)) { + return false; + } + + if (isGlobalThrottlingEnabled) { + boolean isThrottled; + throttleKey += "_default"; + + isThrottled = dataHolder.isThrottled(throttleKey); + log.debug("Resource Level throttle decision: {}", isThrottled); + return isThrottled; + } + return false; + } + //TODO (amaliMatharaarachchi) Add default values to keys. // Handle fault invocations. // Test all flows. // Add unit tests. + /** * This will generate the throttling event map to be publish to the traffic manager. *