Search in sources :

Example 81 with ColumnFamilyStore

use of org.apache.cassandra.db.ColumnFamilyStore in project eiger by wlloyd.

the class StreamInSession method closeIfFinished.

public void closeIfFinished() throws IOException {
    if (files.isEmpty()) {
        HashMap<ColumnFamilyStore, List<SSTableReader>> cfstores = new HashMap<ColumnFamilyStore, List<SSTableReader>>();
        try {
            for (SSTableReader sstable : readers) {
                assert sstable.getTableName().equals(table);
                // so it can't get compacted out of existence in between
                if (!sstable.acquireReference())
                    throw new AssertionError("We shouldn't fail acquiring a reference on a sstable that has just been transfered");
                ColumnFamilyStore cfs = Table.open(sstable.getTableName()).getColumnFamilyStore(sstable.getColumnFamilyName());
                cfs.addSSTable(sstable);
                if (!cfstores.containsKey(cfs))
                    cfstores.put(cfs, new ArrayList<SSTableReader>());
                cfstores.get(cfs).add(sstable);
            }
            // build secondary indexes
            for (Map.Entry<ColumnFamilyStore, List<SSTableReader>> entry : cfstores.entrySet()) {
                if (entry.getKey() != null)
                    entry.getKey().indexManager.maybeBuildSecondaryIndexes(entry.getValue(), entry.getKey().indexManager.getIndexedColumns());
            }
        } finally {
            for (List<SSTableReader> referenced : cfstores.values()) SSTableReader.releaseReferences(referenced);
        }
        // send reply to source that we're done
        StreamReply reply = new StreamReply("", getSessionId(), StreamReply.Status.SESSION_FINISHED);
        logger.info("Finished streaming session {} from {}", getSessionId(), getHost());
        try {
            if (socket != null)
                OutboundTcpConnection.write(reply.getMessage(Gossiper.instance.getVersion(getHost())), context.right.toString(), new DataOutputStream(socket.getOutputStream()));
            else
                logger.debug("No socket to reply to {} with!", getHost());
        } finally {
            if (socket != null)
                socket.close();
        }
        if (callback != null)
            callback.run();
        sessions.remove(context);
    }
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.SSTableReader) NonBlockingHashMap(org.cliffc.high_scale_lib.NonBlockingHashMap) DataOutputStream(java.io.DataOutputStream) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) NonBlockingHashMap(org.cliffc.high_scale_lib.NonBlockingHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 82 with ColumnFamilyStore

use of org.apache.cassandra.db.ColumnFamilyStore in project eiger by wlloyd.

the class StreamOut method flushSSTables.

/**
     * Flushes matching column families from the given keyspace, or all columnFamilies
     * if the cf list is empty.
     */
private static void flushSSTables(Iterable<ColumnFamilyStore> stores) throws IOException {
    logger.info("Flushing memtables for {}...", stores);
    List<Future<?>> flushes;
    flushes = new ArrayList<Future<?>>();
    for (ColumnFamilyStore cfstore : stores) {
        Future<?> flush = cfstore.forceFlush();
        if (flush != null)
            flushes.add(flush);
    }
    FBUtilities.waitOnFutures(flushes);
}
Also used : ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) Future(java.util.concurrent.Future)

Example 83 with ColumnFamilyStore

use of org.apache.cassandra.db.ColumnFamilyStore in project eiger by wlloyd.

the class StreamOut method transferRanges.

/**
     * Stream the given ranges to the target endpoint from each of the given CFs.
    */
public static void transferRanges(StreamOutSession session, Iterable<ColumnFamilyStore> cfses, Collection<Range<Token>> ranges, OperationType type) {
    assert ranges.size() > 0;
    logger.info("Beginning transfer to {}", session.getHost());
    logger.debug("Ranges are {}", StringUtils.join(ranges, ","));
    try {
        flushSSTables(cfses);
        Iterable<SSTableReader> sstables = Collections.emptyList();
        for (ColumnFamilyStore cfStore : cfses) sstables = Iterables.concat(sstables, cfStore.markCurrentSSTablesReferenced());
        transferSSTables(session, sstables, ranges, type);
    } catch (IOException e) {
        throw new IOError(e);
    }
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.SSTableReader) IOError(java.io.IOError) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) IOException(java.io.IOException)

Example 84 with ColumnFamilyStore

use of org.apache.cassandra.db.ColumnFamilyStore in project eiger by wlloyd.

the class StreamingRepairTask method initiateStreaming.

private void initiateStreaming() {
    ColumnFamilyStore cfstore = Table.open(tableName).getColumnFamilyStore(cfName);
    try {
        logger.info(String.format("[streaming task #%s] Performing streaming repair of %d ranges with %s", id, ranges.size(), dst));
        // We acquire references for transferSSTables
        Collection<SSTableReader> sstables = cfstore.markCurrentSSTablesReferenced();
        // send ranges to the remote node
        StreamOutSession outsession = StreamOutSession.create(tableName, dst, callback);
        StreamOut.transferSSTables(outsession, sstables, ranges, OperationType.AES);
        // request ranges from the remote node
        StreamIn.requestRanges(dst, tableName, Collections.singleton(cfstore), ranges, callback, OperationType.AES);
    } catch (Exception e) {
        throw new RuntimeException("Streaming repair failed", e);
    }
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.SSTableReader) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore)

