use of org.apache.accumulo.monitor.rest.tservers.TabletServer in project accumulo by apache.
the class XMLResource method getInformation.
/**
* Generates summary of the Monitor
*
* @return SummaryInformation object
*/
public SummaryInformation getInformation() {
MasterMonitorInfo mmi = Monitor.getMmi();
if (null == mmi) {
throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
}
// Add Monitor information
SummaryInformation xml = new SummaryInformation(mmi.tServerInfo.size(), MasterResource.getTables(), TablesResource.getTables());
// Add tserver information
for (TabletServerStatus status : mmi.tServerInfo) {
xml.addTabletServer(new TabletServer(status));
}
return xml;
}
use of org.apache.accumulo.monitor.rest.tservers.TabletServer in project accumulo by apache.
the class TablesResource method getParticipatingTabletServers.
/**
* Generates a list of participating tservers for a table
*
* @param tableIdStr
* Table ID to find participating tservers
* @return List of participating tservers
*/
@Path("{tableId}")
@GET
public TabletServers getParticipatingTabletServers(@PathParam("tableId") @NotNull @Pattern(regexp = ALPHA_NUM_REGEX_TABLE_ID) String tableIdStr) {
Instance instance = Monitor.getContext().getInstance();
Table.ID tableId = Table.ID.of(tableIdStr);
TabletServers tabletServers = new TabletServers(Monitor.getMmi().tServerInfo.size());
if (StringUtils.isBlank(tableIdStr)) {
return tabletServers;
}
TreeSet<String> locs = new TreeSet<>();
if (RootTable.ID.equals(tableId)) {
locs.add(instance.getRootTabletLocation());
} else {
String systemTableName = MetadataTable.ID.equals(tableId) ? RootTable.NAME : MetadataTable.NAME;
MetaDataTableScanner scanner = new MetaDataTableScanner(Monitor.getContext(), new Range(KeyExtent.getMetadataEntry(tableId, new Text()), KeyExtent.getMetadataEntry(tableId, null)), systemTableName);
while (scanner.hasNext()) {
TabletLocationState state = scanner.next();
if (state.current != null) {
try {
locs.add(state.current.hostPort());
} catch (Exception ex) {
scanner.close();
return tabletServers;
}
}
}
scanner.close();
}
List<TabletServerStatus> tservers = new ArrayList<>();
if (Monitor.getMmi() != null) {
for (TabletServerStatus tss : Monitor.getMmi().tServerInfo) {
try {
if (tss.name != null && locs.contains(tss.name))
tservers.add(tss);
} catch (Exception ex) {
return tabletServers;
}
}
}
// Adds tservers to the list
for (TabletServerStatus status : tservers) {
if (status == null)
status = NO_STATUS;
TableInfo summary = TableInfoUtil.summarizeTableStats(status);
if (tableId != null)
summary = status.tableMap.get(tableId.canonicalID());
if (summary == null)
continue;
TabletServer tabletServerInfo = new TabletServer();
tabletServerInfo.updateTabletServerInfo(status, summary);
tabletServers.addTablet(tabletServerInfo);
}
return tabletServers;
}
Aggregations