-
Notifications
You must be signed in to change notification settings - Fork 625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Add Burst control capability for Applications #12162
Conversation
@@ -627,6 +638,15 @@ private boolean doThrottle(MessageContext messageContext) { | |||
initThrottleForSubscriptionLevelSpikeArrest(messageContext, authenticationContext); | |||
context.stop(); | |||
} | |||
|
|||
if(authenticationContext != null && authenticationContext.getApplicationSpikesArrestLimit() > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in b56bf30
try { | ||
parsedPolicy = AXIOMUtil.stringToOM(policy.toString()); | ||
} catch (XMLStreamException e) { | ||
log.error("Error occurred while creating policy file for Hard Throttling.", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a reason why this exception is ignored (without throwing an exception and stopping the flow)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added in b56bf30
String applicationLevelThrottleKey = authenticationContext.getApplicationId()+":"+authenticationContext.getUsername(); | ||
int maxRequestCount = authenticationContext.getApplicationSpikesArrestLimit(); | ||
int applicationSpikeArrestWindowUnitTime = 0; | ||
if(maxRequestCount != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in b56bf30
private void initThrottleForApplicationLevelSpikeArrest(MessageContext synCtx, | ||
AuthenticationContext authenticationContext) { | ||
policyKeyApplication = authenticationContext.getApplicationTier(); | ||
String applicationLevelThrottleKey = authenticationContext.getApplicationId()+":"+authenticationContext.getUsername(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in b56bf30
} | ||
|
||
private void setRateLimitDetails(ApplicationPolicy policy, ResultSet resultSet) throws SQLException { | ||
if(resultSet.getInt(ThrottlePolicyConstants.COLUMN_RATE_LIMIT_COUNT) > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in b56bf30
@@ -180,6 +180,25 @@ public void setConsumerKey(String consumerKey) { | |||
this.consumerKey = consumerKey; | |||
} | |||
|
|||
private int applicationSpikesArrestLimit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we add the variables along with the other variables on the top?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored in 547e395
import org.wso2.carbon.apimgt.internal.service.dto.SubscriptionPolicyListDTO; | ||
import org.wso2.carbon.apimgt.internal.service.dto.ThrottleLimitDTO; | ||
import org.wso2.carbon.apimgt.internal.service.dto.URLMappingDTO; | ||
import org.wso2.carbon.apimgt.internal.service.dto.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change the import into individual
4f025c3
to
407a5bc
Compare
588ce33
The PR adds the capability to support burst control for Application policies similar to what the product already has for Subscription policies.