ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dma...@apache.org
Subject [12/17] ignite git commit: IGNITE-3168 Added idle timeout property.
Date Fri, 27 May 2016 11:30:51 GMT
IGNITE-3168 Added idle timeout property.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/183620cd
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/183620cd
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/183620cd

Branch: refs/heads/master
Commit: 183620cd31095dcd92471927cccf8741e3b63ed7
Parents: 727afc8
Author: nikolay_tikhonov <ntikhonov@gridgain.com>
Authored: Wed May 25 09:47:14 2016 +0300
Committer: nikolay_tikhonov <ntikhonov@gridgain.com>
Committed: Wed May 25 09:51:08 2016 +0300

----------------------------------------------------------------------
 .../apache/ignite/mesos/ClusterProperties.java  | 39 ++++++++++++++++++++
 .../apache/ignite/mesos/IgniteFramework.java    | 10 ++---
 .../ignite/mesos/resource/JettyServer.java      | 16 ++++++--
 3 files changed, 55 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/183620cd/modules/mesos/src/main/java/org/apache/ignite/mesos/ClusterProperties.java
----------------------------------------------------------------------
diff --git a/modules/mesos/src/main/java/org/apache/ignite/mesos/ClusterProperties.java b/modules/mesos/src/main/java/org/apache/ignite/mesos/ClusterProperties.java
index 747fbe9..3c8f396 100644
--- a/modules/mesos/src/main/java/org/apache/ignite/mesos/ClusterProperties.java
+++ b/modules/mesos/src/main/java/org/apache/ignite/mesos/ClusterProperties.java
@@ -200,6 +200,15 @@ public class ClusterProperties {
     /** */
     public static final String IGNITE_CONFIG_XML_URL = "IGNITE_CONFIG_XML_URL";
 
+    /** */
+    public static final String IGNITE_HTTP_SERVER_IDLE_TIMEOUT = "IGNITE_HTTP_SERVER_IDLE_TIMEOUT";
+
+    /** */
+    public static final long IGNITE_HTTP_SERVER_IDLE_TIMEOUT_DEFAULT = 30000L;
+
+    /** Jetty idle timeout. */
+    private long idleTimeout = IGNITE_HTTP_SERVER_IDLE_TIMEOUT_DEFAULT;
+
     /** Url to ignite config. */
     private String igniteCfgUrl = null;
 
@@ -400,6 +409,17 @@ public class ClusterProperties {
     }
 
     /**
+     * Sets the maximum Idle time for a http connection, which will be used for
+     * jetty server. The server provides resources for ignite mesos framework such as
+     * ignite archive, user's libs, configurations and etc.
+     *
+     * @return Http server idle timeout.
+     */
+    public long idleTimeout() {
+        return idleTimeout;
+    }
+
+    /**
      * URL to ignite package. The URL should to point at valid apache ignite archive.
      * This property can be useful if using own apache ignite build.
      *
@@ -502,6 +522,8 @@ public class ClusterProperties {
 
             String ptrn = getStringProperty(IGNITE_HOSTNAME_CONSTRAINT, props, null);
 
+            prop.idleTimeout = getLongProperty(IGNITE_HTTP_SERVER_IDLE_TIMEOUT, props, IGNITE_HTTP_SERVER_IDLE_TIMEOUT_DEFAULT);
+
             if (ptrn != null) {
                 try {
                     prop.hostnameConstraint = Pattern.compile(ptrn);
@@ -540,6 +562,23 @@ public class ClusterProperties {
      * @param fileProps Property file.
      * @return Property value.
      */
+    private static long getLongProperty(String name, Properties fileProps, Long dfltVal)
{
+        if (fileProps != null && fileProps.containsKey(name))
+            return Long.valueOf(fileProps.getProperty(name));
+
+        String prop = System.getProperty(name);
+
+        if (prop == null)
+            prop = System.getenv(name);
+
+        return prop == null ? dfltVal : Long.valueOf(prop);
+    }
+
+    /**
+     * @param name Property name.
+     * @param fileProps Property file.
+     * @return Property value.
+     */
     private static String getStringProperty(String name, Properties fileProps, String dfltVal)
{
         if (fileProps != null && fileProps.containsKey(name))
             return fileProps.getProperty(name);

http://git-wip-us.apache.org/repos/asf/ignite/blob/183620cd/modules/mesos/src/main/java/org/apache/ignite/mesos/IgniteFramework.java
----------------------------------------------------------------------
diff --git a/modules/mesos/src/main/java/org/apache/ignite/mesos/IgniteFramework.java b/modules/mesos/src/main/java/org/apache/ignite/mesos/IgniteFramework.java
index 0cd9efb..6054302 100644
--- a/modules/mesos/src/main/java/org/apache/ignite/mesos/IgniteFramework.java
+++ b/modules/mesos/src/main/java/org/apache/ignite/mesos/IgniteFramework.java
@@ -18,8 +18,6 @@
 package org.apache.ignite.mesos;
 
 import com.google.protobuf.ByteString;
-import java.net.InetSocketAddress;
-import java.util.concurrent.TimeUnit;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import org.apache.ignite.mesos.resource.IgniteProvider;
@@ -35,10 +33,10 @@ import org.apache.mesos.Scheduler;
  */
 public class IgniteFramework {
     /** */
-    public static final Logger log = Logger.getLogger(IgniteFramework.class.getSimpleName());
+    private static final Logger log = Logger.getLogger(IgniteFramework.class.getSimpleName());
 
     /** Framework name. */
-    public static final String IGNITE_FRAMEWORK_NAME = "Ignite";
+    private static final String IGNITE_FRAMEWORK_NAME = "Ignite";
 
     /**
      * Main methods has only one optional parameter - path to properties files.
@@ -68,8 +66,8 @@ public class IgniteFramework {
         JettyServer httpSrv = new JettyServer();
 
         httpSrv.start(
-            new InetSocketAddress(clusterProps.httpServerHost(), clusterProps.httpServerPort()),
-            new ResourceHandler(clusterProps.userLibs(), clusterProps.igniteCfg(), clusterProps.igniteWorkDir())
+            new ResourceHandler(clusterProps.userLibs(), clusterProps.igniteCfg(), clusterProps.igniteWorkDir()),
+            clusterProps
         );
 
         ResourceProvider provider = new ResourceProvider();

http://git-wip-us.apache.org/repos/asf/ignite/blob/183620cd/modules/mesos/src/main/java/org/apache/ignite/mesos/resource/JettyServer.java
----------------------------------------------------------------------
diff --git a/modules/mesos/src/main/java/org/apache/ignite/mesos/resource/JettyServer.java
b/modules/mesos/src/main/java/org/apache/ignite/mesos/resource/JettyServer.java
index 444c751..f1f5189 100644
--- a/modules/mesos/src/main/java/org/apache/ignite/mesos/resource/JettyServer.java
+++ b/modules/mesos/src/main/java/org/apache/ignite/mesos/resource/JettyServer.java
@@ -17,9 +17,10 @@
 
 package org.apache.ignite.mesos.resource;
 
-import java.net.InetSocketAddress;
+import org.apache.ignite.mesos.ClusterProperties;
 import org.eclipse.jetty.server.Handler;
 import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.ServerConnector;
 
 /**
  * Embedded jetty server.
@@ -31,14 +32,21 @@ public class JettyServer {
     /**
      * Starts jetty server.
      *
-     * @param address Inter socket address.
      * @param handler Handler.
+     * @param props Cluster properties.
      * @throws Exception If failed.
      */
-    public void start(InetSocketAddress address, Handler handler) throws Exception {
+    public void start(Handler handler, ClusterProperties props) throws Exception {
         if (server == null) {
-            server = new Server(address);
+            server = new Server();
 
+            ServerConnector connector = new ServerConnector(server);
+
+            connector.setHost(props.httpServerHost());
+            connector.setPort(props.httpServerPort());
+            connector.setIdleTimeout(props.idleTimeout());
+
+            server.addConnector(connector);
             server.setHandler(handler);
 
             server.start();


Mime
View raw message