sonatype-lift[bot] commented on code in PR #9689:
URL: https://github.com/apache/skywalking/pull/9689#discussion_r979858902
##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/DurationUtils.java:
##########
@@ -42,6 +44,9 @@ public enum DurationUtils {
private static final DateTimeFormatter YYYYMMDDHHMM =
DateTimeFormat.forPattern("yyyyMMddHHmm");
private static final DateTimeFormatter YYYYMMDDHHMMSS =
DateTimeFormat.forPattern("yyyyMMddHHmmss");
+ @Setter
+ private ConfigService configService;
Review Comment:
*[ImmutableEnumChecker](https://errorprone.info/bugpattern/ImmutableEnumChecker):*
enums should be immutable: 'DurationUtils' has non-final field 'configService'
---
```suggestion
private final ConfigService configService;
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with
***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this
PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified
`file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see
its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new)
to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=337688227&lift_comment_rating=1)
] - [ [đ Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=337688227&lift_comment_rating=2)
] - [ [đ Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=337688227&lift_comment_rating=3)
] - [ [đ Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=337688227&lift_comment_rating=4)
] - [ [đ Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=337688227&lift_comment_rating=5)
]
##########
oap-server/server-storage-plugin/storage-shardingsphere-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/shardingsphere/mysql/ShardingRulesOperator.java:
##########
@@ -0,0 +1,272 @@
+/*
+ * 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.shardingsphere.mysql;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.skywalking.oap.server.core.UnexpectedException;
+import org.apache.skywalking.oap.server.core.storage.ShardingAlgorithm;
+import org.apache.skywalking.oap.server.core.storage.StorageException;
+import org.apache.skywalking.oap.server.core.storage.model.Model;
+import
org.apache.skywalking.oap.server.core.storage.model.SQLDatabaseModelExtension;
+import
org.apache.skywalking.oap.server.library.client.jdbc.JDBCClientException;
+import
org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient;
+import org.apache.skywalking.oap.server.storage.plugin.jdbc.SQLBuilder;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.shardingsphere.ShardingRule;
+import org.joda.time.DateTime;
+import org.joda.time.Days;
+
+public enum ShardingRulesOperator {
+ INSTANCE;
+
+ private final Map<String, ShardingRule> modelShardingRules = new
HashMap<>();
Review Comment:
*[ImmutableEnumChecker](https://errorprone.info/bugpattern/ImmutableEnumChecker):*
enums should be immutable: 'ShardingRulesOperator' has field
'modelShardingRules' of type
'java.util.Map<java.lang.String,org.apache.skywalking.oap.server.storage.plugin.jdbc.shardingsphere.ShardingRule>',
'Map' is mutable
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with
***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this
PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified
`file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see
its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new)
to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=337688245&lift_comment_rating=1)
] - [ [đ Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=337688245&lift_comment_rating=2)
] - [ [đ Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=337688245&lift_comment_rating=3)
] - [ [đ Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=337688245&lift_comment_rating=4)
] - [ [đ Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=337688245&lift_comment_rating=5)
]
##########
oap-server/server-storage-plugin/storage-shardingsphere-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/shardingsphere/mysql/ShardingRulesOperator.java:
##########
@@ -0,0 +1,272 @@
+/*
+ * 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.shardingsphere.mysql;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.skywalking.oap.server.core.UnexpectedException;
+import org.apache.skywalking.oap.server.core.storage.ShardingAlgorithm;
+import org.apache.skywalking.oap.server.core.storage.StorageException;
+import org.apache.skywalking.oap.server.core.storage.model.Model;
+import
org.apache.skywalking.oap.server.core.storage.model.SQLDatabaseModelExtension;
+import
org.apache.skywalking.oap.server.library.client.jdbc.JDBCClientException;
+import
org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient;
+import org.apache.skywalking.oap.server.storage.plugin.jdbc.SQLBuilder;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.shardingsphere.ShardingRule;
+import org.joda.time.DateTime;
+import org.joda.time.Days;
+
+public enum ShardingRulesOperator {
+ INSTANCE;
+
+ private final Map<String, ShardingRule> modelShardingRules = new
HashMap<>();
+
+ private static final String TIME_RELATIVE_ID_SHARDING_EXPRESSION =
+ "${long time_bucket =
Long.parseLong(id.substring(0,id.indexOf('_')));\n" +
+ "if (10000000L < time_bucket && time_bucket < 99999999L) {return
time_bucket;}\n" +
+ "if (1000000000L < time_bucket && time_bucket < 9999999999L) {return
time_bucket.intdiv(100);}\n" +
+ "if (100000000000L < time_bucket && time_bucket < 999999999999L)
{return time_bucket.intdiv(100*100);}\n" +
+ "if (10000000000000L < time_bucket && time_bucket < 99999999999999L)
{return time_bucket.intdiv(100*100*100);}\n" +
+ "}";
+
+ private static final String TIME_RANGE_SHARDING_EXPRESSION =
+ "\"datetime-pattern\"=\"yyyyMMddHHmmss\"," +
+ "\"datetime-interval-unit\"=\"days\"," +
+ "\"datetime-interval-amount\"=\"1\"," +
+ "\"sharding-suffix-pattern\"=\"yyyyMMdd\"," +
+ "\"datetime-lower\"=\"20220101000000\"," +
+ "\"datetime-upper\"=\"20991201000000\"";
+
+ private static final String TIME_BUCKET_SHARDING_EXPRESSION =
+ "${\n" +
+ "if (10000000L < time_bucket && time_bucket < 99999999L) {return
time_bucket;}\n" +
+ "if (1000000000L < time_bucket && time_bucket < 9999999999L) {return
time_bucket.intdiv(100);}\n" +
+ "if (100000000000L < time_bucket && time_bucket < 999999999999L)
{return time_bucket.intdiv(100*100);}\n" +
+ "if (10000000000000L < time_bucket && time_bucket < 99999999999999L)
{return time_bucket.intdiv(100*100*100);}\n" +
+ "}";
+
+ public void start(JDBCHikariCPClient client) throws IOException,
SQLException, StorageException {
+ initShardingRules(client);
+ }
+
+ boolean createOrUpdateShardingRule(JDBCHikariCPClient client, Model model,
Set<String> dataSources, int ttl) throws StorageException {
+ boolean isExecuted;
+ ShardingRule.ShardingRuleBuilder builder = ShardingRule.builder();
+ builder.table(model.getName());
+ String tableName = model.getName();
+ SQLDatabaseModelExtension.Sharding sharding =
model.getSqlDBModelExtension().getSharding();
+ isExecuted = executeShardingRule(
+ buildShardingRule(builder, tableName, dataSources,
sharding.getShardingAlgorithm(),
+ sharding.getTableShardingColumn(),
+ sharding.getDsShardingColumn(),
+ ttl,
+ new DateTime()
Review Comment:
*[JodaConstructors](https://errorprone.info/bugpattern/JodaConstructors):*
Use of certain JodaTime constructors are not allowed.
---
```suggestion
DateTime.now()
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with
***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this
PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified
`file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see
its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new)
to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=337688188&lift_comment_rating=1)
] - [ [đ Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=337688188&lift_comment_rating=2)
] - [ [đ Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=337688188&lift_comment_rating=3)
] - [ [đ Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=337688188&lift_comment_rating=4)
] - [ [đ Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=337688188&lift_comment_rating=5)
]
##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/DurationUtils.java:
##########
@@ -188,4 +191,49 @@ public void verifyDateTimeString(Step step, String
dateStr) {
throw new UnexpectedException("Unsupported step " + step.name());
}
+ // Trim the startStr according to the TTL, for query
+ public long trimToStartTimeBucket(Step step, String startStr, boolean
isRecord) {
+ if (configService == null) {
+ throw new UnexpectedException("ConfigService can not be null,
should set ConfigService first.");
+ }
+ int ttl = isRecord ? configService.getRecordDataTTL() :
configService.getMetricsDataTTL();
+ long startDate = convertToTimeBucket(step, startStr);
+ long timeFloor = Long.parseLong(new DateTime().plusDays(1 -
ttl).toString("yyyyMMdd"));
+ switch (step) {
+ case DAY:
+ break;
+ case HOUR:
+ timeFloor = timeFloor * 100;
+ break;
+ case MINUTE:
+ timeFloor = timeFloor * 100 * 100;
+ break;
+ case SECOND:
+ timeFloor = timeFloor * 100 * 100 * 100;
+ break;
+ }
+
+ return Math.max(timeFloor, startDate);
+ }
+
+ // Trim the endStr according to the real date, for query
+ public long trimToEndTimeBucket(Step step, String endStr) {
+ long endDate = convertToTimeBucket(step, endStr);
+ long timeCeiling = Long.parseLong(new DateTime().toString("yyyyMMdd"));
Review Comment:
*[JodaConstructors](https://errorprone.info/bugpattern/JodaConstructors):*
Use of certain JodaTime constructors are not allowed.
---
```suggestion
long timeCeiling =
Long.parseLong(DateTime.now().toString("yyyyMMdd"));
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with
***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this
PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified
`file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see
its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new)
to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=337688211&lift_comment_rating=1)
] - [ [đ Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=337688211&lift_comment_rating=2)
] - [ [đ Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=337688211&lift_comment_rating=3)
] - [ [đ Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=337688211&lift_comment_rating=4)
] - [ [đ Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=337688211&lift_comment_rating=5)
]
##########
oap-server/server-storage-plugin/storage-shardingsphere-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/shardingsphere/mysql/ShardingRulesOperator.java:
##########
@@ -0,0 +1,272 @@
+/*
+ * 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.shardingsphere.mysql;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.skywalking.oap.server.core.UnexpectedException;
+import org.apache.skywalking.oap.server.core.storage.ShardingAlgorithm;
+import org.apache.skywalking.oap.server.core.storage.StorageException;
+import org.apache.skywalking.oap.server.core.storage.model.Model;
+import
org.apache.skywalking.oap.server.core.storage.model.SQLDatabaseModelExtension;
+import
org.apache.skywalking.oap.server.library.client.jdbc.JDBCClientException;
+import
org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient;
+import org.apache.skywalking.oap.server.storage.plugin.jdbc.SQLBuilder;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.shardingsphere.ShardingRule;
+import org.joda.time.DateTime;
+import org.joda.time.Days;
+
+public enum ShardingRulesOperator {
+ INSTANCE;
+
+ private final Map<String, ShardingRule> modelShardingRules = new
HashMap<>();
+
+ private static final String TIME_RELATIVE_ID_SHARDING_EXPRESSION =
+ "${long time_bucket =
Long.parseLong(id.substring(0,id.indexOf('_')));\n" +
+ "if (10000000L < time_bucket && time_bucket < 99999999L) {return
time_bucket;}\n" +
+ "if (1000000000L < time_bucket && time_bucket < 9999999999L) {return
time_bucket.intdiv(100);}\n" +
+ "if (100000000000L < time_bucket && time_bucket < 999999999999L)
{return time_bucket.intdiv(100*100);}\n" +
+ "if (10000000000000L < time_bucket && time_bucket < 99999999999999L)
{return time_bucket.intdiv(100*100*100);}\n" +
+ "}";
+
+ private static final String TIME_RANGE_SHARDING_EXPRESSION =
+ "\"datetime-pattern\"=\"yyyyMMddHHmmss\"," +
+ "\"datetime-interval-unit\"=\"days\"," +
+ "\"datetime-interval-amount\"=\"1\"," +
+ "\"sharding-suffix-pattern\"=\"yyyyMMdd\"," +
+ "\"datetime-lower\"=\"20220101000000\"," +
+ "\"datetime-upper\"=\"20991201000000\"";
+
+ private static final String TIME_BUCKET_SHARDING_EXPRESSION =
+ "${\n" +
+ "if (10000000L < time_bucket && time_bucket < 99999999L) {return
time_bucket;}\n" +
+ "if (1000000000L < time_bucket && time_bucket < 9999999999L) {return
time_bucket.intdiv(100);}\n" +
+ "if (100000000000L < time_bucket && time_bucket < 999999999999L)
{return time_bucket.intdiv(100*100);}\n" +
+ "if (10000000000000L < time_bucket && time_bucket < 99999999999999L)
{return time_bucket.intdiv(100*100*100);}\n" +
+ "}";
+
+ public void start(JDBCHikariCPClient client) throws IOException,
SQLException, StorageException {
+ initShardingRules(client);
+ }
+
+ boolean createOrUpdateShardingRule(JDBCHikariCPClient client, Model model,
Set<String> dataSources, int ttl) throws StorageException {
+ boolean isExecuted;
+ ShardingRule.ShardingRuleBuilder builder = ShardingRule.builder();
+ builder.table(model.getName());
+ String tableName = model.getName();
+ SQLDatabaseModelExtension.Sharding sharding =
model.getSqlDBModelExtension().getSharding();
+ isExecuted = executeShardingRule(
+ buildShardingRule(builder, tableName, dataSources,
sharding.getShardingAlgorithm(),
+ sharding.getTableShardingColumn(),
+ sharding.getDsShardingColumn(),
+ ttl,
+ new DateTime()
+ ),
+ client,
+ tableName
+ );
+ // additional tables
+ for (String additionalTable :
model.getSqlDBModelExtension().getAdditionalTables().keySet()) {
+ ShardingRule.ShardingRuleBuilder additionalBuilder =
ShardingRule.builder();
+ additionalBuilder.table(additionalTable);
+ isExecuted = executeShardingRule(
+ buildShardingRule(additionalBuilder, additionalTable,
dataSources, sharding.getShardingAlgorithm(),
+ sharding.getTableShardingColumn(),
+ sharding.getDsShardingColumn(), ttl, new
DateTime()
Review Comment:
*[JodaConstructors](https://errorprone.info/bugpattern/JodaConstructors):*
Use of certain JodaTime constructors are not allowed.
---
```suggestion
sharding.getDsShardingColumn(), ttl,
DateTime.now()
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with
***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this
PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified
`file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see
its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new)
to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=337688312&lift_comment_rating=1)
] - [ [đ Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=337688312&lift_comment_rating=2)
] - [ [đ Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=337688312&lift_comment_rating=3)
] - [ [đ Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=337688312&lift_comment_rating=4)
] - [ [đ Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=337688312&lift_comment_rating=5)
]
##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/DurationUtils.java:
##########
@@ -188,4 +191,49 @@ public void verifyDateTimeString(Step step, String
dateStr) {
throw new UnexpectedException("Unsupported step " + step.name());
}
+ // Trim the startStr according to the TTL, for query
+ public long trimToStartTimeBucket(Step step, String startStr, boolean
isRecord) {
+ if (configService == null) {
+ throw new UnexpectedException("ConfigService can not be null,
should set ConfigService first.");
+ }
+ int ttl = isRecord ? configService.getRecordDataTTL() :
configService.getMetricsDataTTL();
+ long startDate = convertToTimeBucket(step, startStr);
+ long timeFloor = Long.parseLong(new DateTime().plusDays(1 -
ttl).toString("yyyyMMdd"));
Review Comment:
*[JodaConstructors](https://errorprone.info/bugpattern/JodaConstructors):*
Use of certain JodaTime constructors are not allowed.
---
```suggestion
long timeFloor = Long.parseLong(DateTime.now().plusDays(1 -
ttl).toString("yyyyMMdd"));
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with
***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this
PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified
`file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see
its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new)
to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=337688400&lift_comment_rating=1)
] - [ [đ Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=337688400&lift_comment_rating=2)
] - [ [đ Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=337688400&lift_comment_rating=3)
] - [ [đ Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=337688400&lift_comment_rating=4)
] - [ [đ Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=337688400&lift_comment_rating=5)
]
##########
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/relation/endpoint/EndpointRelationServerSideMetrics.java:
##########
@@ -27,17 +27,23 @@
import
org.apache.skywalking.oap.server.core.analysis.worker.MetricsStreamProcessor;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
+import org.apache.skywalking.oap.server.core.storage.ShardingAlgorithm;
import org.apache.skywalking.oap.server.core.storage.annotation.BanyanDB;
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
+import org.apache.skywalking.oap.server.core.storage.annotation.SQLDatabase;
import org.apache.skywalking.oap.server.core.storage.type.Convert2Entity;
import org.apache.skywalking.oap.server.core.storage.type.Convert2Storage;
import org.apache.skywalking.oap.server.core.storage.type.StorageBuilder;
+import static
org.apache.skywalking.oap.server.core.analysis.metrics.Metrics.ENTITY_ID;
+import static
org.apache.skywalking.oap.server.core.analysis.metrics.Metrics.TIME_BUCKET;
+
@Stream(name = EndpointRelationServerSideMetrics.INDEX_NAME, scopeId =
DefaultScopeDefine.ENDPOINT_RELATION,
builder = EndpointRelationServerSideMetrics.Builder.class, processor =
MetricsStreamProcessor.class)
@EqualsAndHashCode(of = {
Review Comment:
*[MissingOverride](https://errorprone.info/bugpattern/MissingOverride):*
canEqual overrides method in Metrics; expected @Override
---
```suggestion
@Override @EqualsAndHashCode(of = {
```
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with
***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this
PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified
`file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see
its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new)
to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=337688113&lift_comment_rating=1)
] - [ [đ Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=337688113&lift_comment_rating=2)
] - [ [đ Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=337688113&lift_comment_rating=3)
] - [ [đ Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=337688113&lift_comment_rating=4)
] - [ [đ Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=337688113&lift_comment_rating=5)
]
##########
oap-server/server-storage-plugin/storage-shardingsphere-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/shardingsphere/mysql/MySQLShardingStorageProvider.java:
##########
@@ -0,0 +1,185 @@
+/*
+ * 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.shardingsphere.mysql;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.oap.server.core.CoreModule;
+import org.apache.skywalking.oap.server.core.config.ConfigService;
+import org.apache.skywalking.oap.server.core.storage.IBatchDAO;
+import org.apache.skywalking.oap.server.core.storage.IHistoryDeleteDAO;
+import org.apache.skywalking.oap.server.core.storage.StorageBuilderFactory;
+import org.apache.skywalking.oap.server.core.storage.StorageDAO;
+import org.apache.skywalking.oap.server.core.storage.StorageException;
+import org.apache.skywalking.oap.server.core.storage.StorageModule;
+import
org.apache.skywalking.oap.server.core.storage.cache.INetworkAddressAliasDAO;
+import
org.apache.skywalking.oap.server.core.storage.management.UITemplateManagementDAO;
+import org.apache.skywalking.oap.server.core.storage.model.ModelCreator;
+import
org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IEBPFProfilingDataDAO;
+import
org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IEBPFProfilingScheduleDAO;
+import
org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IEBPFProfilingTaskDAO;
+import
org.apache.skywalking.oap.server.core.storage.profiling.ebpf.IServiceLabelDAO;
+import
org.apache.skywalking.oap.server.core.storage.profiling.trace.IProfileTaskLogQueryDAO;
+import
org.apache.skywalking.oap.server.core.storage.profiling.trace.IProfileTaskQueryDAO;
+import
org.apache.skywalking.oap.server.core.storage.profiling.trace.IProfileThreadSnapshotQueryDAO;
+import
org.apache.skywalking.oap.server.core.storage.query.IAggregationQueryDAO;
+import org.apache.skywalking.oap.server.core.storage.query.IAlarmQueryDAO;
+import org.apache.skywalking.oap.server.core.storage.query.IBrowserLogQueryDAO;
+import org.apache.skywalking.oap.server.core.storage.query.IEventQueryDAO;
+import org.apache.skywalking.oap.server.core.storage.query.ILogQueryDAO;
+import org.apache.skywalking.oap.server.core.storage.query.IMetadataQueryDAO;
+import org.apache.skywalking.oap.server.core.storage.query.IMetricsQueryDAO;
+import
org.apache.skywalking.oap.server.core.storage.query.ITagAutoCompleteQueryDAO;
+import
org.apache.skywalking.oap.server.core.storage.query.ITopNRecordsQueryDAO;
+import org.apache.skywalking.oap.server.core.storage.query.ITopologyQueryDAO;
+import org.apache.skywalking.oap.server.core.storage.query.ITraceQueryDAO;
+import org.apache.skywalking.oap.server.core.storage.query.IZipkinQueryDAO;
+import
org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient;
+import org.apache.skywalking.oap.server.library.module.ModuleConfig;
+import org.apache.skywalking.oap.server.library.module.ModuleDefine;
+import org.apache.skywalking.oap.server.library.module.ModuleProvider;
+import org.apache.skywalking.oap.server.library.module.ModuleStartException;
+import
org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException;
+import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2BatchDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2EBPFProfilingDataDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2EBPFProfilingScheduleDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2EBPFProfilingTaskDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2EventQueryDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2HistoryDeleteDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2MetadataQueryDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2NetworkAddressAliasDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2ServiceLabelQueryDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2ProfileTaskLogQueryDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2ProfileTaskQueryDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2ProfileThreadSnapshotQueryDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2StorageDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2TagAutoCompleteQueryDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2TopNRecordsQueryDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2TopologyQueryDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2UITemplateManagementDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.mysql.MySQLAggregationQueryDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.mysql.MySQLAlarmQueryDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.mysql.MySQLLogQueryDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.mysql.MySQLTraceQueryDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.mysql.MysqlBrowserLogQueryDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.shardingsphere.mysql.dao.MySQLMetricsQueryDAO;
+import
org.apache.skywalking.oap.server.storage.plugin.jdbc.shardingsphere.mysql.dao.MySQLZipkinQueryDAO;
+
+@Slf4j
+public class MySQLShardingStorageProvider extends ModuleProvider {
+
+ private MySQLShardingStorageConfig config;
+ private JDBCHikariCPClient mysqlClient;
+
+ public MySQLShardingStorageProvider() {
+ config = new MySQLShardingStorageConfig();
+ }
+
+ @Override
+ public String name() {
+ return "mysql-sharding";
+ }
+
+ @Override
+ public Class<? extends ModuleDefine> module() {
+ return StorageModule.class;
+ }
+
+ @Override
+ public ModuleConfig createConfigBeanIfAbsent() {
+ return config;
+ }
+
+ @Override
+ public void prepare() throws ServiceNotProvidedException {
+ this.registerServiceImplementation(StorageBuilderFactory.class, new
StorageBuilderFactory.Default());
+
+ mysqlClient = new JDBCHikariCPClient(config.getProperties());
+
+ this.registerServiceImplementation(IBatchDAO.class, new
H2BatchDAO(mysqlClient, config.getMaxSizeOfBatchSql(),
config.getAsyncBatchPersistentPoolSize()));
+ this.registerServiceImplementation(
+ StorageDAO.class,
+ new H2StorageDAO(mysqlClient));
+ this.registerServiceImplementation(
+ INetworkAddressAliasDAO.class, new
H2NetworkAddressAliasDAO(mysqlClient));
+
+ this.registerServiceImplementation(ITopologyQueryDAO.class, new
H2TopologyQueryDAO(mysqlClient));
+ this.registerServiceImplementation(IMetricsQueryDAO.class, new
MySQLMetricsQueryDAO(mysqlClient));
+ this.registerServiceImplementation(
+ ITraceQueryDAO.class,
+ new MySQLTraceQueryDAO(getManager(), mysqlClient)
+ );
+ this.registerServiceImplementation(IBrowserLogQueryDAO.class, new
MysqlBrowserLogQueryDAO(mysqlClient));
+ this.registerServiceImplementation(
+ IMetadataQueryDAO.class, new H2MetadataQueryDAO(mysqlClient,
config.getMetadataQueryMaxSize()));
+ this.registerServiceImplementation(IAggregationQueryDAO.class, new
MySQLAggregationQueryDAO(mysqlClient));
+ this.registerServiceImplementation(IAlarmQueryDAO.class, new
MySQLAlarmQueryDAO(mysqlClient, getManager()));
+ this.registerServiceImplementation(
+ IHistoryDeleteDAO.class, new H2HistoryDeleteDAO(mysqlClient));
+ this.registerServiceImplementation(ITopNRecordsQueryDAO.class, new
H2TopNRecordsQueryDAO(mysqlClient));
+ this.registerServiceImplementation(
+ ILogQueryDAO.class,
+ new MySQLLogQueryDAO(mysqlClient, getManager()));
+
+ this.registerServiceImplementation(IProfileTaskQueryDAO.class, new
H2ProfileTaskQueryDAO(mysqlClient));
+ this.registerServiceImplementation(IProfileTaskLogQueryDAO.class, new
H2ProfileTaskLogQueryDAO(mysqlClient));
+ this.registerServiceImplementation(
+ IProfileThreadSnapshotQueryDAO.class, new
H2ProfileThreadSnapshotQueryDAO(mysqlClient));
+ this.registerServiceImplementation(UITemplateManagementDAO.class, new
H2UITemplateManagementDAO(mysqlClient));
+
+ this.registerServiceImplementation(
+ IHistoryDeleteDAO.class, new
MySQLShardingHistoryDeleteDAO(mysqlClient, config, getManager()));
+
+ this.registerServiceImplementation(IEventQueryDAO.class, new
H2EventQueryDAO(mysqlClient));
+
+ this.registerServiceImplementation(IEBPFProfilingTaskDAO.class, new
H2EBPFProfilingTaskDAO(mysqlClient));
+ this.registerServiceImplementation(IEBPFProfilingScheduleDAO.class,
new H2EBPFProfilingScheduleDAO(mysqlClient));
+ this.registerServiceImplementation(IEBPFProfilingDataDAO.class, new
H2EBPFProfilingDataDAO(mysqlClient));
+ this.registerServiceImplementation(IServiceLabelDAO.class, new
H2ServiceLabelQueryDAO(mysqlClient));
+ this.registerServiceImplementation(ITagAutoCompleteQueryDAO.class, new
H2TagAutoCompleteQueryDAO(mysqlClient));
+ this.registerServiceImplementation(IZipkinQueryDAO.class, new
MySQLZipkinQueryDAO(mysqlClient));
+ }
+
+ @Override
+ public void start() throws ServiceNotProvidedException,
ModuleStartException {
+ final ConfigService configService = getManager().find(CoreModule.NAME)
Review Comment:
*[UnusedVariable](https://errorprone.info/bugpattern/UnusedVariable):* The
local variable 'configService' is never read.
---
<details><summary><b>âšī¸ Learn about @sonatype-lift commands</b></summary>
You can reply with the following commands. For example, reply with
***@sonatype-lift ignoreall*** to leave out all findings.
| **Command** | **Usage** |
| ------------- | ------------- |
| `@sonatype-lift ignore` | Leave out the above finding from this PR |
| `@sonatype-lift ignoreall` | Leave out all the existing findings from this
PR |
| `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified
`file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
**Note:** When talking to LiftBot, you need to **refresh** the page to see
its response.
<sub>[Click here](https://github.com/apps/sonatype-lift/installations/new)
to add LiftBot to another repo.</sub></details>
---
Was this a good recommendation?
[ [đ Not
relevant](https://www.sonatype.com/lift-comment-rating?comment=337688261&lift_comment_rating=1)
] - [ [đ Won't
fix](https://www.sonatype.com/lift-comment-rating?comment=337688261&lift_comment_rating=2)
] - [ [đ Not critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=337688261&lift_comment_rating=3)
] - [ [đ Critical, will
fix](https://www.sonatype.com/lift-comment-rating?comment=337688261&lift_comment_rating=4)
] - [ [đ Critical, fixing
now](https://www.sonatype.com/lift-comment-rating?comment=337688261&lift_comment_rating=5)
]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]