use of org.apache.cassandra.io.sstable.Descriptor in project eiger by wlloyd.
the class ColumnFamilyStore method loadNewSSTables.
/**
* #{@inheritDoc}
*/
public synchronized void loadNewSSTables() {
logger.info("Loading new SSTables for " + table.name + "/" + columnFamily + "...");
// current view over ColumnFamilyStore
DataTracker.View view = data.getView();
// descriptors of currently registered SSTables
Set<Descriptor> currentDescriptors = new HashSet<Descriptor>();
// going to hold new SSTable view of the CFS containing old and new SSTables
Set<SSTableReader> sstables = new HashSet<SSTableReader>();
// get the max generation number, to prevent generation conflicts
int generation = 0;
for (SSTableReader reader : view.sstables) {
// first of all, add old SSTables
sstables.add(reader);
currentDescriptors.add(reader.descriptor);
if (reader.descriptor.generation > generation)
generation = reader.descriptor.generation;
}
SSTableReader reader;
// set to true if we have at least one new SSTable to load
boolean atLeastOneNew = false;
Directories.SSTableLister lister = directories.sstableLister().skipCompacted(true).skipTemporary(true);
for (Map.Entry<Descriptor, Set<Component>> rawSSTable : lister.list().entrySet()) {
Descriptor descriptor = rawSSTable.getKey();
if (currentDescriptors.contains(descriptor))
// old (initialized) SSTable found, skipping
continue;
if (!descriptor.isCompatible())
throw new RuntimeException(String.format("Can't open incompatible SSTable! Current version %s, found file: %s", Descriptor.CURRENT_VERSION, descriptor));
logger.info("Initializing new SSTable {}", rawSSTable);
try {
Set<DecoratedKey> savedKeys = CacheService.instance.keyCache.readSaved(descriptor.ksname, descriptor.cfname);
reader = SSTableReader.open(rawSSTable.getKey(), rawSSTable.getValue(), savedKeys, data, metadata, partitioner);
} catch (IOException e) {
SSTableReader.logOpenException(rawSSTable.getKey(), e);
continue;
}
sstables.add(reader);
if (descriptor.generation > generation)
generation = descriptor.generation;
if (// set flag only once
!atLeastOneNew)
atLeastOneNew = true;
}
if (!atLeastOneNew) {
logger.info("No new SSTables where found for " + table.name + "/" + columnFamily);
return;
}
logger.info("Loading new SSTables and building secondary indexes for " + table.name + "/" + columnFamily + ": " + sstables);
SSTableReader.acquireReferences(sstables);
data.addSSTables(sstables);
try {
indexManager.maybeBuildSecondaryIndexes(sstables, indexManager.getIndexedColumns());
} catch (IOException e) {
throw new IOError(e);
} finally {
SSTableReader.releaseReferences(sstables);
}
logger.info("Setting up new generation: " + generation);
fileIndexGenerator.set(generation);
logger.info("Done loading load new SSTables for " + table.name + "/" + columnFamily);
}
use of org.apache.cassandra.io.sstable.Descriptor in project eiger by wlloyd.
the class BootstrapTest method testGetNewNames.
@Test
public void testGetNewNames() throws IOException {
Descriptor desc = Descriptor.fromFilename(new File("Keyspace1", "Keyspace1-Standard1-f-500-Data.db").toString());
// deliberately test old version
assert !desc.isLatestVersion;
PendingFile inContext = new PendingFile(null, desc, "Data.db", Arrays.asList(new Pair<Long, Long>(0L, 1L)), OperationType.BOOTSTRAP);
PendingFile outContext = StreamIn.getContextMapping(inContext);
// filename and generation are expected to have changed
assert !inContext.getFilename().equals(outContext.getFilename());
// nothing else should
assertEquals(inContext.component, outContext.component);
assertEquals(desc.ksname, outContext.desc.ksname);
assertEquals(desc.cfname, outContext.desc.cfname);
assertEquals(desc.version, outContext.desc.version);
}
use of org.apache.cassandra.io.sstable.Descriptor in project eiger by wlloyd.
the class SerializationsTest method makePendingFile.
private static PendingFile makePendingFile(boolean sst, int numSecs, OperationType op) {
Descriptor desc = new Descriptor("z", new File("path/doesn't/matter"), "Keyspace1", "Standard1", 23, false);
List<Pair<Long, Long>> sections = new ArrayList<Pair<Long, Long>>();
for (int i = 0; i < numSecs; i++) sections.add(new Pair<Long, Long>(new Long(i), new Long(i * i)));
return new PendingFile(sst ? makeSSTable() : null, desc, SSTable.COMPONENT_DATA, sections, op);
}
Aggregations