Example 85 with ColumnFamilyStore

use of org.apache.cassandra.db.ColumnFamilyStore in project eiger by wlloyd.

the class StatusLogger method log.

public static void log() {
    MBeanServer server = ManagementFactory.getPlatformMBeanServer();
    // everything from o.a.c.concurrent
    logger.info(String.format("%-25s%10s%10s%10s", "Pool Name", "Active", "Pending", "Blocked"));
    Set<ObjectName> request, internal;
    try {
        request = server.queryNames(new ObjectName("org.apache.cassandra.request:type=*"), null);
        internal = server.queryNames(new ObjectName("org.apache.cassandra.internal:type=*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }
    for (ObjectName objectName : Iterables.concat(request, internal)) {
        String poolName = objectName.getKeyProperty("type");
        JMXEnabledThreadPoolExecutorMBean threadPoolProxy = JMX.newMBeanProxy(server, objectName, JMXEnabledThreadPoolExecutorMBean.class);
        logger.info(String.format("%-25s%10s%10s%10s", poolName, threadPoolProxy.getActiveCount(), threadPoolProxy.getPendingTasks(), threadPoolProxy.getCurrentlyBlockedTasks()));
    }
    // one offs
    logger.info(String.format("%-25s%10s%10s", "CompactionManager", "n/a", CompactionManager.instance.getPendingTasks()));
    int pendingCommands = 0;
    for (int n : MessagingService.instance().getCommandPendingTasks().values()) {
        pendingCommands += n;
    }
    int pendingResponses = 0;
    for (int n : MessagingService.instance().getResponsePendingTasks().values()) {
        pendingResponses += n;
    }
    logger.info(String.format("%-25s%10s%10s", "MessagingService", "n/a", pendingCommands + "," + pendingResponses));
    // Global key/row cache information
    AutoSavingCache<KeyCacheKey, Long> keyCache = CacheService.instance.keyCache;
    AutoSavingCache<RowCacheKey, ColumnFamily> rowCache = CacheService.instance.rowCache;
    int keyCacheKeysToSave = DatabaseDescriptor.getKeyCacheKeysToSave();
    int rowCacheKeysToSave = DatabaseDescriptor.getRowCacheKeysToSave();
    logger.info(String.format("%-25s%10s%25s%25s%65s", "Cache Type", "Size", "Capacity", "KeysToSave", "Provider"));
    logger.info(String.format("%-25s%10s%25s%25s%65s", "KeyCache", keyCache.weightedSize(), keyCache.getCapacity(), keyCacheKeysToSave == Integer.MAX_VALUE ? "all" : keyCacheKeysToSave, ""));
    logger.info(String.format("%-25s%10s%25s%25s%65s", "RowCache", rowCache.weightedSize(), rowCache.getCapacity(), rowCacheKeysToSave == Integer.MAX_VALUE ? "all" : rowCacheKeysToSave, DatabaseDescriptor.getRowCacheProvider().getClass().getName()));
    // per-CF stats
    logger.info(String.format("%-25s%20s", "ColumnFamily", "Memtable ops,data"));
    for (ColumnFamilyStore cfs : ColumnFamilyStore.all()) {
        logger.info(String.format("%-25s%20s", cfs.table.name + "." + cfs.columnFamily, cfs.getMemtableColumnsCount() + "," + cfs.getMemtableDataSize()));
    }
}
Also used : MalformedObjectNameException(javax.management.MalformedObjectNameException) JMXEnabledThreadPoolExecutorMBean(org.apache.cassandra.concurrent.JMXEnabledThreadPoolExecutorMBean) KeyCacheKey(org.apache.cassandra.cache.KeyCacheKey) ObjectName(javax.management.ObjectName) ColumnFamily(org.apache.cassandra.db.ColumnFamily) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) RowCacheKey(org.apache.cassandra.cache.RowCacheKey) MBeanServer(javax.management.MBeanServer)

Aggregations

ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)175 Test (org.junit.Test)110 SSTableReader (org.apache.cassandra.io.sstable.format.SSTableReader)90 Keyspace (org.apache.cassandra.db.Keyspace)64 File (java.io.File)30 Directories (org.apache.cassandra.db.Directories)25 LifecycleTransaction (org.apache.cassandra.db.lifecycle.LifecycleTransaction)24 DecoratedKey (org.apache.cassandra.db.DecoratedKey)22 RowUpdateBuilder (org.apache.cassandra.db.RowUpdateBuilder)20 AbstractTransactionalTest (org.apache.cassandra.utils.concurrent.AbstractTransactionalTest)20 RandomAccessFile (java.io.RandomAccessFile)19 CompactionController (org.apache.cassandra.db.compaction.CompactionController)14 ArrayList (java.util.ArrayList)13 ByteBuffer (java.nio.ByteBuffer)12 CompactionIterator (org.apache.cassandra.db.compaction.CompactionIterator)12 Range (org.apache.cassandra.dht.Range)11 Table (org.apache.cassandra.db.Table)9 Token (org.apache.cassandra.dht.Token)9 Descriptor (org.apache.cassandra.io.sstable.Descriptor)9 StatsMetadata (org.apache.cassandra.io.sstable.metadata.StatsMetadata)9