incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefane...@apache.org
Subject svn commit: r1565606 - in /sling/trunk/bundles/extensions/discovery/impl/src/main: java/org/apache/sling/discovery/impl/ java/org/apache/sling/discovery/impl/topology/connector/ resources/OSGI-INF/metatype/
Date Fri, 07 Feb 2014 10:10:10 GMT
Author: stefanegli
Date: Fri Feb  7 10:10:10 2014
New Revision: 1565606

URL: http://svn.apache.org/r1565606
Log:
SLING-3366 : allow to configure connectionTimeout and soTimeout

Modified:
    sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/Config.java
    sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/topology/connector/TopologyConnectorClient.java
    sling/trunk/bundles/extensions/discovery/impl/src/main/resources/OSGI-INF/metatype/metatype.properties

Modified: sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/Config.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/Config.java?rev=1565606&r1=1565605&r2=1565606&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/Config.java
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/Config.java
Fri Feb  7 10:10:10 2014
@@ -74,6 +74,23 @@ public class Config {
     public static final String MIN_EVENT_DELAY_KEY = "minEventDelay";
     private int minEventDelay = DEFAULT_MIN_EVENT_DELAY;
 
+    /** Configure the socket connect timeout for topology connectors. */
+    public static final int DEFAULT_CONNECTION_TIMEOUT = 10;
+    @Property(intValue=DEFAULT_CONNECTION_TIMEOUT)
+    public static final String CONNECTION_TIMEOUT_KEY = "connectionTimeout";
+    private int connectionTimeout = DEFAULT_CONNECTION_TIMEOUT;
+
+    /** Configure the socket read timeout (SO_TIMEOUT) for topology connectors. */
+    public static final int DEFAULT_SO_TIMEOUT = 10;
+    @Property(intValue=DEFAULT_SO_TIMEOUT)
+    public static final String SO_TIMEOUT_KEY = "soTimeout";
+    private int soTimeout = DEFAULT_SO_TIMEOUT;
+
+    /** Name of the repository descriptor to be taken into account for leader election:
+        those instances have preference to become leader which have the corresponding descriptor
value of 'false' */
+    @Property
+    public static final String LEADER_ELECTION_REPOSITORY_DESCRIPTOR_NAME_KEY = "leaderElectionRepositoryDescriptor";
+    
     /** URLs where to join a topology, eg http://localhost:4502/libs/sling/topology/connector
*/
     @Property(cardinality=1024)
     public static final String TOPOLOGY_CONNECTOR_URLS_KEY = "topologyConnectorUrls";
@@ -91,11 +108,6 @@ public class Config {
     public static final String DISCOVERY_RESOURCE_PATH_KEY = "discoveryResourcePath";
     private String discoveryResourcePath = DEFAULT_DISCOVERY_RESOURCE_PATH;
 
-    /** Name of the repository descriptor to be taken into account for leader election:
-        those instances have preference to become leader which have the corresponding descriptor
value of 'false' */
-    @Property
-    public static final String LEADER_ELECTION_REPOSITORY_DESCRIPTOR_NAME_KEY = "leaderElectionRepositoryDescriptor";
-
     /**
      * If set to true, local-loops of topology connectors are automatically stopped when
detected so.
      */
@@ -188,6 +200,19 @@ public class Config {
         logger.debug("configure: minEventDelay='{}'",
                 this.minEventDelay);
         
+        this.connectionTimeout = PropertiesUtil.toInteger(
+                properties.get(CONNECTION_TIMEOUT_KEY),
+                DEFAULT_CONNECTION_TIMEOUT);
+        logger.debug("configure: connectionTimeout='{}'",
+                this.connectionTimeout);
+        
+        this.soTimeout = PropertiesUtil.toInteger(
+                properties.get(SO_TIMEOUT_KEY),
+                DEFAULT_SO_TIMEOUT);
+        logger.debug("configure: soTimeout='{}'",
+                this.soTimeout);
+        
+        
         String[] topologyConnectorUrlsStr = PropertiesUtil.toStringArray(
                 properties.get(TOPOLOGY_CONNECTOR_URLS_KEY), null);
         if (topologyConnectorUrlsStr!=null && topologyConnectorUrlsStr.length >
0) {
@@ -262,8 +287,24 @@ public class Config {
     public long getHeartbeatTimeout() {
         return heartbeatTimeout;
     }
+    
+    /**
+     * Returns the socket connect() timeout used by the topology connector, 0 disables the
timeout
+     * @return the socket connect() timeout used by the topology connector, 0 disables the
timeout
+     */
+    public int getConnectionTimeout() {
+        return connectionTimeout;
+    }
 
     /**
+     * Returns the socket read timeout (SO_TIMEOUT) used by the topology connector, 0 disables
the timeout
+     * @return the socket read timeout (SO_TIMEOUT) used by the topology connector, 0 disables
the timeout
+     */
+    public int getSoTimeout() {
+        return soTimeout;
+    }
+    
+    /**
      * Returns the interval (in seconds) in which heartbeats are sent
      * @return the interval (in seconds) in which heartbeats are sent
      */

Modified: sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/topology/connector/TopologyConnectorClient.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/topology/connector/TopologyConnectorClient.java?rev=1565606&r1=1565605&r2=1565606&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/topology/connector/TopologyConnectorClient.java
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/main/java/org/apache/sling/discovery/impl/topology/connector/TopologyConnectorClient.java
Fri Feb  7 10:10:10 2014
@@ -199,6 +199,9 @@ public class TopologyConnectorClient imp
             method.addRequestHeader("Accept-Encoding", "gzip");
             DefaultHttpMethodRetryHandler retryhandler = new DefaultHttpMethodRetryHandler(0,
false);
             httpClient.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryhandler);
+            httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(1000*config.getConnectionTimeout());
+            httpClient.getHttpConnectionManager().getParams().setSoTimeout(1000*config.getSoTimeout());
+            method.getParams().setSoTimeout(1000*config.getSoTimeout());
             httpClient.executeMethod(method);
         	if (logger.isDebugEnabled()) {
 	            logger.debug("ping: done. code=" + method.getStatusCode() + " - "

Modified: sling/trunk/bundles/extensions/discovery/impl/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/impl/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=1565606&r1=1565605&r2=1565606&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/discovery/impl/src/main/resources/OSGI-INF/metatype/metatype.properties
(original)
+++ sling/trunk/bundles/extensions/discovery/impl/src/main/resources/OSGI-INF/metatype/metatype.properties
Fri Feb  7 10:10:10 2014
@@ -26,7 +26,7 @@ config.description = The configuration o
 
 heartbeatTimeout.name = Heartbeat timeout (seconds)
 heartbeatTimeout.description = Configure the timeout (in seconds) after which an instance
is \
- considered dead/crashed. Default is 45 seconds.
+ considered dead/crashed. Must be higher than the heartbeat interval! Default is 45 seconds.
 
 heartbeatInterval.name = Heartbeat interval (seconds)
 heartbeatInterval.description = Configure the interval (in seconds) according to which the
\
@@ -35,7 +35,7 @@ heartbeatInterval.description = Configur
 minEventDelay.name = Minimal Event Delay (seconds)
 minEventDelay.description = Configure a minimal delay (in seconds) between TOPOLOGY_CHANGING
\
  and TOPOLOGY_CHANGED. Any further changes happening during this delay are accumulated and
\
- combined in the TOPOLOGY_CHANGED after this delay. THis helps avoiding event-flooding. \
+ combined in the TOPOLOGY_CHANGED after this delay. This helps avoiding event-flooding. \
  Default is 3 seconds. A negative value or zero disables this delay.
 
 topologyConnectorUrls.name = Topology Connector URLs
@@ -58,16 +58,24 @@ leaderElectionRepositoryDescriptor.descr
  into account for leader election: those instances have preference to become leader which
have \
  the corresponding descriptor value of 'false'.
 
-autoStopLocalLoopEnabled.name = Enable Auto-Stop for Local-Loop Connectors
+autoStopLocalLoopEnabled.name = Auto-Stop Local-Loops
 autoStopLocalLoopEnabled.description = If true, and the discovery.impl detects a local-looping
\
  topology connector, the corresponding topology connector will be automatically stopped.
\
  This is useful to prevent unnecessary loops with eg pre-configured topology connectors.
 
-gzipConnectorRequestsEnabled.name = Enable GZip-ing requests
+gzipConnectorRequestsEnabled.name = gzip requests
 gzipConnectorRequestsEnabled.description = If true, the payloads of topology connector requests
\
  will be gzipped. This is advisable on certain connector structures, eg in a tree structure,
where \
  a topology connector announces a large sub-topology. Note that this only works with \
- the server running discovery.impl 1.0.4 and onwards.
+ the server running discovery.impl 1.0.4 and onwards. Replies are gzipped automatically.
+
+connectionTimeout.name = connector's connection timeout
+connectionTimeout.description = Timeout (in seconds!) until the topology connector's connection
\
+ is established (ie socket.connect())
+ 
+soTimeout.name = connector's read timeout
+soTimeout.description = Topology connector's socket timeout (SO_TIMEOUT) (in seconds!) which
is \
+ the timeout for waiting for data
 
 hmacEnabled.name = Enable Hmac message signatures
 hmacEnabled.description = If true, and the Shared Key is set to the same value on all members
of the \



Mime
View raw message