Search in sources :

Example 6 with Tablet

use of org.apache.accumulo.tserver.tablet.Tablet in project accumulo by apache.

the class TabletServer method getStats.

public TabletServerStatus getStats(Map<Table.ID, MapCounter<ScanRunState>> scanCounts) {
    long start = System.currentTimeMillis();
    TabletServerStatus result = new TabletServerStatus();
    Map<KeyExtent, Tablet> onlineTabletsCopy;
    synchronized (this.onlineTablets) {
        onlineTabletsCopy = new HashMap<>(this.onlineTablets);
    }
    Map<String, TableInfo> tables = new HashMap<>();
    for (Entry<KeyExtent, Tablet> entry : onlineTabletsCopy.entrySet()) {
        String tableId = entry.getKey().getTableId().canonicalID();
        TableInfo table = tables.get(tableId);
        if (table == null) {
            table = new TableInfo();
            table.minors = new Compacting();
            table.majors = new Compacting();
            tables.put(tableId, table);
        }
        Tablet tablet = entry.getValue();
        long recs = tablet.getNumEntries();
        table.tablets++;
        table.onlineTablets++;
        table.recs += recs;
        table.queryRate += tablet.queryRate();
        table.queryByteRate += tablet.queryByteRate();
        table.ingestRate += tablet.ingestRate();
        table.ingestByteRate += tablet.ingestByteRate();
        table.scanRate += tablet.scanRate();
        long recsInMemory = tablet.getNumEntriesInMemory();
        table.recsInMemory += recsInMemory;
        if (tablet.isMinorCompactionRunning())
            table.minors.running++;
        if (tablet.isMinorCompactionQueued())
            table.minors.queued++;
        if (tablet.isMajorCompactionRunning())
            table.majors.running++;
        if (tablet.isMajorCompactionQueued())
            table.majors.queued++;
    }
    for (Entry<Table.ID, MapCounter<ScanRunState>> entry : scanCounts.entrySet()) {
        TableInfo table = tables.get(entry.getKey().canonicalID());
        if (table == null) {
            table = new TableInfo();
            tables.put(entry.getKey().canonicalID(), table);
        }
        if (table.scans == null)
            table.scans = new Compacting();
        table.scans.queued += entry.getValue().get(ScanRunState.QUEUED);
        table.scans.running += entry.getValue().get(ScanRunState.RUNNING);
    }
    ArrayList<KeyExtent> offlineTabletsCopy = new ArrayList<>();
    synchronized (this.unopenedTablets) {
        synchronized (this.openingTablets) {
            offlineTabletsCopy.addAll(this.unopenedTablets);
            offlineTabletsCopy.addAll(this.openingTablets);
        }
    }
    for (KeyExtent extent : offlineTabletsCopy) {
        String tableId = extent.getTableId().canonicalID();
        TableInfo table = tables.get(tableId);
        if (table == null) {
            table = new TableInfo();
            tables.put(tableId, table);
        }
        table.tablets++;
    }
    result.lastContact = RelativeTime.currentTimeMillis();
    result.tableMap = tables;
    result.osLoad = ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage();
    result.name = getClientAddressString();
    result.holdTime = resourceManager.holdTime();
    result.lookups = seekCount.get();
    result.indexCacheHits = resourceManager.getIndexCache().getStats().hitCount();
    result.indexCacheRequest = resourceManager.getIndexCache().getStats().requestCount();
    result.dataCacheHits = resourceManager.getDataCache().getStats().hitCount();
    result.dataCacheRequest = resourceManager.getDataCache().getStats().requestCount();
    result.logSorts = logSorter.getLogSorts();
    result.flushs = flushCounter.get();
    result.syncs = syncCounter.get();
    result.bulkImports = new ArrayList<>();
    result.bulkImports.addAll(clientHandler.getBulkLoadStatus());
    result.bulkImports.addAll(bulkImportStatus.getBulkLoadStatus());
    result.version = getVersion();
    result.responseTime = System.currentTimeMillis() - start;
    return result;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TKeyExtent(org.apache.accumulo.core.data.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) Compacting(org.apache.accumulo.core.master.thrift.Compacting) MapCounter(org.apache.accumulo.core.util.MapCounter) Tablet(org.apache.accumulo.tserver.tablet.Tablet) TableInfo(org.apache.accumulo.core.master.thrift.TableInfo) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus)

Example 7 with Tablet

use of org.apache.accumulo.tserver.tablet.Tablet in project accumulo by apache.

the class TabletServer method markUnusedWALs.

private void markUnusedWALs() {
    Set<DfsLogger> candidates;
    synchronized (closedLogs) {
        candidates = new HashSet<>(closedLogs);
    }
    for (Tablet tablet : getOnlineTablets()) {
        candidates.removeAll(tablet.getCurrentLogFiles());
    }
    try {
        TServerInstance session = this.getTabletSession();
        for (DfsLogger candidate : candidates) {
            log.info("Marking " + candidate.getPath() + " as unreferenced");
            walMarker.walUnreferenced(session, candidate.getPath());
        }
        synchronized (closedLogs) {
            closedLogs.removeAll(candidates);
        }
    } catch (WalMarkerException ex) {
        log.info(ex.toString(), ex);
    }
}
Also used : Tablet(org.apache.accumulo.tserver.tablet.Tablet) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) DfsLogger(org.apache.accumulo.tserver.log.DfsLogger) WalMarkerException(org.apache.accumulo.server.log.WalStateManager.WalMarkerException)

Aggregations

Tablet (org.apache.accumulo.tserver.tablet.Tablet)7 HashMap (java.util.HashMap)3 KeyExtent (org.apache.accumulo.core.data.impl.KeyExtent)3 TKeyExtent (org.apache.accumulo.core.data.thrift.TKeyExtent)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 SampleNotPresentException (org.apache.accumulo.core.client.SampleNotPresentException)2 IterationInterruptedException (org.apache.accumulo.core.iterators.IterationInterruptedException)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 Translator (org.apache.accumulo.core.client.impl.Translator)1 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)1 Key (org.apache.accumulo.core.data.Key)1 Range (org.apache.accumulo.core.data.Range)1 MultiScanResult (org.apache.accumulo.core.data.thrift.MultiScanResult)1