Search in sources :

Example 1 with MessagingService

use of org.apache.cassandra.net.MessagingService in project eiger by wlloyd.

the class AntiEntropyService method respond.

/**
 * Responds to the node that requested the given valid tree.
 * @param validator A locally generated validator
 * @param local localhost (parameterized for testing)
 */
void respond(Validator validator, InetAddress local) {
    MessagingService ms = MessagingService.instance();
    try {
        Message message = TreeResponseVerbHandler.makeVerb(local, validator);
        if (!validator.request.endpoint.equals(FBUtilities.getBroadcastAddress()))
            logger.info(String.format("[repair #%s] Sending completed merkle tree to %s for %s", validator.request.sessionid, validator.request.endpoint, validator.request.cf));
        ms.sendOneWay(message, validator.request.endpoint);
    } catch (Exception e) {
        logger.error(String.format("[repair #%s] Error sending completed merkle tree to %s for %s ", validator.request.sessionid, validator.request.endpoint, validator.request.cf), e);
    }
}
Also used : Message(org.apache.cassandra.net.Message) MessagingService(org.apache.cassandra.net.MessagingService)

Example 2 with MessagingService

use of org.apache.cassandra.net.MessagingService in project cassandra by apache.

the class GossipSettlesTest method testGossipSettles.

