[
https://issues.apache.org/jira/browse/GOSSIP-63?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15901232#comment-15901232
]
ASF GitHub Bot commented on GOSSIP-63:
--------------------------------------
Github user edwardcapriolo commented on a diff in the pull request:
https://github.com/apache/incubator-gossip/pull/41#discussion_r104914632
--- Diff: src/main/java/org/apache/gossip/crdt/GrowOnlyCounter.java ---
@@ -0,0 +1,94 @@
+package org.apache.gossip.crdt;
+
+
+import java.lang.annotation.ElementType;
+import java.util.HashMap;
+import java.util.Map;
+
+public class GrowOnlyCounter implements CrdtCounter<Long, GrowOnlyCounter>
{
+
+
+ private final Map<String, Long> counters = new HashMap<>();
+ private final String myID;
+
+ public GrowOnlyCounter(String myID) {
+ this.myID = myID;
+ counters.putIfAbsent(myID, 0L);
+ }
+
+ private GrowOnlyCounter(String myID, Long count) {
+ this.myID = myID;
+ counters.putIfAbsent(myID, count);
+ }
+
+ private GrowOnlyCounter(String myID, Map<String, Long> counters) {
--- End diff --
I do not think we want users to manage the myId themselves. I think the
interface we should provide is a builder like OrSet
public GrowOnlyCounter(GrowOnlyCounter g, new
GrowOnlyBuilder().setGosipManager(this).increment(1).decrement(3) ){ }
With reference to GossipManager you can call
gossipManager.getMyself().getId() to use as the id
> Implement Crdt G-Counter
> ------------------------
>
> Key: GOSSIP-63
> URL: https://issues.apache.org/jira/browse/GOSSIP-63
> Project: Gossip
> Issue Type: New Feature
> Reporter: Edward Capriolo
>
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)