hybrid db initial commit
This commit is contained in:
parent
75b77f09f8
commit
b7ed7ea039
@ -116,7 +116,7 @@ public class ThingsboardInstallService {
|
|||||||
|
|
||||||
log.info("Installing DataBase schema...");
|
log.info("Installing DataBase schema...");
|
||||||
|
|
||||||
databaseSchemaService.createDatabaseSchema();
|
databaseSchemaService.createDatabaseSchema();//TODO
|
||||||
|
|
||||||
log.info("Loading system data...");
|
log.info("Loading system data...");
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.context.annotation.Profile;
|
import org.springframework.context.annotation.Profile;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thingsboard.server.dao.cassandra.CassandraInstallCluster;
|
import org.thingsboard.server.dao.cassandra.CassandraInstallCluster;
|
||||||
import org.thingsboard.server.dao.util.NoSqlDao;
|
import org.thingsboard.server.dao.util.NoSqlAnyDao;
|
||||||
import org.thingsboard.server.service.install.cql.CQLStatementsParser;
|
import org.thingsboard.server.service.install.cql.CQLStatementsParser;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@ -28,7 +28,7 @@ import java.nio.file.Paths;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@NoSqlDao
|
@NoSqlAnyDao
|
||||||
@Profile("install")
|
@Profile("install")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class CassandraDatabaseSchemaService implements DatabaseSchemaService {
|
public class CassandraDatabaseSchemaService implements DatabaseSchemaService {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.thingsboard.server.dao.cassandra.CassandraCluster;
|
import org.thingsboard.server.dao.cassandra.CassandraCluster;
|
||||||
import org.thingsboard.server.dao.cassandra.CassandraInstallCluster;
|
import org.thingsboard.server.dao.cassandra.CassandraInstallCluster;
|
||||||
import org.thingsboard.server.dao.dashboard.DashboardService;
|
import org.thingsboard.server.dao.dashboard.DashboardService;
|
||||||
import org.thingsboard.server.dao.util.NoSqlDao;
|
import org.thingsboard.server.dao.util.NoSqlAnyDao;
|
||||||
import org.thingsboard.server.service.install.cql.CQLStatementsParser;
|
import org.thingsboard.server.service.install.cql.CQLStatementsParser;
|
||||||
import org.thingsboard.server.service.install.cql.CassandraDbHelper;
|
import org.thingsboard.server.service.install.cql.CassandraDbHelper;
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ import static org.thingsboard.server.service.install.DatabaseHelper.TENANT_ID;
|
|||||||
import static org.thingsboard.server.service.install.DatabaseHelper.TITLE;
|
import static org.thingsboard.server.service.install.DatabaseHelper.TITLE;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@NoSqlDao
|
@NoSqlAnyDao
|
||||||
@Profile("install")
|
@Profile("install")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class CassandraDatabaseUpgradeService implements DatabaseUpgradeService {
|
public class CassandraDatabaseUpgradeService implements DatabaseUpgradeService {
|
||||||
|
|||||||
@ -151,6 +151,7 @@ quota:
|
|||||||
# Enable Host API Limits
|
# Enable Host API Limits
|
||||||
enabled: "${QUOTA_TENANT_ENABLED:false}"
|
enabled: "${QUOTA_TENANT_ENABLED:false}"
|
||||||
# Array of whitelist tenants
|
# Array of whitelist tenants
|
||||||
|
# Array of whitelist tenants
|
||||||
whitelist: "${QUOTA_TENANT_WHITELIST:}"
|
whitelist: "${QUOTA_TENANT_WHITELIST:}"
|
||||||
# Array of blacklist tenants
|
# Array of blacklist tenants
|
||||||
blacklist: "${QUOTA_HOST_BLACKLIST:}"
|
blacklist: "${QUOTA_HOST_BLACKLIST:}"
|
||||||
@ -160,6 +161,10 @@ quota:
|
|||||||
|
|
||||||
database:
|
database:
|
||||||
type: "${DATABASE_TYPE:sql}" # cassandra OR sql
|
type: "${DATABASE_TYPE:sql}" # cassandra OR sql
|
||||||
|
entities:
|
||||||
|
type: "${DATABASE_TYPE:sql}" # cassandra OR sql
|
||||||
|
ts:
|
||||||
|
type: "${DATABASE_TYPE:cassandra}" # cassandra OR sql
|
||||||
|
|
||||||
# Cassandra driver configuration parameters
|
# Cassandra driver configuration parameters
|
||||||
cassandra:
|
cassandra:
|
||||||
@ -206,7 +211,7 @@ cassandra:
|
|||||||
write_consistency_level: "${CASSANDRA_WRITE_CONSISTENCY_LEVEL:ONE}"
|
write_consistency_level: "${CASSANDRA_WRITE_CONSISTENCY_LEVEL:ONE}"
|
||||||
default_fetch_size: "${CASSANDRA_DEFAULT_FETCH_SIZE:2000}"
|
default_fetch_size: "${CASSANDRA_DEFAULT_FETCH_SIZE:2000}"
|
||||||
# Specify partitioning size for timestamp key-value storage. Example MINUTES, HOURS, DAYS, MONTHS,INDEFINITE
|
# Specify partitioning size for timestamp key-value storage. Example MINUTES, HOURS, DAYS, MONTHS,INDEFINITE
|
||||||
ts_key_value_partitioning: "${TS_KV_PARTITIONING:MONTHS}"
|
ts_key_value_partitioning: "${TS_KV_PARTITIONING:INDEFINITE}"
|
||||||
ts_key_value_ttl: "${TS_KV_TTL:0}"
|
ts_key_value_ttl: "${TS_KV_TTL:0}"
|
||||||
buffer_size: "${CASSANDRA_QUERY_BUFFER_SIZE:200000}"
|
buffer_size: "${CASSANDRA_QUERY_BUFFER_SIZE:200000}"
|
||||||
concurrent_limit: "${CASSANDRA_QUERY_CONCURRENT_LIMIT:1000}"
|
concurrent_limit: "${CASSANDRA_QUERY_CONCURRENT_LIMIT:1000}"
|
||||||
|
|||||||
@ -17,12 +17,12 @@ package org.thingsboard.server.dao.cassandra;
|
|||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.thingsboard.server.dao.util.NoSqlDao;
|
import org.thingsboard.server.dao.util.NoSqlAnyDao;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@NoSqlDao
|
@NoSqlAnyDao
|
||||||
public class CassandraCluster extends AbstractCassandraCluster {
|
public class CassandraCluster extends AbstractCassandraCluster {
|
||||||
|
|
||||||
@Value("${cassandra.keyspace_name}")
|
@Value("${cassandra.keyspace_name}")
|
||||||
|
|||||||
@ -17,12 +17,12 @@ package org.thingsboard.server.dao.cassandra;
|
|||||||
|
|
||||||
import org.springframework.context.annotation.Profile;
|
import org.springframework.context.annotation.Profile;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.thingsboard.server.dao.util.NoSqlDao;
|
import org.thingsboard.server.dao.util.NoSqlAnyDao;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@NoSqlDao
|
@NoSqlAnyDao
|
||||||
@Profile("install")
|
@Profile("install")
|
||||||
public class CassandraInstallCluster extends AbstractCassandraCluster {
|
public class CassandraInstallCluster extends AbstractCassandraCluster {
|
||||||
|
|
||||||
|
|||||||
@ -21,14 +21,14 @@ import lombok.Data;
|
|||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.thingsboard.server.dao.util.NoSqlDao;
|
import org.thingsboard.server.dao.util.NoSqlAnyDao;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Configuration
|
@Configuration
|
||||||
@Data
|
@Data
|
||||||
@NoSqlDao
|
@NoSqlAnyDao
|
||||||
public class CassandraQueryOptions {
|
public class CassandraQueryOptions {
|
||||||
|
|
||||||
@Value("${cassandra.query.default_fetch_size}")
|
@Value("${cassandra.query.default_fetch_size}")
|
||||||
|
|||||||
@ -20,14 +20,14 @@ import lombok.Data;
|
|||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.thingsboard.server.dao.util.NoSqlDao;
|
import org.thingsboard.server.dao.util.NoSqlAnyDao;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Configuration
|
@Configuration
|
||||||
@Data
|
@Data
|
||||||
@NoSqlDao
|
@NoSqlAnyDao
|
||||||
public class CassandraSocketOptions {
|
public class CassandraSocketOptions {
|
||||||
|
|
||||||
@Value("${cassandra.socket.connect_timeout}")
|
@Value("${cassandra.socket.connect_timeout}")
|
||||||
|
|||||||
@ -42,6 +42,7 @@ import org.thingsboard.server.dao.sql.JpaAbstractDaoListeningExecutorService;
|
|||||||
import org.thingsboard.server.dao.timeseries.TimeseriesDao;
|
import org.thingsboard.server.dao.timeseries.TimeseriesDao;
|
||||||
import org.thingsboard.server.dao.timeseries.TsInsertExecutorType;
|
import org.thingsboard.server.dao.timeseries.TsInsertExecutorType;
|
||||||
import org.thingsboard.server.dao.util.SqlDao;
|
import org.thingsboard.server.dao.util.SqlDao;
|
||||||
|
import org.thingsboard.server.dao.util.SqlTsDao;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
@ -58,7 +59,7 @@ import static org.thingsboard.server.common.data.UUIDConverter.fromTimeUUID;
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@SqlDao
|
@SqlTsDao
|
||||||
public class JpaTimeseriesDao extends JpaAbstractDaoListeningExecutorService implements TimeseriesDao {
|
public class JpaTimeseriesDao extends JpaAbstractDaoListeningExecutorService implements TimeseriesDao {
|
||||||
|
|
||||||
@Value("${sql.ts_inserts_executor_type}")
|
@Value("${sql.ts_inserts_executor_type}")
|
||||||
|
|||||||
@ -47,6 +47,7 @@ import org.thingsboard.server.common.data.kv.TsKvQuery;
|
|||||||
import org.thingsboard.server.dao.model.ModelConstants;
|
import org.thingsboard.server.dao.model.ModelConstants;
|
||||||
import org.thingsboard.server.dao.nosql.CassandraAbstractAsyncDao;
|
import org.thingsboard.server.dao.nosql.CassandraAbstractAsyncDao;
|
||||||
import org.thingsboard.server.dao.util.NoSqlDao;
|
import org.thingsboard.server.dao.util.NoSqlDao;
|
||||||
|
import org.thingsboard.server.dao.util.NoSqlTsDao;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
@ -68,7 +69,7 @@ import static com.datastax.driver.core.querybuilder.QueryBuilder.eq;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@NoSqlDao
|
@NoSqlTsDao
|
||||||
public class CassandraBaseTimeseriesDao extends CassandraAbstractAsyncDao implements TimeseriesDao {
|
public class CassandraBaseTimeseriesDao extends CassandraAbstractAsyncDao implements TimeseriesDao {
|
||||||
|
|
||||||
private static final int MIN_AGGREGATION_STEP_MS = 1000;
|
private static final int MIN_AGGREGATION_STEP_MS = 1000;
|
||||||
|
|||||||
@ -34,7 +34,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@NoSqlDao
|
@NoSqlAnyDao
|
||||||
public class BufferedRateLimiter implements AsyncRateLimiter {
|
public class BufferedRateLimiter implements AsyncRateLimiter {
|
||||||
|
|
||||||
private final ListeningExecutorService pool = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
|
private final ListeningExecutorService pool = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
|
||||||
|
|||||||
@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* Copyright © 2016-2018 The Thingsboard Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.thingsboard.server.dao.util;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
|
||||||
|
|
||||||
|
@ConditionalOnExpression("'${database.type}'=='cassandra' || '${database.ts.type}'=='cassandra'")
|
||||||
|
public @interface NoSqlAnyDao {
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* Copyright © 2016-2018 The Thingsboard Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.thingsboard.server.dao.util;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
|
||||||
|
@ConditionalOnProperty(prefix = "database.ts", value = "type", havingValue = "cassandra")
|
||||||
|
public @interface NoSqlTsDao {
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* Copyright © 2016-2018 The Thingsboard Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.thingsboard.server.dao.util;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
|
|
||||||
|
@ConditionalOnProperty(prefix = "database.ts", value = "type", havingValue = "sql")
|
||||||
|
public @interface SqlTsDao {
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user