migrate to java 17
This commit is contained in:
parent
17f084ec57
commit
40d6e67131
@ -21,7 +21,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.thingsboard.server.cache.CacheSpecsMap;
|
import org.thingsboard.server.cache.CacheSpecsMap;
|
||||||
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
||||||
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
||||||
import org.thingsboard.server.cache.TbFSTRedisSerializer;
|
import org.thingsboard.server.cache.TbJavaRedisSerializer;
|
||||||
import org.thingsboard.server.common.data.CacheConstants;
|
import org.thingsboard.server.common.data.CacheConstants;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -31,6 +31,6 @@ import java.util.UUID;
|
|||||||
public class VersionControlTaskRedisCache extends RedisTbTransactionalCache<UUID, VersionControlTaskCacheEntry> {
|
public class VersionControlTaskRedisCache extends RedisTbTransactionalCache<UUID, VersionControlTaskCacheEntry> {
|
||||||
|
|
||||||
public VersionControlTaskRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
public VersionControlTaskRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
||||||
super(CacheConstants.VERSION_CONTROL_TASK_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>());
|
super(CacheConstants.VERSION_CONTROL_TASK_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbJavaRedisSerializer<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.thingsboard.server.cache.CacheSpecsMap;
|
import org.thingsboard.server.cache.CacheSpecsMap;
|
||||||
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
||||||
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
||||||
import org.thingsboard.server.cache.TbFSTRedisSerializer;
|
import org.thingsboard.server.cache.TbJavaRedisSerializer;
|
||||||
import org.thingsboard.server.common.data.CacheConstants;
|
import org.thingsboard.server.common.data.CacheConstants;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
import org.thingsboard.server.common.data.sync.vc.AutoCommitSettings;
|
import org.thingsboard.server.common.data.sync.vc.AutoCommitSettings;
|
||||||
@ -31,6 +31,6 @@ import org.thingsboard.server.common.data.sync.vc.AutoCommitSettings;
|
|||||||
public class AutoCommitSettingsRedisCache extends RedisTbTransactionalCache<TenantId, AutoCommitSettings> {
|
public class AutoCommitSettingsRedisCache extends RedisTbTransactionalCache<TenantId, AutoCommitSettings> {
|
||||||
|
|
||||||
public AutoCommitSettingsRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
public AutoCommitSettingsRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
||||||
super(CacheConstants.AUTO_COMMIT_SETTINGS_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>());
|
super(CacheConstants.AUTO_COMMIT_SETTINGS_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbJavaRedisSerializer<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.thingsboard.server.cache.CacheSpecsMap;
|
import org.thingsboard.server.cache.CacheSpecsMap;
|
||||||
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
||||||
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
||||||
import org.thingsboard.server.cache.TbFSTRedisSerializer;
|
import org.thingsboard.server.cache.TbJavaRedisSerializer;
|
||||||
import org.thingsboard.server.common.data.CacheConstants;
|
import org.thingsboard.server.common.data.CacheConstants;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
import org.thingsboard.server.common.data.sync.vc.RepositorySettings;
|
import org.thingsboard.server.common.data.sync.vc.RepositorySettings;
|
||||||
@ -31,6 +31,6 @@ import org.thingsboard.server.common.data.sync.vc.RepositorySettings;
|
|||||||
public class RepositorySettingsRedisCache extends RedisTbTransactionalCache<TenantId, RepositorySettings> {
|
public class RepositorySettingsRedisCache extends RedisTbTransactionalCache<TenantId, RepositorySettings> {
|
||||||
|
|
||||||
public RepositorySettingsRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
public RepositorySettingsRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
||||||
super(CacheConstants.REPOSITORY_SETTINGS_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>());
|
super(CacheConstants.REPOSITORY_SETTINGS_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbJavaRedisSerializer<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -116,6 +116,8 @@ import org.thingsboard.server.service.security.auth.jwt.RefreshTokenRequest;
|
|||||||
import org.thingsboard.server.service.security.auth.rest.LoginRequest;
|
import org.thingsboard.server.service.security.auth.rest.LoginRequest;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.invoke.MethodHandles;
|
||||||
|
import java.lang.invoke.VarHandle;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -927,9 +929,15 @@ public abstract class AbstractWebTest extends AbstractInMemoryStorageTest {
|
|||||||
protected static void setStaticFinalFieldValue(Class<?> targetCls, String fieldName, Object value) throws Exception {
|
protected static void setStaticFinalFieldValue(Class<?> targetCls, String fieldName, Object value) throws Exception {
|
||||||
Field field = targetCls.getDeclaredField(fieldName);
|
Field field = targetCls.getDeclaredField(fieldName);
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
Field modifiers = Field.class.getDeclaredField("modifiers");
|
// Get the VarHandle for the 'modifiers' field in the Field class
|
||||||
modifiers.setAccessible(true);
|
MethodHandles.Lookup lookup = MethodHandles.privateLookupIn(Field.class, MethodHandles.lookup());
|
||||||
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
|
VarHandle modifiersHandle = lookup.findVarHandle(Field.class, "modifiers", int.class);
|
||||||
|
|
||||||
|
// Remove the final modifier from the field
|
||||||
|
int currentModifiers = field.getModifiers();
|
||||||
|
modifiersHandle.set(field, currentModifiers & ~Modifier.FINAL);
|
||||||
|
|
||||||
|
// Set the new value
|
||||||
field.set(null, value);
|
field.set(null, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,17 +16,17 @@
|
|||||||
package org.thingsboard.server.cache;
|
package org.thingsboard.server.cache;
|
||||||
|
|
||||||
import org.springframework.data.redis.serializer.SerializationException;
|
import org.springframework.data.redis.serializer.SerializationException;
|
||||||
import org.thingsboard.server.common.data.FSTUtils;
|
import org.thingsboard.server.common.data.JavaSerDesUtil;
|
||||||
|
|
||||||
public class TbFSTRedisSerializer<K, V> implements TbRedisSerializer<K, V> {
|
public class TbJavaRedisSerializer<K, V> implements TbRedisSerializer<K, V> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] serialize(V value) throws SerializationException {
|
public byte[] serialize(V value) throws SerializationException {
|
||||||
return FSTUtils.encode(value);
|
return JavaSerDesUtil.encode(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public V deserialize(K key, byte[] bytes) throws SerializationException {
|
public V deserialize(K key, byte[] bytes) throws SerializationException {
|
||||||
return FSTUtils.decode(bytes);
|
return JavaSerDesUtil.decode(bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -21,7 +21,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.thingsboard.server.cache.CacheSpecsMap;
|
import org.thingsboard.server.cache.CacheSpecsMap;
|
||||||
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
||||||
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
||||||
import org.thingsboard.server.cache.TbFSTRedisSerializer;
|
import org.thingsboard.server.cache.TbJavaRedisSerializer;
|
||||||
import org.thingsboard.server.common.data.CacheConstants;
|
import org.thingsboard.server.common.data.CacheConstants;
|
||||||
import org.thingsboard.server.common.data.Device;
|
import org.thingsboard.server.common.data.Device;
|
||||||
|
|
||||||
@ -30,6 +30,6 @@ import org.thingsboard.server.common.data.Device;
|
|||||||
public class DeviceRedisCache extends RedisTbTransactionalCache<DeviceCacheKey, Device> {
|
public class DeviceRedisCache extends RedisTbTransactionalCache<DeviceCacheKey, Device> {
|
||||||
|
|
||||||
public DeviceRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
public DeviceRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
||||||
super(CacheConstants.DEVICE_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>());
|
super(CacheConstants.DEVICE_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbJavaRedisSerializer<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.thingsboard.server.cache.CacheSpecsMap;
|
import org.thingsboard.server.cache.CacheSpecsMap;
|
||||||
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
||||||
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
||||||
import org.thingsboard.server.cache.TbFSTRedisSerializer;
|
import org.thingsboard.server.cache.TbJavaRedisSerializer;
|
||||||
import org.thingsboard.server.common.data.CacheConstants;
|
import org.thingsboard.server.common.data.CacheConstants;
|
||||||
|
|
||||||
@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "redis")
|
@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "redis")
|
||||||
@ -31,6 +31,6 @@ public class UsersSessionInvalidationRedisCache extends RedisTbTransactionalCach
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public UsersSessionInvalidationRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
public UsersSessionInvalidationRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
||||||
super(CacheConstants.USERS_SESSION_INVALIDATION_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>());
|
super(CacheConstants.USERS_SESSION_INVALIDATION_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbJavaRedisSerializer<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -108,10 +108,6 @@
|
|||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>de.ruedigermoeller</groupId>
|
|
||||||
<artifactId>fst</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.protobuf</groupId>
|
<groupId>com.google.protobuf</groupId>
|
||||||
<artifactId>protobuf-java-util</artifactId>
|
<artifactId>protobuf-java-util</artifactId>
|
||||||
|
|||||||
@ -1,35 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright © 2016-2023 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.common.data;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.nustaq.serialization.FSTConfiguration;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
public class FSTUtils {
|
|
||||||
|
|
||||||
public static final FSTConfiguration CONFIG = FSTConfiguration.createDefaultConfiguration();
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static <T> T decode(byte[] byteArray) {
|
|
||||||
return byteArray != null && byteArray.length > 0 ? (T) CONFIG.asObject(byteArray) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> byte[] encode(T msq) {
|
|
||||||
return CONFIG.asByteArray(msq);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* Copyright © 2016-2023 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.common.data;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class JavaSerDesUtil {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static <T> T decode(byte[] byteArray) {
|
||||||
|
if (byteArray == null || byteArray.length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
InputStream is = new ByteArrayInputStream(byteArray);
|
||||||
|
try (ObjectInputStream ois = new ObjectInputStream(is)) {
|
||||||
|
return (T) ois.readObject();
|
||||||
|
} catch (IOException | ClassNotFoundException e) {
|
||||||
|
log.error("Error during deserialization message, [{}]", e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> byte[] encode(T msq) {
|
||||||
|
if (msq == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
ByteArrayOutputStream boas = new ByteArrayOutputStream();
|
||||||
|
try (ObjectOutputStream ois = new ObjectOutputStream(boas)) {
|
||||||
|
ois.writeObject(msq);
|
||||||
|
return boas.toByteArray();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("Error during serialization message, [{}]", e.getMessage());
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -19,9 +19,11 @@ import io.swagger.annotations.ApiModel;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
@ApiModel
|
@ApiModel
|
||||||
@Data
|
@Data
|
||||||
public class LwM2MServerSecurityConfig {
|
public class LwM2MServerSecurityConfig implements Serializable {
|
||||||
|
|
||||||
@ApiModelProperty(position = 1, value = "Server short Id. Used as link to associate server Object Instance. This identifier uniquely identifies each LwM2M Server configured for the LwM2M Client. " +
|
@ApiModelProperty(position = 1, value = "Server short Id. Used as link to associate server Object Instance. This identifier uniquely identifies each LwM2M Server configured for the LwM2M Client. " +
|
||||||
"This Resource MUST be set when the Bootstrap-Server Resource has a value of 'false'. " +
|
"This Resource MUST be set when the Bootstrap-Server Resource has a value of 'false'. " +
|
||||||
|
|||||||
@ -17,8 +17,11 @@ package org.thingsboard.server.common.data.device.profile.lwm2m.bootstrap;
|
|||||||
|
|
||||||
import org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurityMode;
|
import org.thingsboard.server.common.data.device.credentials.lwm2m.LwM2MSecurityMode;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
public class NoSecLwM2MBootstrapServerCredential extends AbstractLwM2MBootstrapServerCredential {
|
public class NoSecLwM2MBootstrapServerCredential extends AbstractLwM2MBootstrapServerCredential {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 5540417758424747066L;
|
private static final long serialVersionUID = 5540417758424747066L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
package org.thingsboard.server.common.msg;
|
package org.thingsboard.server.common.msg;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.thingsboard.server.common.data.FSTUtils;
|
import org.thingsboard.server.common.data.JavaSerDesUtil;
|
||||||
import org.thingsboard.server.common.data.id.RuleChainId;
|
import org.thingsboard.server.common.data.id.RuleChainId;
|
||||||
import org.thingsboard.server.common.data.id.RuleNodeId;
|
import org.thingsboard.server.common.data.id.RuleNodeId;
|
||||||
|
|
||||||
@ -29,8 +29,8 @@ class TbMsgProcessingStackItemTest {
|
|||||||
@Test
|
@Test
|
||||||
void testSerialization() {
|
void testSerialization() {
|
||||||
TbMsgProcessingStackItem item = new TbMsgProcessingStackItem(new RuleChainId(UUID.randomUUID()), new RuleNodeId(UUID.randomUUID()));
|
TbMsgProcessingStackItem item = new TbMsgProcessingStackItem(new RuleChainId(UUID.randomUUID()), new RuleNodeId(UUID.randomUUID()));
|
||||||
byte[] bytes = FSTUtils.encode(item);
|
byte[] bytes = JavaSerDesUtil.encode(item);
|
||||||
TbMsgProcessingStackItem itemDecoded = FSTUtils.decode(bytes);
|
TbMsgProcessingStackItem itemDecoded = JavaSerDesUtil.decode(bytes);
|
||||||
assertThat(item).isEqualTo(itemDecoded);
|
assertThat(item).isEqualTo(itemDecoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,33 +16,21 @@
|
|||||||
package org.thingsboard.server.queue.util;
|
package org.thingsboard.server.queue.util;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nustaq.serialization.FSTConfiguration;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thingsboard.server.common.data.FSTUtils;
|
import org.thingsboard.server.common.data.JavaSerDesUtil;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class ProtoWithFSTService implements DataDecodingEncodingService {
|
public class JavaDataDecodingEncodingService implements DataDecodingEncodingService {
|
||||||
|
|
||||||
public static final FSTConfiguration CONFIG = FSTConfiguration.createDefaultConfiguration();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> Optional<T> decode(byte[] byteArray) {
|
public <T> Optional<T> decode(byte[] byteArray) {
|
||||||
try {
|
return Optional.ofNullable(JavaSerDesUtil.decode(byteArray));
|
||||||
return Optional.ofNullable(FSTUtils.decode(byteArray));
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
log.error("Error during deserialization message, [{}]", e.getMessage());
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> byte[] encode(T msq) {
|
public <T> byte[] encode(T msq) {
|
||||||
return FSTUtils.encode(msq);
|
return JavaSerDesUtil.encode(msq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -52,6 +52,10 @@
|
|||||||
<groupId>org.javadelight</groupId>
|
<groupId>org.javadelight</groupId>
|
||||||
<artifactId>delight-nashorn-sandbox</artifactId>
|
<artifactId>delight-nashorn-sandbox</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjdk.nashorn</groupId>
|
||||||
|
<artifactId>nashorn-core</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
|
|||||||
@ -15,25 +15,23 @@
|
|||||||
*/
|
*/
|
||||||
package org.thingsboard.server.transport.lwm2m.server.store;
|
package org.thingsboard.server.transport.lwm2m.server.store;
|
||||||
|
|
||||||
import org.nustaq.serialization.FSTConfiguration;
|
|
||||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
import org.thingsboard.server.common.data.JavaSerDesUtil;
|
||||||
import org.thingsboard.server.transport.lwm2m.secure.TbX509DtlsSessionInfo;
|
import org.thingsboard.server.transport.lwm2m.secure.TbX509DtlsSessionInfo;
|
||||||
|
|
||||||
public class TbLwM2MDtlsSessionRedisStore implements TbLwM2MDtlsSessionStore {
|
public class TbLwM2MDtlsSessionRedisStore implements TbLwM2MDtlsSessionStore {
|
||||||
|
|
||||||
private static final String SESSION_EP = "SESSION#EP#";
|
private static final String SESSION_EP = "SESSION#EP#";
|
||||||
private final RedisConnectionFactory connectionFactory;
|
private final RedisConnectionFactory connectionFactory;
|
||||||
private final FSTConfiguration serializer;
|
|
||||||
|
|
||||||
public TbLwM2MDtlsSessionRedisStore(RedisConnectionFactory redisConnectionFactory) {
|
public TbLwM2MDtlsSessionRedisStore(RedisConnectionFactory redisConnectionFactory) {
|
||||||
this.connectionFactory = redisConnectionFactory;
|
this.connectionFactory = redisConnectionFactory;
|
||||||
this.serializer = FSTConfiguration.createDefaultConfiguration();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void put(String endpoint, TbX509DtlsSessionInfo msg) {
|
public void put(String endpoint, TbX509DtlsSessionInfo msg) {
|
||||||
try (var c = connectionFactory.getConnection()) {
|
try (var c = connectionFactory.getConnection()) {
|
||||||
var serializedMsg = serializer.asByteArray(msg);
|
var serializedMsg = JavaSerDesUtil.encode(msg);
|
||||||
if (serializedMsg != null) {
|
if (serializedMsg != null) {
|
||||||
c.set(getKey(endpoint), serializedMsg);
|
c.set(getKey(endpoint), serializedMsg);
|
||||||
} else {
|
} else {
|
||||||
@ -47,7 +45,7 @@ public class TbLwM2MDtlsSessionRedisStore implements TbLwM2MDtlsSessionStore {
|
|||||||
try (var c = connectionFactory.getConnection()) {
|
try (var c = connectionFactory.getConnection()) {
|
||||||
var data = c.get(getKey(endpoint));
|
var data = c.get(getKey(endpoint));
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
return (TbX509DtlsSessionInfo) serializer.asObject(data);
|
return JavaSerDesUtil.decode(data);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,9 +18,9 @@ package org.thingsboard.server.transport.lwm2m.server.store;
|
|||||||
import org.eclipse.leshan.core.SecurityMode;
|
import org.eclipse.leshan.core.SecurityMode;
|
||||||
import org.eclipse.leshan.server.security.NonUniqueSecurityInfoException;
|
import org.eclipse.leshan.server.security.NonUniqueSecurityInfoException;
|
||||||
import org.eclipse.leshan.server.security.SecurityInfo;
|
import org.eclipse.leshan.server.security.SecurityInfo;
|
||||||
import org.nustaq.serialization.FSTConfiguration;
|
|
||||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
import org.springframework.integration.redis.util.RedisLockRegistry;
|
import org.springframework.integration.redis.util.RedisLockRegistry;
|
||||||
|
import org.thingsboard.server.common.data.JavaSerDesUtil;
|
||||||
import org.thingsboard.server.transport.lwm2m.secure.TbLwM2MSecurityInfo;
|
import org.thingsboard.server.transport.lwm2m.secure.TbLwM2MSecurityInfo;
|
||||||
|
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
@ -31,13 +31,11 @@ public class TbLwM2mRedisSecurityStore implements TbEditableSecurityStore {
|
|||||||
private static final String PSKID_SEC = "PSKID#SEC";
|
private static final String PSKID_SEC = "PSKID#SEC";
|
||||||
|
|
||||||
private final RedisConnectionFactory connectionFactory;
|
private final RedisConnectionFactory connectionFactory;
|
||||||
private final FSTConfiguration serializer;
|
|
||||||
private final RedisLockRegistry redisLock;
|
private final RedisLockRegistry redisLock;
|
||||||
|
|
||||||
public TbLwM2mRedisSecurityStore(RedisConnectionFactory connectionFactory) {
|
public TbLwM2mRedisSecurityStore(RedisConnectionFactory connectionFactory) {
|
||||||
this.connectionFactory = connectionFactory;
|
this.connectionFactory = connectionFactory;
|
||||||
redisLock = new RedisLockRegistry(connectionFactory, "Security");
|
redisLock = new RedisLockRegistry(connectionFactory, "Security");
|
||||||
serializer = FSTConfiguration.createDefaultConfiguration();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -50,12 +48,11 @@ public class TbLwM2mRedisSecurityStore implements TbEditableSecurityStore {
|
|||||||
if (data == null || data.length == 0) {
|
if (data == null || data.length == 0) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
if (SecurityMode.NO_SEC.equals(((TbLwM2MSecurityInfo) serializer.asObject(data)).getSecurityMode())) {
|
if (SecurityMode.NO_SEC.equals(((TbLwM2MSecurityInfo) JavaSerDesUtil.decode(data)).getSecurityMode())) {
|
||||||
return SecurityInfo.newPreSharedKeyInfo(SecurityMode.NO_SEC.toString(), SecurityMode.NO_SEC.toString(),
|
return SecurityInfo.newPreSharedKeyInfo(SecurityMode.NO_SEC.toString(), SecurityMode.NO_SEC.toString(),
|
||||||
SecurityMode.NO_SEC.toString().getBytes());
|
SecurityMode.NO_SEC.toString().getBytes());
|
||||||
}
|
} else {
|
||||||
else {
|
return ((TbLwM2MSecurityInfo) JavaSerDesUtil.decode(data)).getSecurityInfo();
|
||||||
return ((TbLwM2MSecurityInfo) serializer.asObject(data)).getSecurityInfo();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@ -79,7 +76,7 @@ public class TbLwM2mRedisSecurityStore implements TbEditableSecurityStore {
|
|||||||
if (data == null || data.length == 0) {
|
if (data == null || data.length == 0) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return ((TbLwM2MSecurityInfo) serializer.asObject(data)).getSecurityInfo();
|
return ((TbLwM2MSecurityInfo) JavaSerDesUtil.decode(data)).getSecurityInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@ -92,7 +89,7 @@ public class TbLwM2mRedisSecurityStore implements TbEditableSecurityStore {
|
|||||||
@Override
|
@Override
|
||||||
public void put(TbLwM2MSecurityInfo tbSecurityInfo) throws NonUniqueSecurityInfoException {
|
public void put(TbLwM2MSecurityInfo tbSecurityInfo) throws NonUniqueSecurityInfoException {
|
||||||
SecurityInfo info = tbSecurityInfo.getSecurityInfo();
|
SecurityInfo info = tbSecurityInfo.getSecurityInfo();
|
||||||
byte[] tbSecurityInfoSerialized = serializer.asByteArray(tbSecurityInfo);
|
byte[] tbSecurityInfoSerialized = JavaSerDesUtil.encode(tbSecurityInfo);
|
||||||
Lock lock = null;
|
Lock lock = null;
|
||||||
try (var connection = connectionFactory.getConnection()) {
|
try (var connection = connectionFactory.getConnection()) {
|
||||||
lock = redisLock.obtain(tbSecurityInfo.getEndpoint());
|
lock = redisLock.obtain(tbSecurityInfo.getEndpoint());
|
||||||
@ -110,7 +107,7 @@ public class TbLwM2mRedisSecurityStore implements TbEditableSecurityStore {
|
|||||||
|
|
||||||
byte[] previousData = connection.getSet((SEC_EP + tbSecurityInfo.getEndpoint()).getBytes(), tbSecurityInfoSerialized);
|
byte[] previousData = connection.getSet((SEC_EP + tbSecurityInfo.getEndpoint()).getBytes(), tbSecurityInfoSerialized);
|
||||||
if (previousData != null && info != null) {
|
if (previousData != null && info != null) {
|
||||||
String previousIdentity = ((TbLwM2MSecurityInfo) serializer.asObject(previousData)).getSecurityInfo().getIdentity();
|
String previousIdentity = ((TbLwM2MSecurityInfo) JavaSerDesUtil.decode(previousData)).getSecurityInfo().getIdentity();
|
||||||
if (previousIdentity != null && !previousIdentity.equals(info.getIdentity())) {
|
if (previousIdentity != null && !previousIdentity.equals(info.getIdentity())) {
|
||||||
connection.hDel(PSKID_SEC.getBytes(), previousIdentity.getBytes());
|
connection.hDel(PSKID_SEC.getBytes(), previousIdentity.getBytes());
|
||||||
}
|
}
|
||||||
@ -130,7 +127,7 @@ public class TbLwM2mRedisSecurityStore implements TbEditableSecurityStore {
|
|||||||
lock.lock();
|
lock.lock();
|
||||||
byte[] data = connection.get((SEC_EP + endpoint).getBytes());
|
byte[] data = connection.get((SEC_EP + endpoint).getBytes());
|
||||||
if (data != null && data.length > 0) {
|
if (data != null && data.length > 0) {
|
||||||
return (TbLwM2MSecurityInfo) serializer.asObject(data);
|
return JavaSerDesUtil.decode(data);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -149,7 +146,7 @@ public class TbLwM2mRedisSecurityStore implements TbEditableSecurityStore {
|
|||||||
lock.lock();
|
lock.lock();
|
||||||
byte[] data = connection.get((SEC_EP + endpoint).getBytes());
|
byte[] data = connection.get((SEC_EP + endpoint).getBytes());
|
||||||
if (data != null && data.length > 0) {
|
if (data != null && data.length > 0) {
|
||||||
SecurityInfo info = ((TbLwM2MSecurityInfo) serializer.asObject(data)).getSecurityInfo();
|
SecurityInfo info = ((TbLwM2MSecurityInfo) JavaSerDesUtil.decode(data)).getSecurityInfo();
|
||||||
if (info != null && info.getIdentity() != null) {
|
if (info != null && info.getIdentity() != null) {
|
||||||
connection.hDel(PSKID_SEC.getBytes(), info.getIdentity().getBytes());
|
connection.hDel(PSKID_SEC.getBytes(), info.getIdentity().getBytes());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.thingsboard.server.cache.CacheSpecsMap;
|
import org.thingsboard.server.cache.CacheSpecsMap;
|
||||||
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
||||||
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
||||||
import org.thingsboard.server.cache.TbFSTRedisSerializer;
|
import org.thingsboard.server.cache.TbJavaRedisSerializer;
|
||||||
import org.thingsboard.server.common.data.CacheConstants;
|
import org.thingsboard.server.common.data.CacheConstants;
|
||||||
import org.thingsboard.server.common.data.asset.AssetProfile;
|
import org.thingsboard.server.common.data.asset.AssetProfile;
|
||||||
|
|
||||||
@ -30,6 +30,6 @@ import org.thingsboard.server.common.data.asset.AssetProfile;
|
|||||||
public class AssetProfileRedisCache extends RedisTbTransactionalCache<AssetProfileCacheKey, AssetProfile> {
|
public class AssetProfileRedisCache extends RedisTbTransactionalCache<AssetProfileCacheKey, AssetProfile> {
|
||||||
|
|
||||||
public AssetProfileRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
public AssetProfileRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
||||||
super(CacheConstants.ASSET_PROFILE_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>());
|
super(CacheConstants.ASSET_PROFILE_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbJavaRedisSerializer<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,13 +23,13 @@ import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
|||||||
import org.thingsboard.server.common.data.CacheConstants;
|
import org.thingsboard.server.common.data.CacheConstants;
|
||||||
import org.thingsboard.server.common.data.asset.Asset;
|
import org.thingsboard.server.common.data.asset.Asset;
|
||||||
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
||||||
import org.thingsboard.server.cache.TbFSTRedisSerializer;
|
import org.thingsboard.server.cache.TbJavaRedisSerializer;
|
||||||
|
|
||||||
@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "redis")
|
@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "redis")
|
||||||
@Service("AssetCache")
|
@Service("AssetCache")
|
||||||
public class AssetRedisCache extends RedisTbTransactionalCache<AssetCacheKey, Asset> {
|
public class AssetRedisCache extends RedisTbTransactionalCache<AssetCacheKey, Asset> {
|
||||||
|
|
||||||
public AssetRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
public AssetRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
||||||
super(CacheConstants.ASSET_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>());
|
super(CacheConstants.ASSET_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbJavaRedisSerializer<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.thingsboard.server.cache.CacheSpecsMap;
|
import org.thingsboard.server.cache.CacheSpecsMap;
|
||||||
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
||||||
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
||||||
import org.thingsboard.server.cache.TbFSTRedisSerializer;
|
import org.thingsboard.server.cache.TbJavaRedisSerializer;
|
||||||
import org.thingsboard.server.common.data.CacheConstants;
|
import org.thingsboard.server.common.data.CacheConstants;
|
||||||
import org.thingsboard.server.common.data.id.DashboardId;
|
import org.thingsboard.server.common.data.id.DashboardId;
|
||||||
|
|
||||||
@ -30,6 +30,6 @@ import org.thingsboard.server.common.data.id.DashboardId;
|
|||||||
public class DashboardTitlesRedisCache extends RedisTbTransactionalCache<DashboardId, String> {
|
public class DashboardTitlesRedisCache extends RedisTbTransactionalCache<DashboardId, String> {
|
||||||
|
|
||||||
public DashboardTitlesRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
public DashboardTitlesRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
||||||
super(CacheConstants.DASHBOARD_TITLES_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>());
|
super(CacheConstants.DASHBOARD_TITLES_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbJavaRedisSerializer<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thingsboard.server.cache.CacheSpecsMap;
|
import org.thingsboard.server.cache.CacheSpecsMap;
|
||||||
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
||||||
import org.thingsboard.server.cache.TbFSTRedisSerializer;
|
import org.thingsboard.server.cache.TbJavaRedisSerializer;
|
||||||
import org.thingsboard.server.common.data.CacheConstants;
|
import org.thingsboard.server.common.data.CacheConstants;
|
||||||
import org.thingsboard.server.common.data.security.DeviceCredentials;
|
import org.thingsboard.server.common.data.security.DeviceCredentials;
|
||||||
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
||||||
@ -30,6 +30,6 @@ import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
|||||||
public class DeviceCredentialsRedisCache extends RedisTbTransactionalCache<String, DeviceCredentials> {
|
public class DeviceCredentialsRedisCache extends RedisTbTransactionalCache<String, DeviceCredentials> {
|
||||||
|
|
||||||
public DeviceCredentialsRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
public DeviceCredentialsRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
||||||
super(CacheConstants.DEVICE_CREDENTIALS_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>());
|
super(CacheConstants.DEVICE_CREDENTIALS_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbJavaRedisSerializer<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thingsboard.server.cache.CacheSpecsMap;
|
import org.thingsboard.server.cache.CacheSpecsMap;
|
||||||
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
||||||
import org.thingsboard.server.cache.TbFSTRedisSerializer;
|
import org.thingsboard.server.cache.TbJavaRedisSerializer;
|
||||||
import org.thingsboard.server.common.data.CacheConstants;
|
import org.thingsboard.server.common.data.CacheConstants;
|
||||||
import org.thingsboard.server.common.data.DeviceProfile;
|
import org.thingsboard.server.common.data.DeviceProfile;
|
||||||
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
||||||
@ -30,6 +30,6 @@ import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
|||||||
public class DeviceProfileRedisCache extends RedisTbTransactionalCache<DeviceProfileCacheKey, DeviceProfile> {
|
public class DeviceProfileRedisCache extends RedisTbTransactionalCache<DeviceProfileCacheKey, DeviceProfile> {
|
||||||
|
|
||||||
public DeviceProfileRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
public DeviceProfileRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
||||||
super(CacheConstants.DEVICE_PROFILE_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>());
|
super(CacheConstants.DEVICE_PROFILE_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbJavaRedisSerializer<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,13 +23,13 @@ import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
|||||||
import org.thingsboard.server.common.data.CacheConstants;
|
import org.thingsboard.server.common.data.CacheConstants;
|
||||||
import org.thingsboard.server.common.data.edge.Edge;
|
import org.thingsboard.server.common.data.edge.Edge;
|
||||||
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
||||||
import org.thingsboard.server.cache.TbFSTRedisSerializer;
|
import org.thingsboard.server.cache.TbJavaRedisSerializer;
|
||||||
|
|
||||||
@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "redis")
|
@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "redis")
|
||||||
@Service("EdgeCache")
|
@Service("EdgeCache")
|
||||||
public class EdgeRedisCache extends RedisTbTransactionalCache<EdgeCacheKey, Edge> {
|
public class EdgeRedisCache extends RedisTbTransactionalCache<EdgeCacheKey, Edge> {
|
||||||
|
|
||||||
public EdgeRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
public EdgeRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
||||||
super(CacheConstants.EDGE_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>());
|
super(CacheConstants.EDGE_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbJavaRedisSerializer<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.thingsboard.server.cache.CacheSpecsMap;
|
import org.thingsboard.server.cache.CacheSpecsMap;
|
||||||
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
||||||
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
||||||
import org.thingsboard.server.cache.TbFSTRedisSerializer;
|
import org.thingsboard.server.cache.TbJavaRedisSerializer;
|
||||||
import org.thingsboard.server.common.data.CacheConstants;
|
import org.thingsboard.server.common.data.CacheConstants;
|
||||||
import org.thingsboard.server.dao.entity.EntityCountCacheKey;
|
import org.thingsboard.server.dao.entity.EntityCountCacheKey;
|
||||||
|
|
||||||
@ -30,6 +30,6 @@ import org.thingsboard.server.dao.entity.EntityCountCacheKey;
|
|||||||
public class EntityCountRedisCache extends RedisTbTransactionalCache<EntityCountCacheKey, Long> {
|
public class EntityCountRedisCache extends RedisTbTransactionalCache<EntityCountCacheKey, Long> {
|
||||||
|
|
||||||
public EntityCountRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
public EntityCountRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
||||||
super(CacheConstants.ENTITY_COUNT_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>());
|
super(CacheConstants.ENTITY_COUNT_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbJavaRedisSerializer<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,13 +22,13 @@ import org.thingsboard.server.cache.CacheSpecsMap;
|
|||||||
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
||||||
import org.thingsboard.server.common.data.CacheConstants;
|
import org.thingsboard.server.common.data.CacheConstants;
|
||||||
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
||||||
import org.thingsboard.server.cache.TbFSTRedisSerializer;
|
import org.thingsboard.server.cache.TbJavaRedisSerializer;
|
||||||
|
|
||||||
@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "redis")
|
@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "redis")
|
||||||
@Service("EntityViewCache")
|
@Service("EntityViewCache")
|
||||||
public class EntityViewRedisCache extends RedisTbTransactionalCache<EntityViewCacheKey, EntityViewCacheValue> {
|
public class EntityViewRedisCache extends RedisTbTransactionalCache<EntityViewCacheKey, EntityViewCacheValue> {
|
||||||
|
|
||||||
public EntityViewRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
public EntityViewRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
||||||
super(CacheConstants.ENTITY_VIEW_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>());
|
super(CacheConstants.ENTITY_VIEW_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbJavaRedisSerializer<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thingsboard.server.cache.CacheSpecsMap;
|
import org.thingsboard.server.cache.CacheSpecsMap;
|
||||||
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
||||||
import org.thingsboard.server.cache.TbFSTRedisSerializer;
|
import org.thingsboard.server.cache.TbJavaRedisSerializer;
|
||||||
import org.thingsboard.server.common.data.CacheConstants;
|
import org.thingsboard.server.common.data.CacheConstants;
|
||||||
import org.thingsboard.server.common.data.OtaPackageInfo;
|
import org.thingsboard.server.common.data.OtaPackageInfo;
|
||||||
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
||||||
@ -30,6 +30,6 @@ import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
|||||||
public class OtaPackageRedisCache extends RedisTbTransactionalCache<OtaPackageCacheKey, OtaPackageInfo> {
|
public class OtaPackageRedisCache extends RedisTbTransactionalCache<OtaPackageCacheKey, OtaPackageInfo> {
|
||||||
|
|
||||||
public OtaPackageRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
public OtaPackageRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
||||||
super(CacheConstants.OTA_PACKAGE_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>());
|
super(CacheConstants.OTA_PACKAGE_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbJavaRedisSerializer<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thingsboard.server.cache.CacheSpecsMap;
|
import org.thingsboard.server.cache.CacheSpecsMap;
|
||||||
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
||||||
import org.thingsboard.server.cache.TbFSTRedisSerializer;
|
import org.thingsboard.server.cache.TbJavaRedisSerializer;
|
||||||
import org.thingsboard.server.common.data.CacheConstants;
|
import org.thingsboard.server.common.data.CacheConstants;
|
||||||
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
||||||
|
|
||||||
@ -29,6 +29,6 @@ import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
|||||||
public class RelationRedisCache extends RedisTbTransactionalCache<RelationCacheKey, RelationCacheValue> {
|
public class RelationRedisCache extends RedisTbTransactionalCache<RelationCacheKey, RelationCacheValue> {
|
||||||
|
|
||||||
public RelationRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
public RelationRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
||||||
super(CacheConstants.RELATIONS_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>());
|
super(CacheConstants.RELATIONS_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbJavaRedisSerializer<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.thingsboard.server.cache.CacheSpecsMap;
|
import org.thingsboard.server.cache.CacheSpecsMap;
|
||||||
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
||||||
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
||||||
import org.thingsboard.server.cache.TbFSTRedisSerializer;
|
import org.thingsboard.server.cache.TbJavaRedisSerializer;
|
||||||
import org.thingsboard.server.common.data.CacheConstants;
|
import org.thingsboard.server.common.data.CacheConstants;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
|
|
||||||
@ -30,6 +30,6 @@ import org.thingsboard.server.common.data.id.TenantId;
|
|||||||
public class TenantExistsRedisCache extends RedisTbTransactionalCache<TenantId, Boolean> {
|
public class TenantExistsRedisCache extends RedisTbTransactionalCache<TenantId, Boolean> {
|
||||||
|
|
||||||
public TenantExistsRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
public TenantExistsRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
||||||
super(CacheConstants.TENANTS_EXIST_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>());
|
super(CacheConstants.TENANTS_EXIST_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbJavaRedisSerializer<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,13 +23,13 @@ import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
|||||||
import org.thingsboard.server.common.data.CacheConstants;
|
import org.thingsboard.server.common.data.CacheConstants;
|
||||||
import org.thingsboard.server.common.data.TenantProfile;
|
import org.thingsboard.server.common.data.TenantProfile;
|
||||||
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
||||||
import org.thingsboard.server.cache.TbFSTRedisSerializer;
|
import org.thingsboard.server.cache.TbJavaRedisSerializer;
|
||||||
|
|
||||||
@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "redis")
|
@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "redis")
|
||||||
@Service("TenantProfileCache")
|
@Service("TenantProfileCache")
|
||||||
public class TenantProfileRedisCache extends RedisTbTransactionalCache<TenantProfileCacheKey, TenantProfile> {
|
public class TenantProfileRedisCache extends RedisTbTransactionalCache<TenantProfileCacheKey, TenantProfile> {
|
||||||
|
|
||||||
public TenantProfileRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
public TenantProfileRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
||||||
super(CacheConstants.TENANT_PROFILE_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>());
|
super(CacheConstants.TENANT_PROFILE_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbJavaRedisSerializer<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.thingsboard.server.cache.CacheSpecsMap;
|
import org.thingsboard.server.cache.CacheSpecsMap;
|
||||||
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
||||||
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
||||||
import org.thingsboard.server.cache.TbFSTRedisSerializer;
|
import org.thingsboard.server.cache.TbJavaRedisSerializer;
|
||||||
import org.thingsboard.server.common.data.CacheConstants;
|
import org.thingsboard.server.common.data.CacheConstants;
|
||||||
import org.thingsboard.server.common.data.Tenant;
|
import org.thingsboard.server.common.data.Tenant;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
@ -31,6 +31,6 @@ import org.thingsboard.server.common.data.id.TenantId;
|
|||||||
public class TenantRedisCache extends RedisTbTransactionalCache<TenantId, Tenant> {
|
public class TenantRedisCache extends RedisTbTransactionalCache<TenantId, Tenant> {
|
||||||
|
|
||||||
public TenantRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
public TenantRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
||||||
super(CacheConstants.TENANTS_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>());
|
super(CacheConstants.TENANTS_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbJavaRedisSerializer<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,9 +21,8 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.thingsboard.server.cache.CacheSpecsMap;
|
import org.thingsboard.server.cache.CacheSpecsMap;
|
||||||
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
import org.thingsboard.server.cache.RedisTbTransactionalCache;
|
||||||
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
import org.thingsboard.server.cache.TBRedisCacheConfiguration;
|
||||||
import org.thingsboard.server.cache.TbFSTRedisSerializer;
|
import org.thingsboard.server.cache.TbJavaRedisSerializer;
|
||||||
import org.thingsboard.server.common.data.CacheConstants;
|
import org.thingsboard.server.common.data.CacheConstants;
|
||||||
import org.thingsboard.server.common.data.id.UserId;
|
|
||||||
import org.thingsboard.server.common.data.settings.UserSettings;
|
import org.thingsboard.server.common.data.settings.UserSettings;
|
||||||
import org.thingsboard.server.common.data.settings.UserSettingsCompositeKey;
|
import org.thingsboard.server.common.data.settings.UserSettingsCompositeKey;
|
||||||
|
|
||||||
@ -32,6 +31,6 @@ import org.thingsboard.server.common.data.settings.UserSettingsCompositeKey;
|
|||||||
public class UserSettingsRedisCache extends RedisTbTransactionalCache<UserSettingsCompositeKey, UserSettings> {
|
public class UserSettingsRedisCache extends RedisTbTransactionalCache<UserSettingsCompositeKey, UserSettings> {
|
||||||
|
|
||||||
public UserSettingsRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
public UserSettingsRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) {
|
||||||
super(CacheConstants.USER_SETTINGS_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>());
|
super(CacheConstants.USER_SETTINGS_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbJavaRedisSerializer<>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
pom.xml
17
pom.xml
@ -79,7 +79,7 @@
|
|||||||
<protobuf.version>3.21.9</protobuf.version>
|
<protobuf.version>3.21.9</protobuf.version>
|
||||||
<grpc.version>1.42.1</grpc.version>
|
<grpc.version>1.42.1</grpc.version>
|
||||||
<tbel.version>1.0.6</tbel.version>
|
<tbel.version>1.0.6</tbel.version>
|
||||||
<lombok.version>1.18.18</lombok.version>
|
<lombok.version>1.18.26</lombok.version>
|
||||||
<paho.client.version>1.2.4</paho.client.version>
|
<paho.client.version>1.2.4</paho.client.version>
|
||||||
<paho.mqttv5.client.version>1.2.5</paho.mqttv5.client.version>
|
<paho.mqttv5.client.version>1.2.5</paho.mqttv5.client.version>
|
||||||
<netty.version>4.1.91.Final</netty.version>
|
<netty.version>4.1.91.Final</netty.version>
|
||||||
@ -100,12 +100,12 @@
|
|||||||
</sonar.exclusions>
|
</sonar.exclusions>
|
||||||
<elasticsearch.version>5.0.2</elasticsearch.version>
|
<elasticsearch.version>5.0.2</elasticsearch.version>
|
||||||
<delight-nashorn-sandbox.version>0.2.1</delight-nashorn-sandbox.version>
|
<delight-nashorn-sandbox.version>0.2.1</delight-nashorn-sandbox.version>
|
||||||
|
<nashorn-core.version>15.4</nashorn-core.version>
|
||||||
<!-- IMPORTANT: If you change the version of the kafka client, make sure to synchronize our overwritten implementation of the
|
<!-- IMPORTANT: If you change the version of the kafka client, make sure to synchronize our overwritten implementation of the
|
||||||
org.apache.kafka.common.network.NetworkReceive class in the application module. It addresses the issue https://issues.apache.org/jira/browse/KAFKA-4090.
|
org.apache.kafka.common.network.NetworkReceive class in the application module. It addresses the issue https://issues.apache.org/jira/browse/KAFKA-4090.
|
||||||
Here is the source to track https://github.com/apache/kafka/tree/trunk/clients/src/main/java/org/apache/kafka/common/network -->
|
Here is the source to track https://github.com/apache/kafka/tree/trunk/clients/src/main/java/org/apache/kafka/common/network -->
|
||||||
<kafka.version>3.2.0</kafka.version>
|
<kafka.version>3.2.0</kafka.version>
|
||||||
<bucket4j.version>4.1.1</bucket4j.version>
|
<bucket4j.version>4.1.1</bucket4j.version>
|
||||||
<fst.version>2.57</fst.version>
|
|
||||||
<antlr.version>2.7.7</antlr.version>
|
<antlr.version>2.7.7</antlr.version>
|
||||||
<snakeyaml.version>2.0</snakeyaml.version>
|
<snakeyaml.version>2.0</snakeyaml.version>
|
||||||
<aws.sdk.version>1.11.747</aws.sdk.version>
|
<aws.sdk.version>1.11.747</aws.sdk.version>
|
||||||
@ -607,7 +607,7 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.1</version>
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<release>11</release>
|
<release>17</release>
|
||||||
<compilerArgs>
|
<compilerArgs>
|
||||||
<arg>-Xlint:deprecation</arg>
|
<arg>-Xlint:deprecation</arg>
|
||||||
<arg>-Xlint:removal</arg>
|
<arg>-Xlint:removal</arg>
|
||||||
@ -664,6 +664,7 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<argLine>
|
<argLine>
|
||||||
--illegal-access=permit -XX:+UseStringDeduplication -XX:MaxGCPauseMillis=20
|
--illegal-access=permit -XX:+UseStringDeduplication -XX:MaxGCPauseMillis=20
|
||||||
|
--add-opens java.base/java.lang.reflect=ALL-UNNAMED
|
||||||
</argLine>
|
</argLine>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
@ -1797,11 +1798,6 @@
|
|||||||
<artifactId>bucket4j-core</artifactId>
|
<artifactId>bucket4j-core</artifactId>
|
||||||
<version>${bucket4j.version}</version>
|
<version>${bucket4j.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>de.ruedigermoeller</groupId>
|
|
||||||
<artifactId>fst</artifactId>
|
|
||||||
<version>${fst.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.locationtech.spatial4j</groupId>
|
<groupId>org.locationtech.spatial4j</groupId>
|
||||||
<artifactId>spatial4j</artifactId>
|
<artifactId>spatial4j</artifactId>
|
||||||
@ -2007,6 +2003,11 @@
|
|||||||
<artifactId>oshi-core</artifactId>
|
<artifactId>oshi-core</artifactId>
|
||||||
<version>${oshi.version}</version>
|
<version>${oshi.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.openjdk.nashorn</groupId>
|
||||||
|
<artifactId>nashorn-core</artifactId>
|
||||||
|
<version>${nashorn-core.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user