You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2016/03/03 04:30:49 UTC
[02/25] kylin git commit: rebase 2.x-staging
rebase 2.x-staging
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/7617025a
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/7617025a
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/7617025a
Branch: refs/heads/helix-rebase
Commit: 7617025a1d8cc3c977a1a6c5f7c8da100331aab9
Parents: 294fc70
Author: shaofengshi <sh...@apache.org>
Authored: Wed Dec 30 14:18:06 2015 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Wed Mar 2 17:24:10 2016 +0800
----------------------------------------------------------------------
build/bin/kylin.sh | 10 +++++
.../test_case_data/sandbox/kylin.properties | 1 +
.../java/org/apache/kylin/rest/DebugTomcat.java | 3 ++
.../kylin/rest/controller/JobController.java | 44 ++++++++++----------
4 files changed, 37 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/7617025a/build/bin/kylin.sh
----------------------------------------------------------------------
diff --git a/build/bin/kylin.sh b/build/bin/kylin.sh
index a21928e..eaa6209 100644
--- a/build/bin/kylin.sh
+++ b/build/bin/kylin.sh
@@ -73,6 +73,15 @@ then
mkdir -p ${KYLIN_HOME}/ext
export HBASE_CLASSPATH=$hive_dependency:${KYLIN_HOME}/lib/*:${KYLIN_HOME}/ext/*:${HBASE_CLASSPATH}
+ if [ -z "$KYLIN_REST_ADDRESS" ]
+ then
+ kylin_rest_address=`hostname`":"`grep "<Connector port=" ${tomcat_root}/conf/server.xml |grep protocol=\"HTTP/1.1\" | cut -d '=' -f 2 | cut -d \" -f 2`
+ echo "KYLIN_REST_ADDRESS not found, will use ${kylin_rest_address}"
+ else
+ echo "KYLIN_REST_ADDRESS is set to: $KYLIN_REST_ADDRESS"
+ kylin_rest_address=$KYLIN_REST_ADDRESS
+ fi
+
#debug if encounter NoClassDefError
#hbase classpath
@@ -88,6 +97,7 @@ then
-Djava.io.tmpdir=${tomcat_root}/temp \
-Dkylin.hive.dependency=${hive_dependency} \
-Dkylin.hbase.dependency=${hbase_dependency} \
+ -Dkylin.rest.address=${kylin_rest_address} \
-Dspring.profiles.active=${spring_profile} \
org.apache.hadoop.util.RunJar ${tomcat_root}/bin/bootstrap.jar org.apache.catalina.startup.Bootstrap start >> ${KYLIN_HOME}/logs/kylin.out 2>&1 & echo $! > ${KYLIN_HOME}/pid &
echo "A new Kylin instance is started by $USER, stop it using \"kylin.sh stop\""
http://git-wip-us.apache.org/repos/asf/kylin/blob/7617025a/examples/test_case_data/sandbox/kylin.properties
----------------------------------------------------------------------
diff --git a/examples/test_case_data/sandbox/kylin.properties b/examples/test_case_data/sandbox/kylin.properties
index bf161fc..18ff1cc 100644
--- a/examples/test_case_data/sandbox/kylin.properties
+++ b/examples/test_case_data/sandbox/kylin.properties
@@ -4,6 +4,7 @@
# currently it will be attached to each kylin's htable attribute
kylin.owner=whoami@kylin.apache.org
+kylin.zookeeper.address=sandbox:2181
# List of web servers in use, this enables one web server instance to sync up with other servers.
kylin.rest.servers=localhost:7070
http://git-wip-us.apache.org/repos/asf/kylin/blob/7617025a/server/src/main/java/org/apache/kylin/rest/DebugTomcat.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/kylin/rest/DebugTomcat.java b/server/src/main/java/org/apache/kylin/rest/DebugTomcat.java
index c0f61d2..139cddc 100644
--- a/server/src/main/java/org/apache/kylin/rest/DebugTomcat.java
+++ b/server/src/main/java/org/apache/kylin/rest/DebugTomcat.java
@@ -30,6 +30,7 @@ import org.apache.catalina.startup.Tomcat;
import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.util.Shell;
import org.apache.kylin.common.KylinConfig;
+import org.apache.kylin.common.util.HostnameUtils;
import org.apache.kylin.rest.util.ClasspathUtil;
public class DebugTomcat {
@@ -45,6 +46,8 @@ public class DebugTomcat {
System.setProperty("spring.profiles.active", "testing");
+ System.setProperty("kylin.rest.address", HostnameUtils.getHostname() + ":" + "7070");
+
//avoid log permission issue
if (System.getProperty("catalina.home") == null)
System.setProperty("catalina.home", ".");
http://git-wip-us.apache.org/repos/asf/kylin/blob/7617025a/server/src/main/java/org/apache/kylin/rest/controller/JobController.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/kylin/rest/controller/JobController.java b/server/src/main/java/org/apache/kylin/rest/controller/JobController.java
index 5c835ac..4d0824a 100644
--- a/server/src/main/java/org/apache/kylin/rest/controller/JobController.java
+++ b/server/src/main/java/org/apache/kylin/rest/controller/JobController.java
@@ -26,6 +26,9 @@ import java.util.List;
import java.util.Map;
import java.util.TimeZone;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import joptsimple.internal.Strings;
import org.apache.kylin.common.KylinConfig;
import org.apache.kylin.job.JobInstance;
import org.apache.kylin.job.constant.JobStatusEnum;
@@ -76,28 +79,15 @@ public class JobController extends BasicController implements InitializingBean {
TimeZone tzone = TimeZone.getTimeZone(timeZone);
TimeZone.setDefault(tzone);
- final KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv();
- String serverMode = kylinConfig.getServerMode();
-
- if (Constant.SERVER_MODE_JOB.equals(serverMode.toLowerCase()) || Constant.SERVER_MODE_ALL.equals(serverMode.toLowerCase())) {
- logger.info("Initializing Job Engine ....");
-
- new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- DefaultScheduler scheduler = DefaultScheduler.getInstance();
- scheduler.init(new JobEngineConfig(kylinConfig), jobLock);
- while (!scheduler.hasStarted()) {
- logger.error("scheduler has not been started");
- Thread.sleep(1000);
- }
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- }).start();
+ if (System.getProperty("kylin.rest.address") == null) {
+ throw new RuntimeException("There is no -Dkylin.rest.address set; Please check bin/kylin.sh");
}
+
+ final String restAddress = System.getProperty("kylin.rest.address");
+ final String hostname = Preconditions.checkNotNull(restAddress.substring(0, restAddress.lastIndexOf(":")));
+ final String port = Preconditions.checkNotNull(restAddress.substring(restAddress.lastIndexOf(":") + 1));
+ final String instanceName = hostname + "_" + port;
+ final KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv();
}
/**
@@ -209,4 +199,16 @@ public class JobController extends BasicController implements InitializingBean {
this.jobService = jobService;
}
+ private void updateKylinConfig(List<String> instances) {
+ List<String> instanceRestAddresses = Lists.newArrayList();
+ for (String instanceName : instances) {
+ int indexOfUnderscore = instanceName.lastIndexOf("_");
+ instanceRestAddresses.add(instanceName.substring(0, indexOfUnderscore) + ":" + instanceName.substring(indexOfUnderscore + 1));
+ }
+ String restServersInCluster = Strings.join(instanceRestAddresses, ",");
+ KylinConfig.getInstanceFromEnv().setProperty("kylin.rest.servers", restServersInCluster);
+ System.setProperty("kylin.rest.servers", restServersInCluster);
+
+ }
+
}