atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject [1/5] atlas git commit: ATLAS-1218: Atlas says it is started but does not accept REST requests
Date Mon, 11 Sep 2017 21:34:29 GMT
Repository: atlas
Updated Branches:
  refs/heads/branch-0.8 7299815d1 -> 5ca7955a1


ATLAS-1218: Atlas says it is started but does not accept REST requests

Signed-off-by: Madhan Neethiraj <madhan@apache.org>
(cherry picked from commit cba5f7622b0724b158e93ac3d9cd7bd8de6d4c2b)


Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/97ce63ec
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/97ce63ec
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/97ce63ec

Branch: refs/heads/branch-0.8
Commit: 97ce63ec7c596f80978a07d5bbc7875f55bf4ff3
Parents: 7299815
Author: Richard Ding <rding@yahoo-inc.com>
Authored: Sat Aug 26 02:06:59 2017 -0700
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Mon Sep 11 11:37:08 2017 -0700

----------------------------------------------------------------------
 distro/src/bin/atlas_config.py | 51 +++++++++++++++++++++++++++++++++++++
 distro/src/bin/atlas_start.py  |  4 +--
 2 files changed, 53 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/97ce63ec/distro/src/bin/atlas_config.py
----------------------------------------------------------------------
diff --git a/distro/src/bin/atlas_config.py b/distro/src/bin/atlas_config.py
index 1be9ca2..ada5743 100755
--- a/distro/src/bin/atlas_config.py
+++ b/distro/src/bin/atlas_config.py
@@ -23,6 +23,7 @@ import subprocess
 import sys
 import time
 import errno
+import socket
 from re import split
 from time import sleep
 
@@ -65,6 +66,11 @@ SOLR_INDEX_CONF_ENTRY="atlas.graph.index.search.backend\s*=\s*solr5"
 SOLR_INDEX_LOCAL_CONF_ENTRY="atlas.graph.index.search.solr.zookeeper-url\s*=\s*localhost"
 SOLR_INDEX_ZK_URL="atlas.graph.index.search.solr.zookeeper-url"
 TOPICS_TO_CREATE="atlas.notification.topics"
+ATLAS_HTTP_PORT="atlas.server.http.port"
+ATLAS_HTTPS_PORT="atlas.server.https.port"
+DEFAULT_ATLAS_HTTP_PORT="21000"
+DEFAULT_ATLAS_HTTPS_PORT="21443"
+ATLAS_ENABLE_TLS="atlas.enableTLS"
 
 DEBUG = False
 
@@ -442,6 +448,45 @@ def get_topics_to_create(confdir):
         topics = ["ATLAS_HOOK", "ATLAS_ENTITIES"]
     return topics
 
+def get_atlas_url_port(confdir):
+    port = None
+    if '-port' in sys.argv:
+        port = sys.argv[sys.argv.index('-port')+1]
+
+    if port is None:
+        confdir = os.path.join(confdir, CONF_FILE)
+        enable_tls = getConfig(confdir, ATLAS_ENABLE_TLS)
+        if enable_tls is not None and enable_tls.lower() == 'true':
+            port = getConfigWithDefault(confdir, ATLAS_HTTPS_PORT, DEFAULT_ATLAS_HTTPS_PORT)
+        else:
+            port = getConfigWithDefault(confdir, ATLAS_HTTP_PORT, DEFAULT_ATLAS_HTTP_PORT)
+
+    print "starting atlas on port %s" % port
+    return port
+
+def wait_for_startup(confdir, wait):
+    count = 0
+    port = get_atlas_url_port(confdir)
+    while True:
+        try:
+            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+            s.settimeout(1)
+            s.connect(('localhost', int(port)))
+            s.close()
+            break
+        except Exception as e:
+            # Wait for 1 sec before next ping
+            sys.stdout.write('.')
+            sys.stdout.flush()
+            sleep(1)
+
+        if count > wait:
+            s.close()
+            break
+
+        count = count + 1
+
+    sys.stdout.write('\n')
 
 def run_solr(dir, action, zk_url = None, port = None, logdir = None, wait=True):
 
@@ -525,6 +570,12 @@ def getConfig(file, key):
             return line.split('=')[1].strip()
     return None
 
+def getConfigWithDefault(file, key, defaultValue):
+    value = getConfig(file, key)
+    if value is None:
+        value = defaultValue
+    return value
+
 def isCygwin():
     return platform.system().startswith("CYGWIN")
 

http://git-wip-us.apache.org/repos/asf/atlas/blob/97ce63ec/distro/src/bin/atlas_start.py
----------------------------------------------------------------------
diff --git a/distro/src/bin/atlas_start.py b/distro/src/bin/atlas_start.py
index a6a3455..5ea93fc 100755
--- a/distro/src/bin/atlas_start.py
+++ b/distro/src/bin/atlas_start.py
@@ -131,6 +131,8 @@ def main():
         web_app_path = mc.convertCygwinPath(web_app_path)
     if not is_setup:
         start_atlas_server(atlas_classpath, atlas_pid_file, jvm_logdir, jvm_opts_list, web_app_path)
+        mc.wait_for_startup(confdir, 300)
+        print "Apache Atlas Server started!!!\n"
     else:
         process = mc.java("org.apache.atlas.web.setup.AtlasSetup", [], atlas_classpath, jvm_opts_list,
jvm_logdir)
         return process.wait()
@@ -141,8 +143,6 @@ def start_atlas_server(atlas_classpath, atlas_pid_file, jvm_logdir, jvm_opts_lis
     args.extend(sys.argv[1:])
     process = mc.java("org.apache.atlas.Atlas", args, atlas_classpath, jvm_opts_list, jvm_logdir)
     mc.writePid(atlas_pid_file, process)
-    print "Apache Atlas Server started!!!\n"
-
 
 if __name__ == '__main__':
     try:


Mime
View raw message