Search in sources :

Example 96 with InetAddressAndPort

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;
    }
}
Also used : InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort)

Example 97 with InetAddressAndPort

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);
}
Also used : RepairException(org.apache.cassandra.exceptions.RepairException) Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) TimeoutException(java.util.concurrent.TimeoutException) ByteOrderedPartitioner(org.apache.cassandra.dht.ByteOrderedPartitioner) ExecutorFactory(org.apache.cassandra.concurrent.ExecutorFactory) Map(java.util.Map) After(org.junit.After) Murmur3Partitioner(org.apache.cassandra.dht.Murmur3Partitioner) Assertions(org.assertj.core.api.Assertions) SyncTaskAssert.assertThat(org.apache.cassandra.utils.asserts.SyncTaskAssert.assertThat) Assert.fail(org.junit.Assert.fail) SyncTaskListAssert(org.apache.cassandra.utils.asserts.SyncTaskListAssert) Keyspace(org.apache.cassandra.db.Keyspace) FBUtilities(org.apache.cassandra.utils.FBUtilities) ImmutableMap(com.google.common.collect.ImmutableMap) Predicate(java.util.function.Predicate) KeyspaceParams(org.apache.cassandra.schema.KeyspaceParams) Set(java.util.Set) SyncRequest(org.apache.cassandra.repair.messages.SyncRequest) UUID(java.util.UUID) Verb(org.apache.cassandra.net.Verb) Collectors(java.util.stream.Collectors) UUIDGen(org.apache.cassandra.utils.UUIDGen) SyncTaskListAssert.assertThat(org.apache.cassandra.utils.asserts.SyncTaskListAssert.assertThat) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) Throwables(org.apache.cassandra.utils.Throwables) ObjectSizes(org.apache.cassandra.utils.ObjectSizes) InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) MerkleTrees(org.apache.cassandra.utils.MerkleTrees) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) BeforeClass(org.junit.BeforeClass) Range(org.apache.cassandra.dht.Range) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) CompletableFuture(java.util.concurrent.CompletableFuture) Message(org.apache.cassandra.net.Message) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) SessionSummary(org.apache.cassandra.streaming.SessionSummary) Token(org.apache.cassandra.dht.Token) ActiveRepairService(org.apache.cassandra.service.ActiveRepairService) MerkleTree(org.apache.cassandra.utils.MerkleTree) Before(org.junit.Before) MessagingService(org.apache.cassandra.net.MessagingService) ByteBufferUtil(org.apache.cassandra.utils.ByteBufferUtil) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) UnknownHostException(java.net.UnknownHostException) ExecutorPlus(org.apache.cassandra.concurrent.ExecutorPlus) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) SchemaLoader(org.apache.cassandra.SchemaLoader) RepairMessage(org.apache.cassandra.repair.messages.RepairMessage) PreviewKind(org.apache.cassandra.streaming.PreviewKind) IPartitioner(org.apache.cassandra.dht.IPartitioner) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort)

Example 98 with InetAddressAndPort

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());
}
Also used : InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) UUID(java.util.UUID) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 99 with InetAddressAndPort

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);
}
Also used : InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort)

Example 100 with InetAddressAndPort

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());
}
Also used : InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) TraceType(org.apache.cassandra.tracing.Tracing.TraceType) UUID(java.util.UUID) Test(org.junit.Test)

Aggregations

InetAddressAndPort (org.apache.cassandra.locator.InetAddressAndPort)281 Test (org.junit.Test)129 Token (org.apache.cassandra.dht.Token)65 TokenMetadata (org.apache.cassandra.locator.TokenMetadata)43 EndpointsForRange (org.apache.cassandra.locator.EndpointsForRange)39 Range (org.apache.cassandra.dht.Range)28 Replica (org.apache.cassandra.locator.Replica)25 ArrayList (java.util.ArrayList)24 ByteBuffer (java.nio.ByteBuffer)23 HashMap (java.util.HashMap)23 UUID (java.util.UUID)22 HashSet (java.util.HashSet)20 Map (java.util.Map)20 Mutation (org.apache.cassandra.db.Mutation)17 PartitionIterator (org.apache.cassandra.db.partitions.PartitionIterator)17 UnfilteredPartitionIterator (org.apache.cassandra.db.partitions.UnfilteredPartitionIterator)16 VersionedValue (org.apache.cassandra.gms.VersionedValue)16 VisibleForTesting (com.google.common.annotations.VisibleForTesting)15 IPartitioner (org.apache.cassandra.dht.IPartitioner)15 BigIntegerToken (org.apache.cassandra.dht.RandomPartitioner.BigIntegerToken)15