hawq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ictmalili <...@git.apache.org>
Subject [GitHub] incubator-hawq pull request #690: HAWQ-778. Refine hawq register, add sanity...
Date Mon, 06 Jun 2016 02:41:23 GMT
Github user ictmalili commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/690#discussion_r65832309
  
    --- Diff: tools/bin/hawqregister ---
    @@ -103,6 +113,61 @@ def check_hash_type(options, databasename, tablename):
             sys.exit(1)
     
     
    +def get_metadata_from_database(options, databasename, tablename, seg_name):
    +    try:
    +        query = "select segno from pg_aoseg.%s;" % seg_name
    +        dburl = dbconn.DbURL(hostname=options.host, port=options.port, username=options.user,
dbname=databasename)
    +        conn = dbconn.connect(dburl, False)
    +        rows = dbconn.execSQL(conn, query)
    +	conn.commit()
    +        conn.close()
    +
    +    except DatabaseError, ex:
    +        logger.error("Failed to connect to database, this script can only be run when
the database is up")
    +        logger.error("host = %s, port = %d, user = %s, dbname = %s, query = %s" % (options.host,
options.port, options.user, databasename, query))
    +        sys.exit(1)
    +
    +    firstsegno = rows.rowcount + 1
    +
    +    # get the full path of correspoding file for target table
    +    try:
    +        query = ("select location, gp_persistent_tablespace_node.tablespace_oid, database_oid,
relfilenode from pg_class, gp_persistent_relation_node, "
    +                 "gp_persistent_tablespace_node, gp_persistent_filespace_node where relname
= '%s' and pg_class.relfilenode = "
    +                 "gp_persistent_relation_node.relfilenode_oid and gp_persistent_relation_node.tablespace_oid
= gp_persistent_tablespace_node.tablespace_oid "
    +                 "and gp_persistent_filespace_node.filespace_oid = gp_persistent_filespace_node.filespace_oid;")
% tablename
    +        dburl = dbconn.DbURL(hostname=options.host, port=options.port, username=options.user,
dbname=databasename)
    +        conn = dbconn.connect(dburl, False)
    +        rows = dbconn.execSQL(conn, query)
    +	conn.commit()
    +        conn.close()
    +
    +    except DatabaseError, ex:
    +        logger.error("Failed to connect to database, this script can only be run when
the database is up")
    +        logger.error("host = %s, port = %d, user = %s, dbname = %s, query = %s" % (options.host,
options.port, options.user, databasename, query))
    +        sys.exit(1)
    +
    +    for row in rows:
    +        tabledir = row[0].strip() + "/" + str(row[1]) + "/" + str(row[2]) + "/" + str(row[3])
+ "/"
    +
    +    return firstsegno, tabledir
    +
    +
    +def check_files_and_table_in_same_hdfs_cluster(filepath, tabledir):
    +    # check whether the files to be registered is in hdfs
    +    filesystem = filepath.split('://')
    +    if filesystem[0] != 'hdfs':
    +        logger.error("Only support to register file(s) in hdfs")
    +        sys.exit(1)
    +    fileroot = filepath.split('/')
    +    tableroot = tabledir.split('/')
    +    print fileroot
    +    print tableroot
    --- End diff --
    
    I think it's better not to print meaningless codes out to console, since the command result
is directly output to user, instead of written into log. Make sure every output it meaningful
to user is necessary.
    Currently when I run the hawq register, the output contains following:
    
    ['hdfs:', '', 'localhost:8020', 'tmpData']
    ['hdfs:', '', 'localhost:8020', 'hawq_default', '16385', '16387', '24616', '']
    
    Please modify it to more meaningful sentences.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message