コード例 #1
0
ファイル: atlas_stop.py プロジェクト: zhangjianhrm/datariver
def main():

    metadata_home = mc.metadataDir()
    confdir = mc.dirMustExist(mc.confDir(metadata_home))
    mc.executeEnvSh(confdir)
    piddir = mc.dirMustExist(mc.logDir(metadata_home))

    metadata_pid_file = mc.pidFile(metadata_home)

    try:
        pf = file(metadata_pid_file, 'r')
        pid = int(pf.read().strip())
        pf.close()
    except:
        pid = None
    if not pid:
        sys.stderr.write("No process ID file found. Server not running?\n")
        return
    if mc.ON_POSIX:
        if not mc.unix_exist_pid(pid):
            sys.stderr.write("Server no longer running with pid %s\nImproper shutdown?\npid file deleted.\n" %pid)
            os.remove(metadata_pid_file)
            return
    else:
        if mc.IS_WINDOWS:
            if not mc.win_exist_pid((str)(pid)):
                sys.stderr.write("Server no longer running with pid %s\nImproper shutdown?\npid file deleted.\n" %pid)
                os.remove(metadata_pid_file)
                return
    os.kill(pid, SIGTERM)

    # assuming kill worked since process check on windows is more involved...
    if os.path.exists(metadata_pid_file):
        os.remove(metadata_pid_file)
コード例 #2
0
def main():

    atlas_home = mc.atlasDir()
    confdir = mc.dirMustExist(mc.confDir(atlas_home))
    mc.executeEnvSh(confdir)
    logdir = mc.dirMustExist(mc.logDir(atlas_home))
    if mc.isCygwin():
        # Pathnames that are passed to JVM must be converted to Windows format.
        jvm_atlas_home = mc.convertCygwinPath(atlas_home)
        jvm_confdir = mc.convertCygwinPath(confdir)
        jvm_logdir = mc.convertCygwinPath(logdir)
    else:
        jvm_atlas_home = atlas_home
        jvm_confdir = confdir
        jvm_logdir = logdir

    #create sys property for conf dirs
    jvm_opts_list = (ATLAS_LOG_OPTS % jvm_logdir).split()

    cmd_opts = (ATLAS_COMMAND_OPTS % jvm_atlas_home)
    jvm_opts_list.extend(cmd_opts.split())

    config_opts = (ATLAS_CONFIG_OPTS % jvm_confdir)
    jvm_opts_list.extend(config_opts.split())

    default_jvm_opts = DEFAULT_JVM_OPTS
    atlas_jvm_opts = os.environ.get(mc.ATLAS_OPTS, default_jvm_opts)
    jvm_opts_list.extend(atlas_jvm_opts.split())

    #expand web app dir
    web_app_dir = mc.webAppDir(atlas_home)
    mc.expandWebApp(atlas_home)

    #add hbase-site.xml to classpath
    hbase_conf_dir = mc.hbaseConfDir(confdir)

    p = os.pathsep
    atlas_classpath = confdir + p \
                       + os.path.join(web_app_dir, "atlas", "WEB-INF", "classes" ) + p \
                       + os.path.join(web_app_dir, "atlas", "WEB-INF", "lib", "atlas-titan-${project.version}.jar" ) + p \
                       + os.path.join(web_app_dir, "atlas", "WEB-INF", "lib", "*" )  + p \
                       + os.path.join(atlas_home, "libext", "*")
    if os.path.exists(hbase_conf_dir):
        atlas_classpath = atlas_classpath + p \
                            + hbase_conf_dir
    else:
        storage_backend = mc.grep(os.path.join(confdir, CONF_FILE),
                                  HBASE_STORAGE_CONF_ENTRY)
        if storage_backend != None:
            raise Exception(
                "Could not find hbase-site.xml in %s. Please set env var HBASE_CONF_DIR to the hbase client conf dir",
                hbase_conf_dir)

    if mc.isCygwin():
        atlas_classpath = mc.convertCygwinPath(atlas_classpath, True)

    atlas_pid_file = mc.pidFile(atlas_home)

    if os.path.isfile(atlas_pid_file):
        #Check if process listed in atlas.pid file is still running
        pf = file(atlas_pid_file, 'r')
        pid = pf.read().strip()
        pf.close()

        if mc.ON_POSIX:

            if mc.unix_exist_pid((int)(pid)):
                mc.server_already_running(pid)
            else:
                mc.server_pid_not_running(pid)

        else:
            if mc.IS_WINDOWS:
                if mc.win_exist_pid(pid):
                    mc.server_already_running(pid)
                else:
                    mc.server_pid_not_running(pid)

            else:
                #os other than nt or posix - not supported - need to delete the file to restart server if pid no longer exist
                mc.server_already_running(pid)

    web_app_path = os.path.join(web_app_dir, "atlas")
    if (mc.isCygwin()):
        web_app_path = mc.convertCygwinPath(web_app_path)
    args = ["-app", web_app_path]
    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"
