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);
}
}
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);
}
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);
}
}
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);
}
}
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()));
}
}
Aggregations