Search in sources :

Example 56 with InetAddressAndPort

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

the class StreamingMetricsTest method checkDataSent.

private long checkDataSent(Cluster cluster, int node, int peer) {
    InetAddressAndPort address = getNodeAddress(cluster, peer);
    return cluster.get(node).callOnInstance(() -> {
        StreamingMetrics metrics = StreamingMetrics.get(address);
        long outgoingBytes = metrics.outgoingBytes.getCount();
        assertThat(outgoingBytes).describedAs("There should be data streamed from node" + node + " to node" + peer).isGreaterThan(0);
        return outgoingBytes;
    });
}
Also used : InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) StreamingMetrics(org.apache.cassandra.metrics.StreamingMetrics)

Example 57 with InetAddressAndPort

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

the class VirtualTableFromInternode method readCommandAccessVirtualTable.

@Test
public void readCommandAccessVirtualTable() {
    CLUSTER.get(1).runOnInstance(() -> {
        boolean didWork = false;
        for (InetAddressAndPort address : Gossiper.instance.getLiveMembers()) {
            didWork = true;
            UntypedResultSet rs = QueryProcessor.executeAsync(address, "SELECT * FROM system_views.settings").syncUninterruptibly().getNow();
            assertThat(rs.isEmpty()).isFalse();
            for (UntypedResultSet.Row row : rs) {
                String name = row.getString("name");
                switch(name) {
                    case "broadcast_address":
                    case "rpc_address":
                        assertThat(row.getString("value")).isEqualTo(address.getAddress().getHostAddress());
                        break;
                }
            }
        }
        assertThat(didWork).isTrue();
    });
}
Also used : UntypedResultSet(org.apache.cassandra.cql3.UntypedResultSet) InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) Test(org.junit.Test)

Example 58 with InetAddressAndPort

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

the class SystemKeyspaceTest method testNonLocalToken.

@Test
public void testNonLocalToken() throws UnknownHostException {
    BytesToken token = new BytesToken(ByteBufferUtil.bytes("token3"));
    InetAddressAndPort address = InetAddressAndPort.getByName("127.0.0.2");
    SystemKeyspace.updateTokens(address, Collections.<Token>singletonList(token));
    assert SystemKeyspace.loadTokens().get(address).contains(token);
    SystemKeyspace.removeEndpoint(address);
    assert !SystemKeyspace.loadTokens().containsValue(token);
}
Also used : InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) BytesToken(org.apache.cassandra.dht.ByteOrderedPartitioner.BytesToken) Test(org.junit.Test)

Example 59 with InetAddressAndPort

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

the class ReadCommandTest method copyMultipleTransientAsDigestQuery.

@Test(expected = IllegalArgumentException.class)
public void copyMultipleTransientAsDigestQuery() {
    ColumnFamilyStore cfs = Keyspace.open(KEYSPACE).getColumnFamilyStore(CF6);
    DecoratedKey key = Util.dk("key");
    Token token = key.getToken();
    // Address is unimportant for this test
    InetAddressAndPort addr = FBUtilities.getBroadcastAddressAndPort();
    ReadCommand readCommand = Util.cmd(cfs, key).build();
    readCommand.copyAsDigestQuery(EndpointsForToken.of(token, ReplicaUtils.trans(addr, token), ReplicaUtils.full(addr, token)));
}
Also used : InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) EndpointsForToken(org.apache.cassandra.locator.EndpointsForToken) Token(org.apache.cassandra.dht.Token) Test(org.junit.Test)

Example 60 with InetAddressAndPort

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

the class ReadCommandTest method copyMultipleFullAsTransientTest.

@Test(expected = IllegalArgumentException.class)
public void copyMultipleFullAsTransientTest() {
    ColumnFamilyStore cfs = Keyspace.open(KEYSPACE).getColumnFamilyStore(CF6);
    DecoratedKey key = Util.dk("key");
    Token token = key.getToken();
    // Address is unimportant for this test
    InetAddressAndPort addr = FBUtilities.getBroadcastAddressAndPort();
    ReadCommand readCommand = Util.cmd(cfs, key).build();
    readCommand.copyAsTransientQuery(EndpointsForToken.of(token, ReplicaUtils.trans(addr, token), ReplicaUtils.full(addr, token)));
}
Also used : InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) EndpointsForToken(org.apache.cassandra.locator.EndpointsForToken) Token(org.apache.cassandra.dht.Token) 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