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-component server-component queue-component - persistence-component stream-component remote-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 args) { + MessageFormat messageFormat = new MessageFormat(sql); + return messageFormat.format(args.toArray(new Object[0])); + } + + public static String buildBatchInsertSql(String tableName, Set columnNames) { + StringBuilder sb = new StringBuilder("insert into "); + sb.append(tableName).append("("); + columnNames.forEach((columnName) -> sb.append(columnName).append(",")); + sb.delete(sb.length() - 1, sb.length()); + sb.append(") values("); + for (int i = 0; i < columnNames.size(); i++) { + sb.append("?,"); + } + sb.delete(sb.length() - 1, sb.length()); + sb.append(")"); + return sb.toString(); + } + + public static String buildBatchUpdateSql(String tableName, Set columnNames, String whereClauseName) { + StringBuilder sb = new StringBuilder("update "); + sb.append(tableName).append(" set "); + columnNames.forEach((columnName) -> sb.append(columnName).append("=?,")); + sb.delete(sb.length() - 1, sb.length()); + sb.append(" where ").append(whereClauseName).append("=?"); + return sb.toString(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java index c8dc51260d8b54bd253aa8b5c147d5ee9dadfcdf..cb99a34b5587d228d68e4f854a030539c6259ecb 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java @@ -18,17 +18,38 @@ package org.skywalking.apm.collector.storage.es; +import java.util.List; import java.util.Properties; +import org.skywalking.apm.collector.client.ClientException; +import org.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.skywalking.apm.collector.core.define.DefineException; import org.skywalking.apm.collector.core.module.Module; import org.skywalking.apm.collector.core.module.ModuleProvider; import org.skywalking.apm.collector.core.module.ServiceNotProvidedException; +import org.skywalking.apm.collector.storage.StorageException; import org.skywalking.apm.collector.storage.StorageModule; +import org.skywalking.apm.collector.storage.dao.DAOContainer; +import org.skywalking.apm.collector.storage.es.dao.EsDAO; +import org.skywalking.apm.collector.storage.es.dao.EsDAODefineLoader; +import org.skywalking.apm.collector.storage.es.define.ElasticSearchStorageInstaller; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author peng-yongsheng */ public class StorageModuleEsProvider extends ModuleProvider { + private final Logger logger = LoggerFactory.getLogger(StorageModuleEsProvider.class); + + private static final String CLUSTER_NAME = "cluster_name"; + private static final String CLUSTER_TRANSPORT_SNIFFER = "cluster_transport_sniffer"; + private static final String CLUSTER_NODES = "cluster_nodes"; + private static final String INDEX_SHARDS_NUMBER = "index_shards_number"; + private static final String INDEX_REPLICAS_NUMBER = "index_replicas_number"; + + private ElasticSearchClient elasticSearchClient; + @Override public String name() { return "elasticsearch"; } @@ -38,11 +59,31 @@ public class StorageModuleEsProvider extends ModuleProvider { } @Override public void prepare(Properties config) throws ServiceNotProvidedException { - + String clusterName = config.getProperty(CLUSTER_NAME); + Boolean clusterTransportSniffer = (Boolean)config.get(CLUSTER_TRANSPORT_SNIFFER); + String clusterNodes = config.getProperty(CLUSTER_NODES); + elasticSearchClient = new ElasticSearchClient(clusterName, clusterTransportSniffer, clusterNodes); } @Override public void start(Properties config) throws ServiceNotProvidedException { + Integer indexShardsNumber = (Integer)config.get(INDEX_SHARDS_NUMBER); + Integer indexReplicasNumber = (Integer)config.get(INDEX_REPLICAS_NUMBER); + try { + elasticSearchClient.initialize(); + + EsDAODefineLoader loader = new EsDAODefineLoader(); + List esDAOs = loader.load(); + esDAOs.forEach(esDAO -> { + esDAO.setClient(elasticSearchClient); + String interFaceName = esDAO.getClass().getInterfaces()[0].getName(); + DAOContainer.INSTANCE.put(interFaceName, esDAO); + }); + ElasticSearchStorageInstaller installer = new ElasticSearchStorageInstaller(indexShardsNumber, indexReplicasNumber); + installer.install(elasticSearchClient); + } catch (ClientException | DefineException | StorageException e) { + logger.error(e.getMessage(), e); + } } @Override public void notifyAfterCompleted() throws ServiceNotProvidedException { diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/BatchEsDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/BatchEsDAO.java new file mode 100644 index 0000000000000000000000000000000000000000..e9bbb7fee3a8bb1a8ce40c02ecb31e6790b394cc --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/BatchEsDAO.java @@ -0,0 +1,59 @@ +/* + * 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.es.dao; + +import java.util.List; +import org.elasticsearch.action.bulk.BulkRequestBuilder; +import org.elasticsearch.action.bulk.BulkResponse; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; +import org.skywalking.apm.collector.core.util.CollectionUtils; +import org.skywalking.apm.collector.storage.dao.IBatchDAO; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class BatchEsDAO extends EsDAO implements IBatchDAO { + + private final Logger logger = LoggerFactory.getLogger(BatchEsDAO.class); + + @Override public void batchPersistence(List batchCollection) { + BulkRequestBuilder bulkRequest = getClient().prepareBulk(); + + logger.debug("bulk data size: {}", batchCollection.size()); + if (CollectionUtils.isNotEmpty(batchCollection)) { + for (int i = 0; i < batchCollection.size(); i++) { + Object builder = batchCollection.get(i); + if (builder instanceof IndexRequestBuilder) { + bulkRequest.add((IndexRequestBuilder)builder); + } + if (builder instanceof UpdateRequestBuilder) { + bulkRequest.add((UpdateRequestBuilder)builder); + } + } + + BulkResponse bulkResponse = bulkRequest.execute().actionGet(); + if (bulkResponse.hasFailures()) { + logger.error(bulkResponse.buildFailureMessage()); + } + } + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/EsDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/EsDAO.java new file mode 100644 index 0000000000000000000000000000000000000000..2b40df121d9ec37476420ed983694314c964987a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/EsDAO.java @@ -0,0 +1,73 @@ +/* + * 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.es.dao; + +import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.search.aggregations.AggregationBuilders; +import org.elasticsearch.search.aggregations.metrics.max.Max; +import org.elasticsearch.search.aggregations.metrics.max.MaxAggregationBuilder; +import org.elasticsearch.search.aggregations.metrics.min.Min; +import org.elasticsearch.search.aggregations.metrics.min.MinAggregationBuilder; +import org.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.skywalking.apm.collector.storage.dao.DAO; + +/** + * @author peng-yongsheng + */ +public abstract class EsDAO extends DAO { + + public final int getMaxId(String indexName, String columnName) { + ElasticSearchClient client = getClient(); + SearchRequestBuilder searchRequestBuilder = client.prepareSearch(indexName); + searchRequestBuilder.setTypes("type"); + searchRequestBuilder.setSize(0); + MaxAggregationBuilder aggregation = AggregationBuilders.max("agg").field(columnName); + searchRequestBuilder.addAggregation(aggregation); + + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + Max agg = searchResponse.getAggregations().get("agg"); + + int id = (int)agg.getValue(); + if (id == Integer.MAX_VALUE || id == Integer.MIN_VALUE) { + return 0; + } else { + return id; + } + } + + public final int getMinId(String indexName, String columnName) { + ElasticSearchClient client = getClient(); + SearchRequestBuilder searchRequestBuilder = client.prepareSearch(indexName); + searchRequestBuilder.setTypes("type"); + searchRequestBuilder.setSize(0); + MinAggregationBuilder aggregation = AggregationBuilders.min("agg").field(columnName); + searchRequestBuilder.addAggregation(aggregation); + + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + Min agg = searchResponse.getAggregations().get("agg"); + + int id = (int)agg.getValue(); + if (id == Integer.MAX_VALUE || id == Integer.MIN_VALUE) { + return 0; + } else { + return id; + } + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/EsDAODefineLoader.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/EsDAODefineLoader.java new file mode 100644 index 0000000000000000000000000000000000000000..1edd72f32849a1bb55b83b4000ab3a0f825a8b64 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/EsDAODefineLoader.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.es.dao; + +import java.util.ArrayList; +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 EsDAODefineLoader implements Loader> { + + private final Logger logger = LoggerFactory.getLogger(EsDAODefineLoader.class); + + @Override public List load() throws DefineException { + List esDAOs = new ArrayList<>(); + + EsDAODefinitionFile definitionFile = new EsDAODefinitionFile(); + logger.info("elasticsearch dao definition file name: {}", definitionFile.fileName()); + DefinitionLoader definitionLoader = DefinitionLoader.load(EsDAO.class, definitionFile); + for (EsDAO dao : definitionLoader) { + logger.info("loaded elasticsearch dao definition class: {}", dao.getClass().getName()); + esDAOs.add(dao); + } + return esDAOs; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/EsDAODefinitionFile.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/EsDAODefinitionFile.java new file mode 100644 index 0000000000000000000000000000000000000000..cadb614926f5a6553f83cd10f6857500befda16f --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/dao/EsDAODefinitionFile.java @@ -0,0 +1,31 @@ +/* + * 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.es.dao; + +import org.skywalking.apm.collector.core.define.DefinitionFile; + +/** + * @author peng-yongsheng + */ +public class EsDAODefinitionFile extends DefinitionFile { + + @Override protected String fileName() { + return "es_dao.define"; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/define/ElasticSearchColumnDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/define/ElasticSearchColumnDefine.java new file mode 100644 index 0000000000000000000000000000000000000000..fa2f4ad0c2501691390bc193c23db1bdc08c1d1a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/define/ElasticSearchColumnDefine.java @@ -0,0 +1,34 @@ +/* + * 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.es.define; + +import org.skywalking.apm.collector.storage.define.ColumnDefine; + +/** + * @author peng-yongsheng + */ +public class ElasticSearchColumnDefine extends ColumnDefine { + public ElasticSearchColumnDefine(String name, String type) { + super(name, type); + } + + public enum Type { + Binary, Boolean, Keyword, Long, Integer, Double, Text + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/define/ElasticSearchStorageInstaller.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/define/ElasticSearchStorageInstaller.java new file mode 100644 index 0000000000000000000000000000000000000000..3407e7abd3c5863f69d24d8f5d80d60827926f88 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/define/ElasticSearchStorageInstaller.java @@ -0,0 +1,133 @@ +/* + * 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.es.define; + +import java.io.IOException; +import java.util.List; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.index.IndexNotFoundException; +import org.skywalking.apm.collector.client.Client; +import org.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.skywalking.apm.collector.storage.StorageInstaller; +import org.skywalking.apm.collector.storage.define.ColumnDefine; +import org.skywalking.apm.collector.storage.define.TableDefine; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ElasticSearchStorageInstaller extends StorageInstaller { + + private final Logger logger = LoggerFactory.getLogger(ElasticSearchStorageInstaller.class); + + private final int indexShardsNumber; + private final int indexReplicasNumber; + + public ElasticSearchStorageInstaller(int indexShardsNumber, int indexReplicasNumber) { + this.indexShardsNumber = indexShardsNumber; + this.indexReplicasNumber = indexReplicasNumber; + } + + @Override protected void defineFilter(List tableDefines) { + int size = tableDefines.size(); + for (int i = size - 1; i >= 0; i--) { + if (!(tableDefines.get(i) instanceof ElasticSearchTableDefine)) { + tableDefines.remove(i); + } + } + } + + @Override protected boolean createTable(Client client, TableDefine tableDefine) { + ElasticSearchClient esClient = (ElasticSearchClient)client; + ElasticSearchTableDefine esTableDefine = (ElasticSearchTableDefine)tableDefine; + // mapping + XContentBuilder mappingBuilder = null; + + Settings settings = createSettingBuilder(esTableDefine); + try { + mappingBuilder = createMappingBuilder(esTableDefine); + logger.info("mapping builder str: {}", mappingBuilder.string()); + } catch (Exception e) { + logger.error("create {} index mapping builder error", esTableDefine.getName()); + } + + boolean isAcknowledged = esClient.createIndex(esTableDefine.getName(), esTableDefine.type(), settings, mappingBuilder); + logger.info("create {} index with type of {} finished, isAcknowledged: {}", esTableDefine.getName(), esTableDefine.type(), isAcknowledged); + return isAcknowledged; + } + + private Settings createSettingBuilder(ElasticSearchTableDefine tableDefine) { + return Settings.builder() + .put("index.number_of_shards", indexShardsNumber) + .put("index.number_of_replicas", indexReplicasNumber) + .put("index.refresh_interval", String.valueOf(tableDefine.refreshInterval()) + "s") + + .put("analysis.analyzer.collector_analyzer.tokenizer", "collector_tokenizer") + .put("analysis.tokenizer.collector_tokenizer.type", "standard") + .put("analysis.tokenizer.collector_tokenizer.max_token_length", 5) + .build(); + } + + private XContentBuilder createMappingBuilder(ElasticSearchTableDefine tableDefine) throws IOException { + XContentBuilder mappingBuilder = XContentFactory.jsonBuilder() + .startObject() + .startObject("properties"); + + for (ColumnDefine columnDefine : tableDefine.getColumnDefines()) { + ElasticSearchColumnDefine elasticSearchColumnDefine = (ElasticSearchColumnDefine)columnDefine; + + if (ElasticSearchColumnDefine.Type.Text.name().toLowerCase().equals(elasticSearchColumnDefine.getType().toLowerCase())) { + mappingBuilder + .startObject(elasticSearchColumnDefine.getName()) + .field("type", elasticSearchColumnDefine.getType().toLowerCase()) + .field("fielddata", true) + .endObject(); + } else { + mappingBuilder + .startObject(elasticSearchColumnDefine.getName()) + .field("type", elasticSearchColumnDefine.getType().toLowerCase()) + .endObject(); + } + } + + mappingBuilder + .endObject() + .endObject(); + logger.debug("create elasticsearch index: {}", mappingBuilder.string()); + return mappingBuilder; + } + + @Override protected boolean deleteTable(Client client, TableDefine tableDefine) { + ElasticSearchClient esClient = (ElasticSearchClient)client; + try { + return esClient.deleteIndex(tableDefine.getName()); + } catch (IndexNotFoundException e) { + logger.info("{} index not found", tableDefine.getName()); + } + return false; + } + + @Override protected boolean isExists(Client client, TableDefine tableDefine) { + ElasticSearchClient esClient = (ElasticSearchClient)client; + return esClient.isExistsIndex(tableDefine.getName()); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/define/ElasticSearchTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/define/ElasticSearchTableDefine.java new file mode 100644 index 0000000000000000000000000000000000000000..4216634b3431ede4a738e2c3e2e900384a289243 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/skywalking/apm/collector/storage/es/define/ElasticSearchTableDefine.java @@ -0,0 +1,37 @@ +/* + * 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.es.define; + +import org.skywalking.apm.collector.storage.define.TableDefine; + +/** + * @author peng-yongsheng + */ +public abstract class ElasticSearchTableDefine extends TableDefine { + + public ElasticSearchTableDefine(String name) { + super(name); + } + + public final String type() { + return "type"; + } + + public abstract int refreshInterval(); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java index 311aeaf87567c8d878a9d35a0e30f23b497a1b17..1dedd81be18a472653aa22cd40a4c7539fd7654f 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java @@ -18,17 +18,36 @@ package org.skywalking.apm.collector.storage.h2; +import java.util.List; import java.util.Properties; +import org.skywalking.apm.collector.client.h2.H2Client; +import org.skywalking.apm.collector.client.h2.H2ClientException; +import org.skywalking.apm.collector.core.define.DefineException; import org.skywalking.apm.collector.core.module.Module; import org.skywalking.apm.collector.core.module.ModuleProvider; import org.skywalking.apm.collector.core.module.ServiceNotProvidedException; +import org.skywalking.apm.collector.storage.StorageException; import org.skywalking.apm.collector.storage.StorageModule; +import org.skywalking.apm.collector.storage.dao.DAOContainer; +import org.skywalking.apm.collector.storage.h2.dao.H2DAO; +import org.skywalking.apm.collector.storage.h2.dao.H2DAODefineLoader; +import org.skywalking.apm.collector.storage.h2.define.H2StorageInstaller; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author peng-yongsheng */ public class StorageModuleH2Provider extends ModuleProvider { + private final Logger logger = LoggerFactory.getLogger(StorageModuleH2Provider.class); + + private static final String URL = "url"; + private static final String USER_NAME = "user_name"; + private static final String PASSWORD = "password"; + + private H2Client client; + @Override public String name() { return "h2"; } @@ -38,11 +57,29 @@ public class StorageModuleH2Provider extends ModuleProvider { } @Override public void prepare(Properties config) throws ServiceNotProvidedException { - + String url = config.getProperty(URL); + String userName = config.getProperty(USER_NAME); + String password = config.getProperty(PASSWORD); + client = new H2Client(url, userName, password); } @Override public void start(Properties config) throws ServiceNotProvidedException { + try { + client.initialize(); + + H2DAODefineLoader loader = new H2DAODefineLoader(); + List h2DAOs = loader.load(); + h2DAOs.forEach(h2DAO -> { + h2DAO.setClient(client); + String interFaceName = h2DAO.getClass().getInterfaces()[0].getName(); + DAOContainer.INSTANCE.put(interFaceName, h2DAO); + }); + H2StorageInstaller installer = new H2StorageInstaller(); + installer.install(client); + } catch (H2ClientException | DefineException | StorageException e) { + logger.error(e.getMessage(), e); + } } @Override public void notifyAfterCompleted() throws ServiceNotProvidedException { diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/BatchH2DAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/BatchH2DAO.java new file mode 100644 index 0000000000000000000000000000000000000000..4175f47bb2029268634ae215f696201d000b61ba --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/BatchH2DAO.java @@ -0,0 +1,85 @@ +/* + * 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.h2.dao; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.skywalking.apm.collector.client.h2.H2ClientException; +import org.skywalking.apm.collector.storage.dao.IBatchDAO; +import org.skywalking.apm.collector.storage.h2.define.H2SqlEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class BatchH2DAO extends H2DAO implements IBatchDAO { + private final Logger logger = LoggerFactory.getLogger(BatchH2DAO.class); + + @Override + public void batchPersistence(List batchCollection) { + if (batchCollection != null && batchCollection.size() > 0) { + logger.debug("the batch collection size is {}", batchCollection.size()); + Connection conn; + final Map batchSqls = new HashMap<>(); + try { + conn = getClient().getConnection(); + conn.setAutoCommit(true); + PreparedStatement ps; + for (Object entity : batchCollection) { + H2SqlEntity e = getH2SqlEntity(entity); + String sql = e.getSql(); + if (batchSqls.containsKey(sql)) { + ps = batchSqls.get(sql); + } else { + ps = conn.prepareStatement(sql); + batchSqls.put(sql, ps); + } + + Object[] params = e.getParams(); + if (params != null) { + logger.debug("the sql is {}, params size is {}, params: {}", e.getSql(), params.length, params); + for (int i = 0; i < params.length; i++) { + ps.setObject(i + 1, params[i]); + } + } + ps.addBatch(); + } + + for (String k : batchSqls.keySet()) { + batchSqls.get(k).executeBatch(); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + batchSqls.clear(); + } + } + + private H2SqlEntity getH2SqlEntity(Object entity) { + if (entity instanceof H2SqlEntity) { + return (H2SqlEntity)entity; + } + return null; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/H2DAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/H2DAO.java new file mode 100644 index 0000000000000000000000000000000000000000..ff6403353e250e6c9e3d64159cf0ea6a493363f0 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/H2DAO.java @@ -0,0 +1,61 @@ +/* + * 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.h2.dao; + +import java.sql.ResultSet; +import java.sql.SQLException; +import org.skywalking.apm.collector.client.h2.H2Client; +import org.skywalking.apm.collector.client.h2.H2ClientException; +import org.skywalking.apm.collector.storage.dao.DAO; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public abstract class H2DAO extends DAO { + private final Logger logger = LoggerFactory.getLogger(H2DAO.class); + + protected final int getMaxId(String tableName, String columnName) { + String sql = "select max(" + columnName + ") from " + tableName; + return getIntValueBySQL(sql); + } + + protected final int getMinId(String tableName, String columnName) { + String sql = "select min(" + columnName + ") from " + tableName; + return getIntValueBySQL(sql); + } + + private int getIntValueBySQL(String sql) { + H2Client client = getClient(); + try (ResultSet rs = client.executeQuery(sql, null)) { + if (rs.next()) { + int id = rs.getInt(1); + if (id == Integer.MAX_VALUE || id == Integer.MIN_VALUE) { + return 0; + } else { + return id; + } + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return 0; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/H2DAODefineLoader.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/H2DAODefineLoader.java new file mode 100644 index 0000000000000000000000000000000000000000..df93af70a21020a347e6c51426e4caba095022c2 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/H2DAODefineLoader.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.h2.dao; + +import java.util.ArrayList; +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 H2DAODefineLoader implements Loader> { + + private final Logger logger = LoggerFactory.getLogger(H2DAODefineLoader.class); + + @Override public List load() throws DefineException { + List h2DAOs = new ArrayList<>(); + + H2DAODefinitionFile definitionFile = new H2DAODefinitionFile(); + logger.info("h2 dao definition file name: {}", definitionFile.fileName()); + DefinitionLoader definitionLoader = DefinitionLoader.load(H2DAO.class, definitionFile); + for (H2DAO dao : definitionLoader) { + logger.info("loaded h2 dao definition class: {}", dao.getClass().getName()); + h2DAOs.add(dao); + } + return h2DAOs; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/H2DAODefinitionFile.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/H2DAODefinitionFile.java new file mode 100644 index 0000000000000000000000000000000000000000..ef47eff3420ee99ddcddae04af574ba29cef6570 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/dao/H2DAODefinitionFile.java @@ -0,0 +1,31 @@ +/* + * 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.h2.dao; + +import org.skywalking.apm.collector.core.define.DefinitionFile; + +/** + * @author peng-yongsheng + */ +public class H2DAODefinitionFile extends DefinitionFile { + + @Override protected String fileName() { + return "h2_dao.define"; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/H2ColumnDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/H2ColumnDefine.java new file mode 100644 index 0000000000000000000000000000000000000000..d8fd379ee29723c51ca7e7525d6bc28007245edd --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/H2ColumnDefine.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.storage.h2.define; + +import org.skywalking.apm.collector.storage.define.ColumnDefine; + +/** + * @author peng-yongsheng + */ +public class H2ColumnDefine extends ColumnDefine { + + public H2ColumnDefine(String name, String type) { + super(name, type); + } + + public enum Type { + Boolean, Varchar, Int, Bigint, BINARY, Double + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/H2SqlEntity.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/H2SqlEntity.java new file mode 100644 index 0000000000000000000000000000000000000000..39cba0ad9405d030b3a35cf31fc3c7d841912504 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/H2SqlEntity.java @@ -0,0 +1,43 @@ +/* + * 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.h2.define; + +/** + * @author clevertension + */ +public class H2SqlEntity { + private String sql; + private Object[] params; + + public String getSql() { + return sql; + } + + public void setSql(String sql) { + this.sql = sql; + } + + public Object[] getParams() { + return params; + } + + public void setParams(Object[] params) { + this.params = params; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/H2StorageInstaller.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/H2StorageInstaller.java new file mode 100644 index 0000000000000000000000000000000000000000..44c4eacee3b9c17761ed65fb5f24fe63a20d2b56 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/H2StorageInstaller.java @@ -0,0 +1,110 @@ +/* + * 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.h2.define; + +import org.skywalking.apm.collector.client.Client; +import org.skywalking.apm.collector.client.h2.H2Client; +import org.skywalking.apm.collector.client.h2.H2ClientException; +import org.skywalking.apm.collector.storage.StorageException; +import org.skywalking.apm.collector.storage.StorageInstallException; +import org.skywalking.apm.collector.storage.StorageInstaller; +import org.skywalking.apm.collector.storage.define.TableDefine; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class H2StorageInstaller extends StorageInstaller { + + private final Logger logger = LoggerFactory.getLogger(H2StorageInstaller.class); + + @Override protected void defineFilter(List tableDefines) { + int size = tableDefines.size(); + for (int i = size - 1; i >= 0; i--) { + if (!(tableDefines.get(i) instanceof H2TableDefine)) { + tableDefines.remove(i); + } + } + } + + @Override protected boolean isExists(Client client, TableDefine tableDefine) throws StorageException { + H2Client h2Client = (H2Client)client; + ResultSet rs = null; + try { + logger.info("check if table {} exist ", tableDefine.getName()); + rs = h2Client.getConnection().getMetaData().getTables(null, null, tableDefine.getName().toUpperCase(), null); + if (rs.next()) { + return true; + } + } catch (SQLException | H2ClientException e) { + throw new StorageInstallException(e.getMessage(), e); + } finally { + try { + if (rs != null) { + rs.close(); + } + } catch (SQLException e) { + throw new StorageInstallException(e.getMessage(), e); + } + } + return false; + } + + @Override protected boolean deleteTable(Client client, TableDefine tableDefine) throws StorageException { + H2Client h2Client = (H2Client)client; + try { + h2Client.execute("drop table if exists " + tableDefine.getName()); + return true; + } catch (H2ClientException e) { + throw new StorageInstallException(e.getMessage(), e); + } + } + + @Override protected boolean createTable(Client client, TableDefine tableDefine) throws StorageException { + H2Client h2Client = (H2Client)client; + H2TableDefine h2TableDefine = (H2TableDefine)tableDefine; + + StringBuilder sqlBuilder = new StringBuilder(); + sqlBuilder.append("CREATE TABLE ").append(h2TableDefine.getName()).append(" ("); + + h2TableDefine.getColumnDefines().forEach(columnDefine -> { + H2ColumnDefine h2ColumnDefine = (H2ColumnDefine)columnDefine; + if (h2ColumnDefine.getType().equals(H2ColumnDefine.Type.Varchar.name())) { + sqlBuilder.append(h2ColumnDefine.getName()).append(" ").append(h2ColumnDefine.getType()).append("(255),"); + } else { + sqlBuilder.append(h2ColumnDefine.getName()).append(" ").append(h2ColumnDefine.getType()).append(","); + } + }); + //remove last comma + sqlBuilder.delete(sqlBuilder.length() - 1, sqlBuilder.length()); + sqlBuilder.append(")"); + try { + logger.info("create h2 table with sql {}", sqlBuilder); + h2Client.execute(sqlBuilder.toString()); + } catch (H2ClientException e) { + throw new StorageInstallException(e.getMessage(), e); + } + return true; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/H2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/H2TableDefine.java new file mode 100644 index 0000000000000000000000000000000000000000..b638ddc5103174711b55535e02a7708b7644d716 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/skywalking/apm/collector/storage/h2/define/H2TableDefine.java @@ -0,0 +1,31 @@ +/* + * 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.h2.define; + +import org.skywalking.apm.collector.storage.define.TableDefine; + +/** + * @author peng-yongsheng + */ +public abstract class H2TableDefine extends TableDefine { + + public H2TableDefine(String name) { + super(name); + } +} diff --git a/apm-collector/apm-collector-storage/pom.xml b/apm-collector/apm-collector-storage/pom.xml index be293dd06ed5ebbf7fbd04d6ff6a5fa2db80fb4e..09df8908193d85aee2867a023c87bde6f0389b99 100644 --- a/apm-collector/apm-collector-storage/pom.xml +++ b/apm-collector/apm-collector-storage/pom.xml @@ -25,7 +25,7 @@ org.skywalking - persistence-component + client-component ${project.version}