protected int removeReplicationEntries(Map<UUID,TServerInstance> candidates) { try { try { final Scanner s = ReplicationTable.getScanner(context); StatusSection.limit(s); for (Entry<Key,Value> entry : s) { UUID id = path2uuid(new Path(entry.getKey().getRow().toString())); candidates.remove(id); log.info("Ignore closed log " + id + " because it is being replicated"); } } catch (ReplicationTableOfflineException ex) { return candidates.size(); } final Scanner scanner = context.createScanner(MetadataTable.NAME, Authorizations.EMPTY); scanner.fetchColumnFamily(MetadataSchema.ReplicationSection.COLF); scanner.setRange(MetadataSchema.ReplicationSection.getRange()); for (Entry<Key,Value> entry : scanner) { Text file = new Text(); MetadataSchema.ReplicationSection.getFile(entry.getKey(), file); UUID id = path2uuid(new Path(file.toString())); candidates.remove(id); log.info("Ignore closed log " + id + " because it is being replicated"); } return candidates.size(); } catch (TableNotFoundException e) { log.error("Failed to scan metadata table", e); throw new IllegalArgumentException(e); } }
metaBs.setRanges(Collections.singleton(ReplicationSection.getRange())); metaBs.fetchColumnFamily(ReplicationSection.COLF); try {
final Set<Range> range = Collections.singleton(new Range(ReplicationSection.getRange())); BatchScanner bs; try {
for (int i = 0; i < 5; i++) { s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY); s.setRange(ReplicationSection.getRange()); entries.clear(); for (Entry<Key,Value> entry : s) { for (int i = 0; i < 10; i++) { s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY); s.setRange(ReplicationSection.getRange()); remaining.clear(); for (Entry<Key,Value> e : s) {
s.setRange(MetadataSchema.ReplicationSection.getRange()); for (Entry<Key,Value> metadata : s) { records.add(metadata);
s.setRange(MetadataSchema.ReplicationSection.getRange()); for (Entry<Key,Value> entry : s) { System.out.println(entry.getKey().toStringNoTruncate() + " " s.setRange(MetadataSchema.ReplicationSection.getRange()); for (Entry<Key,Value> entry : s) { log.info(entry.getKey().toStringNoTruncate() + " " s.setRange(MetadataSchema.ReplicationSection.getRange()); for (Entry<Key,Value> entry : s) { Status status = Status.parseFrom(entry.getValue().get());
s.setRange(ReplicationSection.getRange()); s.fetchColumnFamily(ReplicationSection.COLF); Assert.assertEquals(0, Iterables.size(s)); s.setRange(ReplicationSection.getRange()); s.fetchColumnFamily(ReplicationSection.COLF); Assert.assertEquals(0, Iterables.size(s)); s.setRange(ReplicationSection.getRange()); iter = s.iterator(); Assert.assertTrue("Found no stat records in replication table", iter.hasNext());
s.setRange(ReplicationSection.getRange());
final Set<Range> range = Collections.singleton(new Range(ReplicationSection.getRange())); BatchScanner bs; try {
s.setRange(ReplicationSection.getRange()); s.fetchColumnFamily(ReplicationSection.COLF); Assert.assertEquals(0, Iterables.size(s));
s.setRange(ReplicationSection.getRange()); s.fetchColumnFamily(ReplicationSection.COLF); for (Entry<Key,Value> entry : s) {
metaBs.setRanges(Collections.singleton(ReplicationSection.getRange())); metaBs.fetchColumnFamily(ReplicationSection.COLF); try {
s.setRange(ReplicationSection.getRange()); s.fetchColumnFamily(ReplicationSection.COLF); Assert.assertEquals(files.size(), Iterables.size(s));
@Test public void combinerWorksOnMetadata() throws Exception { Connector conn = getConnector(); conn.securityOperations().grantTablePermission("root", MetadataTable.NAME, TablePermission.WRITE); ReplicationTableUtil.configureMetadataTable(conn, MetadataTable.NAME); Status stat1 = StatusUtil.fileCreated(100); Status stat2 = StatusUtil.fileClosed(); BatchWriter bw = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig()); Mutation m = new Mutation( ReplicationSection.getRowPrefix() + "file:/accumulo/wals/tserver+port/uuid"); m.put(ReplicationSection.COLF, new Text("1"), ProtobufUtil.toValue(stat1)); bw.addMutation(m); bw.close(); Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY); s.setRange(ReplicationSection.getRange()); Status actual = Status.parseFrom(Iterables.getOnlyElement(s).getValue().get()); Assert.assertEquals(stat1, actual); bw = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig()); m = new Mutation(ReplicationSection.getRowPrefix() + "file:/accumulo/wals/tserver+port/uuid"); m.put(ReplicationSection.COLF, new Text("1"), ProtobufUtil.toValue(stat2)); bw.addMutation(m); bw.close(); s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY); s.setRange(ReplicationSection.getRange()); actual = Status.parseFrom(Iterables.getOnlyElement(s).getValue().get()); Status expected = Status.newBuilder().setBegin(0).setEnd(0).setClosed(true).setInfiniteEnd(true) .setCreatedTime(100).build(); Assert.assertEquals(expected, actual); }
scanner.setRange(MetadataSchema.ReplicationSection.getRange()); for (Entry<Key,Value> entry : scanner) { Text file = new Text();
/** * Get the replication status messages for the given table that exist in the metadata table (~repl * entries) */ private Map<String,Status> getMetadataStatusForTable(String tableName) throws Exception { final Connector conn = getConnector(); final String tableId = conn.tableOperations().tableIdMap().get(tableName); Assert.assertNotNull("Could not determine table ID for " + tableName, tableId); Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY); Range r = MetadataSchema.ReplicationSection.getRange(); s.setRange(r); s.fetchColumn(MetadataSchema.ReplicationSection.COLF, new Text(tableId)); Map<String,Status> fileToStatus = new HashMap<>(); for (Entry<Key,Value> entry : s) { Text file = new Text(); MetadataSchema.ReplicationSection.getFile(entry.getKey(), file); Status status = Status.parseFrom(entry.getValue().get()); log.info("Got status for {}: {}", file, ProtobufUtil.toString(status)); fileToStatus.put(file.toString(), status); } return fileToStatus; }
s.setRange(ReplicationSection.getRange());