Search in sources :

Example 46 with InetAddressAndPort

use of org.apache.cassandra.locator.InetAddressAndPort in project cassandra by apache.

the class AsymmetricRemoteSyncTask method startSync.

public void startSync() {
    InetAddressAndPort local = FBUtilities.getBroadcastAddressAndPort();
    SyncRequest request = new SyncRequest(desc, local, nodePair.coordinator, nodePair.peer, rangesToSync, previewKind, true);
    String message = String.format("Forwarding streaming repair of %d ranges to %s (to be streamed with %s)", request.ranges.size(), request.src, request.dst);
    Tracing.traceRepair(message);
    MessagingService.instance().send(Message.out(SYNC_REQ, request), request.src);
}
Also used : InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) SyncRequest(org.apache.cassandra.repair.messages.SyncRequest)

Example 47 with InetAddressAndPort

use of org.apache.cassandra.locator.InetAddressAndPort in project cassandra by apache.

the class IncrementalRepairTask method performUnsafe.

@Override
public Future<CoordinatedRepairResult> performUnsafe(ExecutorPlus executor) throws Exception {
    // the local node also needs to be included in the set of participants, since coordinator sessions aren't persisted
    Set<InetAddressAndPort> allParticipants = ImmutableSet.<InetAddressAndPort>builder().addAll(neighborsAndRanges.participants).add(FBUtilities.getBroadcastAddressAndPort()).build();
    // Not necessary to include self for filtering. The common ranges only contains neighbhor node endpoints.
    List<CommonRange> allRanges = neighborsAndRanges.filterCommonRanges(keyspace, cfnames);
    CoordinatorSession coordinatorSession = ActiveRepairService.instance.consistent.coordinated.registerSession(parentSession, allParticipants, neighborsAndRanges.shouldExcludeDeadParticipants);
    return coordinatorSession.execute(() -> runRepair(parentSession, true, executor, allRanges, cfnames));
}
Also used : InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) CoordinatorSession(org.apache.cassandra.repair.consistent.CoordinatorSession)

Example 48 with InetAddressAndPort

use of org.apache.cassandra.locator.InetAddressAndPort in project cassandra by apache.

the class LocalSyncTask method createStreamPlan.

@VisibleForTesting
StreamPlan createStreamPlan() {
    InetAddressAndPort remote = nodePair.peer;
    StreamPlan plan = new StreamPlan(StreamOperation.REPAIR, 1, false, pendingRepair, previewKind).listeners(this).flushBeforeTransfer(pendingRepair == null);
    if (requestRanges) {
        // see comment on RangesAtEndpoint.toDummyList for why we synthesize replicas here
        plan.requestRanges(remote, desc.keyspace, RangesAtEndpoint.toDummyList(rangesToSync), RangesAtEndpoint.toDummyList(Collections.emptyList()), desc.columnFamily);
    }
    if (transferRanges) {
        // send ranges to the remote node if we are not performing a pull repair
        // see comment on RangesAtEndpoint.toDummyList for why we synthesize replicas here
        plan.transferRanges(remote, desc.keyspace, RangesAtEndpoint.toDummyList(rangesToSync), desc.columnFamily);
    }
    return plan;
}
Also used : StreamPlan(org.apache.cassandra.streaming.StreamPlan) InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 49 with InetAddressAndPort

use of org.apache.cassandra.locator.InetAddressAndPort in project cassandra by apache.

the class InboundConnectionSettings method withDefaults.

// note that connectTo is updated even if specified, in the case of pre40 messaging and using encryption (to update port)
public InboundConnectionSettings withDefaults() {
    // this is for the socket that can be plain, only ssl, or optional plain/ssl
    if (bindAddress.getPort() != DatabaseDescriptor.getStoragePort() && bindAddress.getPort() != DatabaseDescriptor.getSSLStoragePort())
        throw new ConfigurationException(format("Local endpoint port %d doesn't match YAML configured port %d or legacy SSL port %d", bindAddress.getPort(), DatabaseDescriptor.getStoragePort(), DatabaseDescriptor.getSSLStoragePort()));
    IInternodeAuthenticator authenticator = this.authenticator;
    ServerEncryptionOptions encryption = this.encryption;
    Integer socketReceiveBufferSizeInBytes = this.socketReceiveBufferSizeInBytes;
    Integer applicationReceiveQueueCapacityInBytes = this.applicationReceiveQueueCapacityInBytes;
    AcceptVersions acceptMessaging = this.acceptMessaging;
    AcceptVersions acceptStreaming = this.acceptStreaming;
    SocketFactory socketFactory = this.socketFactory;
    Function<InetAddressAndPort, InboundMessageHandlers> handlersFactory = this.handlers;
    if (authenticator == null)
        authenticator = DatabaseDescriptor.getInternodeAuthenticator();
    if (encryption == null)
        encryption = DatabaseDescriptor.getInternodeMessagingEncyptionOptions();
    if (socketReceiveBufferSizeInBytes == null)
        socketReceiveBufferSizeInBytes = DatabaseDescriptor.getInternodeSocketReceiveBufferSizeInBytes();
    if (applicationReceiveQueueCapacityInBytes == null)
        applicationReceiveQueueCapacityInBytes = DatabaseDescriptor.getInternodeApplicationReceiveQueueCapacityInBytes();
    if (acceptMessaging == null)
        acceptMessaging = accept_messaging;
    if (acceptStreaming == null)
        acceptStreaming = accept_streaming;
    if (socketFactory == null)
        socketFactory = instance().socketFactory;
    if (handlersFactory == null)
        handlersFactory = instance()::getInbound;
    Preconditions.checkArgument(socketReceiveBufferSizeInBytes == 0 || socketReceiveBufferSizeInBytes >= 1 << 10, "illegal socket send buffer size: " + socketReceiveBufferSizeInBytes);
    Preconditions.checkArgument(applicationReceiveQueueCapacityInBytes >= 1 << 10, "illegal application receive queue capacity: " + applicationReceiveQueueCapacityInBytes);
    return new InboundConnectionSettings(authenticator, bindAddress, encryption, socketReceiveBufferSizeInBytes, applicationReceiveQueueCapacityInBytes, acceptMessaging, acceptStreaming, socketFactory, handlersFactory);
}
Also used : InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) ConfigurationException(org.apache.cassandra.exceptions.ConfigurationException) IInternodeAuthenticator(org.apache.cassandra.auth.IInternodeAuthenticator) ServerEncryptionOptions(org.apache.cassandra.config.EncryptionOptions.ServerEncryptionOptions)

Example 50 with InetAddressAndPort

use of org.apache.cassandra.locator.InetAddressAndPort in project cassandra by apache.

the class SetHostStatWithPort method add.

public void add(String token, String host, Map<String, Float> ownerships) throws UnknownHostException {
    InetAddressAndPort endpoint = InetAddressAndPort.getByName(host);
    Float owns = ownerships.get(endpoint.getHostAddressAndPort());
    hostStats.add(new HostStatWithPort(token, endpoint, resolveIp, owns));
}
Also used : InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort)

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