Search in sources :

Example 1 with TabletServer

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;
}
Also used : MasterMonitorInfo(org.apache.accumulo.core.master.thrift.MasterMonitorInfo) WebApplicationException(javax.ws.rs.WebApplicationException) TabletServer(org.apache.accumulo.monitor.rest.tservers.TabletServer) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus)

Example 2 with TabletServer

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;
}
Also used : MetadataTable(org.apache.accumulo.core.metadata.MetadataTable) RootTable(org.apache.accumulo.core.metadata.RootTable) Table(org.apache.accumulo.core.client.impl.Table) Instance(org.apache.accumulo.core.client.Instance) HdfsZooInstance(org.apache.accumulo.server.client.HdfsZooInstance) ArrayList(java.util.ArrayList) Text(org.apache.hadoop.io.Text) Range(org.apache.accumulo.core.data.Range) TabletServers(org.apache.accumulo.monitor.rest.tservers.TabletServers) TreeSet(java.util.TreeSet) MetaDataTableScanner(org.apache.accumulo.server.master.state.MetaDataTableScanner) TabletServer(org.apache.accumulo.monitor.rest.tservers.TabletServer) TabletLocationState(org.apache.accumulo.server.master.state.TabletLocationState) TableInfo(org.apache.accumulo.core.master.thrift.TableInfo) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

TabletServerStatus (org.apache.accumulo.core.master.thrift.TabletServerStatus)2 TabletServer (org.apache.accumulo.monitor.rest.tservers.TabletServer)2 ArrayList (java.util.ArrayList)1 TreeSet (java.util.TreeSet)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Instance (org.apache.accumulo.core.client.Instance)1 Table (org.apache.accumulo.core.client.impl.Table)1 Range (org.apache.accumulo.core.data.Range)1 MasterMonitorInfo (org.apache.accumulo.core.master.thrift.MasterMonitorInfo)1 TableInfo (org.apache.accumulo.core.master.thrift.TableInfo)1 MetadataTable (org.apache.accumulo.core.metadata.MetadataTable)1 RootTable (org.apache.accumulo.core.metadata.RootTable)1 TabletServers (org.apache.accumulo.monitor.rest.tservers.TabletServers)1 HdfsZooInstance (org.apache.accumulo.server.client.HdfsZooInstance)1 MetaDataTableScanner (org.apache.accumulo.server.master.state.MetaDataTableScanner)1 TabletLocationState (org.apache.accumulo.server.master.state.TabletLocationState)1 Text (org.apache.hadoop.io.Text)1