use of org.apache.cassandra.locator.InetAddressAndPort in project cassandra by apache.
the class CoordinatorSession method finalizePropose.
public synchronized Future<Void> finalizePropose() {
Preconditions.checkArgument(allStates(State.REPAIRING));
logger.info("Proposing finalization of repair session {}", sessionID);
Message<RepairMessage> message = Message.out(Verb.FINALIZE_PROPOSE_MSG, new FinalizePropose(sessionID));
for (final InetAddressAndPort participant : participants) {
sendMessage(participant, message);
}
return finalizeProposeFuture;
}
use of org.apache.cassandra.locator.InetAddressAndPort in project cassandra by apache.
the class CoordinatorSession method prepare.
public Future<Void> prepare() {
Preconditions.checkArgument(allStates(State.PREPARING));
logger.info("Beginning prepare phase of incremental repair session {}", sessionID);
Message<RepairMessage> message = Message.out(Verb.PREPARE_CONSISTENT_REQ, new PrepareConsistentRequest(sessionID, coordinator, participants));
for (final InetAddressAndPort participant : participants) {
sendMessage(participant, message);
}
return prepareFuture;
}
use of org.apache.cassandra.locator.InetAddressAndPort in project cassandra by apache.
the class GossipHelper method changeGossipState.
/**
* Changes gossip state of the `peer` on `target`
*/
public static void changeGossipState(IInvokableInstance target, IInstance peer, List<VersionedApplicationState> newState) {
InetSocketAddress addr = peer.broadcastAddress();
UUID hostId = peer.config().hostId();
int netVersion = peer.getMessagingVersion();
target.runOnInstance(() -> {
InetAddressAndPort endpoint = toCassandraInetAddressAndPort(addr);
StorageService storageService = StorageService.instance;
Gossiper.runInGossipStageBlocking(() -> {
EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
if (state == null) {
Gossiper.instance.initializeNodeUnsafe(endpoint, hostId, netVersion, 1);
state = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
if (state.isAlive() && !Gossiper.instance.isDeadState(state))
Gossiper.instance.realMarkAlive(endpoint, state);
}
for (VersionedApplicationState value : newState) {
ApplicationState as = toApplicationState(value);
VersionedValue vv = toVersionedValue(value);
state.addApplicationState(as, vv);
storageService.onChange(endpoint, as, vv);
}
});
});
}
use of org.apache.cassandra.locator.InetAddressAndPort in project cassandra by apache.
the class MessageFiltersTest method outboundBeforeInbound.
@Test
public void outboundBeforeInbound() throws Throwable {
try (Cluster cluster = Cluster.create(2)) {
InetAddressAndPort other = InetAddressAndPort.getByAddressOverrideDefaults(cluster.get(2).broadcastAddress().getAddress(), cluster.get(2).broadcastAddress().getPort());
CountDownLatch waitForIt = new CountDownLatch(1);
Set<Integer> outboundMessagesSeen = new HashSet<>();
Set<Integer> inboundMessagesSeen = new HashSet<>();
AtomicBoolean outboundAfterInbound = new AtomicBoolean(false);
cluster.filters().outbound().verbs(Verb.ECHO_REQ.id, Verb.ECHO_RSP.id).messagesMatching((from, to, msg) -> {
outboundMessagesSeen.add(msg.verb());
if (inboundMessagesSeen.contains(msg.verb()))
outboundAfterInbound.set(true);
return false;
}).drop();
cluster.filters().inbound().verbs(Verb.ECHO_REQ.id, Verb.ECHO_RSP.id).messagesMatching((from, to, msg) -> {
inboundMessagesSeen.add(msg.verb());
return false;
}).drop();
cluster.filters().inbound().verbs(Verb.ECHO_RSP.id).messagesMatching((from, to, msg) -> {
waitForIt.countDown();
return false;
}).drop();
cluster.get(1).runOnInstance(() -> {
MessagingService.instance().send(Message.out(Verb.ECHO_REQ, NoPayload.noPayload), other);
});
waitForIt.await();
Assert.assertEquals(outboundMessagesSeen, inboundMessagesSeen);
// since both are equal, only need to confirm the size of one
Assert.assertEquals(2, outboundMessagesSeen.size());
Assert.assertFalse("outbound message saw after inbound", outboundAfterInbound.get());
}
}
use of org.apache.cassandra.locator.InetAddressAndPort in project cassandra by apache.
the class DescribeStatementTest method testDescribeCluster.
@Test
public void testDescribeCluster() throws Throwable {
for (String describeKeyword : new String[] { "DESCRIBE", "DESC" }) {
assertRowsNet(executeDescribeNet(describeKeyword + " CLUSTER"), row("Test Cluster", "ByteOrderedPartitioner", DatabaseDescriptor.getEndpointSnitch().getClass().getName()));
assertRowsNet(executeDescribeNet("system_virtual_schema", describeKeyword + " CLUSTER"), row("Test Cluster", "ByteOrderedPartitioner", DatabaseDescriptor.getEndpointSnitch().getClass().getName()));
}
TokenMetadata tokenMetadata = StorageService.instance.getTokenMetadata();
Token token = tokenMetadata.sortedTokens().get(0);
InetAddressAndPort addressAndPort = tokenMetadata.getAllEndpoints().iterator().next();
assertRowsNet(executeDescribeNet(KEYSPACE, "DESCRIBE CLUSTER"), row("Test Cluster", "ByteOrderedPartitioner", DatabaseDescriptor.getEndpointSnitch().getClass().getName(), ImmutableMap.of(token.toString(), ImmutableList.of(addressAndPort.toString()))));
}
Aggregations