diff --git a/apm-collector/apm-collector-boot/src/main/resources/application.yml b/apm-collector/apm-collector-boot/src/main/resources/application.yml
index b7d1af13f5125603d9e0f5b01a55887d21f6d4e0..33b26ad1e2297c3d3535875daf9673d8446c77f7 100644
--- a/apm-collector/apm-collector-boot/src/main/resources/application.yml
+++ b/apm-collector/apm-collector-boot/src/main/resources/application.yml
@@ -27,13 +27,13 @@ ui:
# grpc:
# host: localhost
# port: 11800
-#storage:
-# elasticsearch:
-# cluster_name: CollectorDBCluster
-# cluster_transport_sniffer: true
-# cluster_nodes: localhost:9300
-# index_shards_number: 2
-# index_replicas_number: 0
+storage:
+ elasticsearch:
+ cluster_name: CollectorDBCluster
+ cluster_transport_sniffer: true
+ cluster_nodes: localhost:9300
+ index_shards_number: 2
+ index_replicas_number: 0
#storage:
# h2:
# url: jdbc:h2:tcp://localhost/~/test
diff --git a/apm-collector/apm-collector-component/persistence-component/pom.xml b/apm-collector/apm-collector-component/persistence-component/pom.xml
deleted file mode 100644
index 8095e0b1f8dc57e8f82d595296e99e864e69abfb..0000000000000000000000000000000000000000
--- a/apm-collector/apm-collector-component/persistence-component/pom.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
- apm-collector-component
- org.skywalking
- 3.2.3-2017
-
- 4.0.0
-
- persistence-component
- jar
-
\ No newline at end of file
diff --git a/apm-collector/apm-collector-component/pom.xml b/apm-collector/apm-collector-component/pom.xml
index b7dbe6e0a060193e42ed98d1d9494aa5f513e245..bbab409adf2a59bd8a4c0fa43829f5964f0dcf02 100644
--- a/apm-collector/apm-collector-component/pom.xml
+++ b/apm-collector/apm-collector-component/pom.xml
@@ -15,7 +15,6 @@
client-componentserver-componentqueue-component
- persistence-componentstream-componentremote-component
diff --git a/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/define/DefineException.java b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/define/DefineException.java
new file mode 100644
index 0000000000000000000000000000000000000000..281d22d6355b88c82331aebb35bc014f3e484892
--- /dev/null
+++ b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/define/DefineException.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.collector.core.define;
+
+import org.skywalking.apm.collector.core.CollectorException;
+
+/**
+ * @author peng-yongsheng
+ */
+public abstract class DefineException extends CollectorException {
+
+ public DefineException(String message) {
+ super(message);
+ }
+
+ public DefineException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/define/DefinitionFile.java b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/define/DefinitionFile.java
new file mode 100644
index 0000000000000000000000000000000000000000..be2915e26b8c92aa2f15739736b523be654a71a5
--- /dev/null
+++ b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/define/DefinitionFile.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.collector.core.define;
+
+/**
+ * @author peng-yongsheng
+ */
+public abstract class DefinitionFile {
+
+ private static final String CATALOG = "META-INF/defines/";
+
+ protected abstract String fileName();
+
+ public final String get() {
+ return CATALOG + fileName();
+ }
+}
diff --git a/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/define/DefinitionLoader.java b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/define/DefinitionLoader.java
new file mode 100644
index 0000000000000000000000000000000000000000..363cd805a337c66c6007652750c6b2aa5694ee5c
--- /dev/null
+++ b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/define/DefinitionLoader.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.collector.core.define;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+import java.util.Properties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author peng-yongsheng
+ */
+public class DefinitionLoader implements Iterable {
+
+ private final Logger logger = LoggerFactory.getLogger(DefinitionLoader.class);
+
+ private final Class definition;
+ private final DefinitionFile definitionFile;
+
+ protected DefinitionLoader(Class svc, DefinitionFile definitionFile) {
+ this.definition = Objects.requireNonNull(svc, "definition interface cannot be null");
+ this.definitionFile = definitionFile;
+ }
+
+ public static DefinitionLoader load(Class definition, DefinitionFile definitionFile) {
+ return new DefinitionLoader(definition, definitionFile);
+ }
+
+ @Override public final Iterator iterator() {
+ logger.info("load definition file: {}", definitionFile.get());
+ List definitionList = new LinkedList<>();
+ try {
+ Enumeration urlEnumeration = this.getClass().getClassLoader().getResources(definitionFile.get());
+ while (urlEnumeration.hasMoreElements()) {
+ URL definitionFileURL = urlEnumeration.nextElement();
+ logger.info("definition file url: {}", definitionFileURL.getPath());
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(definitionFileURL.openStream()));
+ Properties properties = new Properties();
+ properties.load(bufferedReader);
+
+ Enumeration defineItem = properties.propertyNames();
+ while (defineItem.hasMoreElements()) {
+ String fullNameClass = (String)defineItem.nextElement();
+ definitionList.add(fullNameClass);
+ }
+ }
+ } catch (IOException e) {
+ logger.error(e.getMessage(), e);
+ }
+
+ Iterator moduleDefineIterator = definitionList.iterator();
+
+ return new Iterator() {
+ @Override public boolean hasNext() {
+ return moduleDefineIterator.hasNext();
+ }
+
+ @Override public D next() {
+ String definitionClass = moduleDefineIterator.next();
+ logger.info("definitionClass: {}", definitionClass);
+ try {
+ Class c = Class.forName(definitionClass);
+ return (D)c.newInstance();
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ }
+ return null;
+ }
+ };
+ }
+}
diff --git a/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/define/Loader.java b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/define/Loader.java
new file mode 100644
index 0000000000000000000000000000000000000000..18af026ab5e4fdaef4dc46fe52b97b6bdd018501
--- /dev/null
+++ b/apm-collector/apm-collector-core/src/main/java/org/skywalking/apm/collector/core/define/Loader.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.collector.core.define;
+
+/**
+ * @author peng-yongsheng
+ */
+public interface Loader {
+ T load() throws DefineException;
+}
diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/StorageException.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/StorageException.java
new file mode 100644
index 0000000000000000000000000000000000000000..396277d72bdc6cba315f06fa3762ae1a70a32459
--- /dev/null
+++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/StorageException.java
@@ -0,0 +1,17 @@
+package org.skywalking.apm.collector.storage;
+
+import org.skywalking.apm.collector.core.CollectorException;
+
+/**
+ * @author peng-yongsheng
+ */
+public abstract class StorageException extends CollectorException {
+
+ public StorageException(String message) {
+ super(message);
+ }
+
+ public StorageException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/StorageInstallException.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/StorageInstallException.java
new file mode 100644
index 0000000000000000000000000000000000000000..a25a45f40e2a9c03d3f5b49c2a760e05110bd4b9
--- /dev/null
+++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/StorageInstallException.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.collector.storage;
+
+/**
+ * @author peng-yongsheng
+ */
+public class StorageInstallException extends StorageException {
+
+ public StorageInstallException(String message) {
+ super(message);
+ }
+
+ public StorageInstallException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/StorageInstaller.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/StorageInstaller.java
new file mode 100644
index 0000000000000000000000000000000000000000..aedc597761eebb752b7cd7b03e978426d51fc9f8
--- /dev/null
+++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/StorageInstaller.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.collector.storage;
+
+import java.util.List;
+import org.skywalking.apm.collector.client.Client;
+import org.skywalking.apm.collector.core.define.DefineException;
+import org.skywalking.apm.collector.storage.define.StorageDefineLoader;
+import org.skywalking.apm.collector.storage.define.TableDefine;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author peng-yongsheng
+ */
+public abstract class StorageInstaller {
+
+ private final Logger logger = LoggerFactory.getLogger(StorageInstaller.class);
+
+ public final void install(Client client) throws StorageException {
+ StorageDefineLoader defineLoader = new StorageDefineLoader();
+ try {
+ List tableDefines = defineLoader.load();
+ defineFilter(tableDefines);
+ Boolean debug = System.getProperty("debug") != null;
+
+ for (TableDefine tableDefine : tableDefines) {
+ tableDefine.initialize();
+ if (!isExists(client, tableDefine)) {
+ logger.info("table: {} not exists", tableDefine.getName());
+ createTable(client, tableDefine);
+ } else if (debug) {
+ logger.info("table: {} exists", tableDefine.getName());
+ deleteTable(client, tableDefine);
+ createTable(client, tableDefine);
+ }
+ }
+ } catch (DefineException e) {
+ throw new StorageInstallException(e.getMessage(), e);
+ }
+ }
+
+ protected abstract void defineFilter(List tableDefines);
+
+ protected abstract boolean isExists(Client client, TableDefine tableDefine) throws StorageException;
+
+ protected abstract boolean deleteTable(Client client, TableDefine tableDefine) throws StorageException;
+
+ protected abstract boolean createTable(Client client, TableDefine tableDefine) throws StorageException;
+}
diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/DAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/DAO.java
new file mode 100644
index 0000000000000000000000000000000000000000..b6819c5b476b479a1cd1642f332f03e9b2c317ab
--- /dev/null
+++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/DAO.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.collector.storage.dao;
+
+import org.skywalking.apm.collector.client.Client;
+
+/**
+ * @author peng-yongsheng
+ */
+public abstract class DAO {
+ private C client;
+
+ public final C getClient() {
+ return client;
+ }
+
+ public final void setClient(C client) {
+ this.client = client;
+ }
+}
diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/DAOContainer.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/DAOContainer.java
new file mode 100644
index 0000000000000000000000000000000000000000..4d2c9b91e1818f64250128a30b4ad23a1bb3ef85
--- /dev/null
+++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/DAOContainer.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.collector.storage.dao;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author peng-yongsheng
+ */
+public enum DAOContainer {
+ INSTANCE;
+
+ private Map daos = new HashMap<>();
+
+ public void put(String interfaceName, DAO dao) {
+ daos.put(interfaceName, dao);
+ }
+
+ public DAO get(String interfaceName) {
+ return daos.get(interfaceName);
+ }
+}
diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IBatchDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IBatchDAO.java
new file mode 100644
index 0000000000000000000000000000000000000000..f57aa8f5e9b80c7381e3658d69bfa2b0bc534312
--- /dev/null
+++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/dao/IBatchDAO.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.collector.storage.dao;
+
+import java.util.List;
+
+/**
+ * @author peng-yongsheng
+ */
+public interface IBatchDAO {
+ void batchPersistence(List> batchCollection);
+}
diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/ColumnDefine.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/ColumnDefine.java
new file mode 100644
index 0000000000000000000000000000000000000000..f2da01dfa9b26040ba25789803cad17763f79a15
--- /dev/null
+++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/ColumnDefine.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.collector.storage.define;
+
+/**
+ * @author peng-yongsheng
+ */
+public abstract class ColumnDefine {
+ private final String name;
+ private final String type;
+
+ public ColumnDefine(String name, String type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public final String getName() {
+ return name;
+ }
+
+ public String getType() {
+ return type;
+ }
+}
diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/StorageDefineLoader.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/StorageDefineLoader.java
new file mode 100644
index 0000000000000000000000000000000000000000..c7402858bbb739d61b565c7af469372c71fa0c5f
--- /dev/null
+++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/StorageDefineLoader.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.collector.storage.define;
+
+import java.util.LinkedList;
+import java.util.List;
+import org.skywalking.apm.collector.core.define.DefineException;
+import org.skywalking.apm.collector.core.define.DefinitionLoader;
+import org.skywalking.apm.collector.core.define.Loader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author peng-yongsheng
+ */
+public class StorageDefineLoader implements Loader> {
+
+ private final Logger logger = LoggerFactory.getLogger(StorageDefineLoader.class);
+
+ @Override public List load() throws DefineException {
+ List tableDefines = new LinkedList<>();
+
+ StorageDefinitionFile definitionFile = new StorageDefinitionFile();
+ logger.info("storage definition file name: {}", definitionFile.fileName());
+ DefinitionLoader definitionLoader = DefinitionLoader.load(TableDefine.class, definitionFile);
+ for (TableDefine tableDefine : definitionLoader) {
+ logger.info("loaded storage definition class: {}", tableDefine.getClass().getName());
+ tableDefines.add(tableDefine);
+ }
+ return tableDefines;
+ }
+}
diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/StorageDefinitionFile.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/StorageDefinitionFile.java
new file mode 100644
index 0000000000000000000000000000000000000000..e15355bfa766a67f3079092d26785ea6996d70bf
--- /dev/null
+++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/StorageDefinitionFile.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.collector.storage.define;
+
+import org.skywalking.apm.collector.core.define.DefinitionFile;
+
+/**
+ * @author peng-yongsheng
+ */
+public class StorageDefinitionFile extends DefinitionFile {
+ @Override protected String fileName() {
+ return "storage.define";
+ }
+}
diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/TableDefine.java
new file mode 100644
index 0000000000000000000000000000000000000000..eb7e8669dcc4273bdbd6a4fbcf87e6a46a169e17
--- /dev/null
+++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/define/TableDefine.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.collector.storage.define;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @author peng-yongsheng
+ */
+public abstract class TableDefine {
+ private final String name;
+ private final List columnDefines;
+
+ public TableDefine(String name) {
+ this.name = name;
+ this.columnDefines = new LinkedList<>();
+ }
+
+ public abstract void initialize();
+
+ public final void addColumn(ColumnDefine columnDefine) {
+ columnDefines.add(columnDefine);
+ }
+
+ public final String getName() {
+ return name;
+ }
+
+ public final List getColumnDefines() {
+ return columnDefines;
+ }
+}
diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/sql/SqlBuilder.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/sql/SqlBuilder.java
new file mode 100644
index 0000000000000000000000000000000000000000..4a19b6691d3aaaf029dd2b8c5646eaf9e840458f
--- /dev/null
+++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/skywalking/apm/collector/storage/sql/SqlBuilder.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.collector.storage.sql;
+
+import java.text.MessageFormat;
+import java.util.List;
+import java.util.Set;
+
+public class SqlBuilder {
+ public static String buildSql(String sql, Object... args) {
+ return MessageFormat.format(sql, args);
+ }
+
+ public static String buildSql(String sql, List