コード例 #1
0
ファイル: ThrottleManager.java プロジェクト: CHATTG1/sofa
  /** Starts the throttle manager. */
  @Override
  public void start() {
    // Use the default ThrottleSettings if one is not set already.
    if (settings == null) settings = new ThrottleSettings();

    if (settings.isDestinationThrottleEnabled()) {
      inboundDestinationMark = new MessageFrequency(settings.getIncomingDestinationFrequency());
      outboundDestinationMark = new MessageFrequency(settings.getOutgoingDestinationFrequency());
    }

    if (settings.isInboundClientThrottleEnabled())
      inboundClientMarks = new HashMap<String, MessageFrequency>();
  }
コード例 #2
0
ファイル: ThrottleManager.java プロジェクト: CHATTG1/sofa
 /**
  * Sets the throttling settings of the throttle manager.
  *
  * @param throttleSettings The throttling settings for the throttle manager.
  */
 public void setThrottleSettings(ThrottleSettings throttleSettings) {
   // Make sure that we have valid outbound policies.
   Policy outPolicy = throttleSettings.getOutboundPolicy();
   if (outPolicy != Policy.NONE && outPolicy != Policy.IGNORE) {
     ConfigurationException ex = new ConfigurationException();
     ex.setMessage(
         "Invalid outbound throttle policy '"
             + outPolicy
             + "' for destination '"
             + throttleSettings.getDestinationName()
             + "'. Valid values are 'NONE' and 'IGNORE'.");
     throw ex;
   }
   settings = throttleSettings;
 }
コード例 #3
0
ファイル: ThrottleManager.java プロジェクト: CHATTG1/sofa
 /** Updates the incoming client level message frequency. */
 public void updateMessageFrequencyIncomingClientLevel(Message message) {
   String clientId = (String) message.getClientId();
   if (settings.isInboundClientThrottleEnabled()) {
     MessageFrequency clientLevelMark = inboundClientMarks.get(clientId);
     if (clientLevelMark != null) clientLevelMark.updateMessageFrequency();
   }
 }
コード例 #4
0
ファイル: ThrottleManager.java プロジェクト: CHATTG1/sofa
  /**
   * Attempts to throttle client-level incoming messages only. Client-level outgoing messages are
   * throttled at the FlexClientOutboundQueueProcessor.
   *
   * @param message Message to throttle.
   * @return The result of the throttling attempt.
   */
  protected ThrottleResult throttleIncomingClientLevel(Message message) {
    String clientId = (String) message.getClientId();
    if (settings.isInboundClientThrottleEnabled()) {
      MessageFrequency clientLevelMark;
      clientLevelMark = inboundClientMarks.get(clientId);
      if (clientLevelMark == null)
        clientLevelMark = new MessageFrequency(settings.getIncomingClientFrequency());

      ThrottleResult result =
          clientLevelMark.checkLimit(
              settings.getIncomingClientFrequency(), settings.getInboundPolicy());
      inboundClientMarks.put(clientId, clientLevelMark);
      return result;
    }
    // Return the default OK result.
    return new ThrottleResult();
  }
コード例 #5
0
ファイル: ThrottleManager.java プロジェクト: CHATTG1/sofa
 /**
  * Attempts to throttle destination-level incoming and outgoing messages.
  *
  * @param message Message to throttle.
  * @param incoming Whether the message is incoming or outgoing.
  * @return The result of the throttling attempt.
  */
 public ThrottleResult throttleDestinationLevel(Message message, boolean incoming) {
   if (incoming && settings.isInboundDestinationThrottleEnabled()) {
     ThrottleResult result =
         inboundDestinationMark.checkLimit(
             settings.getIncomingDestinationFrequency(), settings.getInboundPolicy());
     return result;
   } else if (!incoming && settings.isOutboundDestinationThrottleEnabled()) {
     ThrottleResult result =
         outboundDestinationMark.checkLimit(
             settings.getOutgoingDestinationFrequency(), settings.getOutboundPolicy());
     return result;
   }
   // Return the default OK result.
   return new ThrottleResult();
 }
コード例 #6
0
ファイル: ThrottleManager.java プロジェクト: CHATTG1/sofa
 /**
  * Updates the destination level message frequency.
  *
  * <p>param incoming Whether the message is incoming or outgoing.
  */
 public void updateMessageFrequencyDestinationLevel(boolean incoming) {
   if (incoming && settings.isInboundDestinationThrottleEnabled())
     inboundDestinationMark.updateMessageFrequency();
   else if (!incoming && settings.isOutboundDestinationThrottleEnabled())
     outboundDestinationMark.updateMessageFrequency();
 }
コード例 #7
0
ファイル: ThrottleManager.java プロジェクト: CHATTG1/sofa
 /**
  * Returns the outbound policy being used by the throttle manager.
  *
  * @return The outbound policy for the throttle manager.
  */
 public Policy getOutboundPolicy() {
   return settings == null ? null : settings.getOutboundPolicy();
 }