[ https://issues.apache.org/jira/browse/GOSSIP-75?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16088610#comment-16088610 ]
ASF GitHub Bot commented on GOSSIP-75: -------------------------------------- Github user edwardcapriolo commented on a diff in the pull request: https://github.com/apache/incubator-gossip/pull/62#discussion_r127584659 --- Diff: gossip-base/src/main/java/org/apache/gossip/lock/LockManager.java --- @@ -0,0 +1,152 @@ +package org.apache.gossip.lock; + +import org.apache.gossip.Member; +import org.apache.gossip.event.data.UpdateSharedDataEventHandler; +import org.apache.gossip.lock.vote.Vote; +import org.apache.gossip.lock.vote.VoteContext; +import org.apache.gossip.manager.GossipManager; +import org.apache.gossip.model.SharedDataMessage; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Timer; +import java.util.TimerTask; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +public class LockManager { + + private final GossipManager gossipManager; + private final Map<String, VoteContext> voteContextMap; + private final ScheduledExecutorService scheduledExecutorService; + + public LockManager(GossipManager gossipManager) { + this.gossipManager = gossipManager; + this.voteContextMap = new ConcurrentHashMap<>(); + this.gossipManager.registerSharedDataSubscriber((key, oldValue, newValue) -> { + if(newValue != null && newValue instanceof VoteContext){ + VoteContext voteContext = (VoteContext) newValue; + voteContextMap.put(voteContext.getVoteId(),voteContext); + if(gossipManager.getMyself().getId().equals("4")) { --- End diff -- Hardcode here > Voting interface > ---------------- > > Key: GOSSIP-75 > URL: https://issues.apache.org/jira/browse/GOSSIP-75 > Project: Gossip > Issue Type: New Feature > Reporter: Edward Capriolo > > Gossip has CRDT support. This is an important building block to doing higher > level things. The next piece is being able to act on an object when we > receive it. For example lets take the most simple case. I want the cluster to > vote on something such as "who asked for this lock first". Currently we > replicate objects lazily through a thread, what we want to do is on reception > of an object apply some function such that we can modify the object being > received. > The way I want to go about this is voting objects can be injected with a type > like VoteContext > http://stackoverflow.com/questions/27133161/how-to-pass-constructors-parameters-with-jackson > > Users can register Voter implementations. On receiving an object the > interface allows logic to be run. In the case of a Voting each node appends > its vote as the object moves around over time you can poll your local copy > and determine the result of the vote. -- This message was sent by Atlassian JIRA (v6.4.14#64029)