use of org.apache.accumulo.core.metadata.TabletLocationState in project accumulo by apache.
the class FindOfflineTablets method findOffline.
static int findOffline(ServerContext context, String tableName) throws 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 = TabletStateStore.getStoreForLevel(DataLevel.ROOT, context).iterator();
int offline = 0;
System.out.println("Scanning zookeeper");
if ((offline = checkTablets(context, zooScanner, tservers)) > 0)
return offline;
if (RootTable.NAME.equals(tableName))
return 0;
System.out.println("Scanning " + RootTable.NAME);
Iterator<TabletLocationState> rootScanner = new MetaDataTableScanner(context, TabletsSection.getRange(), RootTable.NAME);
if ((offline = checkTablets(context, rootScanner, tservers)) > 0)
return offline;
if (MetadataTable.NAME.equals(tableName))
return 0;
System.out.println("Scanning " + MetadataTable.NAME);
Range range = TabletsSection.getRange();
if (tableName != null) {
TableId tableId = context.getTableId(tableName);
range = new KeyExtent(tableId, null, null).toMetaRange();
}
try (MetaDataTableScanner metaScanner = new MetaDataTableScanner(context, range, MetadataTable.NAME)) {
return checkTablets(context, metaScanner, tservers);
}
}
use of org.apache.accumulo.core.metadata.TabletLocationState in project accumulo by apache.
the class TabletLocationStateTest method testGetServer_None.
@Test
public void testGetServer_None() throws Exception {
tls = new TabletLocationState(keyExtent, null, null, null, null, walogs, true);
assertNull(tls.getLocation());
}
use of org.apache.accumulo.core.metadata.TabletLocationState in project accumulo by apache.
the class TabletLocationStateTest method testConstruction_NoCurrent.
@Test
public void testConstruction_NoCurrent() throws Exception {
tls = new TabletLocationState(keyExtent, future, null, last, null, walogs, true);
assertSame(keyExtent, tls.extent);
assertSame(future, tls.future);
assertNull(tls.current);
assertSame(last, tls.last);
assertSame(walogs, tls.walogs);
assertTrue(tls.chopped);
}
use of org.apache.accumulo.core.metadata.TabletLocationState in project accumulo by apache.
the class TabletLocationStateTest method testGetState_Hosted.
@Test
public void testGetState_Hosted() throws Exception {
Set<TServerInstance> liveServers = new java.util.HashSet<>();
liveServers.add(current);
tls = new TabletLocationState(keyExtent, null, current, last, null, walogs, true);
assertEquals(TabletState.HOSTED, tls.getState(liveServers));
}
use of org.apache.accumulo.core.metadata.TabletLocationState in project accumulo by apache.
the class TabletLocationStateTest method testGetState_Unassigned2.
@Test
public void testGetState_Unassigned2() throws Exception {
tls = new TabletLocationState(keyExtent, null, null, last, null, walogs, true);
assertEquals(TabletState.UNASSIGNED, tls.getState(null));
}
Aggregations