Showing
14 changed files
with
90 additions
and
17 deletions
@@ -116,7 +116,7 @@ public class ThingsboardInstallService { | @@ -116,7 +116,7 @@ public class ThingsboardInstallService { | ||
116 | 116 | ||
117 | log.info("Installing DataBase schema..."); | 117 | log.info("Installing DataBase schema..."); |
118 | 118 | ||
119 | - databaseSchemaService.createDatabaseSchema(); | 119 | + databaseSchemaService.createDatabaseSchema();//TODO |
120 | 120 | ||
121 | log.info("Loading system data..."); | 121 | log.info("Loading system data..."); |
122 | 122 |
application/src/main/java/org/thingsboard/server/service/install/CassandraDatabaseSchemaService.java
@@ -20,7 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -20,7 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
20 | import org.springframework.context.annotation.Profile; | 20 | import org.springframework.context.annotation.Profile; |
21 | import org.springframework.stereotype.Service; | 21 | import org.springframework.stereotype.Service; |
22 | import org.thingsboard.server.dao.cassandra.CassandraInstallCluster; | 22 | import org.thingsboard.server.dao.cassandra.CassandraInstallCluster; |
23 | -import org.thingsboard.server.dao.util.NoSqlDao; | 23 | +import org.thingsboard.server.dao.util.NoSqlAnyDao; |
24 | import org.thingsboard.server.service.install.cql.CQLStatementsParser; | 24 | import org.thingsboard.server.service.install.cql.CQLStatementsParser; |
25 | 25 | ||
26 | import java.nio.file.Path; | 26 | import java.nio.file.Path; |
@@ -28,7 +28,7 @@ import java.nio.file.Paths; | @@ -28,7 +28,7 @@ import java.nio.file.Paths; | ||
28 | import java.util.List; | 28 | import java.util.List; |
29 | 29 | ||
30 | @Service | 30 | @Service |
31 | -@NoSqlDao | 31 | +@NoSqlAnyDao |
32 | @Profile("install") | 32 | @Profile("install") |
33 | @Slf4j | 33 | @Slf4j |
34 | public class CassandraDatabaseSchemaService implements DatabaseSchemaService { | 34 | public class CassandraDatabaseSchemaService implements DatabaseSchemaService { |
@@ -23,7 +23,7 @@ import org.springframework.stereotype.Service; | @@ -23,7 +23,7 @@ import org.springframework.stereotype.Service; | ||
23 | import org.thingsboard.server.dao.cassandra.CassandraCluster; | 23 | import org.thingsboard.server.dao.cassandra.CassandraCluster; |
24 | import org.thingsboard.server.dao.cassandra.CassandraInstallCluster; | 24 | import org.thingsboard.server.dao.cassandra.CassandraInstallCluster; |
25 | import org.thingsboard.server.dao.dashboard.DashboardService; | 25 | import org.thingsboard.server.dao.dashboard.DashboardService; |
26 | -import org.thingsboard.server.dao.util.NoSqlDao; | 26 | +import org.thingsboard.server.dao.util.NoSqlAnyDao; |
27 | import org.thingsboard.server.service.install.cql.CQLStatementsParser; | 27 | import org.thingsboard.server.service.install.cql.CQLStatementsParser; |
28 | import org.thingsboard.server.service.install.cql.CassandraDbHelper; | 28 | import org.thingsboard.server.service.install.cql.CassandraDbHelper; |
29 | 29 | ||
@@ -45,7 +45,7 @@ import static org.thingsboard.server.service.install.DatabaseHelper.TENANT_ID; | @@ -45,7 +45,7 @@ import static org.thingsboard.server.service.install.DatabaseHelper.TENANT_ID; | ||
45 | import static org.thingsboard.server.service.install.DatabaseHelper.TITLE; | 45 | import static org.thingsboard.server.service.install.DatabaseHelper.TITLE; |
46 | 46 | ||
47 | @Service | 47 | @Service |
48 | -@NoSqlDao | 48 | +@NoSqlAnyDao |
49 | @Profile("install") | 49 | @Profile("install") |
50 | @Slf4j | 50 | @Slf4j |
51 | public class CassandraDatabaseUpgradeService implements DatabaseUpgradeService { | 51 | public class CassandraDatabaseUpgradeService implements DatabaseUpgradeService { |
@@ -151,6 +151,7 @@ quota: | @@ -151,6 +151,7 @@ quota: | ||
151 | # Enable Host API Limits | 151 | # Enable Host API Limits |
152 | enabled: "${QUOTA_TENANT_ENABLED:false}" | 152 | enabled: "${QUOTA_TENANT_ENABLED:false}" |
153 | # Array of whitelist tenants | 153 | # Array of whitelist tenants |
154 | + # Array of whitelist tenants | ||
154 | whitelist: "${QUOTA_TENANT_WHITELIST:}" | 155 | whitelist: "${QUOTA_TENANT_WHITELIST:}" |
155 | # Array of blacklist tenants | 156 | # Array of blacklist tenants |
156 | blacklist: "${QUOTA_HOST_BLACKLIST:}" | 157 | blacklist: "${QUOTA_HOST_BLACKLIST:}" |
@@ -160,6 +161,10 @@ quota: | @@ -160,6 +161,10 @@ quota: | ||
160 | 161 | ||
161 | database: | 162 | database: |
162 | type: "${DATABASE_TYPE:sql}" # cassandra OR sql | 163 | type: "${DATABASE_TYPE:sql}" # cassandra OR sql |
164 | + entities: | ||
165 | + type: "${DATABASE_TYPE:sql}" # cassandra OR sql | ||
166 | + ts: | ||
167 | + type: "${DATABASE_TYPE:cassandra}" # cassandra OR sql | ||
163 | 168 | ||
164 | # Cassandra driver configuration parameters | 169 | # Cassandra driver configuration parameters |
165 | cassandra: | 170 | cassandra: |
@@ -206,7 +211,7 @@ cassandra: | @@ -206,7 +211,7 @@ cassandra: | ||
206 | write_consistency_level: "${CASSANDRA_WRITE_CONSISTENCY_LEVEL:ONE}" | 211 | write_consistency_level: "${CASSANDRA_WRITE_CONSISTENCY_LEVEL:ONE}" |
207 | default_fetch_size: "${CASSANDRA_DEFAULT_FETCH_SIZE:2000}" | 212 | default_fetch_size: "${CASSANDRA_DEFAULT_FETCH_SIZE:2000}" |
208 | # Specify partitioning size for timestamp key-value storage. Example MINUTES, HOURS, DAYS, MONTHS,INDEFINITE | 213 | # Specify partitioning size for timestamp key-value storage. Example MINUTES, HOURS, DAYS, MONTHS,INDEFINITE |
209 | - ts_key_value_partitioning: "${TS_KV_PARTITIONING:MONTHS}" | 214 | + ts_key_value_partitioning: "${TS_KV_PARTITIONING:INDEFINITE}" |
210 | ts_key_value_ttl: "${TS_KV_TTL:0}" | 215 | ts_key_value_ttl: "${TS_KV_TTL:0}" |
211 | buffer_size: "${CASSANDRA_QUERY_BUFFER_SIZE:200000}" | 216 | buffer_size: "${CASSANDRA_QUERY_BUFFER_SIZE:200000}" |
212 | concurrent_limit: "${CASSANDRA_QUERY_CONCURRENT_LIMIT:1000}" | 217 | concurrent_limit: "${CASSANDRA_QUERY_CONCURRENT_LIMIT:1000}" |
@@ -17,12 +17,12 @@ package org.thingsboard.server.dao.cassandra; | @@ -17,12 +17,12 @@ package org.thingsboard.server.dao.cassandra; | ||
17 | 17 | ||
18 | import org.springframework.beans.factory.annotation.Value; | 18 | import org.springframework.beans.factory.annotation.Value; |
19 | import org.springframework.stereotype.Component; | 19 | import org.springframework.stereotype.Component; |
20 | -import org.thingsboard.server.dao.util.NoSqlDao; | 20 | +import org.thingsboard.server.dao.util.NoSqlAnyDao; |
21 | 21 | ||
22 | import javax.annotation.PostConstruct; | 22 | import javax.annotation.PostConstruct; |
23 | 23 | ||
24 | @Component | 24 | @Component |
25 | -@NoSqlDao | 25 | +@NoSqlAnyDao |
26 | public class CassandraCluster extends AbstractCassandraCluster { | 26 | public class CassandraCluster extends AbstractCassandraCluster { |
27 | 27 | ||
28 | @Value("${cassandra.keyspace_name}") | 28 | @Value("${cassandra.keyspace_name}") |
@@ -17,12 +17,12 @@ package org.thingsboard.server.dao.cassandra; | @@ -17,12 +17,12 @@ package org.thingsboard.server.dao.cassandra; | ||
17 | 17 | ||
18 | import org.springframework.context.annotation.Profile; | 18 | import org.springframework.context.annotation.Profile; |
19 | import org.springframework.stereotype.Component; | 19 | import org.springframework.stereotype.Component; |
20 | -import org.thingsboard.server.dao.util.NoSqlDao; | 20 | +import org.thingsboard.server.dao.util.NoSqlAnyDao; |
21 | 21 | ||
22 | import javax.annotation.PostConstruct; | 22 | import javax.annotation.PostConstruct; |
23 | 23 | ||
24 | @Component | 24 | @Component |
25 | -@NoSqlDao | 25 | +@NoSqlAnyDao |
26 | @Profile("install") | 26 | @Profile("install") |
27 | public class CassandraInstallCluster extends AbstractCassandraCluster { | 27 | public class CassandraInstallCluster extends AbstractCassandraCluster { |
28 | 28 |
@@ -21,14 +21,14 @@ import lombok.Data; | @@ -21,14 +21,14 @@ import lombok.Data; | ||
21 | import org.springframework.beans.factory.annotation.Value; | 21 | import org.springframework.beans.factory.annotation.Value; |
22 | import org.springframework.context.annotation.Configuration; | 22 | import org.springframework.context.annotation.Configuration; |
23 | import org.springframework.stereotype.Component; | 23 | import org.springframework.stereotype.Component; |
24 | -import org.thingsboard.server.dao.util.NoSqlDao; | 24 | +import org.thingsboard.server.dao.util.NoSqlAnyDao; |
25 | 25 | ||
26 | import javax.annotation.PostConstruct; | 26 | import javax.annotation.PostConstruct; |
27 | 27 | ||
28 | @Component | 28 | @Component |
29 | @Configuration | 29 | @Configuration |
30 | @Data | 30 | @Data |
31 | -@NoSqlDao | 31 | +@NoSqlAnyDao |
32 | public class CassandraQueryOptions { | 32 | public class CassandraQueryOptions { |
33 | 33 | ||
34 | @Value("${cassandra.query.default_fetch_size}") | 34 | @Value("${cassandra.query.default_fetch_size}") |
@@ -20,14 +20,14 @@ import lombok.Data; | @@ -20,14 +20,14 @@ import lombok.Data; | ||
20 | import org.springframework.beans.factory.annotation.Value; | 20 | import org.springframework.beans.factory.annotation.Value; |
21 | import org.springframework.context.annotation.Configuration; | 21 | import org.springframework.context.annotation.Configuration; |
22 | import org.springframework.stereotype.Component; | 22 | import org.springframework.stereotype.Component; |
23 | -import org.thingsboard.server.dao.util.NoSqlDao; | 23 | +import org.thingsboard.server.dao.util.NoSqlAnyDao; |
24 | 24 | ||
25 | import javax.annotation.PostConstruct; | 25 | import javax.annotation.PostConstruct; |
26 | 26 | ||
27 | @Component | 27 | @Component |
28 | @Configuration | 28 | @Configuration |
29 | @Data | 29 | @Data |
30 | -@NoSqlDao | 30 | +@NoSqlAnyDao |
31 | public class CassandraSocketOptions { | 31 | public class CassandraSocketOptions { |
32 | 32 | ||
33 | @Value("${cassandra.socket.connect_timeout}") | 33 | @Value("${cassandra.socket.connect_timeout}") |
@@ -42,6 +42,7 @@ import org.thingsboard.server.dao.sql.JpaAbstractDaoListeningExecutorService; | @@ -42,6 +42,7 @@ import org.thingsboard.server.dao.sql.JpaAbstractDaoListeningExecutorService; | ||
42 | import org.thingsboard.server.dao.timeseries.TimeseriesDao; | 42 | import org.thingsboard.server.dao.timeseries.TimeseriesDao; |
43 | import org.thingsboard.server.dao.timeseries.TsInsertExecutorType; | 43 | import org.thingsboard.server.dao.timeseries.TsInsertExecutorType; |
44 | import org.thingsboard.server.dao.util.SqlDao; | 44 | import org.thingsboard.server.dao.util.SqlDao; |
45 | +import org.thingsboard.server.dao.util.SqlTsDao; | ||
45 | 46 | ||
46 | import javax.annotation.Nullable; | 47 | import javax.annotation.Nullable; |
47 | import javax.annotation.PostConstruct; | 48 | import javax.annotation.PostConstruct; |
@@ -58,7 +59,7 @@ import static org.thingsboard.server.common.data.UUIDConverter.fromTimeUUID; | @@ -58,7 +59,7 @@ import static org.thingsboard.server.common.data.UUIDConverter.fromTimeUUID; | ||
58 | 59 | ||
59 | @Component | 60 | @Component |
60 | @Slf4j | 61 | @Slf4j |
61 | -@SqlDao | 62 | +@SqlTsDao |
62 | public class JpaTimeseriesDao extends JpaAbstractDaoListeningExecutorService implements TimeseriesDao { | 63 | public class JpaTimeseriesDao extends JpaAbstractDaoListeningExecutorService implements TimeseriesDao { |
63 | 64 | ||
64 | @Value("${sql.ts_inserts_executor_type}") | 65 | @Value("${sql.ts_inserts_executor_type}") |
@@ -47,6 +47,7 @@ import org.thingsboard.server.common.data.kv.TsKvQuery; | @@ -47,6 +47,7 @@ import org.thingsboard.server.common.data.kv.TsKvQuery; | ||
47 | import org.thingsboard.server.dao.model.ModelConstants; | 47 | import org.thingsboard.server.dao.model.ModelConstants; |
48 | import org.thingsboard.server.dao.nosql.CassandraAbstractAsyncDao; | 48 | import org.thingsboard.server.dao.nosql.CassandraAbstractAsyncDao; |
49 | import org.thingsboard.server.dao.util.NoSqlDao; | 49 | import org.thingsboard.server.dao.util.NoSqlDao; |
50 | +import org.thingsboard.server.dao.util.NoSqlTsDao; | ||
50 | 51 | ||
51 | import javax.annotation.Nullable; | 52 | import javax.annotation.Nullable; |
52 | import javax.annotation.PostConstruct; | 53 | import javax.annotation.PostConstruct; |
@@ -68,7 +69,7 @@ import static com.datastax.driver.core.querybuilder.QueryBuilder.eq; | @@ -68,7 +69,7 @@ import static com.datastax.driver.core.querybuilder.QueryBuilder.eq; | ||
68 | */ | 69 | */ |
69 | @Component | 70 | @Component |
70 | @Slf4j | 71 | @Slf4j |
71 | -@NoSqlDao | 72 | +@NoSqlTsDao |
72 | public class CassandraBaseTimeseriesDao extends CassandraAbstractAsyncDao implements TimeseriesDao { | 73 | public class CassandraBaseTimeseriesDao extends CassandraAbstractAsyncDao implements TimeseriesDao { |
73 | 74 | ||
74 | private static final int MIN_AGGREGATION_STEP_MS = 1000; | 75 | private static final int MIN_AGGREGATION_STEP_MS = 1000; |
@@ -34,7 +34,7 @@ import java.util.concurrent.atomic.AtomicInteger; | @@ -34,7 +34,7 @@ import java.util.concurrent.atomic.AtomicInteger; | ||
34 | 34 | ||
35 | @Component | 35 | @Component |
36 | @Slf4j | 36 | @Slf4j |
37 | -@NoSqlDao | 37 | +@NoSqlAnyDao |
38 | public class BufferedRateLimiter implements AsyncRateLimiter { | 38 | public class BufferedRateLimiter implements AsyncRateLimiter { |
39 | 39 | ||
40 | private final ListeningExecutorService pool = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10)); | 40 | private final ListeningExecutorService pool = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10)); |
1 | +/** | ||
2 | + * Copyright © 2016-2018 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.util; | ||
17 | + | ||
18 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; | ||
19 | + | ||
20 | +@ConditionalOnExpression("'${database.type}'=='cassandra' || '${database.ts.type}'=='cassandra'") | ||
21 | +public @interface NoSqlAnyDao { | ||
22 | +} |
1 | +/** | ||
2 | + * Copyright © 2016-2018 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.util; | ||
17 | + | ||
18 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
19 | + | ||
20 | +@ConditionalOnProperty(prefix = "database.ts", value = "type", havingValue = "cassandra") | ||
21 | +public @interface NoSqlTsDao { | ||
22 | +} |
1 | +/** | ||
2 | + * Copyright © 2016-2018 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.util; | ||
17 | + | ||
18 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
19 | + | ||
20 | +@ConditionalOnProperty(prefix = "database.ts", value = "type", havingValue = "sql") | ||
21 | +public @interface SqlTsDao { | ||
22 | +} |