use of org.apache.accumulo.server.replication.proto.Replication.Status in project accumulo by apache.
the class GarbageCollectorCommunicatesWithTServersIT method testActiveWalPrecludesClosing.
@Test
public void testActiveWalPrecludesClosing() throws Exception {
final String table = getUniqueNames(1)[0];
final Connector conn = getConnector();
// Bring the replication table online first and foremost
ReplicationTable.setOnline(conn);
log.info("Creating {}", table);
conn.tableOperations().create(table);
conn.tableOperations().setProperty(table, Property.TABLE_REPLICATION.getKey(), "true");
log.info("Writing a few mutations to the table");
BatchWriter bw = conn.createBatchWriter(table, null);
byte[] empty = new byte[0];
for (int i = 0; i < 5; i++) {
Mutation m = new Mutation(Integer.toString(i));
m.put(empty, empty, empty);
bw.addMutation(m);
}
log.info("Flushing mutations to the server");
bw.flush();
log.info("Checking that metadata only has two WALs recorded for this table (inUse, and opened)");
Set<String> wals = getWalsForTable(table);
Assert.assertEquals("Expected to only find two WALs for the table", 2, wals.size());
// Flush our test table to remove the WAL references in it
conn.tableOperations().flush(table, null, null, true);
// Flush the metadata table too because it will have a reference to the WAL
conn.tableOperations().flush(MetadataTable.NAME, null, null, true);
log.info("Waiting for replication table to come online");
log.info("Fetching replication statuses from metadata table");
Map<String, Status> fileToStatus = getMetadataStatusForTable(table);
Assert.assertEquals("Expected to only find one replication status message", 1, fileToStatus.size());
String walName = fileToStatus.keySet().iterator().next();
wals.retainAll(fileToStatus.keySet());
Assert.assertEquals(1, wals.size());
Status status = fileToStatus.get(walName);
Assert.assertEquals("Expected Status for file to not be closed", false, status.getClosed());
Set<String> filesForTable = getFilesForTable(table);
Assert.assertEquals("Expected to only find one rfile for table", 1, filesForTable.size());
log.info("Files for table before MajC: {}", filesForTable);
// Issue a MajC to roll a new file in HDFS
conn.tableOperations().compact(table, null, null, false, true);
Set<String> filesForTableAfterCompaction = getFilesForTable(table);
log.info("Files for table after MajC: {}", filesForTableAfterCompaction);
Assert.assertEquals("Expected to only find one rfile for table", 1, filesForTableAfterCompaction.size());
Assert.assertNotEquals("Expected the files before and after compaction to differ", filesForTableAfterCompaction, filesForTable);
// Use the rfile which was just replaced by the MajC to determine when the GC has ran
Path fileToBeDeleted = new Path(filesForTable.iterator().next());
FileSystem fs = getCluster().getFileSystem();
boolean fileExists = fs.exists(fileToBeDeleted);
while (fileExists) {
log.info("File which should get deleted still exists: {}", fileToBeDeleted);
Thread.sleep(2000);
fileExists = fs.exists(fileToBeDeleted);
}
Map<String, Status> fileToStatusAfterMinc = getMetadataStatusForTable(table);
Assert.assertEquals("Expected to still find only one replication status message: " + fileToStatusAfterMinc, 1, fileToStatusAfterMinc.size());
Assert.assertEquals("Status before and after MinC should be identical", fileToStatus, fileToStatusAfterMinc);
}
use of org.apache.accumulo.server.replication.proto.Replication.Status in project accumulo by apache.
the class CloseWriteAheadLogReferencesIT method unclosedWalsLeaveStatusOpen.
@Test
public void unclosedWalsLeaveStatusOpen() throws Exception {
Set<String> wals = Collections.emptySet();
BatchWriter bw = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
Mutation m = new Mutation(ReplicationSection.getRowPrefix() + "file:/accumulo/wal/tserver+port/12345");
m.put(ReplicationSection.COLF, new Text("1"), StatusUtil.fileCreatedValue(System.currentTimeMillis()));
bw.addMutation(m);
bw.close();
refs.updateReplicationEntries(conn, wals);
try (Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
s.fetchColumnFamily(ReplicationSection.COLF);
Entry<Key, Value> entry = Iterables.getOnlyElement(s);
Status status = Status.parseFrom(entry.getValue().get());
Assert.assertFalse(status.getClosed());
}
}
Aggregations