use of org.apache.cassandra.io.sstable.SSTableReader in project eiger by wlloyd.
the class ColumnFamilyStoreTest method testGetColumnWithWrongBF.
@Test
public void testGetColumnWithWrongBF() throws IOException, ExecutionException, InterruptedException {
Table table = Table.open("Keyspace1");
ColumnFamilyStore cfs = table.getColumnFamilyStore("Standard1");
cfs.truncate().get();
List<IMutation> rms = new LinkedList<IMutation>();
RowMutation rm;
rm = new RowMutation("Keyspace1", ByteBufferUtil.bytes("key1"));
rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes("Column1")), ByteBufferUtil.bytes("asdf"), 0);
rm.add(new QueryPath("Standard1", null, ByteBufferUtil.bytes("Column2")), ByteBufferUtil.bytes("asdf"), 0);
rms.add(rm);
Util.writeColumnFamily(rms);
List<SSTableReader> ssTables = table.getAllSSTables();
assertEquals(1, ssTables.size());
ssTables.get(0).forceFilterFailures();
ColumnFamily cf = cfs.getColumnFamily(QueryFilter.getIdentityFilter(Util.dk("key2"), new QueryPath("Standard1", null, ByteBufferUtil.bytes("Column1"))));
assertNull(cf);
}
use of org.apache.cassandra.io.sstable.SSTableReader 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.io.sstable.SSTableReader 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.io.sstable.SSTableReader 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.io.sstable.SSTableReader in project eiger by wlloyd.
the class LeveledManifest method serialize.
public synchronized void serialize() {
File manifestFile = cfs.directories.getOrCreateLeveledManifest();
File oldFile = new File(manifestFile.getPath().replace(EXTENSION, "-old.json"));
File tmpFile = new File(manifestFile.getPath().replace(EXTENSION, "-tmp.json"));
JsonFactory f = new JsonFactory();
try {
JsonGenerator g = f.createJsonGenerator(tmpFile, JsonEncoding.UTF8);
g.useDefaultPrettyPrinter();
g.writeStartObject();
g.writeArrayFieldStart("generations");
for (int level = 0; level < generations.length; level++) {
g.writeStartObject();
g.writeNumberField("generation", level);
g.writeArrayFieldStart("members");
for (SSTableReader ssTableReader : generations[level]) g.writeNumber(ssTableReader.descriptor.generation);
// members
g.writeEndArray();
// generation
g.writeEndObject();
}
// for field generations
g.writeEndArray();
// write global object
g.writeEndObject();
g.close();
if (oldFile.exists() && manifestFile.exists())
FileUtils.deleteWithConfirm(oldFile);
if (manifestFile.exists())
FileUtils.renameWithConfirm(manifestFile, oldFile);
assert tmpFile.exists();
FileUtils.renameWithConfirm(tmpFile, manifestFile);
logger.debug("Saved manifest {}", manifestFile);
} catch (IOException e) {
throw new IOError(e);
}
}
Aggregations