use of io.datarouter.nodewatch.storage.tablecount.TableCountKey in project datarouter by hotpads.
the class MigrateTableCountMetadataHandler method migrate.
private void migrate(String sourceNode, String targetNode) {
String sourceClientName = sourceNode.split("\\.")[0];
String sourceTableName = sourceNode.split("\\.")[1];
String targetClientName = targetNode.split("\\.")[0];
String targetTableName = targetNode.split("\\.")[1];
// migrate rows in TableCount
var tableCountKeyPrefix = new TableCountKey(sourceClientName, sourceTableName, null);
tableCountDao.scanWithPrefix(tableCountKeyPrefix).map(tableCount -> {
tableCount.getKey().setClientName(targetClientName);
tableCount.getKey().setTableName(targetTableName);
return tableCount;
}).batch(100).forEach(tableCountDao::putMulti);
// migrate rows in TableSample
var tableSampleKeyPrefix = new TableSampleKey(sourceClientName, sourceTableName, null, null);
tableSampleDao.scanWithPrefix(tableSampleKeyPrefix).map(tableSample -> {
tableSample.getKey().setClientName(targetClientName);
tableSample.getKey().setTableName(targetTableName);
return tableSample;
}).batch(100).forEach(tableSampleDao::putMulti);
}
use of io.datarouter.nodewatch.storage.tablecount.TableCountKey in project datarouter by hotpads.
the class TableCountHandler method deleteAllMetadata.
@Handler
private Mav deleteAllMetadata(String clientName, String tableName) {
// delete rows from TableCount
var tableCountKeyPrefix = new TableCountKey(clientName, tableName, null);
tableCountDao.deleteWithPrefix(tableCountKeyPrefix);
// delete rows from TableSample
var tableSampleKeyPrefix = new TableSampleKey(clientName, tableName, null, null);
tableSampleDao.deleteWithPrefix(tableSampleKeyPrefix);
// delete from LatestTableCount
var latestTableCountKey = new LatestTableCountKey(clientName, tableName);
latestTableCountDao.delete(latestTableCountKey);
var dto = new DatarouterChangelogDtoBuilder("Nodewatch", clientName + "." + tableName, "deleted metadata", getSessionInfo().getNonEmptyUsernameOrElse("")).build();
changelogRecorder.record(dto);
return new InContextRedirectMav(request, paths.datarouter.nodewatch.tableCount.toSlashedString());
}
Aggregations