use of org.apache.accumulo.server.master.state.DistributedStoreException in project accumulo by apache.
the class FindOfflineTablets method findOffline.
static int findOffline(ClientContext context, String tableName) throws AccumuloException, TableNotFoundException {
final AtomicBoolean scanning = new AtomicBoolean(false);
LiveTServerSet tservers = new LiveTServerSet(context, new Listener() {
@Override
public void update(LiveTServerSet current, Set<TServerInstance> deleted, Set<TServerInstance> added) {
if (!deleted.isEmpty() && scanning.get())
log.warn("Tablet servers deleted while scanning: {}", deleted);
if (!added.isEmpty() && scanning.get())
log.warn("Tablet servers added while scanning: {}", added);
}
});
tservers.startListeningForTabletServerChanges();
scanning.set(true);
Iterator<TabletLocationState> zooScanner;
try {
zooScanner = new ZooTabletStateStore().iterator();
} catch (DistributedStoreException e) {
throw new AccumuloException(e);
}
int offline = 0;
System.out.println("Scanning zookeeper");
if ((offline = checkTablets(zooScanner, tservers)) > 0)
return offline;
if (RootTable.NAME.equals(tableName))
return 0;
System.out.println("Scanning " + RootTable.NAME);
Iterator<TabletLocationState> rootScanner = new MetaDataTableScanner(context, MetadataSchema.TabletsSection.getRange(), RootTable.NAME);
if ((offline = checkTablets(rootScanner, tservers)) > 0)
return offline;
if (MetadataTable.NAME.equals(tableName))
return 0;
System.out.println("Scanning " + MetadataTable.NAME);
Range range = MetadataSchema.TabletsSection.getRange();
if (tableName != null) {
Table.ID tableId = Tables.getTableId(context.getInstance(), tableName);
range = new KeyExtent(tableId, null, null).toMetadataRange();
}
try (MetaDataTableScanner metaScanner = new MetaDataTableScanner(context, range, MetadataTable.NAME)) {
return checkTablets(metaScanner, tservers);
}
}
Aggregations