@Test
public void testGossipSettles() throws Throwable {
    /* Use withSubnet(1) to prove seed provider is set correctly - without the fix to pass a seed provider, this test fails */
    try (Cluster cluster = builder().withNodes(3).withConfig(config -> config.with(GOSSIP).with(NETWORK)).withSubnet(1).start()) {
        // Verify the 4.0 WithPort versions of status reporting methods match their InetAddress
        // counterparts.  Disable Gossip first to prevent any bump in heartbeats that would
        // invalidate the comparison.  Compare the newer WithPort versions by adding the
        // storage port to IP addresses in keys/values/strings as appropriate.
        cluster.forEach(i -> i.runOnInstance(() -> {
            Gossiper.instance.stop();
        }));
        cluster.get(1).runOnInstance(() -> {
            // First prove that the storage port is added
            Assert.assertEquals("stuff 127.0.0.1:7012 morestuff 127.0.0.2:7012", addStoragePortToIP("stuff 127.0.0.1 morestuff 127.0.0.2"));
            FailureDetector fd = ((FailureDetector) FailureDetector.instance);
            Assert.assertEquals(addStoragePortToInstanceName(fd.getAllEndpointStates(false)), fd.getAllEndpointStates(true));
            Assert.assertEquals(addPortToKeys(fd.getSimpleStates()), fd.getSimpleStatesWithPort());
            StorageProxy sp = StorageProxy.instance;
            Assert.assertEquals(addPortToSchemaVersions(sp.getSchemaVersions()), sp.getSchemaVersionsWithPort());
            StorageService ss = StorageService.instance;
            Assert.assertEquals(addPortToValues(ss.getTokenToEndpointMap()), ss.getTokenToEndpointWithPortMap());
            Assert.assertEquals(addPortToKeys(ss.getEndpointToHostId()), ss.getEndpointWithPortToHostId());
            Assert.assertEquals(addPortToValues(ss.getHostIdToEndpoint()), ss.getHostIdToEndpointWithPort());
            Assert.assertEquals(addPortToKeys(ss.getLoadMap()), ss.getLoadMapWithPort());
            Assert.assertEquals(addPortToList(ss.getLiveNodes()), ss.getLiveNodesWithPort());
            List<String> naturalEndpointsAddedPort = ss.getNaturalEndpoints(SchemaConstants.DISTRIBUTED_KEYSPACE_NAME, SystemDistributedKeyspace.VIEW_BUILD_STATUS, "dummy").stream().map(e -> addStoragePortToIP(e.getHostAddress())).collect(Collectors.toList());
            Assert.assertEquals(naturalEndpointsAddedPort, ss.getNaturalEndpointsWithPort(SchemaConstants.DISTRIBUTED_KEYSPACE_NAME, SystemDistributedKeyspace.VIEW_BUILD_STATUS, "dummy"));
            naturalEndpointsAddedPort = ss.getNaturalEndpoints(SchemaConstants.DISTRIBUTED_KEYSPACE_NAME, ByteBufferUtil.EMPTY_BYTE_BUFFER).stream().map(e -> addStoragePortToIP(e.getHostAddress())).collect(Collectors.toList());
            Assert.assertEquals(naturalEndpointsAddedPort, ss.getNaturalEndpointsWithPort(SchemaConstants.DISTRIBUTED_KEYSPACE_NAME, ByteBufferUtil.EMPTY_BYTE_BUFFER));
            // Difference in key type... convert to String and add the port to the older format
            Map<String, Float> getOwnershipKeyAddedPort = ss.getOwnership().entrySet().stream().collect(Collectors.<Map.Entry<InetAddress, Float>, String, Float>toMap(e -> addStoragePortToIP(e.getKey().toString()), Map.Entry::getValue));
            Assert.assertEquals(getOwnershipKeyAddedPort, ss.getOwnershipWithPort());
            MessagingService ms = MessagingService.instance();
            Assert.assertEquals(addPortToKeys(ms.getTimeoutsPerHost()), ms.getTimeoutsPerHostWithPort());
            Assert.assertEquals(addPortToKeys(ms.getLargeMessagePendingTasks()), ms.getLargeMessagePendingTasksWithPort());
            Assert.assertEquals(addPortToKeys(ms.getLargeMessageCompletedTasks()), ms.getLargeMessageCompletedTasksWithPort());
            Assert.assertEquals(addPortToKeys(ms.getLargeMessageDroppedTasks()), ms.getLargeMessageDroppedTasksWithPort());
            Assert.assertEquals(addPortToKeys(ms.getSmallMessagePendingTasks()), ms.getSmallMessagePendingTasksWithPort());
            Assert.assertEquals(addPortToKeys(ms.getSmallMessageCompletedTasks()), ms.getSmallMessageCompletedTasksWithPort());
            Assert.assertEquals(addPortToKeys(ms.getSmallMessageDroppedTasks()), ms.getSmallMessageDroppedTasksWithPort());
            Assert.assertEquals(addPortToKeys(ms.getGossipMessagePendingTasks()), ms.getGossipMessagePendingTasksWithPort());
            Assert.assertEquals(addPortToKeys(ms.getGossipMessageCompletedTasks()), ms.getGossipMessageCompletedTasksWithPort());
            Assert.assertEquals(addPortToKeys(ms.getGossipMessageDroppedTasks()), ms.getGossipMessageDroppedTasksWithPort());
        });
    }
}
Also used : MessagingService(org.apache.cassandra.net.MessagingService) Arrays(java.util.Arrays) ByteBufferUtil(org.apache.cassandra.utils.ByteBufferUtil) StorageService(org.apache.cassandra.service.StorageService) Test(org.junit.Test) Collectors(java.util.stream.Collectors) Gossiper(org.apache.cassandra.gms.Gossiper) InetAddress(java.net.InetAddress) SystemDistributedKeyspace(org.apache.cassandra.schema.SystemDistributedKeyspace) List(java.util.List) StorageProxy(org.apache.cassandra.service.StorageProxy) Map(java.util.Map) Cluster(org.apache.cassandra.distributed.Cluster) Pattern(java.util.regex.Pattern) Assert(org.junit.Assert) FailureDetector(org.apache.cassandra.gms.FailureDetector) DatabaseDescriptor(org.apache.cassandra.config.DatabaseDescriptor) SchemaConstants(org.apache.cassandra.schema.SchemaConstants) NETWORK(org.apache.cassandra.distributed.api.Feature.NETWORK) GOSSIP(org.apache.cassandra.distributed.api.Feature.GOSSIP) StorageProxy(org.apache.cassandra.service.StorageProxy) FailureDetector(org.apache.cassandra.gms.FailureDetector) Cluster(org.apache.cassandra.distributed.Cluster) Map(java.util.Map) InetAddress(java.net.InetAddress) StorageService(org.apache.cassandra.service.StorageService) MessagingService(org.apache.cassandra.net.MessagingService) Test(org.junit.Test)

Aggregations

MessagingService (org.apache.cassandra.net.MessagingService)2 InetAddress (java.net.InetAddress)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Map (java.util.Map)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 DatabaseDescriptor (org.apache.cassandra.config.DatabaseDescriptor)1 Cluster (org.apache.cassandra.distributed.Cluster)1 GOSSIP (org.apache.cassandra.distributed.api.Feature.GOSSIP)1 NETWORK (org.apache.cassandra.distributed.api.Feature.NETWORK)1 FailureDetector (org.apache.cassandra.gms.FailureDetector)1 Gossiper (org.apache.cassandra.gms.Gossiper)1 Message (org.apache.cassandra.net.Message)1 SchemaConstants (org.apache.cassandra.schema.SchemaConstants)1 SystemDistributedKeyspace (org.apache.cassandra.schema.SystemDistributedKeyspace)1 StorageProxy (org.apache.cassandra.service.StorageProxy)1 StorageService (org.apache.cassandra.service.StorageService)1 ByteBufferUtil (org.apache.cassandra.utils.ByteBufferUtil)1 Assert (org.junit.Assert)1