Commit 062cae2e18f431503e588b43016268740c570891

Authored by YevhenBondarenko
1 parent ba680570

Cassandra ts latest improvements

@@ -55,6 +55,8 @@ import static org.thingsboard.server.service.install.migrate.CassandraToSqlColum @@ -55,6 +55,8 @@ import static org.thingsboard.server.service.install.migrate.CassandraToSqlColum
55 @Slf4j 55 @Slf4j
56 public class CassandraTsLatestToSqlMigrateService implements TsLatestMigrateService { 56 public class CassandraTsLatestToSqlMigrateService implements TsLatestMigrateService {
57 57
  58 + private static final int LATEST_KEY_LENGTH = 255;
  59 +
58 @Autowired 60 @Autowired
59 private EntityDatabaseSchemaService entityDatabaseSchemaService; 61 private EntityDatabaseSchemaService entityDatabaseSchemaService;
60 62
@@ -168,6 +170,11 @@ public class CassandraTsLatestToSqlMigrateService implements TsLatestMigrateServ @@ -168,6 +170,11 @@ public class CassandraTsLatestToSqlMigrateService implements TsLatestMigrateServ
168 } 170 }
169 171
170 protected Integer getOrSaveKeyId(String strKey) { 172 protected Integer getOrSaveKeyId(String strKey) {
  173 + if (strKey.length() > LATEST_KEY_LENGTH) {
  174 + log.warn("Key is long. Max key length is 255\n{}", strKey);
  175 + strKey = strKey.substring(0, LATEST_KEY_LENGTH);
  176 + }
  177 +
171 Integer keyId = tsKvDictionaryMap.get(strKey); 178 Integer keyId = tsKvDictionaryMap.get(strKey);
172 if (keyId == null) { 179 if (keyId == null) {
173 Optional<TsKvDictionary> tsKvDictionaryOptional; 180 Optional<TsKvDictionary> tsKvDictionaryOptional;