[
https://issues.apache.org/jira/browse/CASSANDRA-19412?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ling Mao updated CASSANDRA-19412:
---------------------------------
Description:
Every normal write request will go through this
method({_}*sendToHintedReplicas*{_}). However, the list:backPressureHosts in
the method has never been used functionally. The _*backpressure*_ was
introduced by:
{code:java}
Support optional backpressure strategies at the coordinator
patch by Sergio Bossa; reviewed by Stefania Alborghetti for CASSANDRA-9318
d43b9ce5 Sergio Bossa <[email protected]> on 2016/9/19 at 10:42 AM {code}
{code:java}
public static void sendToHintedEndpoints(final Mutation mutation,
Iterable<InetAddress> targets,
AbstractWriteResponseHandler<IMutation> responseHandler,
String localDataCenter,
Stage stage)
throws OverloadedException
{
int targetsSize = Iterables.size(targets);
// this dc replicas:
Collection<InetAddress> localDc = null;
// extra-datacenter replicas, grouped by dc
Map<String, Collection<InetAddress>> dcGroups = null;
// only need to create a Message for non-local writes
MessageOut<Mutation> message = null;
boolean insertLocal = false;
ArrayList<InetAddress> endpointsToHint = null;
List<InetAddress> backPressureHosts = null;
for (InetAddress destination : targets)
{
checkHintOverload(destination);
if (FailureDetector.instance.isAlive(destination))
{
if (canDoLocalRequest(destination))
{
insertLocal = true;
}
else
{
// belongs on a different server
if (message == null)
message = mutation.createMessage();
String dc =
DatabaseDescriptor.getEndpointSnitch().getDatacenter(destination);
// direct writes to local DC or old Cassandra versions
// (1.1 knows how to forward old-style String message IDs;
updated to int in 2.0)
if (localDataCenter.equals(dc))
{
if (localDc == null)
localDc = new ArrayList<>(targetsSize);
localDc.add(destination);
}
else
{
Collection<InetAddress> messages = (dcGroups != null) ?
dcGroups.get(dc) : null;
if (messages == null)
{
messages = new ArrayList<>(3); // most DCs will
have <= 3 replicas
if (dcGroups == null)
dcGroups = new HashMap<>();
dcGroups.put(dc, messages);
}
messages.add(destination);
}
if (backPressureHosts == null)
backPressureHosts = new ArrayList<>(targetsSize);
backPressureHosts.add(destination);
}
}
else
{
if (shouldHint(destination))
{
if (endpointsToHint == null)
endpointsToHint = new ArrayList<>(targetsSize);
endpointsToHint.add(destination);
}
}
}
if (backPressureHosts != null)
MessagingService.instance().applyBackPressure(backPressureHosts,
responseHandler.currentTimeout());
if (endpointsToHint != null)
submitHint(mutation, endpointsToHint, responseHandler);
if (insertLocal)
performLocally(stage, Optional.of(mutation), mutation::apply,
responseHandler);
if (localDc != null)
{
for (InetAddress destination : localDc)
MessagingService.instance().sendRR(message, destination,
responseHandler, true);
}
if (dcGroups != null)
{
// for each datacenter, send the message to one node to relay the
write to other replicas
for (Collection<InetAddress> dcTargets : dcGroups.values())
sendMessagesToNonlocalDC(message, dcTargets, responseHandler);
}
} {code}
Now the backPressure related codes had been deleted in the codebase, and Here
maybe someone forget to remove the collection:
was:I'll write a PR tonight
> delete useless collection:backPressureHosts in the sendToHintedReplicas to
> improve write performance
> ----------------------------------------------------------------------------------------------------
>
> Key: CASSANDRA-19412
> URL: https://issues.apache.org/jira/browse/CASSANDRA-19412
> Project: Cassandra
> Issue Type: Improvement
> Components: Legacy/Local Write-Read Paths
> Reporter: Ling Mao
> Assignee: Ling Mao
> Priority: Low
>
> Every normal write request will go through this
> method({_}*sendToHintedReplicas*{_}). However, the list:backPressureHosts in
> the method has never been used functionally. The _*backpressure*_ was
> introduced by:
>
> {code:java}
> Support optional backpressure strategies at the coordinator
> patch by Sergio Bossa; reviewed by Stefania Alborghetti for CASSANDRA-9318
> d43b9ce5 Sergio Bossa <[email protected]> on 2016/9/19 at 10:42 AM {code}
>
>
> {code:java}
> public static void sendToHintedEndpoints(final Mutation mutation,
> Iterable<InetAddress> targets,
>
> AbstractWriteResponseHandler<IMutation> responseHandler,
> String localDataCenter,
> Stage stage)
> throws OverloadedException
> {
> int targetsSize = Iterables.size(targets);
> // this dc replicas:
> Collection<InetAddress> localDc = null;
> // extra-datacenter replicas, grouped by dc
> Map<String, Collection<InetAddress>> dcGroups = null;
> // only need to create a Message for non-local writes
> MessageOut<Mutation> message = null;
> boolean insertLocal = false;
> ArrayList<InetAddress> endpointsToHint = null;
> List<InetAddress> backPressureHosts = null;
> for (InetAddress destination : targets)
> {
> checkHintOverload(destination);
> if (FailureDetector.instance.isAlive(destination))
> {
> if (canDoLocalRequest(destination))
> {
> insertLocal = true;
> }
> else
> {
> // belongs on a different server
> if (message == null)
> message = mutation.createMessage();
> String dc =
> DatabaseDescriptor.getEndpointSnitch().getDatacenter(destination);
> // direct writes to local DC or old Cassandra versions
> // (1.1 knows how to forward old-style String message
> IDs; updated to int in 2.0)
> if (localDataCenter.equals(dc))
> {
> if (localDc == null)
> localDc = new ArrayList<>(targetsSize);
> localDc.add(destination);
> }
> else
> {
> Collection<InetAddress> messages = (dcGroups != null)
> ? dcGroups.get(dc) : null;
> if (messages == null)
> {
> messages = new ArrayList<>(3); // most DCs will
> have <= 3 replicas
> if (dcGroups == null)
> dcGroups = new HashMap<>();
> dcGroups.put(dc, messages);
> }
> messages.add(destination);
> }
> if (backPressureHosts == null)
> backPressureHosts = new ArrayList<>(targetsSize);
> backPressureHosts.add(destination);
> }
> }
> else
> {
> if (shouldHint(destination))
> {
> if (endpointsToHint == null)
> endpointsToHint = new ArrayList<>(targetsSize);
> endpointsToHint.add(destination);
> }
> }
> }
> if (backPressureHosts != null)
> MessagingService.instance().applyBackPressure(backPressureHosts,
> responseHandler.currentTimeout());
> if (endpointsToHint != null)
> submitHint(mutation, endpointsToHint, responseHandler);
> if (insertLocal)
> performLocally(stage, Optional.of(mutation), mutation::apply,
> responseHandler);
> if (localDc != null)
> {
> for (InetAddress destination : localDc)
> MessagingService.instance().sendRR(message, destination,
> responseHandler, true);
> }
> if (dcGroups != null)
> {
> // for each datacenter, send the message to one node to relay the
> write to other replicas
> for (Collection<InetAddress> dcTargets : dcGroups.values())
> sendMessagesToNonlocalDC(message, dcTargets, responseHandler);
> }
> } {code}
>
> Now the backPressure related codes had been deleted in the codebase, and Here
> maybe someone forget to remove the collection:
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]