[
https://issues.apache.org/jira/browse/GOSSIP-75?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16110138#comment-16110138
]
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_r130771912
--- Diff:
gossip-itest/src/test/java/org/apache/gossip/SharedDataLockTest.java ---
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.gossip;
+
+import io.teknek.tunit.TUnit;
+import org.apache.gossip.crdt.GrowOnlyCounter;
+import org.apache.gossip.event.data.UpdateSharedDataEventHandler;
+import org.apache.gossip.manager.GossipManager;
+import org.apache.gossip.manager.GossipManagerBuilder;
+import org.apache.gossip.model.SharedDataMessage;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.platform.runner.JUnitPlatform;
+import org.junit.runner.RunWith;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+@RunWith(JUnitPlatform.class)
+public class SharedDataLockTest extends AbstractIntegrationBase {
+
+ private String receivedKey = "";
+ private Object receivingNodeDataNewValue = "";
+ private Object receivingNodeDataOldValue = "";
+ private String gCounterKey = "gCounter";
+ private Semaphore lock = new Semaphore(0);
+
+ @Test
+ public void sharedDataEventTest()
+ throws InterruptedException, UnknownHostException,
URISyntaxException {
+ GossipSettings settings = new GossipSettings();
+ settings.setPersistRingState(false);
+ settings.setPersistDataState(false);
+ settings.setGossipInterval(1000);
+ String cluster = UUID.randomUUID().toString();
+ int seedNodes = 1;
+ List<Member> startupMembers = new ArrayList<>();
+ for (int i = 1; i < seedNodes + 1; ++i) {
+ URI uri = new URI("udp://" + "127.0.0.1" + ":" + (50000 + i));
+ startupMembers.add(new RemoteMember(cluster, uri, i + ""));
+ }
+ final List<GossipManager> clients = new ArrayList<>();
+ final int clusterMembers = 10;
+ for (int i = 1; i < clusterMembers + 1; ++i) {
+ URI uri = new URI("udp://" + "127.0.0.1" + ":" + (50000 + i));
+ GossipManager gossipService =
GossipManagerBuilder.newBuilder().cluster(cluster).uri(uri)
+ .id(i +
"").gossipMembers(startupMembers).gossipSettings(settings).build();
+ final int nodeId = i;
+ gossipService.registerSharedDataSubscriber((key, oldValue, newValue)
-> {
--- End diff --
This does not look like it is needed
> 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)