diff --git a/apm-dist/release-docs/LICENSE b/apm-dist/release-docs/LICENSE
index facfc682365f488c6b21844bc385f4c1ee7505bc..c7c4cf568b7be17451a30664f313b38fe7b7747d 100644
--- a/apm-dist/release-docs/LICENSE
+++ b/apm-dist/release-docs/LICENSE
@@ -296,7 +296,7 @@ The text of each license is the standard Apache 2.0 license.
servo 0.10.1: https://github.com/Netflix/servo, Apache 2.0
validation-api 1.1.0.Final: http://beanvalidation.org/licensing/, Apache 2.0
zuul-core 1.3.0: https://github.com/Netflix/zuul, Apache 2.0
- ben-manes caffeine 2.6.2: https://github.com/ben-manes/caffeine, Apache 2.0
+ HikariCP 3.1.0: https://github.com/brettwooldridge/HikariCP, Apache 2.0
zipkin 2.9.1: https://github.com/openzipkin/zipkin, Apache 2.0
sharding-jdbc-core 2.0.3: https://github.com/sharding-sphere/sharding-sphere, Apache 2.0
kubernetes-client 2.0.0: https://github.com/kubernetes-client/java, Apache 2.0
diff --git a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
index ee154374cceeeeea9b74fc6b3d7aa2117c9b2b05..93a57a9d589402d4af4903250d8673aafb7214cc 100644
--- a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
+++ b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
@@ -68,7 +68,7 @@ public class ComponentsDefine {
public static final OfficialComponent JEDIS = new OfficialComponent(30, "Jedis");
- public static final OfficialComponent H2_JDBC_DRIVER = new OfficialComponent(32, "h2-jdbc-driver");
+ public static final OfficialComponent H2_JDBC_DRIVER = new OfficialComponent(32, "jdbc-jdbc-driver");
public static final OfficialComponent MYSQL_JDBC_DRIVER = new OfficialComponent(33, "mysql-connector-java");
diff --git a/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/h2/define/DriverInstrumentation.java b/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/h2/define/DriverInstrumentation.java
index 3d4fafd3cb12b3a21065fd3440dcaa25dd6ed279..1fd69d6532245af5ff3c5b4444b51b054cbd9614 100644
--- a/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/h2/define/DriverInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/h2/define/DriverInstrumentation.java
@@ -30,7 +30,7 @@ import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName
* @author zhangxin
*/
public class DriverInstrumentation extends AbstractDriverInstrumentation {
- private static final String CLASS_OF_INTERCEPT_H2_DRIVER = "org.h2.Driver";
+ private static final String CLASS_OF_INTERCEPT_H2_DRIVER = "org.jdbc.Driver";
@Override
protected ClassMatch enhanceClass() {
diff --git a/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/h2/define/JdbcConnectionInstrumentation.java b/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/h2/define/JdbcConnectionInstrumentation.java
index 0b778b266766334f1016e939efe6a1d34d6e6445..7ee6970d2c1b33cb6c3211e882a86c2310d83007 100644
--- a/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/h2/define/JdbcConnectionInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/h2/define/JdbcConnectionInstrumentation.java
@@ -29,7 +29,7 @@ import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName
* @author zhangxin
*/
public class JdbcConnectionInstrumentation extends AbstractConnectionInstrumentation {
- public static final String ENHANCE_CLASS = "org.h2.jdbc.JdbcConnection";
+ public static final String ENHANCE_CLASS = "org.jdbc.jdbc.JdbcConnection";
@Override protected ClassMatch enhanceClass() {
return byName(ENHANCE_CLASS);
diff --git a/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/h2/define/JdbcXAConnectionInstrumentation.java b/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/h2/define/JdbcXAConnectionInstrumentation.java
index 000f7ba7fccb70f53d4e3932e72ee6d2f80e0db7..6e6945c42870693073645b2bcfdbb4a9c85394fe 100644
--- a/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/h2/define/JdbcXAConnectionInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/h2/define/JdbcXAConnectionInstrumentation.java
@@ -34,8 +34,8 @@ import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName
*/
public class JdbcXAConnectionInstrumentation extends AbstractConnectionInstrumentation {
- public static final String ENHANCE_CLASS = "org.h2.jdbcx.JdbcXAConnection";
- public static final String CONSTRUCTOR_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jdbc.h2.JdbcXAConnectionConstructorInterceptor";
+ public static final String ENHANCE_CLASS = "org.jdbc.jdbcx.JdbcXAConnection";
+ public static final String CONSTRUCTOR_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jdbc.jdbc.JdbcXAConnectionConstructorInterceptor";
@Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[] {
diff --git a/oap-server/pom.xml b/oap-server/pom.xml
index c2995ce93b3f0b7fc10c94fe530266a41d8228b9..8652efab298714e6d5f39bd633d9475c0712ed48 100644
--- a/oap-server/pom.xml
+++ b/oap-server/pom.xml
@@ -60,6 +60,7 @@
6.3.2
2.9.9
2.0.0
+ 3.1.0
@@ -261,6 +262,11 @@
client-java
${kubernetes.version}
+
+ com.zaxxer
+ HikariCP
+ ${hikaricp.version}
+
\ No newline at end of file
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TraceQueryService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TraceQueryService.java
index 12d21d5ed8a3378701dbe2a36b574d3e0a03c073..d475b960e925ef34ac4e8f92688b67821794b43a 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TraceQueryService.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TraceQueryService.java
@@ -121,6 +121,7 @@ public class TraceQueryService implements Service {
}
}
+ trace.getSpans().clear();
trace.getSpans().addAll(sortedSpans);
return trace;
}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/IntValues.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/IntValues.java
index 9426c7935402ef00924add519b406fdf970547ba..aab3dff2dd5e517c40b8cac5a7461bf612a30eb5 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/IntValues.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/IntValues.java
@@ -18,17 +18,26 @@
package org.apache.skywalking.oap.server.core.query.entity;
-import java.util.*;
+import java.util.LinkedList;
+import java.util.List;
import lombok.Getter;
/**
* @author peng-yongsheng
*/
public class IntValues {
-
- @Getter private final List values;
+ @Getter private List values = new LinkedList<>();
- public IntValues() {
- this.values = new LinkedList<>();
+ public void addKVInt(KVInt e) {
+ values.add(e);
+ }
+
+ public int findValue(String id, int defaultValue) {
+ for (KVInt value : values) {
+ if (value.getId().equals(id)) {
+ return value.getValue();
+ }
+ }
+ return defaultValue;
}
}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Thermodynamic.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Thermodynamic.java
index e3b77eb1ffcede86ae04fe47e989a6fe583ca910..98331c019c6f07d9ce0067b754ec74ee0fc6575a 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Thermodynamic.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/entity/Thermodynamic.java
@@ -33,7 +33,28 @@ public class Thermodynamic {
this.nodes = new ArrayList<>();
}
- public void setNodeValue(int columnNum, int rowNum, Long value) {
+ public void fromMatrixData(List> thermodynamicValueMatrix, int numOfSteps) {
+ thermodynamicValueMatrix.forEach(columnOfThermodynamic -> {
+ if (columnOfThermodynamic.size() == 0) {
+ if (numOfSteps > 0) {
+ for (int i = 0; i < numOfSteps; i++) {
+ columnOfThermodynamic.add(0L);
+ }
+ }
+ }
+ }
+ );
+
+ for (int colNum = 0; colNum < thermodynamicValueMatrix.size(); colNum++) {
+ List column = thermodynamicValueMatrix.get(colNum);
+ for (int rowNum = 0; rowNum < column.size(); rowNum++) {
+ Long value = column.get(rowNum);
+ this.setNodeValue(colNum, rowNum, value);
+ }
+ }
+ }
+
+ private void setNodeValue(int columnNum, int rowNum, Long value) {
List element = new ArrayList<>(3);
element.add((long)columnNum);
element.add((long)rowNum);
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/worker/RegisterPersistentWorker.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/worker/RegisterPersistentWorker.java
index 0be299c3d19e484cf3b2fad1b1aeafae74b24fcb..dc6a6a77a05915ff7e2361c2b516ac2b4da9d825 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/worker/RegisterPersistentWorker.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/worker/RegisterPersistentWorker.java
@@ -71,10 +71,10 @@ public class RegisterPersistentWorker extends AbstractWorker {
try {
sources.values().forEach(source -> {
try {
- RegisterSource newSource = registerDAO.get(modelName, source.id());
- if (Objects.nonNull(newSource)) {
- newSource.combine(source);
- registerDAO.forceUpdate(modelName, newSource);
+ RegisterSource dbSource = registerDAO.get(modelName, source.id());
+ if (Objects.nonNull(dbSource)) {
+ dbSource.combine(source);
+ registerDAO.forceUpdate(modelName, dbSource);
} else {
int sequence = registerDAO.max(modelName);
source.setSequence(sequence + 1);
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceRelation.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceRelation.java
index 9ac904b2ee08f0d04f8ba05dfaa7c0c4b4ecf7aa..f4a3a182da988f23031cb66d2fc73681a4995d9d 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceRelation.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/ServiceRelation.java
@@ -38,6 +38,22 @@ public class ServiceRelation extends Source {
return String.valueOf(sourceServiceId) + Const.ID_SPLIT + String.valueOf(destServiceId) + Const.ID_SPLIT + String.valueOf(componentId);
}
+ /**
+ * @param entityId
+ * @return 1. sourceServiceId 2. destServiceId 3. componentId
+ */
+ public static Integer[] splitEntityId(String entityId) {
+ String[] parts = entityId.split(Const.ID_SPLIT);
+ if (parts.length != 3) {
+ throw new RuntimeException("Illegal ServiceRelation eneity id");
+ }
+ Integer[] ids = new Integer[3];
+ ids[0] = Integer.parseInt(parts[0]);
+ ids[1] = Integer.parseInt(parts[1]);
+ ids[2] = Integer.parseInt(parts[2]);
+ return ids;
+ }
+
@Getter @Setter private int sourceServiceId;
@Getter @Setter private String sourceServiceName;
@Getter @Setter private String sourceServiceInstanceName;
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/DownsampleingModelNameBuilder.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/DownSamplingModelNameBuilder.java
similarity index 94%
rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/DownsampleingModelNameBuilder.java
rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/DownSamplingModelNameBuilder.java
index 11a25e40dbd3d7b5d5dee01dd3d0506ff72b3e96..ca7bee9d070ea18ab03af30a7b639cb7e0f305d5 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/DownsampleingModelNameBuilder.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/DownSamplingModelNameBuilder.java
@@ -24,9 +24,9 @@ import org.apache.skywalking.oap.server.core.query.entity.Step;
/**
* @author peng-yongsheng
*/
-public class DownsampleingModelNameBuilder {
+public class DownSamplingModelNameBuilder {
- private DownsampleingModelNameBuilder() {
+ private DownSamplingModelNameBuilder() {
}
public static String build(Step step, String modelName) {
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageException.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageException.java
index b9a4d945efd71f0b6ebcef54478d0056dc0c3939..8f321a16a7cd7f602d8962c45c74d71f5162c3fa 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageException.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/StorageException.java
@@ -26,4 +26,8 @@ public class StorageException extends Exception {
public StorageException(String message) {
super(message);
}
+
+ public StorageException(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/ModelInstaller.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/ModelInstaller.java
index bba466b4f41a781489f737ab335279c4823d0af0..efd9026b1b9c94d981cf9aa786bd0c6ceb0ed5cd 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/ModelInstaller.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/model/ModelInstaller.java
@@ -64,7 +64,7 @@ public abstract class ModelInstaller {
for (Model model : downsamplingModels) {
if (!isExists(client, model)) {
- logger.info("table: {} not exists", model.getName());
+ logger.info("table: {} does not exist", model.getName());
createTable(client, model);
} else if (debug) {
logger.info("table: {} exists", model.getName());
diff --git a/oap-server/server-library/library-client/pom.xml b/oap-server/server-library/library-client/pom.xml
index a8a6bd594ab654f6e4d17f4eabcda14638d04ed4..26cc854b1f619fbc64347408fa586805172df929 100644
--- a/oap-server/server-library/library-client/pom.xml
+++ b/oap-server/server-library/library-client/pom.xml
@@ -36,8 +36,8 @@
grpc-core
- com.h2database
- h2
+ com.zaxxer
+ HikariCP
io.shardingjdbc
diff --git a/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/h2/H2Client.java b/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/h2/H2Client.java
deleted file mode 100644
index 41a24eda7edada3788a9f5dcc39725319b26f082..0000000000000000000000000000000000000000
--- a/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/h2/H2Client.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.skywalking.oap.server.library.client.h2;
-
-import java.sql.*;
-import org.apache.skywalking.oap.server.library.client.Client;
-import org.h2.util.IOUtils;
-import org.slf4j.*;
-
-/**
- * @author peng-yongsheng
- */
-public class H2Client implements Client {
-
- private final Logger logger = LoggerFactory.getLogger(H2Client.class);
-
- private Connection conn;
- private String url;
- private String userName;
- private String password;
-
- public H2Client() {
- this.url = "jdbc:h2:mem:collector";
- this.userName = "";
- this.password = "";
- }
-
- public H2Client(String url, String userName, String password) {
- this.url = url;
- this.userName = userName;
- this.password = password;
- }
-
- @Override public void initialize() throws H2ClientException {
- try {
- Class.forName("org.h2.Driver");
- conn = DriverManager.
- getConnection(this.url, this.userName, this.password);
- } catch (Exception e) {
- throw new H2ClientException(e.getMessage(), e);
- }
- }
-
- @Override public void shutdown() {
- IOUtils.closeSilently(conn);
- }
-
- public Connection getConnection() {
- return conn;
- }
-
- public void execute(String sql) throws H2ClientException {
- try (Statement statement = getConnection().createStatement()) {
- statement.execute(sql);
- statement.closeOnCompletion();
- } catch (SQLException e) {
- throw new H2ClientException(e.getMessage(), e);
- }
- }
-
- public ResultSet executeQuery(String sql, Object[] params) throws H2ClientException {
- logger.debug("execute query with result: {}", sql);
- ResultSet rs;
- PreparedStatement statement;
- try {
- statement = getConnection().prepareStatement(sql);
- if (params != null) {
- for (int i = 0; i < params.length; i++) {
- statement.setObject(i + 1, params[i]);
- }
- }
- rs = statement.executeQuery();
- statement.closeOnCompletion();
- } catch (SQLException e) {
- throw new H2ClientException(e.getMessage(), e);
- }
- return rs;
- }
-
- public boolean execute(String sql, Object[] params) throws H2ClientException {
- logger.debug("execute insert/update/delete: {}", sql);
- boolean flag;
- Connection conn = getConnection();
- try (PreparedStatement statement = conn.prepareStatement(sql)) {
- conn.setAutoCommit(true);
- if (params != null) {
- for (int i = 0; i < params.length; i++) {
- statement.setObject(i + 1, params[i]);
- }
- }
- flag = statement.execute();
- } catch (SQLException e) {
- throw new H2ClientException(e.getMessage(), e);
- }
- return flag;
- }
-}
diff --git a/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/h2/H2ClientException.java b/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/jdbc/JDBCClientException.java
similarity index 73%
rename from oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/h2/H2ClientException.java
rename to oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/jdbc/JDBCClientException.java
index 4c2d8c7b1b4d99a24c27c67f6e026c47b8c561ac..4e1a8ad1e4ec0d2e0d0ec16fe6139c712dc4a676 100644
--- a/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/h2/H2ClientException.java
+++ b/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/jdbc/JDBCClientException.java
@@ -16,20 +16,21 @@
*
*/
-package org.apache.skywalking.oap.server.library.client.h2;
+package org.apache.skywalking.oap.server.library.client.jdbc;
-import org.apache.skywalking.oap.server.library.client.ClientException;
+import java.io.IOException;
/**
- * @author peng-yongsheng
+ * @author wusheng
*/
-public class H2ClientException extends ClientException {
+public class JDBCClientException extends IOException {
- public H2ClientException(String message) {
+ public JDBCClientException(String message) {
super(message);
}
- public H2ClientException(String message, Throwable cause) {
+ public JDBCClientException(String message, Throwable cause) {
super(message, cause);
}
}
+
diff --git a/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/jdbc/hikaricp/JDBCHikariCPClient.java b/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/jdbc/hikaricp/JDBCHikariCPClient.java
new file mode 100644
index 0000000000000000000000000000000000000000..b09bbbfb22452a725dbd7395dc221699f00f9c86
--- /dev/null
+++ b/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/jdbc/hikaricp/JDBCHikariCPClient.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.library.client.jdbc.hikaricp;
+
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
+import org.apache.skywalking.oap.server.library.client.Client;
+import org.apache.skywalking.oap.server.library.client.ClientException;
+import org.apache.skywalking.oap.server.library.client.jdbc.JDBCClientException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * JDBC Client uses HikariCP connection management lib to execute SQL.
+ *
+ * @author wusheng
+ */
+public class JDBCHikariCPClient implements Client {
+ private final Logger logger = LoggerFactory.getLogger(JDBCHikariCPClient.class);
+
+ private HikariDataSource dataSource;
+ private HikariConfig hikariConfig;
+
+ public JDBCHikariCPClient(Properties properties) {
+ hikariConfig = new HikariConfig(properties);
+ }
+
+ @Override public void initialize() throws ClientException {
+ dataSource = new HikariDataSource(hikariConfig);
+ }
+
+ @Override public void shutdown() {
+ }
+
+ public Connection getConnection() throws JDBCClientException {
+ try {
+ Connection connection = dataSource.getConnection();
+ connection.setAutoCommit(true);
+ return connection;
+ } catch (SQLException e) {
+ throw new JDBCClientException(e.getMessage(), e);
+ }
+ }
+
+ public void close(Connection connection) {
+ if (connection != null) {
+ try {
+ connection.commit();
+ connection.close();
+ } catch (SQLException e) {
+ }
+ }
+ }
+
+ public void execute(Connection connection, String sql) throws JDBCClientException {
+ try {
+ connection.setReadOnly(true);
+ } catch (SQLException e) {
+
+ }
+ logger.debug("execute aql: {}", sql);
+ try (Statement statement = connection.createStatement()) {
+ statement.execute(sql);
+ statement.closeOnCompletion();
+ } catch (SQLException e) {
+ throw new JDBCClientException(e.getMessage(), e);
+ }
+ }
+
+ public ResultSet executeQuery(Connection connection, String sql, Object... params) throws JDBCClientException {
+ logger.debug("execute query with result: {}", sql);
+ ResultSet rs;
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement(sql);
+ if (params != null) {
+ for (int i = 0; i < params.length; i++) {
+ Object param = params[i];
+ if (param instanceof String) {
+ statement.setString(i + 1, (String)param);
+ } else if (param instanceof Integer) {
+ statement.setInt(i + 1, (int)param);
+ } else if (param instanceof Double) {
+ statement.setDouble(i + 1, (double)param);
+ } else if (param instanceof Long) {
+ statement.setLong(i + 1, (long)param);
+ } else {
+ throw new JDBCClientException("Unsupported data type, type=" + param.getClass().getName());
+ }
+ }
+ }
+ rs = statement.executeQuery();
+ statement.closeOnCompletion();
+ } catch (SQLException e) {
+ if (statement != null) {
+ try {
+ statement.close();
+ } catch (SQLException e1) {
+ }
+ }
+ throw new JDBCClientException(e.getMessage(), e);
+ }
+
+ return rs;
+ }
+}
diff --git a/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/shardingjdbc/ShardingjdbcClient.java b/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/shardingjdbc/ShardingjdbcClient.java
deleted file mode 100644
index 3fb755900adfeb23687f8925b4f61834b978c4c6..0000000000000000000000000000000000000000
--- a/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/shardingjdbc/ShardingjdbcClient.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.skywalking.oap.server.library.client.shardingjdbc;
-
-import io.shardingjdbc.core.api.ShardingDataSourceFactory;
-import io.shardingjdbc.core.api.config.ShardingRuleConfiguration;
-import java.sql.*;
-import java.util.*;
-import javax.sql.DataSource;
-import org.apache.commons.dbcp.BasicDataSource;
-import org.apache.skywalking.oap.server.library.client.Client;
-import org.slf4j.*;
-
-/**
- * @author linjiaqi
- */
-public class ShardingjdbcClient implements Client {
-
- private static final Logger logger = LoggerFactory.getLogger(ShardingjdbcClient.class);
-
- private Map shardingjdbcClientConfig;
-
- private ShardingRuleConfiguration shardingRuleConfiguration;
-
- private Map shardingDataSource = new HashMap();
-
- private DataSource dataSource;
-
- public ShardingjdbcClient(Map shardingjdbcClientConfig,
- ShardingRuleConfiguration shardingRuleConfiguration) {
- this.shardingjdbcClientConfig = shardingjdbcClientConfig;
- this.shardingRuleConfiguration = shardingRuleConfiguration;
- }
-
- @Override public void initialize() throws ShardingjdbcClientException {
- try {
- shardingjdbcClientConfig.forEach((key, value) -> {
- BasicDataSource basicDataSource = new BasicDataSource();
- basicDataSource.setDriverClassName(value.getDriverClass());
- basicDataSource.setUrl(value.getUrl());
- basicDataSource.setUsername(value.getUserName());
- basicDataSource.setPassword(value.getPassword());
- shardingDataSource.put(key, basicDataSource);
- logger.info("add sharding datasource: {}, url: {}", key, value.getUrl());
- });
- dataSource = ShardingDataSourceFactory.createDataSource(shardingDataSource, shardingRuleConfiguration,
- new HashMap(), new Properties());
- } catch (Exception e) {
- logger.error("case the exception is 'Cannot load JDBC driver class', please add the driver mysql-connector-java-5.1.36.jar to collector-libs manual");
- throw new ShardingjdbcClientException(e.getMessage(), e);
- }
- }
-
- @Override public void shutdown() {
-
- }
-
- public Connection getConnection() throws SQLException {
- return dataSource.getConnection();
- }
-
- public void execute(String sql) throws ShardingjdbcClientException {
- Connection conn = null;
- Statement statement = null;
- try {
- conn = getConnection();
- statement = conn.createStatement();
- statement.execute(sql);
- } catch (SQLException e) {
- throw new ShardingjdbcClientException(e.getMessage(), e);
- } finally {
- try {
- if (statement != null) {
- statement.close();
- }
- if (conn != null) {
- conn.close();
- }
- } catch (SQLException e) {
- throw new ShardingjdbcClientException(e.getMessage(), e);
- }
- }
- }
-
- public ResultSet executeQuery(String sql, Object[] params) throws ShardingjdbcClientException {
- logger.debug("execute query with result: {}", sql);
- ResultSet rs;
- PreparedStatement statement;
- try {
- statement = getConnection().prepareStatement(sql);
- if (params != null) {
- for (int i = 0; i < params.length; i++) {
- statement.setObject(i + 1, params[i]);
- }
- }
- rs = statement.executeQuery();
- } catch (SQLException e) {
- throw new ShardingjdbcClientException(e.getMessage(), e);
- }
- return rs;
- }
-
- public boolean execute(String sql, Object[] params) throws ShardingjdbcClientException {
- logger.debug("execute insert/update/delete: {}", sql);
- boolean flag;
- Connection conn = null;
- PreparedStatement statement = null;
- try {
- conn = getConnection();
- conn.setAutoCommit(true);
- statement = conn.prepareStatement(sql);
- if (params != null) {
- for (int i = 0; i < params.length; i++) {
- statement.setObject(i + 1, params[i]);
- }
- }
- flag = statement.execute();
- } catch (SQLException e) {
- throw new ShardingjdbcClientException(e.getMessage(), e);
- } finally {
- try {
- if (statement != null) {
- statement.close();
- }
- if (conn != null) {
- conn.close();
- }
- } catch (SQLException e) {
- throw new ShardingjdbcClientException(e.getMessage(), e);
- }
- }
- return flag;
- }
-}
diff --git a/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/shardingjdbc/ShardingjdbcClientConfig.java b/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/shardingjdbc/ShardingjdbcClientConfig.java
deleted file mode 100644
index 08edb35e42c4f5a9ca1195a47c261cade43fd727..0000000000000000000000000000000000000000
--- a/oap-server/server-library/library-client/src/main/java/org/apache/skywalking/oap/server/library/client/shardingjdbc/ShardingjdbcClientConfig.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.skywalking.oap.server.library.client.shardingjdbc;
-
-/**
- * @author linjiaqi
- */
-public class ShardingjdbcClientConfig {
-
- private String driverClass;
- private String url;
- private String userName;
- private String password;
-
- public ShardingjdbcClientConfig() {
-
- }
-
- public ShardingjdbcClientConfig(String driverClass, String url, String username, String password) {
- this.driverClass = driverClass;
- this.url = url;
- this.userName = username;
- this.password = password;
- }
-
- public String getDriverClass() {
- return driverClass;
- }
-
- public void setDriverClass(String driverClass) {
- this.driverClass = driverClass;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-}
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol b/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
index 3a83be79a9c23aad6576ed2a4a04b82de6d7a829..1122e97b5604ae96447bd58ecdb248d7e02952aa 160000
--- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
@@ -1 +1 @@
-Subproject commit 3a83be79a9c23aad6576ed2a4a04b82de6d7a829
+Subproject commit 1122e97b5604ae96447bd58ecdb248d7e02952aa
diff --git a/oap-server/server-receiver-plugin/skywalking-register-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/register/provider/RegisterModuleProvider.java b/oap-server/server-receiver-plugin/skywalking-register-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/register/provider/RegisterModuleProvider.java
index d6a6f2f4cbbde88508cbd7830e9ed3ac557a136e..10cafe80f1e3d6ef912ec6e4b3de76973ba1212d 100644
--- a/oap-server/server-receiver-plugin/skywalking-register-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/register/provider/RegisterModuleProvider.java
+++ b/oap-server/server-receiver-plugin/skywalking-register-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/register/provider/RegisterModuleProvider.java
@@ -22,6 +22,10 @@ import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.server.*;
import org.apache.skywalking.oap.server.library.module.*;
import org.apache.skywalking.oap.server.receiver.register.module.RegisterModule;
+import org.apache.skywalking.oap.server.receiver.register.provider.handler.v5.grpc.ApplicationRegisterHandler;
+import org.apache.skywalking.oap.server.receiver.register.provider.handler.v5.grpc.InstanceDiscoveryServiceHandler;
+import org.apache.skywalking.oap.server.receiver.register.provider.handler.v5.grpc.NetworkAddressRegisterServiceHandler;
+import org.apache.skywalking.oap.server.receiver.register.provider.handler.v5.grpc.ServiceNameDiscoveryHandler;
import org.apache.skywalking.oap.server.receiver.register.provider.handler.v5.rest.*;
/**
@@ -45,6 +49,13 @@ public class RegisterModuleProvider extends ModuleProvider {
}
@Override public void start() {
+ GRPCHandlerRegister grpcHandlerRegister = getManager().find(CoreModule.NAME).getService(GRPCHandlerRegister.class);
+ grpcHandlerRegister.addHandler(new ApplicationRegisterHandler(getManager()));
+ grpcHandlerRegister.addHandler(new InstanceDiscoveryServiceHandler(getManager()));
+ grpcHandlerRegister.addHandler(new ServiceNameDiscoveryHandler(getManager()));
+ grpcHandlerRegister.addHandler(new NetworkAddressRegisterServiceHandler(getManager()));
+
+
JettyHandlerRegister jettyHandlerRegister = getManager().find(CoreModule.NAME).getService(JettyHandlerRegister.class);
jettyHandlerRegister.addHandler(new ApplicationRegisterServletHandler(getManager()));
jettyHandlerRegister.addHandler(new InstanceDiscoveryServletHandler(getManager()));
diff --git a/oap-server/server-starter/pom.xml b/oap-server/server-starter/pom.xml
index bcfbc5ea6eb6a17d2135a03861436378ce1b0636..9bbe894e1c7ffb23a07131cff2cb2a1fcfe4a119 100644
--- a/oap-server/server-starter/pom.xml
+++ b/oap-server/server-starter/pom.xml
@@ -85,7 +85,7 @@
org.apache.skywalking
- storage-h2-plugin
+ storage-jdbc-hikaricp-plugin
${project.version}
diff --git a/oap-server/server-starter/src/main/assembly/application.yml b/oap-server/server-starter/src/main/assembly/application.yml
index 9fac3e79bf9f5c5948b6ab601942cedcbfa05306..7064bc30c133741747d6288666a6a2d80b1ad854 100644
--- a/oap-server/server-starter/src/main/assembly/application.yml
+++ b/oap-server/server-starter/src/main/assembly/application.yml
@@ -44,15 +44,19 @@ core:
dayMetricsDataTTL: 45 # Unit is day
monthMetricsDataTTL: 18 # Unit is month
storage:
- elasticsearch:
- clusterNodes: localhost:9200
- indexShardsNumber: 2
- indexReplicasNumber: 0
- # Batch process setting, refer to https://www.elastic.co/guide/en/elasticsearch/client/java-api/5.5/java-docs-bulk-processor.html
- bulkActions: 2000 # Execute the bulk every 2000 requests
- bulkSize: 20 # flush the bulk every 20mb
- flushInterval: 10 # flush the bulk every 10 seconds whatever the number of requests
- concurrentRequests: 2 # the number of concurrent requests
+ h2:
+ driver: org.h2.jdbcx.JdbcDataSource
+ url: jdbc:h2:mem:skywalking-oap-db
+ user: sa
+# elasticsearch:
+# clusterNodes: localhost:9200
+# indexShardsNumber: 2
+# indexReplicasNumber: 0
+# # Batch process setting, refer to https://www.elastic.co/guide/en/elasticsearch/client/java-api/5.5/java-docs-bulk-processor.html
+# bulkActions: 2000 # Execute the bulk every 2000 requests
+# bulkSize: 20 # flush the bulk every 20mb
+# flushInterval: 10 # flush the bulk every 10 seconds whatever the number of requests
+# concurrentRequests: 2 # the number of concurrent requests
receiver-register:
default:
receiver-trace:
diff --git a/oap-server/server-starter/src/main/resources/application.yml b/oap-server/server-starter/src/main/resources/application.yml
index 9fac3e79bf9f5c5948b6ab601942cedcbfa05306..2236cfc28e24436a4278ffea8bbe49b29ac6e390 100644
--- a/oap-server/server-starter/src/main/resources/application.yml
+++ b/oap-server/server-starter/src/main/resources/application.yml
@@ -53,6 +53,10 @@ storage:
bulkSize: 20 # flush the bulk every 20mb
flushInterval: 10 # flush the bulk every 10 seconds whatever the number of requests
concurrentRequests: 2 # the number of concurrent requests
+# h2:
+# driver: org.h2.jdbcx.JdbcDataSource
+# url: jdbc:h2:mem:skywalking-oap-db
+# user: sa
receiver-register:
default:
receiver-trace:
diff --git a/oap-server/server-starter/src/main/resources/log4j2.xml b/oap-server/server-starter/src/main/resources/log4j2.xml
index 59229302eec23e6e290d5c910a17cd472ec58f93..0353842db4e2296e2cbe61bb53935a5f80773a42 100644
--- a/oap-server/server-starter/src/main/resources/log4j2.xml
+++ b/oap-server/server-starter/src/main/resources/log4j2.xml
@@ -17,7 +17,7 @@
~
-->
-
+
@@ -33,8 +33,9 @@
-
-
+
+
+
diff --git a/oap-server/server-storage-plugin/pom.xml b/oap-server/server-storage-plugin/pom.xml
index ff237b04a06bbd6c70ec203ba1b2e41fbb5676e7..48d5ac9b4ae7c6c98d44e126347be3d0abd6f55a 100644
--- a/oap-server/server-storage-plugin/pom.xml
+++ b/oap-server/server-storage-plugin/pom.xml
@@ -30,7 +30,7 @@
server-storage-plugin
pom
- storage-h2-plugin
+ storage-jdbc-hikaricp-plugin
storage-elasticsearch-plugin
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/EndpointInventoryCacheEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/EndpointInventoryCacheEsDAO.java
index ecdf877f9a34654c40f60e0178f184f17cea6528..df187ed3cac36285bdbb0374ac427ff183ff4f96 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/EndpointInventoryCacheEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/EndpointInventoryCacheEsDAO.java
@@ -53,7 +53,7 @@ public class EndpointInventoryCacheEsDAO extends EsDAO implements IEndpointInven
return Const.NONE;
}
} catch (Throwable e) {
- logger.error(e.getMessage());
+ logger.error(e.getMessage(), e);
return Const.NONE;
}
}
@@ -72,7 +72,7 @@ public class EndpointInventoryCacheEsDAO extends EsDAO implements IEndpointInven
return null;
}
} catch (Throwable e) {
- logger.error(e.getMessage());
+ logger.error(e.getMessage(), e);
return null;
}
}
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/NetworkAddressInventoryCacheEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/NetworkAddressInventoryCacheEsDAO.java
index 9022f860ba95919a94d4d7a011582dae44e60692..ebec15fa15cedced255821fe7da74886ee93b773 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/NetworkAddressInventoryCacheEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/NetworkAddressInventoryCacheEsDAO.java
@@ -48,7 +48,7 @@ public class NetworkAddressInventoryCacheEsDAO extends EsDAO implements INetwork
String id = NetworkAddressInventory.buildId(networkAddress);
GetResponse response = getClient().get(NetworkAddressInventory.MODEL_NAME, id);
if (response.isExists()) {
- return (int)response.getSource().getOrDefault(RegisterSource.SEQUENCE, 0);
+ return (int)response.getSource().getOrDefault(NetworkAddressInventory.SEQUENCE, 0);
} else {
return Const.NONE;
}
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java
index bbff00d10796064c73e8686a8433a30fb9781d34..a3a79f76965638f245ff3a02a153ad36fb1401ef 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AggregationQueryEsDAO.java
@@ -23,7 +23,7 @@ import java.util.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
import org.apache.skywalking.oap.server.core.query.entity.*;
import org.apache.skywalking.oap.server.core.register.*;
-import org.apache.skywalking.oap.server.core.storage.DownsampleingModelNameBuilder;
+import org.apache.skywalking.oap.server.core.storage.DownSamplingModelNameBuilder;
import org.apache.skywalking.oap.server.core.storage.query.IAggregationQueryDAO;
import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.EsDAO;
@@ -46,7 +46,7 @@ public class AggregationQueryEsDAO extends EsDAO implements IAggregationQueryDAO
@Override
public List getServiceTopN(String indName, String valueCName, int topN, Step step, long startTB,
long endTB, Order order) throws IOException {
- String indexName = DownsampleingModelNameBuilder.build(step, indName);
+ String indexName = DownSamplingModelNameBuilder.build(step, indName);
SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource();
sourceBuilder.query(QueryBuilders.rangeQuery(Indicator.TIME_BUCKET).lte(endTB).gte(startTB));
@@ -55,7 +55,7 @@ public class AggregationQueryEsDAO extends EsDAO implements IAggregationQueryDAO
@Override public List getAllServiceInstanceTopN(String indName, String valueCName, int topN, Step step,
long startTB, long endTB, Order order) throws IOException {
- String indexName = DownsampleingModelNameBuilder.build(step, indName);
+ String indexName = DownSamplingModelNameBuilder.build(step, indName);
SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource();
sourceBuilder.query(QueryBuilders.rangeQuery(Indicator.TIME_BUCKET).lte(endTB).gte(startTB));
@@ -64,7 +64,7 @@ public class AggregationQueryEsDAO extends EsDAO implements IAggregationQueryDAO
@Override public List getServiceInstanceTopN(int serviceId, String indName, String valueCName, int topN,
Step step, long startTB, long endTB, Order order) throws IOException {
- String indexName = DownsampleingModelNameBuilder.build(step, indName);
+ String indexName = DownSamplingModelNameBuilder.build(step, indName);
SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource();
@@ -80,7 +80,7 @@ public class AggregationQueryEsDAO extends EsDAO implements IAggregationQueryDAO
@Override
public List getAllEndpointTopN(String indName, String valueCName, int topN, Step step, long startTB,
long endTB, Order order) throws IOException {
- String indexName = DownsampleingModelNameBuilder.build(step, indName);
+ String indexName = DownSamplingModelNameBuilder.build(step, indName);
SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource();
sourceBuilder.query(QueryBuilders.rangeQuery(Indicator.TIME_BUCKET).lte(endTB).gte(startTB));
@@ -90,7 +90,7 @@ public class AggregationQueryEsDAO extends EsDAO implements IAggregationQueryDAO
@Override
public List getEndpointTopN(int serviceId, String indName, String valueCName, int topN, Step step,
long startTB, long endTB, Order order) throws IOException {
- String indexName = DownsampleingModelNameBuilder.build(step, indName);
+ String indexName = DownSamplingModelNameBuilder.build(step, indName);
SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource();
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricQueryEsDAO.java
index ad897b6429421e43639de10a336d117984322d84..b4ae33df74299633e8d1071545d99e1255ea9c1d 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricQueryEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetricQueryEsDAO.java
@@ -23,7 +23,7 @@ import java.util.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
import org.apache.skywalking.oap.server.core.query.entity.*;
import org.apache.skywalking.oap.server.core.query.sql.*;
-import org.apache.skywalking.oap.server.core.storage.DownsampleingModelNameBuilder;
+import org.apache.skywalking.oap.server.core.storage.DownSamplingModelNameBuilder;
import org.apache.skywalking.oap.server.core.storage.query.IMetricQueryDAO;
import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.EsDAO;
@@ -46,7 +46,7 @@ public class MetricQueryEsDAO extends EsDAO implements IMetricQueryDAO {
public IntValues getValues(String indName, Step step, long startTB, long endTB, Where where, String valueCName,
Function function) throws IOException {
- String indexName = DownsampleingModelNameBuilder.build(step, indName);
+ String indexName = DownSamplingModelNameBuilder.build(step, indName);
SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource();
queryBuild(sourceBuilder, where, startTB, endTB);
@@ -101,7 +101,7 @@ public class MetricQueryEsDAO extends EsDAO implements IMetricQueryDAO {
@Override public IntValues getLinearIntValues(String indName, Step step, List ids,
String valueCName) throws IOException {
- String indexName = DownsampleingModelNameBuilder.build(step, indName);
+ String indexName = DownSamplingModelNameBuilder.build(step, indName);
MultiGetResponse response = getClient().multiGet(indexName, ids);
@@ -122,7 +122,7 @@ public class MetricQueryEsDAO extends EsDAO implements IMetricQueryDAO {
@Override public Thermodynamic getThermodynamic(String indName, Step step, List ids,
String valueCName) throws IOException {
- String indexName = DownsampleingModelNameBuilder.build(step, indName);
+ String indexName = DownSamplingModelNameBuilder.build(step, indName);
MultiGetResponse response = getClient().multiGet(indexName, ids);
@@ -138,7 +138,7 @@ public class MetricQueryEsDAO extends EsDAO implements IMetricQueryDAO {
} else {
int axisYStep = ((Number)source.get(ThermodynamicIndicator.STEP)).intValue();
thermodynamic.setAxisYStep(axisYStep);
- numOfSteps = ((Number)source.get(ThermodynamicIndicator.NUM_OF_STEPS)).intValue();
+ numOfSteps = ((Number)source.get(ThermodynamicIndicator.NUM_OF_STEPS)).intValue() + 1;
String value = (String)source.get(ThermodynamicIndicator.DETAIL_GROUP);
IntKeyLongValueArray intKeyLongValues = new IntKeyLongValueArray(5);
@@ -157,26 +157,7 @@ public class MetricQueryEsDAO extends EsDAO implements IMetricQueryDAO {
}
}
- int defaultNumOfSteps = numOfSteps;
-
- thermodynamicValueMatrix.forEach(columnOfThermodynamic -> {
- if (columnOfThermodynamic.size() == 0) {
- if (defaultNumOfSteps > 0) {
- for (int i = 0; i < defaultNumOfSteps; i++) {
- columnOfThermodynamic.add(0L);
- }
- }
- }
- }
- );
-
- for (int colNum = 0; colNum < thermodynamicValueMatrix.size(); colNum++) {
- List column = thermodynamicValueMatrix.get(colNum);
- for (int rowNum = 0; rowNum < column.size(); rowNum++) {
- Long value = column.get(rowNum);
- thermodynamic.setNodeValue(colNum, rowNum, value);
- }
- }
+ thermodynamic.fromMatrixData(thermodynamicValueMatrix, numOfSteps);
return thermodynamic;
}
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TopologyQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TopologyQueryEsDAO.java
index ac3912ead976ee40bed6cda22513cefc9dd73374..d067b1e5774a6f1131359ea16490efa18c2e072b 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TopologyQueryEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TopologyQueryEsDAO.java
@@ -19,20 +19,25 @@
package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query;
import java.io.IOException;
-import java.util.*;
-import org.apache.skywalking.oap.server.core.*;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.skywalking.oap.server.core.UnexpectedException;
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
import org.apache.skywalking.oap.server.core.analysis.manual.endpointrelation.EndpointRelationServerSideIndicator;
-import org.apache.skywalking.oap.server.core.analysis.manual.servicerelation.*;
-import org.apache.skywalking.oap.server.core.query.entity.*;
+import org.apache.skywalking.oap.server.core.analysis.manual.servicerelation.ServiceRelationClientSideIndicator;
+import org.apache.skywalking.oap.server.core.analysis.manual.servicerelation.ServiceRelationServerSideIndicator;
+import org.apache.skywalking.oap.server.core.query.entity.Call;
+import org.apache.skywalking.oap.server.core.query.entity.Step;
import org.apache.skywalking.oap.server.core.source.DetectPoint;
-import org.apache.skywalking.oap.server.core.storage.DownsampleingModelNameBuilder;
+import org.apache.skywalking.oap.server.core.source.ServiceRelation;
+import org.apache.skywalking.oap.server.core.storage.DownSamplingModelNameBuilder;
import org.apache.skywalking.oap.server.core.storage.query.ITopologyQueryDAO;
import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient;
import org.apache.skywalking.oap.server.library.util.CollectionUtils;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.EsDAO;
import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.index.query.*;
+import org.elasticsearch.index.query.BoolQueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.builder.SearchSourceBuilder;
@@ -57,7 +62,7 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO {
sourceBuilder.size(0);
setQueryCondition(sourceBuilder, startTB, endTB, serviceIds);
- String indexName = DownsampleingModelNameBuilder.build(step, ServiceRelationServerSideIndicator.INDEX_NAME);
+ String indexName = DownSamplingModelNameBuilder.build(step, ServiceRelationServerSideIndicator.INDEX_NAME);
return load(sourceBuilder, indexName, DetectPoint.SERVER);
}
@@ -72,7 +77,7 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO {
sourceBuilder.size(0);
setQueryCondition(sourceBuilder, startTB, endTB, serviceIds);
- String indexName = DownsampleingModelNameBuilder.build(step, ServiceRelationClientSideIndicator.INDEX_NAME);
+ String indexName = DownSamplingModelNameBuilder.build(step, ServiceRelationClientSideIndicator.INDEX_NAME);
return load(sourceBuilder, indexName, DetectPoint.CLIENT);
}
@@ -95,7 +100,7 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO {
}
@Override public List loadServerSideServiceRelations(Step step, long startTB, long endTB) throws IOException {
- String indexName = DownsampleingModelNameBuilder.build(step, ServiceRelationServerSideIndicator.INDEX_NAME);
+ String indexName = DownSamplingModelNameBuilder.build(step, ServiceRelationServerSideIndicator.INDEX_NAME);
SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource();
sourceBuilder.query(QueryBuilders.rangeQuery(ServiceRelationServerSideIndicator.TIME_BUCKET).gte(startTB).lte(endTB));
sourceBuilder.size(0);
@@ -104,7 +109,7 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO {
}
@Override public List loadClientSideServiceRelations(Step step, long startTB, long endTB) throws IOException {
- String indexName = DownsampleingModelNameBuilder.build(step, ServiceRelationClientSideIndicator.INDEX_NAME);
+ String indexName = DownSamplingModelNameBuilder.build(step, ServiceRelationClientSideIndicator.INDEX_NAME);
SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource();
sourceBuilder.query(QueryBuilders.rangeQuery(ServiceRelationServerSideIndicator.TIME_BUCKET).gte(startTB).lte(endTB));
sourceBuilder.size(0);
@@ -115,7 +120,7 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO {
@Override
public List loadSpecifiedDestOfServerSideEndpointRelations(Step step, long startTB, long endTB,
int destEndpointId) throws IOException {
- String indexName = DownsampleingModelNameBuilder.build(step, EndpointRelationServerSideIndicator.INDEX_NAME);
+ String indexName = DownSamplingModelNameBuilder.build(step, EndpointRelationServerSideIndicator.INDEX_NAME);
SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource();
sourceBuilder.size(0);
@@ -143,16 +148,15 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO {
Terms entityTerms = response.getAggregations().get(Indicator.ENTITY_ID);
for (Terms.Bucket entityBucket : entityTerms.getBuckets()) {
String entityId = entityBucket.getKeyAsString();
- String[] ids = entityId.split(Const.ID_SPLIT);
- if (ids.length == 3) {
- Call call = new Call();
- call.setId(entityBucket.getKeyAsString());
- call.setSource(Integer.valueOf(ids[0]));
- call.setTarget(Integer.valueOf(ids[1]));
- call.setComponentId(Integer.valueOf(ids[2]));
- call.setDetectPoint(detectPoint);
- calls.add(call);
- }
+
+ Integer[] entityIds = ServiceRelation.splitEntityId(entityId);
+ Call call = new Call();
+ call.setId(entityId);
+ call.setSource(entityIds[0]);
+ call.setTarget(entityIds[1]);
+ call.setComponentId(entityIds[2]);
+ call.setDetectPoint(detectPoint);
+ calls.add(call);
}
return calls;
}
diff --git a/oap-server/server-storage-plugin/storage-h2-plugin/pom.xml b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/pom.xml
similarity index 67%
rename from oap-server/server-storage-plugin/storage-h2-plugin/pom.xml
rename to oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/pom.xml
index 2cb644e48e9536c0a8fc77b304fc5543f3000798..523467ea5d7548fbbb59cbd9f4b4ef1de8407366 100644
--- a/oap-server/server-storage-plugin/storage-h2-plugin/pom.xml
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/pom.xml
@@ -27,7 +27,24 @@
4.0.0
- storage-h2-plugin
+ storage-jdbc-hikaricp-plugin
jar
+
+
+ org.apache.skywalking
+ server-core
+ ${project.version}
+
+
+ org.apache.skywalking
+ library-client
+ ${project.version}
+
+
+ com.h2database
+ h2
+
+
+
\ No newline at end of file
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/SQLBuilder.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/SQLBuilder.java
new file mode 100644
index 0000000000000000000000000000000000000000..f74b1b691e07a47390f3de082c03d30ed9eb2e6b
--- /dev/null
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/SQLBuilder.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.storage.plugin.jdbc;
+
+/**
+ * SQLBuilder
+ *
+ * @author wusheng
+ */
+public class SQLBuilder {
+ private static String LINE_END = System.lineSeparator();
+
+ private StringBuilder text;
+
+ public SQLBuilder() {
+ this.text = new StringBuilder();
+ }
+
+ public SQLBuilder(String initLine) {
+ this();
+ this.appendLine(initLine);
+ }
+
+ public SQLBuilder append(String fragment) {
+ text.append(fragment);
+ return this;
+ }
+
+ public SQLBuilder appendLine(String line) {
+ text.append(line).append(LINE_END);
+ return this;
+ }
+
+ public String toStringInNewLine() {
+ return LINE_END + toString();
+ }
+
+ @Override public String toString() {
+ return text.toString();
+ }
+}
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/SQLExecutor.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/SQLExecutor.java
new file mode 100644
index 0000000000000000000000000000000000000000..52ab0d4fd8354bf0c1fc2dfc69a972e953ed288d
--- /dev/null
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/SQLExecutor.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.storage.plugin.jdbc;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.List;
+
+/**
+ * A SQL executor.
+ *
+ * @author wusheng
+ */
+public class SQLExecutor {
+ private String sql;
+ private List