use of org.apache.cassandra.locator.InetAddressAndPort in project cassandra by apache.
the class StartupClusterConnectivityCheckerTest method copyCount.
private void copyCount(Set<InetAddressAndPort> source, Set<InetAddressAndPort> dest, int count) {
for (InetAddressAndPort peer : source) {
if (count <= 0)
break;
dest.add(peer);
count -= 1;
}
}
use of org.apache.cassandra.locator.InetAddressAndPort in project cassandra by apache.
the class RepairJobTest method testLocalSyncWithTransient.
public static void testLocalSyncWithTransient(InetAddressAndPort local, boolean pullRepair) {
List<TreeResponse> treeResponses = Arrays.asList(treeResponse(addr1, RANGE_1, "one", RANGE_2, "one", RANGE_3, "one"), treeResponse(addr2, RANGE_1, "two", RANGE_2, "two", RANGE_3, "two"), treeResponse(addr3, RANGE_1, "three", RANGE_2, "three", RANGE_3, "three"), treeResponse(addr4, RANGE_1, "four", RANGE_2, "four", RANGE_3, "four"), treeResponse(addr5, RANGE_1, "five", RANGE_2, "five", RANGE_3, "five"));
Predicate<InetAddressAndPort> isTransient = ep -> ep.equals(addr4) || ep.equals(addr5);
Map<SyncNodePair, SyncTask> tasks = toMap(RepairJob.createStandardSyncTasks(JOB_DESC, treeResponses, // local
local, // transient
isTransient, false, pullRepair, PreviewKind.ALL));
assertThat(tasks).hasSize(9);
for (InetAddressAndPort addr : new InetAddressAndPort[] { addr1, addr2, addr3 }) {
if (local.equals(addr))
continue;
assertThat(tasks.get(pair(local, addr))).isRequestRanges().hasTransferRanges(!pullRepair);
}
assertThat(tasks.get(pair(local, addr4))).isRequestRanges().hasTransferRanges(false);
assertThat(tasks.get(pair(local, addr5))).isRequestRanges().hasTransferRanges(false);
}
use of org.apache.cassandra.locator.InetAddressAndPort in project cassandra by apache.
the class RepairJobTest method setup.
@Before
public void setup() {
Set<InetAddressAndPort> neighbors = new HashSet<>(Arrays.asList(addr2, addr3));
UUID parentRepairSession = UUID.randomUUID();
ActiveRepairService.instance.registerParentRepairSession(parentRepairSession, FBUtilities.getBroadcastAddressAndPort(), Collections.singletonList(Keyspace.open(KEYSPACE).getColumnFamilyStore(CF)), FULL_RANGE, false, ActiveRepairService.UNREPAIRED_SSTABLE, false, PreviewKind.NONE);
this.session = new MeasureableRepairSession(parentRepairSession, UUIDGen.getTimeUUID(), new CommonRange(neighbors, Collections.emptySet(), FULL_RANGE), KEYSPACE, RepairParallelism.SEQUENTIAL, false, false, PreviewKind.NONE, false, CF);
this.job = new RepairJob(session, CF);
this.sessionJobDesc = new RepairJobDesc(session.parentRepairSession, session.getId(), session.keyspace, CF, session.ranges());
FBUtilities.setBroadcastInetAddress(addr1.getAddress());
}
use of org.apache.cassandra.locator.InetAddressAndPort in project cassandra by apache.
the class ValidationTaskTest method createTask.
private ValidationTask createTask() throws UnknownHostException {
InetAddressAndPort addressAndPort = InetAddressAndPort.getByName("127.0.0.1");
RepairJobDesc desc = new RepairJobDesc(UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), null);
return new ValidationTask(desc, addressAndPort, 0, PreviewKind.NONE);
}
use of org.apache.cassandra.locator.InetAddressAndPort in project cassandra by apache.
the class MessageTest method testBuilder.
@Test
public void testBuilder() {
long id = 1;
InetAddressAndPort from = FBUtilities.getLocalAddressAndPort();
long createAtNanos = approxTime.now();
long expiresAtNanos = createAtNanos + TimeUnit.SECONDS.toNanos(1);
TraceType traceType = TraceType.QUERY;
UUID traceSession = UUID.randomUUID();
Message<NoPayload> msg = Message.builder(Verb._TEST_1, noPayload).withId(1).from(from).withCreatedAt(createAtNanos).withExpiresAt(expiresAtNanos).withFlag(MessageFlag.CALL_BACK_ON_FAILURE).withParam(TRACE_TYPE, TraceType.QUERY).withParam(TRACE_SESSION, traceSession).build();
assertEquals(id, msg.id());
assertEquals(from, msg.from());
assertEquals(createAtNanos, msg.createdAtNanos());
assertEquals(expiresAtNanos, msg.expiresAtNanos());
assertTrue(msg.callBackOnFailure());
assertFalse(msg.trackRepairedData());
assertEquals(traceType, msg.traceType());
assertEquals(traceSession, msg.traceSession());
assertNull(msg.forwardTo());
assertNull(msg.respondTo());
}
Aggregations