Search in sources :

Example 1 with TableManager

use of org.apache.accumulo.server.tables.TableManager in project accumulo by apache.

the class Master method onlineTables.

@Override
public Set<Table.ID> onlineTables() {
    Set<Table.ID> result = new HashSet<>();
    if (getMasterState() != MasterState.NORMAL) {
        if (getMasterState() != MasterState.UNLOAD_METADATA_TABLETS)
            result.add(MetadataTable.ID);
        if (getMasterState() != MasterState.UNLOAD_ROOT_TABLET)
            result.add(RootTable.ID);
        return result;
    }
    TableManager manager = TableManager.getInstance();
    for (Table.ID tableId : Tables.getIdToNameMap(getInstance()).keySet()) {
        TableState state = manager.getTableState(tableId);
        if (state != null) {
            if (state == TableState.ONLINE)
                result.add(tableId);
        }
    }
    return result;
}
Also used : RootTable(org.apache.accumulo.core.metadata.RootTable) Table(org.apache.accumulo.core.client.impl.Table) ReplicationTable(org.apache.accumulo.core.replication.ReplicationTable) MetadataTable(org.apache.accumulo.core.metadata.MetadataTable) TableManager(org.apache.accumulo.server.tables.TableManager) HashSet(java.util.HashSet) TableState(org.apache.accumulo.core.master.state.tables.TableState)

Example 2 with TableManager

use of org.apache.accumulo.server.tables.TableManager in project accumulo by apache.

the class TablesResource method getTables.

/**
 * Generates a list of all the tables
 *
 * @return list with all tables
 */
@GET
public static TableInformationList getTables() {
    TableInformationList tableList = new TableInformationList();
    SortedMap<Table.ID, TableInfo> tableStats = new TreeMap<>();
    if (Monitor.getMmi() != null && Monitor.getMmi().tableMap != null)
        for (Map.Entry<String, TableInfo> te : Monitor.getMmi().tableMap.entrySet()) tableStats.put(Table.ID.of(te.getKey()), te.getValue());
    Map<String, Double> compactingByTable = TableInfoUtil.summarizeTableStats(Monitor.getMmi());
    TableManager tableManager = TableManager.getInstance();
    // Add tables to the list
    for (Map.Entry<String, Table.ID> entry : Tables.getNameToIdMap(HdfsZooInstance.getInstance()).entrySet()) {
        String tableName = entry.getKey();
        Table.ID tableId = entry.getValue();
        TableInfo tableInfo = tableStats.get(tableId);
        TableState tableState = tableManager.getTableState(tableId);
        if (null != tableInfo && !tableState.equals(TableState.OFFLINE)) {
            Double holdTime = compactingByTable.get(tableId.canonicalID());
            if (holdTime == null)
                holdTime = 0.;
            tableList.addTable(new TableInformation(tableName, tableId, tableInfo, holdTime, tableState.name()));
        } else {
            tableList.addTable(new TableInformation(tableName, tableId, tableState.name()));
        }
    }
    return tableList;
}
Also used : MetadataTable(org.apache.accumulo.core.metadata.MetadataTable) RootTable(org.apache.accumulo.core.metadata.RootTable) Table(org.apache.accumulo.core.client.impl.Table) TreeMap(java.util.TreeMap) TableManager(org.apache.accumulo.server.tables.TableManager) TableInfo(org.apache.accumulo.core.master.thrift.TableInfo) ALPHA_NUM_REGEX_TABLE_ID(org.apache.accumulo.monitor.util.ParameterValidator.ALPHA_NUM_REGEX_TABLE_ID) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) TableState(org.apache.accumulo.core.master.state.tables.TableState) GET(javax.ws.rs.GET)

Example 3 with TableManager

use of org.apache.accumulo.server.tables.TableManager in project accumulo by apache.

the class Master method displayUnassigned.

// The number of unassigned tablets that should be assigned: displayed on the monitor page
int displayUnassigned() {
    int result = 0;
    switch(getMasterState()) {
        case NORMAL:
            // Count offline tablets for online tables
            for (TabletGroupWatcher watcher : watchers) {
                TableManager manager = TableManager.getInstance();
                for (Entry<Table.ID, TableCounts> entry : watcher.getStats().entrySet()) {
                    Table.ID tableId = entry.getKey();
                    TableCounts counts = entry.getValue();
                    TableState tableState = manager.getTableState(tableId);
                    if (tableState != null && tableState.equals(TableState.ONLINE)) {
                        result += counts.unassigned() + counts.assignedToDeadServers() + counts.assigned() + counts.suspended();
                    }
                }
            }
            break;
        case SAFE_MODE:
            // Count offline tablets for the metadata table
            for (TabletGroupWatcher watcher : watchers) {
                TableCounts counts = watcher.getStats(MetadataTable.ID);
                result += counts.unassigned() + counts.suspended();
            }
            break;
        case UNLOAD_METADATA_TABLETS:
        case UNLOAD_ROOT_TABLET:
            for (TabletGroupWatcher watcher : watchers) {
                TableCounts counts = watcher.getStats(MetadataTable.ID);
                result += counts.unassigned() + counts.suspended();
            }
            break;
        default:
            break;
    }
    return result;
}
Also used : RootTable(org.apache.accumulo.core.metadata.RootTable) Table(org.apache.accumulo.core.client.impl.Table) ReplicationTable(org.apache.accumulo.core.replication.ReplicationTable) MetadataTable(org.apache.accumulo.core.metadata.MetadataTable) TableManager(org.apache.accumulo.server.tables.TableManager) TableCounts(org.apache.accumulo.master.state.TableCounts) TableState(org.apache.accumulo.core.master.state.tables.TableState)

Aggregations

Table (org.apache.accumulo.core.client.impl.Table)3 TableState (org.apache.accumulo.core.master.state.tables.TableState)3 MetadataTable (org.apache.accumulo.core.metadata.MetadataTable)3 RootTable (org.apache.accumulo.core.metadata.RootTable)3 TableManager (org.apache.accumulo.server.tables.TableManager)3 ReplicationTable (org.apache.accumulo.core.replication.ReplicationTable)2 HashSet (java.util.HashSet)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 GET (javax.ws.rs.GET)1 TableInfo (org.apache.accumulo.core.master.thrift.TableInfo)1 TableCounts (org.apache.accumulo.master.state.TableCounts)1 ALPHA_NUM_REGEX_TABLE_ID (org.apache.accumulo.monitor.util.ParameterValidator.ALPHA_NUM_REGEX_TABLE_ID)1