if (colfHolder.equals(ReplicationSection.COLF)) { file = rowHolder.toString(); file = file.substring(ReplicationSection.getRowPrefix().length()); } else if (colfHolder.equals(OrderSection.NAME)) { file = OrderSection.getFile(entry.getKey(), rowHolder);
static Mutation createUpdateMutation(Path file, Value v, KeyExtent extent) { // Need to normalize the file path so we can assuredly find it again later return createUpdateMutation(new Text(ReplicationSection.getRowPrefix() + file), v, extent); }
bw = client.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig()); bs = client.createBatchScanner(MetadataTable.NAME, Authorizations.EMPTY, 4); bs.setRanges(Collections.singleton(Range.prefix(ReplicationSection.getRowPrefix()))); bs.fetchColumnFamily(ReplicationSection.COLF);
m = new Mutation(ReplicationSection.getRowPrefix() + file1); m.put(ReplicationSection.COLF, new Text(tableId1), ProtobufUtil.toValue(stat)); m = new Mutation(ReplicationSection.getRowPrefix() + file2); m.put(ReplicationSection.COLF, new Text(tableId2), ProtobufUtil.toValue(stat)); m = new Mutation(ReplicationSection.getRowPrefix() + file1); m.putDelete(ReplicationSection.COLF, new Text(tableId1)); bw.addMutation(m);
m = new Mutation(ReplicationSection.getRowPrefix() + file1); m.put(ReplicationSection.COLF, new Text(tableId), ProtobufUtil.toValue(stat)); m = new Mutation(ReplicationSection.getRowPrefix() + file2); m.put(ReplicationSection.COLF, new Text(tableId), ProtobufUtil.toValue(stat)); m = new Mutation(ReplicationSection.getRowPrefix() + file1); m.putDelete(ReplicationSection.COLF, new Text(tableId)); bw.addMutation(m); m = new Mutation(ReplicationSection.getRowPrefix() + file2); m.putDelete(ReplicationSection.COLF, new Text(tableId)); bw.addMutation(m);
long index = 1; for (String file : files) { Mutation m = new Mutation(ReplicationSection.getRowPrefix() + file); m.put(ReplicationSection.COLF, new Text(Long.toString(index)), ProtobufUtil.toValue(statBuilder.build()));
m = new Mutation(ReplicationSection.getRowPrefix() + file1); m.put(ReplicationSection.COLF, new Text(tableId1), ProtobufUtil.toValue(stat)); bw.addMutation(m); ReplicationSection.getRowPrefix() + "/accumulo/wals/tserver+port/" + UUID.randomUUID()); m.put(ReplicationSection.COLF, new Text(tableId1), ProtobufUtil.toValue(stat)); bw.addMutation(m); m = new Mutation(ReplicationSection.getRowPrefix() + file1); m.putDelete(ReplicationSection.COLF, new Text(tableId1)); bw.addMutation(m);
bw = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig()); bs = conn.createBatchScanner(MetadataTable.NAME, Authorizations.EMPTY, 4); bs.setRanges(Collections.singleton(Range.prefix(ReplicationSection.getRowPrefix()))); bs.fetchColumnFamily(ReplicationSection.COLF);
m = new Mutation(ReplicationSection.getRowPrefix() + file1); m.put(ReplicationSection.COLF, new Text(tableId1), ProtobufUtil.toValue(stat)); bw.addMutation(m); .setClosed(true).build(); bw = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig()); m = new Mutation(ReplicationSection.getRowPrefix() + file1); m.put(ReplicationSection.COLF, new Text(tableId1), ProtobufUtil.toValue(newStatus)); bw.addMutation(m);
for (String file : files) { statBuilder.setCreatedTime(time++); Mutation m = new Mutation(ReplicationSection.getRowPrefix() + file); m.put(ReplicationSection.COLF, new Text(Integer.toString(index)), ProtobufUtil.toValue(statBuilder.build()));
Map<String,Long> fileToTimeCreated = new HashMap<>(); for (String file : files) { Mutation m = new Mutation(ReplicationSection.getRowPrefix() + file); m.put(ReplicationSection.COLF, new Text(Integer.toString(index)), StatusUtil.fileCreatedValue(timeCreated));
if (colfHolder.equals(ReplicationSection.COLF)) { file = rowHolder.toString(); file = file.substring(ReplicationSection.getRowPrefix().length()); } else if (colfHolder.equals(OrderSection.NAME)) { file = OrderSection.getFile(entry.getKey(), rowHolder);
Mutation m = new Mutation(ReplicationSection.getRowPrefix() + file); m.put(ReplicationSection.COLF, new Text(Integer.toString(index)), ProtobufUtil.toValue(stat)); bw.addMutation(m);
long timeCreated = 0; for (String file : files) { Mutation m = new Mutation(ReplicationSection.getRowPrefix() + file); m.put(ReplicationSection.COLF, new Text(Integer.toString(index)), StatusUtil.fileCreatedValue(timeCreated));
@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); }
@Test public void closedWalsUpdateStatus() throws Exception { String file = "file:/accumulo/wal/tserver+port/12345"; Set<String> wals = Collections.singleton(file); BatchWriter bw = conn.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig()); Mutation m = new Mutation(ReplicationSection.getRowPrefix() + file); m.put(ReplicationSection.COLF, new Text("1"), StatusUtil.fileCreatedValue(System.currentTimeMillis())); bw.addMutation(m); bw.close(); refs.updateReplicationEntries(conn, wals); 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.assertTrue(status.getClosed()); }
@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); 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()); }
private long setAndGetCreatedTime(Path file, String tableId) throws IOException, MutationsRejectedException { long createdTime; if (fs.exists(file)) { createdTime = fs.getFileStatus(file).getModificationTime(); } else { createdTime = System.currentTimeMillis(); } Status status = Status.newBuilder().setCreatedTime(createdTime).build(); Mutation m = new Mutation(new Text(ReplicationSection.getRowPrefix() + file.toString())); m.put(MetadataSchema.ReplicationSection.COLF, new Text(tableId), ProtobufUtil.toValue(status)); replicationWriter.addMutation(m); replicationWriter.flush(); return createdTime; } }
static Mutation createUpdateMutation(Path file, Value v, KeyExtent extent) { // Need to normalize the file path so we can assuredly find it again later return createUpdateMutation(new Text(ReplicationSection.getRowPrefix() + file.toString()), v, extent); }
private long setAndGetCreatedTime(Path file, String tableId) throws IOException, MutationsRejectedException { long createdTime; if (fs.exists(file)) { createdTime = fs.getFileStatus(file).getModificationTime(); } else { createdTime = System.currentTimeMillis(); } Status status = Status.newBuilder().setCreatedTime(createdTime).build(); Mutation m = new Mutation(new Text(ReplicationSection.getRowPrefix() + file)); m.put(MetadataSchema.ReplicationSection.COLF, new Text(tableId), ProtobufUtil.toValue(status)); replicationWriter.addMutation(m); replicationWriter.flush(); return createdTime; } }