use of org.apache.cassandra.gms.IFailureDetectionEventListener in project eiger by wlloyd.
the class BootStrapperTest method testSourceTargetComputation.
private void testSourceTargetComputation(String table, int numOldNodes, int replicationFactor) throws UnknownHostException {
StorageService ss = StorageService.instance;
generateFakeEndpoints(numOldNodes);
Token myToken = StorageService.getPartitioner().getRandomToken();
InetAddress myEndpoint = InetAddress.getByName("127.0.0.1");
TokenMetadata tmd = ss.getTokenMetadata();
assertEquals(numOldNodes, tmd.sortedTokens().size());
BootStrapper b = new BootStrapper(myEndpoint, myToken, tmd);
Multimap<Range<Token>, InetAddress> res = b.getRangesWithSources(table);
int transferCount = 0;
for (Map.Entry<Range<Token>, Collection<InetAddress>> e : res.asMap().entrySet()) {
assert e.getValue() != null && e.getValue().size() > 0 : StringUtils.join(e.getValue(), ", ");
transferCount++;
}
assertEquals(replicationFactor, transferCount);
IFailureDetector mockFailureDetector = new IFailureDetector() {
public boolean isAlive(InetAddress ep) {
return true;
}
public void interpret(InetAddress ep) {
throw new UnsupportedOperationException();
}
public void report(InetAddress ep) {
throw new UnsupportedOperationException();
}
public void registerFailureDetectionEventListener(IFailureDetectionEventListener listener) {
throw new UnsupportedOperationException();
}
public void unregisterFailureDetectionEventListener(IFailureDetectionEventListener listener) {
throw new UnsupportedOperationException();
}
public void remove(InetAddress ep) {
throw new UnsupportedOperationException();
}
public void clear(InetAddress ep) {
throw new UnsupportedOperationException();
}
};
Multimap<InetAddress, Range<Token>> temp = BootStrapper.getWorkMap(res, mockFailureDetector);
// is used, they will vary.
assert temp.keySet().size() > 0;
assert temp.asMap().values().iterator().next().size() > 0;
assert !temp.keySet().iterator().next().equals(myEndpoint);
}
use of org.apache.cassandra.gms.IFailureDetectionEventListener in project cassandra by apache.
the class BootStrapperTest method testSourceTargetComputation.
private RangeStreamer testSourceTargetComputation(String keyspaceName, int numOldNodes, int replicationFactor) throws UnknownHostException {
StorageService ss = StorageService.instance;
TokenMetadata tmd = ss.getTokenMetadata();
generateFakeEndpoints(numOldNodes);
Token myToken = tmd.partitioner.getRandomToken();
InetAddress myEndpoint = InetAddress.getByName("127.0.0.1");
assertEquals(numOldNodes, tmd.sortedTokens().size());
RangeStreamer s = new RangeStreamer(tmd, null, myEndpoint, "Bootstrap", true, DatabaseDescriptor.getEndpointSnitch(), new StreamStateStore(), false, 1);
IFailureDetector mockFailureDetector = new IFailureDetector() {
public boolean isAlive(InetAddress ep) {
return true;
}
public void interpret(InetAddress ep) {
throw new UnsupportedOperationException();
}
public void report(InetAddress ep) {
throw new UnsupportedOperationException();
}
public void registerFailureDetectionEventListener(IFailureDetectionEventListener listener) {
throw new UnsupportedOperationException();
}
public void unregisterFailureDetectionEventListener(IFailureDetectionEventListener listener) {
throw new UnsupportedOperationException();
}
public void remove(InetAddress ep) {
throw new UnsupportedOperationException();
}
public void forceConviction(InetAddress ep) {
throw new UnsupportedOperationException();
}
};
s.addSourceFilter(new RangeStreamer.FailureDetectorSourceFilter(mockFailureDetector));
s.addRanges(keyspaceName, Keyspace.open(keyspaceName).getReplicationStrategy().getPendingAddressRanges(tmd, myToken, myEndpoint));
Collection<Map.Entry<InetAddress, Collection<Range<Token>>>> toFetch = s.toFetch().get(keyspaceName);
// Check we get get RF new ranges in total
Set<Range<Token>> ranges = new HashSet<>();
for (Map.Entry<InetAddress, Collection<Range<Token>>> e : toFetch) ranges.addAll(e.getValue());
assertEquals(replicationFactor, ranges.size());
// is used, they will vary.
assert toFetch.iterator().next().getValue().size() > 0;
assert !toFetch.iterator().next().getKey().equals(myEndpoint);
return s;
}
Aggregations