コード例 #3
0
def main():

    atlas_home = mc.atlasDir()
    confdir = mc.dirMustExist(mc.confDir(atlas_home))
    mc.executeEnvSh(confdir)
    logdir = mc.dirMustExist(mc.logDir(atlas_home))
    if mc.isCygwin():
        # Pathnames that are passed to JVM must be converted to Windows format.
        jvm_atlas_home = mc.convertCygwinPath(atlas_home)
        jvm_confdir = mc.convertCygwinPath(confdir)
        jvm_logdir = mc.convertCygwinPath(logdir)
    else:
        jvm_atlas_home = atlas_home
        jvm_confdir = confdir
        jvm_logdir = logdir

    #create sys property for conf dirs
    jvm_opts_list = (ATLAS_LOG_OPTS % jvm_logdir).split()

    cmd_opts = (ATLAS_COMMAND_OPTS % jvm_atlas_home)
    jvm_opts_list.extend(cmd_opts.split())

    config_opts = (ATLAS_CONFIG_OPTS % jvm_confdir)
    jvm_opts_list.extend(config_opts.split())

    default_jvm_opts = DEFAULT_JVM_OPTS
    atlas_jvm_opts = os.environ.get(mc.ATLAS_OPTS, default_jvm_opts)
    jvm_opts_list.extend(atlas_jvm_opts.split())

    #expand web app dir
    web_app_dir = mc.webAppDir(atlas_home)
    mc.expandWebApp(atlas_home)

    #add hbase-site.xml to classpath
    hbase_conf_dir = mc.hbaseConfDir(confdir)

    p = os.pathsep
    atlas_classpath = confdir + p \
                       + os.path.join(web_app_dir, "atlas", "WEB-INF", "classes" ) + p \
                       + os.path.join(web_app_dir, "atlas", "WEB-INF", "lib", "atlas-titan-${project.version}.jar" ) + p \
                       + os.path.join(web_app_dir, "atlas", "WEB-INF", "lib", "*" )  + p \
                       + os.path.join(atlas_home, "libext", "*")
    if os.path.exists(hbase_conf_dir):
        atlas_classpath = atlas_classpath + p \
                            + hbase_conf_dir
    else: 
       storage_backend = mc.grep(os.path.join(confdir, CONF_FILE), HBASE_STORAGE_CONF_ENTRY)
       if storage_backend != None:
	   raise Exception("Could not find hbase-site.xml in %s. Please set env var HBASE_CONF_DIR to the hbase client conf dir", hbase_conf_dir)
    
    if mc.isCygwin():
        atlas_classpath = mc.convertCygwinPath(atlas_classpath, True)

    atlas_pid_file = mc.pidFile(atlas_home)
            
    if os.path.isfile(atlas_pid_file):
       #Check if process listed in atlas.pid file is still running
       pf = file(atlas_pid_file, 'r')
       pid = pf.read().strip()
       pf.close() 
       

       if  mc.ON_POSIX:
            
            if mc.unix_exist_pid((int)(pid)):
                mc.server_already_running(pid)
            else:
                 mc.server_pid_not_running(pid)
              
              
       else:
            if mc.IS_WINDOWS:
                if mc.win_exist_pid(pid):
                   mc.server_already_running(pid)
                else:
                     mc.server_pid_not_running(pid)
                   
            else:
                #os other than nt or posix - not supported - need to delete the file to restart server if pid no longer exist
                mc.server_already_running(pid)
             

    web_app_path = os.path.join(web_app_dir, "atlas")
    if (mc.isCygwin()):
        web_app_path = mc.convertCygwinPath(web_app_path)
    args = ["-app", web_app_path]
    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"
