Skip to content
This repository has been archived by the owner on Feb 8, 2019. It is now read-only.

GOSSIP-41 Transfer gossip data in bulk #68

Merged
merged 1 commit into from
Sep 3, 2017

Conversation

pxsalehi
Copy link
Contributor

This is the first version I had in mind. The simplest way is to create a bulk message which carries a list of messages. The handler simply unpacks the list of messages and the rest will stay the same. I have failing tests to go through yet. But maybe someone can let me know if this is the way to go or there is a better alternative.

import java.util.List;
import java.util.stream.Collectors;

/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No author comments.

@@ -0,0 +1,27 @@
package org.apache.gossip.model;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All files Requires apache licence header

messages.add(msg);
}

public List<PerNodeDataMessage> getMessages() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent is two spaces. Use our style sheet.

@@ -35,8 +30,8 @@ public static MessageHandler defaultHandler() {
return concurrentHandler(
new TypedMessageHandler(Response.class, new ResponseHandler()),
new TypedMessageHandler(ShutdownMessage.class, new ShutdownMessageHandler()),
new TypedMessageHandler(PerNodeDataMessage.class, new PerNodeDataMessageHandler()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets not remove the old system. Eventually I think the bulk only way makes sense but there is no issue in supporting both in the code and choosing with a switch

message.setExpireAt(innerEntry.getValue().getExpireAt());
message.setKey(innerEntry.getValue().getKey());
message.setNodeId(innerEntry.getValue().getNodeId());
message.setTimestamp(innerEntry.getValue().getTimestamp());
message.setPayload(innerEntry.getValue().getPayload());
message.setReplicable(innerEntry.getValue().getReplicable());
gossipCore.sendOneWay(message, member.getUri());
udpMessage.addMessage(message);
if (udpMessage.getMessages().size() == 100) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be a variable that can be controlled through settings

message.setExpireAt(innerEntry.getValue().getExpireAt());
message.setKey(innerEntry.getValue().getKey());
message.setNodeId(innerEntry.getValue().getNodeId());
message.setTimestamp(innerEntry.getValue().getTimestamp());
message.setPayload(innerEntry.getValue().getPayload());
message.setReplicable(innerEntry.getValue().getReplicable());
gossipCore.sendOneWay(message, member.getUri());
udpMessage.addMessage(message);
if (udpMessage.getMessages().size() == 100) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the same variable to control this.

@pxsalehi pxsalehi force-pushed the GOSSIP_41_bulk branch 2 times, most recently from 1db0a19 to 38e3a12 Compare August 23, 2017 15:15
@pxsalehi
Copy link
Contributor Author

I still have to add tests for bulk transfer. But maybe you can check it out and let me know if there are any other issues.

@pxsalehi
Copy link
Contributor Author

Instead of new tests I have used parameterized tests to run existing tests with bulk transfer activated.

@pxsalehi pxsalehi changed the title [WIP] GOSSIP-41 Transfer gossip data in bulk GOSSIP-41 Transfer gossip data in bulk Aug 27, 2017
Copy link
Contributor

@edwardcapriolo edwardcapriolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I left a comment with minor changes.

return;
}
long startTime = System.currentTimeMillis();
if (gossipSettings.isBulkTransfer()) {
sendSharedDataInBulkInternal(me, member);
} else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use { } even for one line if so your intention is clear.

public final void sendPerNodeData(LocalMember me, LocalMember member){
if (member == null){
return;
}
long startTime = System.currentTimeMillis();
if (gossipSettings.isBulkTransfer()) {
sendPerNodeDataInBulkInternal(me, member);
} else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same deal use { } even for one line if

this.base = base;
this.bulkTransfer = bulkTransfer;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slick. I like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While going through the tests, I noticed the same can be done in TenNodeThreeSeedTest by parameterizing base.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets handle that in a separate ticket.

@pxsalehi
Copy link
Contributor Author

Done!

@pxsalehi pxsalehi closed this Aug 30, 2017
@pxsalehi pxsalehi deleted the GOSSIP_41_bulk branch August 30, 2017 13:56
@pxsalehi pxsalehi restored the GOSSIP_41_bulk branch August 30, 2017 13:57
@pxsalehi pxsalehi reopened this Aug 30, 2017
@asfgit asfgit merged commit 7c457eb into apache:master Sep 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants