kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liy...@apache.org
Subject [08/51] [abbrv] incubator-kylin git commit: KYLIN-544 revise deploy script to accept all special characters in password and zookeeper list, also revised the regular expresion for storage url
Date Fri, 23 Jan 2015 08:30:49 GMT
KYLIN-544 revise deploy script to accept all special characters in password and zookeeper list,
also revised the regular expresion for storage url


Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/589e14b1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/589e14b1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/589e14b1

Branch: refs/heads/staging
Commit: 589e14b19231dc1b61b3c6a2b1aa38fdebca46fb
Parents: 3eeb87b
Author: honma <honma@ebay.com>
Authored: Tue Jan 20 15:31:17 2015 +0800
Committer: honma <honma@ebay.com>
Committed: Tue Jan 20 15:31:17 2015 +0800

----------------------------------------------------------------------
 .../com/kylinolap/common/util/HadoopUtil.java   | 19 ++++++---
 sandbox_deploy.sh                               | 43 +++++++++++++++++---
 2 files changed, 51 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/589e14b1/common/src/main/java/com/kylinolap/common/util/HadoopUtil.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/com/kylinolap/common/util/HadoopUtil.java b/common/src/main/java/com/kylinolap/common/util/HadoopUtil.java
index 576240c..fc6c1a9 100644
--- a/common/src/main/java/com/kylinolap/common/util/HadoopUtil.java
+++ b/common/src/main/java/com/kylinolap/common/util/HadoopUtil.java
@@ -60,7 +60,11 @@ public class HadoopUtil {
     }
 
     /**
-     * e.g. "hbase:kylin-local.corp.ebay.com:2181:/hbase-unsecure"
+     * e.g.
+     * 1. hbase:zk-1.hortonworks.com,zk-2.hortonworks.com,zk-3.hortonworks.com:2181:/hbase-unsecure
+     * 2. hbase:zk-1.hortonworks.com,zk-2.hortonworks.com,zk-3.hortonworks.com:2181
+     * 3. hbase:zk-1.hortonworks.com:2181:/hbase-unsecure
+     * 4. hbase:zk-1.hortonworks.com:2181
      */
     public static Configuration newHBaseConfiguration(String url) {
         Configuration conf = HBaseConfiguration.create();
@@ -76,20 +80,25 @@ public class HadoopUtil {
             return conf;
 
         // case of "hbase:domain.com:2181:/hbase-unsecure"
-        Pattern urlPattern = Pattern.compile("([\\w\\d\\-.]+)[:](\\d+)(?:[:](.*))?");
+        Pattern urlPattern = Pattern.compile("((?:[\\w\\-.]+)(?:\\,[\\w\\-.]+)*)[:](\\d+)(?:[:](.+))?");
         Matcher m = urlPattern.matcher(url);
         if (m.matches() == false)
             throw new IllegalArgumentException("HBase URL '" + url + "' is invalid, expected
url is like '" + "hbase:domain.com:2181:/hbase-unsecure" + "'");
 
         logger.debug("Creating hbase conf by parsing -- " + url);
 
-        String quorum = m.group(1);
+        String quorums = m.group(1);
+        String quorum = null;
         try {
-            InetAddress.getByName(quorum);
+            String[] tokens = quorums.split(",");
+            for (String s : tokens) {
+                quorum = s;
+                InetAddress.getByName(quorum);
+            }
         } catch (UnknownHostException e) {
             throw new IllegalArgumentException("Zookeeper quorum is invalid: " + quorum +
"; urlString=" + url, e);
         }
-        conf.set(HConstants.ZOOKEEPER_QUORUM, quorum);
+        conf.set(HConstants.ZOOKEEPER_QUORUM, quorums);
 
         String port = m.group(2);
         conf.set(HConstants.ZOOKEEPER_CLIENT_PORT, port);

http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/589e14b1/sandbox_deploy.sh
----------------------------------------------------------------------
diff --git a/sandbox_deploy.sh b/sandbox_deploy.sh
index 6331f1b..c5b44c5 100755
--- a/sandbox_deploy.sh
+++ b/sandbox_deploy.sh
@@ -11,6 +11,18 @@ echo "ERROR exit from ${SCRIPT} : line ${LASTLINE} with exit code ${LASTERR}"
 exit 1
 }
 
+function escape_sed_replacement(){
+        v=$1
+        v=$(sed -e 's/[\/&]/\\&/g' <<< $v)
+        echo $v
+}
+
+function escape_sed_pattern(){
+        v=$1
+        v=$(sed -e 's/[]\/$*.^|[]/\\&/g' <<< $v)
+        echo $v
+}
+
 trap 'error ${LINENO} ${?}' ERR
 
 echo ""
@@ -128,15 +140,34 @@ KYLIN_ZOOKEEPER_URL=${KYLIN_ZOOKEEPER_QUORUM}:${KYLIN_ZOOKEEPER_CLIENT_PORT}:${K
 echo "Kylin install script requires root password for ${HOSTNAME}"
 echo "(The default root password for hortonworks VM is hadoop, and for cloudera VM is cloudera)"
 
-[[ "$SILENT" ]] || read -s -p "Enter Password for root: " ROOTPASS
+[[ "$SILENT" ]] || read -r -s -p  "Enter Password for root: " ROOTPASS
+
+#escape special characters for sed
+CHECK_URL_DEFAULT=$(escape_sed_pattern $CHECK_URL_DEFAULT)
+CLI_HOSTNAME_DEFAULT=$(escape_sed_pattern $CLI_HOSTNAME_DEFAULT)
+CLI_PASSWORD_DEFAULT=$(escape_sed_pattern $CLI_PASSWORD_DEFAULT)
+METADATA_URL_DEFAULT=$(escape_sed_pattern $METADATA_URL_DEFAULT)
+STORAGE_URL_DEFAULT=$(escape_sed_pattern $STORAGE_URL_DEFAULT)
+
+
+NEW_CHECK_URL_PREFIX=$(escape_sed_replacement $NEW_CHECK_URL_PREFIX)
+NEW_CLI_HOSTNAME_PREFIX=$(escape_sed_replacement $NEW_CLI_HOSTNAME_PREFIX)
+NEW_CLI_PASSWORD_PREFIX=$(escape_sed_replacement $NEW_CLI_PASSWORD_PREFIX)
+NEW_METADATA_URL_PREFIX=$(escape_sed_replacement $NEW_METADATA_URL_PREFIX)
+NEW_STORAGE_URL_PREFIX=$(escape_sed_replacement $NEW_STORAGE_URL_PREFIX)
+HOSTNAME=$(escape_sed_replacement $HOSTNAME)
+ROOTPASS=$(escape_sed_replacement $ROOTPASS)
+KYLIN_ZOOKEEPER_URL=$(escape_sed_replacement $KYLIN_ZOOKEEPER_URL)
+
+
 
 #deploy kylin.properties to /etc/kylin
 cat examples/test_case_data/sandbox/kylin.properties | \
-    sed -e "s,${CHECK_URL_DEFAULT},${NEW_CHECK_URL_PREFIX}${HOSTNAME}," | \
-    sed -e "s,${CLI_HOSTNAME_DEFAULT},${NEW_CLI_HOSTNAME_PREFIX}${HOSTNAME}," | \
-    sed -e "s,${CLI_PASSWORD_DEFAULT},${NEW_CLI_PASSWORD_PREFIX}${ROOTPASS}," | \
-    sed -e "s,${METADATA_URL_DEFAULT},${NEW_METADATA_URL_PREFIX}${KYLIN_ZOOKEEPER_URL},"
| \
-    sed -e "s,${STORAGE_URL_DEFAULT},${NEW_STORAGE_URL_PREFIX}${KYLIN_ZOOKEEPER_URL}," >
 /etc/kylin/kylin.properties
+    sed -e "s/${CHECK_URL_DEFAULT}/${NEW_CHECK_URL_PREFIX}${HOSTNAME}/g" | \
+    sed -e "s/${CLI_HOSTNAME_DEFAULT}/${NEW_CLI_HOSTNAME_PREFIX}${HOSTNAME}/g" | \
+    sed -e "s/${CLI_PASSWORD_DEFAULT}/${NEW_CLI_PASSWORD_PREFIX}${ROOTPASS}/g" | \
+    sed -e "s/${METADATA_URL_DEFAULT}/${NEW_METADATA_URL_PREFIX}${KYLIN_ZOOKEEPER_URL}/g"
| \
+    sed -e "s/${STORAGE_URL_DEFAULT}/${NEW_STORAGE_URL_PREFIX}${KYLIN_ZOOKEEPER_URL}/g" >
 /etc/kylin/kylin.properties
 
 
 echo "a copy of kylin config is generated at /etc/kylin/kylin.properties:"


Mime
View raw message