private void initDefaultThrottle() throws AxisFault { try { if (defaultPolicy != null) { defaultThrottle = ThrottleFactory.createModuleThrottle(defaultPolicy); if (defaultThrottle == null) { throw new AxisFault("Couldn't create the default throttle" + ".The module is invalid "); } } else { throw new AxisFault("Couldn't find the default throttle policy " + ".the module is invalid "); } } catch (ThrottleException e) { String msg = "Error during processing default throttle policy + system will not works" + e.getMessage(); log.error(msg); throw new AxisFault(msg); } }
/** * Helper method to handle exception * * @param message Debug message * @throws ThrottleException */ private static void handleException(String message) throws ThrottleException { String msg = "Error was occurred during throttle policy processing : " + message; log.error(msg); throw new ThrottleException(msg); } }
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault { //Load throttle try { Throttle throttle = loadThrottle(msgContext, getThrottleType()); if (throttle != null) { process(throttle, msgContext); } } catch (ThrottleException e) { log.error(e.getMessage()); throw new AxisFault(e.getMessage()); } return InvocationResponse.CONTINUE; }
/** * Helper method to handle exception * * @param message Debug message * @throws ThrottleException */ private static void handleException(String message) throws ThrottleException { String msg = "Error was occurred during throttle policy processing " + message; log.error(msg); throw new ThrottleException(msg); }
currentService.getName() + e.getMessage()); log.info("Throttling will occur using default module policy"); throttle = defaultThrottle; "for operation : " + currentOperation.getName() + " in the service :" + currentServiceName + e.getMessage()); log.info("Throttling will occur using default module policy");
/** * To create a ThrottleConfiguration for the given throttle type * * @param throttletype - The type of the throttle * @return ThrottleConfiguration - The corresponding ThrottleConfiguration for * the given throttle type * @throws ThrottleException - Throws for if the throttle type is unknown */ public static ThrottleConfiguration createThrottleConfiguration(int throttletype) throws ThrottleException { if (ThrottleConstants.IP_BASE == throttletype) { return new IPBaseThrottleConfiguration(); } else if (ThrottleConstants.DOMAIN_BASE == throttletype) { return new DomainBaseThrottleConfiguration(); } else if (ThrottleConstants.ROLE_BASE == throttletype) { return new RoleBaseThrottleConfiguration(); } else { throw new ThrottleException("Unknown throttle type"); } }
" module " + e.getMessage()); log.info("Throttling will occur using default module policy");
/** * To create a ThrottleContext for the given throttle type * Needs to provide a throttle configuration * * @param throttletype - The type of the throttle * @param configuration - The throttle configuration * @return ThrottleContext - The corresponding ThrottleContext for the given throttle type * @throws ThrottleException - Throws for if the throttle type is unknown */ public static ThrottleContext createThrottleContext(int throttletype, ThrottleConfiguration configuration) throws ThrottleException { if (ThrottleConstants.IP_BASE == throttletype) { return new IPBaseThrottleContext(configuration, throttleReplicator); } else if (ThrottleConstants.DOMAIN_BASE == throttletype) { return new DomainBaseThrottleContext(configuration, throttleReplicator); } else if (ThrottleConstants.ROLE_BASE == throttletype) { return new RoleBaseThrottleContext(configuration, throttleReplicator); } else { throw new ThrottleException("Unknown throttle type"); } }
/** * To create a CallerContext(the run time data holder for a remote caller) * for the given throttle type. * Needs to provide the ID(ip | domain) of the remote caller (ip/domain according to the policy) * * @param throttletype - The type of the throttle * @param id - The id of the caller * @return caller - The corresponding caller context for the given throttle type * @throws ThrottleException - Throws for if the throttle type is unknown */ public static CallerContext createCaller(int throttletype, String id) throws ThrottleException { if (ThrottleConstants.IP_BASE == throttletype) { return new IPBaseCallerContext(id); } else if (ThrottleConstants.DOMAIN_BASE == throttletype) { return new DomainBaseCallerContext(id); } else if (ThrottleConstants.ROLE_BASE == throttletype) { return new RoleBaseCallerContext(id); } else { throw new ThrottleException("Unknown throttle type"); } } }
/** * To create a CallerConfiguration instance for the given throttle type * * @param throttletype - The type of the throttle * @return CallerConfiguration - The corresponding caller configuration for * the given throttle type * @throws ThrottleException - Throws for if the throttle type is unknown */ public static CallerConfiguration createCallerConfiguration(int throttletype) throws ThrottleException { if (ThrottleConstants.IP_BASE == throttletype) { return new IPBaseCallerConfiguration(); } else if (ThrottleConstants.DOMAIN_BASE == throttletype) { return new DomainBaseCallerConfiguration(); } else if (ThrottleConstants.ROLE_BASE == throttletype) { return new RoleBaseCallerConfiguration(); } else { throw new ThrottleException("Unknown throttle type"); } } }
throw new ThrottleException("Unsupported Throttle type");
|| configuration.getUnitTime() <= 0 || configuration.getProhibitTimePeriod() < 0) { throw new ThrottleException("Invalid Throttle Configuration");