use of com.instaclustr.esop.impl.KeyspaceTable in project esop by instaclustr.
the class ManifestEnricher method enrich.
public void enrich(final CassandraData cassandraData, final Manifest manifest, final Path localRootPath) {
// populate localFile and keyspaceTable for each entry, based on what
// table and its id we have locally, ids might differ in manifest from these which are
// present locally (for example when a table is deleted and then created again and after that
// we want to e.g. restore - id of that table would be suddenly different from one which was
// backed up, so we would have problems upon e.g. hard-linking.
manifest.getSnapshot().forEachEntry((entry, keyspace, table, idInManifest) -> {
final TableName tableName = getTableName(cassandraData, keyspace, table, idInManifest, false);
// "data/system/sstable_activity-5a1ff267ace03f128563cfae6103c65e/1-937685388/na-1-big-Filter.db"
// "data/system/sstable_activity-5a1ff267ace03f128563cfae6103c65e/.indexname/1-937685388/na-1-big-Filter.db"
final int subPathEndIndex = SSTableUtils.isSecondaryIndexManifest(entry.objectKey) ? 4 : 3;
Path initialPath = localRootPath == null ? Paths.get(tableName.keyspace) : localRootPath.resolve(tableName.keyspace);
if (subPathEndIndex == 4) {
Path indexName = entry.objectKey.subpath(0, 4).getFileName();
entry.localFile = initialPath.resolve(tableName.table + "-" + tableName.tableId).resolve(indexName).resolve(entry.objectKey.getFileName());
} else {
entry.localFile = initialPath.resolve(tableName.table + "-" + tableName.tableId).resolve(entry.objectKey.getFileName());
}
entry.keyspaceTable = new KeyspaceTable(tableName.keyspace, tableName.table);
});
// rename ids for tables to reflect what we have locally
manifest.getSnapshot().forEachKeyspace(keyspaceEntry -> {
keyspaceEntry.getValue().forEachTable(tableEntry -> {
cassandraData.getTableId(keyspaceEntry.getKey(), tableEntry.getKey()).ifPresent(id -> tableEntry.getValue().setId(id));
});
});
}
use of com.instaclustr.esop.impl.KeyspaceTable in project esop by instaclustr.
the class ManifestComponentsTest method testManifestEntry.
@Test
public void testManifestEntry() throws CloneNotSupportedException {
ManifestEntry original = new ManifestEntry(Paths.get("object/key"), Paths.get("local/file"), Type.FILE, null, new KeyspaceTable("keyspace", "table"));
ManifestEntry cloned = original.clone();
assertNotEquals(original, cloned);
original.localFile = Paths.get("other/file");
original.objectKey = Paths.get("other/object");
original.type = Type.CQL_SCHEMA;
original.keyspaceTable = new KeyspaceTable("k2", "t2");
assertNotEquals(original, cloned);
}
use of com.instaclustr.esop.impl.KeyspaceTable in project esop by instaclustr.
the class AllManifestsReportTest method testSerialization.
@Test
public void testSerialization() {
Manifest.AllManifestsReport report = new Manifest.AllManifestsReport();
report.totalFiles = 10;
report.totalSize = 500;
report.totalManifests = 10;
Manifest.ManifestReporter.ManifestReport manifestReport = new Manifest.ManifestReporter.ManifestReport();
manifestReport.name = "123";
manifestReport.reclaimableSpace = 100;
manifestReport.size = 10;
manifestReport.files = 3;
manifestReport.unixtimestamp = 124L;
manifestReport.removableEntries = Collections.singletonList("123");
manifestReport.manifest = new ManifestEntry(Paths.get("somekey"), Paths.get("localFile"), ManifestEntry.Type.MANIFEST_FILE, 100, new KeyspaceTable("ks1", "tb1"), "123");
report.reports = Collections.singletonList(manifestReport);
ObjectMapper mapper = new ObjectMapper();
try {
String s = mapper.writeValueAsString(report);
Manifest.AllManifestsReport report1 = mapper.readValue(s, Manifest.AllManifestsReport.class);
System.out.println(report1);
} catch (final Exception ex) {
throw new RuntimeException(ex);
}
}
Aggregations