use of org.apache.cassandra.db.ReadCommand in project cassandra by apache.
the class DataResolverTest method testResolveNewCollection.
@Test
public void testResolveNewCollection() {
EndpointsForRange replicas = makeReplicas(2);
ReadCommand cmd = Util.cmd(cfs2, dk).withNowInSeconds(nowInSec).build();
TestableReadRepair readRepair = new TestableReadRepair(cmd);
DataResolver resolver = new DataResolver(cmd, plan(replicas, ALL), readRepair, nanoTime());
long[] ts = { 100, 200 };
// map column
Row.Builder builder = BTreeRow.unsortedBuilder();
builder.newRow(Clustering.EMPTY);
DeletionTime expectedCmplxDelete = new DeletionTime(ts[0] - 1, nowInSec);
builder.addComplexDeletion(m, expectedCmplxDelete);
Cell<?> expectedCell = mapCell(0, 0, ts[0]);
builder.addCell(expectedCell);
// empty map column
InetAddressAndPort peer1 = replicas.get(0).endpoint();
resolver.preprocess(response(cmd, peer1, iter(PartitionUpdate.singleRowUpdate(cfm2, dk, builder.build()))));
InetAddressAndPort peer2 = replicas.get(1).endpoint();
resolver.preprocess(response(cmd, peer2, iter(PartitionUpdate.emptyUpdate(cfm2, dk))));
try (PartitionIterator data = resolver.resolve()) {
try (RowIterator rows = Iterators.getOnlyElement(data)) {
Row row = Iterators.getOnlyElement(rows);
assertColumns(row, "m");
ComplexColumnData cd = row.getComplexColumnData(m);
assertEquals(Collections.singleton(expectedCell), Sets.newHashSet(cd));
}
}
Assert.assertNull(readRepair.sent.get(peer1));
Mutation mutation = readRepair.getForEndpoint(peer2);
Iterator<Row> rowIter = mutation.getPartitionUpdate(cfm2).iterator();
assertTrue(rowIter.hasNext());
Row row = rowIter.next();
assertFalse(rowIter.hasNext());
ComplexColumnData cd = row.getComplexColumnData(m);
assertEquals(Sets.newHashSet(expectedCell), Sets.newHashSet(cd));
assertEquals(expectedCmplxDelete, cd.complexDeletion());
}
use of org.apache.cassandra.db.ReadCommand in project eiger by wlloyd.
the class ReadCallback method randomlyReadRepair.
private boolean randomlyReadRepair() {
if (resolver instanceof RowDigestResolver) {
assert command instanceof ReadCommand : command;
String table = ((RowDigestResolver) resolver).table;
String columnFamily = ((ReadCommand) command).getColumnFamilyName();
CFMetaData cfmd = Schema.instance.getTableMetaData(table).get(columnFamily);
return cfmd.getReadRepairChance() > FBUtilities.threadLocalRandom().nextDouble();
}
// we don't read repair on range scans
return false;
}
use of org.apache.cassandra.db.ReadCommand in project brisk by riptano.
the class TrackerManager method getCurrentJobtrackerLocation.
/**
* Retrieves the current job tracker IP.
*
* @return the current job tracker IP
* @throws TrackerManagerException
*/
public static InetAddress getCurrentJobtrackerLocation() throws TrackerManagerException {
ReadCommand rc = new SliceByNamesReadCommand(BriskSchema.KEYSPACE_NAME, currentJobtrackerKey, cp, Arrays.asList(columnName));
String result;
try {
List<Row> rows = StorageProxy.read(Arrays.asList(rc), ConsistencyLevel.QUORUM);
IColumn col = validateAndGetColumn(rows, columnName);
// ByteBuffer util duplicates for us the value.
result = ByteBufferUtil.string(col.value());
return InetAddress.getByName(result);
} catch (NotFoundException e) {
return null;
} catch (Exception e) {
throw new TrackerManagerException(e);
}
}
Aggregations