Merge branch 'cassandra-4.1' into cassandra-5.0

This commit is contained in:
Sam Tunnicliffe 2024-11-01 19:01:16 +00:00
commit 8153a0b321
3 changed files with 60 additions and 1 deletions

View File

@ -2,6 +2,7 @@
* Ban the usage of "var" instead of full types in the production code (CASSANDRA-20038)
* Suppress CVE-2024-45772 from lucene-core-9.7.0.jar (CASSANDRA-20024)
Merged from 4.1:
* Equality check for Paxos.Electorate should not depend on collection types (CASSANDRA-19935)
Merged from 4.0:
* Add configurable batchlog endpoint strategies: random_remote, prefer_local, dynamic_remote, and dynamic (CASSANDRA-18120)
* Fix bash-completion for debian distro (CASSANDRA-19999)

View File

@ -277,7 +277,10 @@ public class Paxos
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Electorate that = (Electorate) o;
return natural.equals(that.natural) && pending.equals(that.pending);
return natural.size() == that.natural.size() &&
pending.size() == that.pending.size() &&
natural.containsAll(that.natural) &&
pending.containsAll(that.pending);
}
public int hashCode()

View File

@ -0,0 +1,55 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.cassandra.service.paxos;
import java.net.UnknownHostException;
import java.util.HashSet;
import org.junit.Test;
import org.apache.cassandra.dht.Murmur3Partitioner;
import org.apache.cassandra.dht.Token;
import org.apache.cassandra.locator.EndpointsForToken;
import org.apache.cassandra.locator.InetAddressAndPort;
import org.apache.cassandra.locator.Replica;
import org.apache.cassandra.service.paxos.Paxos.Electorate;
import static org.junit.Assert.assertEquals;
public class PaxosElectorateTest
{
@Test
public void compareElectoratesWithDifferentCollectionTypes() throws UnknownHostException
{
Token t = new Murmur3Partitioner.LongToken(0L);
EndpointsForToken natural = EndpointsForToken.of(t, replica(1),replica(2), replica(3));
EndpointsForToken pending = EndpointsForToken.of(t, replica(4));
Electorate first = new Electorate(natural.endpointList(), pending.endpointList());
Electorate second = new Electorate(new HashSet<>(natural.endpoints()), new HashSet<>(pending.endpoints()));
assertEquals(first, second);
}
private static Replica replica(int i) throws UnknownHostException
{
return Replica.fullReplica(InetAddressAndPort.getByName("127.0.0." + i),
Murmur3Partitioner.instance.getMinimumToken(),
Murmur3Partitioner.instance.getMinimumToken());
}
}