ambari-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AMBARI-22754) STOMP message size limit should be configurable
Date Tue, 09 Jan 2018 18:52:00 GMT

    [ https://issues.apache.org/jira/browse/AMBARI-22754?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16318922#comment-16318922
] 

ASF GitHub Bot commented on AMBARI-22754:
-----------------------------------------

mpapirkovskyy closed pull request #76: [AMBARI-22754] STOMP message size limit should be configurable
URL: https://github.com/apache/ambari/pull/76
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
index 5384da47c90..20cd85baa2c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
@@ -2182,6 +2182,13 @@
   public static final ConfigurationProperty<Integer> API_HEARTBEAT_INTERVAL = new ConfigurationProperty<>(
       "api.heartbeat.interval", 10000);
 
+  /**
+   * The maximum size of a stomp text message. Default is 2 MB.
+   */
+  @Markdown(description = "The maximum size of a stomp text message. Default is 2 MB.")
+  public static final ConfigurationProperty<Integer> STOMP_MAX_MESSAGE_SIZE = new ConfigurationProperty<>(
+      "stomp.max.message.size", 2*1024*1024);
+
   /**
    * The maximum number of threads used to extract Ambari Views when Ambari
    * Server is starting up.
@@ -4918,6 +4925,13 @@ public int getAPIHeartbeatInterval() {
     return Integer.parseInt(getProperty(API_HEARTBEAT_INTERVAL));
   }
 
+  /**
+   * @return the maximum size of a stomp text message. Default is 2 MB.
+   */
+  public int getStompMaxMessageSize() {
+    return Integer.parseInt(getProperty(STOMP_MAX_MESSAGE_SIZE));
+  }
+
   /**
    * @return max thread pool size for agents, default 25
    */
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/configuration/spring/AgentStompConfig.java
b/ambari-server/src/main/java/org/apache/ambari/server/configuration/spring/AgentStompConfig.java
index 516c40584be..9e8be7c6058 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/configuration/spring/AgentStompConfig.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/configuration/spring/AgentStompConfig.java
@@ -17,8 +17,11 @@
  */
 package org.apache.ambari.server.configuration.spring;
 
+import javax.servlet.ServletContext;
+
 import org.apache.ambari.server.agent.stomp.HeartbeatController;
 import org.apache.ambari.server.api.stomp.TestController;
+import org.eclipse.jetty.websocket.server.WebSocketServerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
@@ -27,6 +30,9 @@
 import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
 import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
 import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
+import org.springframework.web.socket.config.annotation.WebSocketTransportRegistration;
+import org.springframework.web.socket.server.jetty.JettyRequestUpgradeStrategy;
+import org.springframework.web.socket.server.support.DefaultHandshakeHandler;
 
 import com.google.inject.Injector;
 
@@ -37,16 +43,27 @@
 public class AgentStompConfig extends AbstractWebSocketMessageBrokerConfigurer {
   private org.apache.ambari.server.configuration.Configuration configuration;
 
+  private final ServletContext servletContext;
+
   @Autowired
   private AgentRegisteringQueueChecker agentRegisteringQueueChecker;
 
-  public AgentStompConfig(Injector injector) {
+  public AgentStompConfig(ServletContext servletContext, Injector injector) {
+    this.servletContext = servletContext;
     configuration = injector.getInstance(org.apache.ambari.server.configuration.Configuration.class);
   }
 
+  public DefaultHandshakeHandler getHandshakeHandler() {
+    WebSocketServerFactory webSocketServerFactory = new WebSocketServerFactory(servletContext);
+    webSocketServerFactory.getPolicy().setMaxTextMessageSize(configuration.getStompMaxMessageSize());
+
+    return new DefaultHandshakeHandler(
+        new JettyRequestUpgradeStrategy(webSocketServerFactory));
+  }
+
   @Override
   public void registerStompEndpoints(StompEndpointRegistry registry) {
-    registry.addEndpoint("/v1")
+    registry.addEndpoint("/v1").setHandshakeHandler(getHandshakeHandler())
         .setAllowedOrigins("*");
 
   }
@@ -61,4 +78,9 @@ public void configureClientOutboundChannel(ChannelRegistration registration)
{
     registration.taskExecutor().corePoolSize(configuration.getSpringMessagingThreadPoolSize());
     registration.setInterceptors(agentRegisteringQueueChecker);
   }
+
+  @Override
+  public void configureWebSocketTransport(WebSocketTransportRegistration registration) {
+    registration.setMessageSizeLimit(configuration.getStompMaxMessageSize());
+  }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> STOMP message size limit should be configurable
> -----------------------------------------------
>
>                 Key: AMBARI-22754
>                 URL: https://issues.apache.org/jira/browse/AMBARI-22754
>             Project: Ambari
>          Issue Type: Task
>          Components: ambari-server
>    Affects Versions: 3.0.0
>            Reporter: Myroslav Papirkovskyi
>            Assignee: Myroslav Papirkovskyi
>            Priority: Critical
>             Fix For: 3.0.0
>
>
> Default jetty and spring maximum size of message is 65536 bytes. This limitation causes
intermittent exceptions during heavyweight messages transfering. Reproduced once for current
alert definitions message and during HA enabling for command statuses. We should add ability
to configure this limit.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message