You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by lt...@apache.org on 2019/03/04 05:51:39 UTC
[incubator-iotdb] branch cluster_akka created (now 74ff205)
This is an automated email from the ASF dual-hosted git repository.
lta pushed a change to branch cluster_akka
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.
at 74ff205 integrate code
This branch includes the following new commits:
new 74ff205 integrate code
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[incubator-iotdb] 01/01: integrate code
Posted by lt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
lta pushed a commit to branch cluster_akka
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit 74ff2052e4f65d4f804548a25e0fcc6fec06094c
Author: lta <li...@163.com>
AuthorDate: Mon Mar 4 13:43:10 2019 +0800
integrate code
---
.../org/apache/iotdb/db/cluster/IoTDBCluster.java | 32 +++++++++++++++
.../org/apache/iotdb/db/cluster/IoTDBClustetr.java | 45 ----------------------
.../org/apache/iotdb/db/cluster/IoTDBNode.java | 27 ++++++-------
.../java/org/apache/iotdb/db/conf/IoTDBConfig.java | 34 ++++++++++++++++
.../org/apache/iotdb/db/conf/IoTDBDescriptor.java | 3 ++
5 files changed, 80 insertions(+), 61 deletions(-)
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/cluster/IoTDBCluster.java b/iotdb/src/main/java/org/apache/iotdb/db/cluster/IoTDBCluster.java
new file mode 100644
index 0000000..ade9c87
--- /dev/null
+++ b/iotdb/src/main/java/org/apache/iotdb/db/cluster/IoTDBCluster.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with the License. You may obtain
+ * a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iotdb.db.cluster;
+
+import akka.actor.ActorSystem;
+import com.typesafe.config.Config;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
+
+/**
+ * @author lta
+ */
+public class IoTDBCluster {
+
+ private static Config clusterConfig = IoTDBDescriptor.getInstance().getConfig().clusterConfig;
+
+ public static void main(String[] args) {
+ ActorSystem system = ActorSystem.create("IoTDBClusterSystem", clusterConfig);
+ system.actorOf(IoTDBNode.props(), "clusterListener");
+ }
+}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/cluster/IoTDBClustetr.java b/iotdb/src/main/java/org/apache/iotdb/db/cluster/IoTDBClustetr.java
deleted file mode 100644
index e82497f..0000000
--- a/iotdb/src/main/java/org/apache/iotdb/db/cluster/IoTDBClustetr.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.iotdb.db.cluster;
-
-import akka.actor.ActorSystem;
-import com.typesafe.config.Config;
-import com.typesafe.config.ConfigFactory;
-import java.io.File;
-import org.apache.iotdb.db.conf.IoTDBConstant;
-
-/**
- * @author lta
- */
-public class IoTDBClustetr {
-
- public static void main(String[] args) {
- String url = System.getProperty(IoTDBConstant.IOTDB_CONF, null);
- Config config;
- if (url != null) {
- config = ConfigFactory.parseFile(new File(url, IoTDBConstant.CLUSTER_CONFIG));
- } else {
- config = ConfigFactory.parseFile(new File(
- "/Users/litianan/workspace/java/IDEA/IoTDBProject/incubator-iotdb/iotdb/iotdb/conf",
- IoTDBConstant.CLUSTER_CONFIG));
- }
- ActorSystem system = ActorSystem.create("IoTDBClusterSystem", config);
- system.actorOf(IoTDBNode.props(), "clusterListener");
- }
-}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/cluster/IoTDBNode.java b/iotdb/src/main/java/org/apache/iotdb/db/cluster/IoTDBNode.java
index 68334b0..4526ab0 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/cluster/IoTDBNode.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/cluster/IoTDBNode.java
@@ -1,19 +1,15 @@
/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with the License. You may obtain
+ * a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations
* under the License.
*/
package org.apache.iotdb.db.cluster;
@@ -28,7 +24,6 @@ import akka.cluster.ClusterEvent.MemberUp;
import akka.cluster.ClusterEvent.UnreachableMember;
import akka.event.Logging;
import akka.event.LoggingAdapter;
-import org.apache.iotdb.db.exception.FileNodeManagerException;
import org.apache.iotdb.db.service.IoTDB;
/**
@@ -53,9 +48,9 @@ public class IoTDBNode extends AbstractActor {
}
@Override
- public void postStop() throws FileNodeManagerException {
+ public void postStop() {
+ daemon.deactivate();
cluster.unsubscribe(self());
- daemon.stop();
}
public IoTDBNode() {
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java b/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
index 96e2969..acb74ce 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
@@ -18,6 +18,8 @@
*/
package org.apache.iotdb.db.conf;
+import com.typesafe.config.Config;
+import com.typesafe.config.ConfigFactory;
import java.io.File;
import java.time.ZoneId;
import java.util.ArrayList;
@@ -273,6 +275,12 @@ public class IoTDBConfig {
*/
public long cacheFileReaderClearPeriod = 100000;
+ /**
+ * Cluster Config
+ */
+ public Config clusterConfig;
+
+
public IoTDBConfig() {
// empty constructor
}
@@ -322,6 +330,32 @@ public class IoTDBConfig {
derbyHome = sysDir + derbyHome;
indexFileDir = dataDir + indexFileDir;
+
+ // default cluster configuration
+ clusterConfig = ConfigFactory.parseString("akka {\n"
+ + " actor {\n"
+ + " provider = \"cluster\"\n"
+ + " }\n"
+ + " remote {\n"
+ + " netty.tcp {\n"
+ + " hostname = \"127.0.0.1\"\n"
+ + " port = 2552\n"
+ + " }\n"
+ + "\n"
+ + " artery {\n"
+ + " enabled = off\n"
+ + " transport = tcp\n"
+ + " canonical.hostname = \"127.0.0.1\"\n"
+ + " canonical.port = 0\n"
+ + " }\n"
+ + " }\n"
+ + "\n"
+ + " cluster {\n"
+ + " seed-nodes = [\n"
+ + " \"akka.tcp://IoTDBClusterSystem@127.0.0.1:2552\"]\n"
+ + " auto-down-unreachable-after = 10s\n"
+ + " }\n"
+ + "}");
}
/*
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java b/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
index 5cb2fab..f23a122 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
@@ -18,6 +18,7 @@
*/
package org.apache.iotdb.db.conf;
+import com.typesafe.config.ConfigFactory;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -78,6 +79,8 @@ public class IoTDBDescriptor {
return;
}
+ conf.clusterConfig = ConfigFactory.parseFile(new File(url, IoTDBConstant.CLUSTER_CONFIG));
+
LOGGER.info("Start to read config file {}", url);
Properties properties = new Properties();
try {