set prepared statement array atomically to prevent corrupted arrays to be created in case of temporary issues on Cassandra cluster
This commit is contained in:
parent
6c9ad0399d
commit
ba2a15b0e4
@ -643,9 +643,9 @@ public class CassandraBaseTimeseriesDao extends AbstractCassandraBaseTimeseriesD
|
|||||||
stmtCreationLock.lock();
|
stmtCreationLock.lock();
|
||||||
try {
|
try {
|
||||||
if (saveStmts == null) {
|
if (saveStmts == null) {
|
||||||
saveStmts = new PreparedStatement[DataType.values().length];
|
var stmts = new PreparedStatement[DataType.values().length];
|
||||||
for (DataType type : DataType.values()) {
|
for (DataType type : DataType.values()) {
|
||||||
saveStmts[type.ordinal()] = prepare(INSERT_INTO + ModelConstants.TS_KV_CF +
|
stmts[type.ordinal()] = prepare(INSERT_INTO + ModelConstants.TS_KV_CF +
|
||||||
"(" + ModelConstants.ENTITY_TYPE_COLUMN +
|
"(" + ModelConstants.ENTITY_TYPE_COLUMN +
|
||||||
"," + ModelConstants.ENTITY_ID_COLUMN +
|
"," + ModelConstants.ENTITY_ID_COLUMN +
|
||||||
"," + ModelConstants.KEY_COLUMN +
|
"," + ModelConstants.KEY_COLUMN +
|
||||||
@ -654,6 +654,7 @@ public class CassandraBaseTimeseriesDao extends AbstractCassandraBaseTimeseriesD
|
|||||||
"," + getColumnName(type) + ")" +
|
"," + getColumnName(type) + ")" +
|
||||||
" VALUES(?, ?, ?, ?, ?, ?)");
|
" VALUES(?, ?, ?, ?, ?, ?)");
|
||||||
}
|
}
|
||||||
|
saveStmts = stmts;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
stmtCreationLock.unlock();
|
stmtCreationLock.unlock();
|
||||||
@ -667,9 +668,9 @@ public class CassandraBaseTimeseriesDao extends AbstractCassandraBaseTimeseriesD
|
|||||||
stmtCreationLock.lock();
|
stmtCreationLock.lock();
|
||||||
try {
|
try {
|
||||||
if (saveTtlStmts == null) {
|
if (saveTtlStmts == null) {
|
||||||
saveTtlStmts = new PreparedStatement[DataType.values().length];
|
var stmts = new PreparedStatement[DataType.values().length];
|
||||||
for (DataType type : DataType.values()) {
|
for (DataType type : DataType.values()) {
|
||||||
saveTtlStmts[type.ordinal()] = prepare(INSERT_INTO + ModelConstants.TS_KV_CF +
|
stmts[type.ordinal()] = prepare(INSERT_INTO + ModelConstants.TS_KV_CF +
|
||||||
"(" + ModelConstants.ENTITY_TYPE_COLUMN +
|
"(" + ModelConstants.ENTITY_TYPE_COLUMN +
|
||||||
"," + ModelConstants.ENTITY_ID_COLUMN +
|
"," + ModelConstants.ENTITY_ID_COLUMN +
|
||||||
"," + ModelConstants.KEY_COLUMN +
|
"," + ModelConstants.KEY_COLUMN +
|
||||||
@ -678,6 +679,7 @@ public class CassandraBaseTimeseriesDao extends AbstractCassandraBaseTimeseriesD
|
|||||||
"," + getColumnName(type) + ")" +
|
"," + getColumnName(type) + ")" +
|
||||||
" VALUES(?, ?, ?, ?, ?, ?) USING TTL ?");
|
" VALUES(?, ?, ?, ?, ?, ?) USING TTL ?");
|
||||||
}
|
}
|
||||||
|
saveTtlStmts = stmts;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
stmtCreationLock.unlock();
|
stmtCreationLock.unlock();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user