コード例 #4
0
def main():

    metadata_home = mc.metadataDir()
    confdir = mc.dirMustExist(mc.confDir(metadata_home))
    mc.executeEnvSh(confdir)
    logdir = mc.dirMustExist(mc.logDir(metadata_home))

    #create sys property for conf dirs
    jvm_opts_list = (METADATA_LOG_OPTS % logdir).split()

    cmd_opts = (METADATA_COMMAND_OPTS % metadata_home)
    jvm_opts_list.extend(cmd_opts.split())

    config_opts = (METADATA_CONFIG_OPTS % confdir)
    jvm_opts_list.extend(config_opts.split())

    default_jvm_opts = DEFAULT_JVM_OPTS
    metadata_jvm_opts = os.environ.get(mc.METADATA_OPTS, default_jvm_opts)
    jvm_opts_list.extend(metadata_jvm_opts.split())

    #expand web app dir
    web_app_dir = mc.webAppDir(metadata_home)
    mc.expandWebApp(metadata_home)

    p = os.pathsep
    metadata_classpath = confdir + p \
                       + os.path.join(web_app_dir, "atlas", "WEB-INF", "classes" ) + p \
                       + os.path.join(web_app_dir, "atlas", "WEB-INF", "lib", "*" )  + p \
                       + os.path.join(metadata_home, "libext", "*")

    
    metadata_pid_file = mc.pidFile(metadata_home)
    
            
    if os.path.isfile(metadata_pid_file):
       #Check if process listed in atlas.pid file is still running
       pf = file(metadata_pid_file, 'r')
       pid = pf.read().strip()
       pf.close() 
       

       if  mc.ON_POSIX:
            
            if mc.unix_exist_pid((int)(pid)):
                mc.server_already_running(pid)
            else:
                 mc.server_pid_not_running(pid)
              
              
       else:
            if mc.IS_WINDOWS:
                if mc.win_exist_pid(pid):
                   mc.server_already_running(pid)
                else:
                     mc.server_pid_not_running(pid)
                   
            else:
                #os other than nt or posix - not supported - need to delete the file to restart server if pid no longer exist
                mc.server_already_running(pid)
             


    args = ["-app", os.path.join(web_app_dir, "atlas")]
    args.extend(sys.argv[1:])

    process = mc.java("org.apache.atlas.Atlas", args, metadata_classpath, jvm_opts_list, logdir)
    mc.writePid(metadata_pid_file, process)

    print "Apache Atlas Server started!!!\n"
コード例 #5
0
def main():

    metadata_home = mc.metadataDir()
    confdir = mc.dirMustExist(mc.confDir(metadata_home))
    mc.executeEnvSh(confdir)
    logdir = mc.dirMustExist(mc.logDir(metadata_home))

    #create sys property for conf dirs
    jvm_opts_list = (METADATA_LOG_OPTS % logdir).split()

    cmd_opts = (METADATA_COMMAND_OPTS % metadata_home)
    jvm_opts_list.extend(cmd_opts.split())

    config_opts = (METADATA_CONFIG_OPTS % confdir)
    jvm_opts_list.extend(config_opts.split())

    default_jvm_opts = DEFAULT_JVM_OPTS
    metadata_jvm_opts = os.environ.get(mc.METADATA_OPTS, default_jvm_opts)
    jvm_opts_list.extend(metadata_jvm_opts.split())

    #expand web app dir
    web_app_dir = mc.webAppDir(metadata_home)
    mc.expandWebApp(metadata_home)

    #add hbase-site.xml to classpath
    hbase_conf_dir = mc.hbaseConfDir(confdir)

    p = os.pathsep
    metadata_classpath = confdir + p \
                       + os.path.join(web_app_dir, "atlas", "WEB-INF", "classes" ) + p \
                       + os.path.join(web_app_dir, "atlas", "WEB-INF", "lib", "*" )  + p \
                       + os.path.join(metadata_home, "libext", "*")
    if os.path.exists(hbase_conf_dir):
        metadata_classpath = metadata_classpath + p \
                            + hbase_conf_dir
    else:
        storage_backend = mc.grep(os.path.join(confdir, CONF_FILE),
                                  HBASE_STORAGE_CONF_ENTRY)
        if storage_backend != None:
            raise Exception(
                "Could not find hbase-site.xml in %s. Please set env var HBASE_CONF_DIR to the hbase client conf dir",
                hbase_conf_dir)

    metadata_pid_file = mc.pidFile(metadata_home)

    if os.path.isfile(metadata_pid_file):
        #Check if process listed in atlas.pid file is still running
        pf = file(metadata_pid_file, 'r')
        pid = pf.read().strip()
        pf.close()

        if mc.ON_POSIX:

            if mc.unix_exist_pid((int)(pid)):
                mc.server_already_running(pid)
            else:
                mc.server_pid_not_running(pid)

        else:
            if mc.IS_WINDOWS:
                if mc.win_exist_pid(pid):
                    mc.server_already_running(pid)
                else:
                    mc.server_pid_not_running(pid)

            else:
                #os other than nt or posix - not supported - need to delete the file to restart server if pid no longer exist
                mc.server_already_running(pid)

    args = ["-app", os.path.join(web_app_dir, "atlas")]
    args.extend(sys.argv[1:])

    process = mc.java("org.apache.atlas.Atlas", args, metadata_classpath,
                      jvm_opts_list, logdir)
    mc.writePid(metadata_pid_file, process)

    print "Apache Atlas Server started!!!\n"