Fixed build
This commit is contained in:
@ -21,10 +21,6 @@ import java.io.IOException;
|
||||
|
||||
public class RunStandardExamples {
|
||||
|
||||
private static boolean WILL_READ = true;
|
||||
|
||||
private static boolean WILL_NOT_READ = false;
|
||||
|
||||
public static void main(String[] args) {
|
||||
if ((args.length < 1) || args[0].equals("-h") || args[0].equals("--help") || args.length < 2) {
|
||||
System.out.print(usage());
|
||||
@ -37,16 +33,18 @@ public class RunStandardExamples {
|
||||
System.out.print(usage());
|
||||
return;
|
||||
}
|
||||
runExaple(example, channel);
|
||||
runExample(example, channel);
|
||||
} catch (Exception e) {
|
||||
System.out.print(usage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void runExaple(int exampleNumber, int channel) throws IOException {
|
||||
String[] args = stanardArgs(channel, new String[4]);
|
||||
private static void runExample(int exampleNumber, int channel) throws IOException {
|
||||
String[] args = standardArgs(channel, new String[4]);
|
||||
boolean WILL_READ = true;
|
||||
if (exampleNumber == 1) {
|
||||
StandAloneNode example = new StandAloneNode(args);
|
||||
boolean WILL_NOT_READ = false;
|
||||
example.exec(WILL_NOT_READ);
|
||||
} else if (exampleNumber == 2) {
|
||||
StandAloneNodeCrdtOrSet example = new StandAloneNodeCrdtOrSet(args);
|
||||
@ -61,7 +59,7 @@ public class RunStandardExamples {
|
||||
}
|
||||
}
|
||||
|
||||
private static String[] stanardArgs(int channel, String[] args) {
|
||||
private static String[] standardArgs(int channel, String[] args) {
|
||||
// see README.md for examples
|
||||
args[0] = "udp://localhost:1000" + channel;
|
||||
args[1] = "" + channel;
|
||||
@ -71,7 +69,7 @@ public class RunStandardExamples {
|
||||
}
|
||||
|
||||
private static String[] extendedArgs(int channel, String[] args) {
|
||||
args = stanardArgs(channel, args);
|
||||
standardArgs(channel, args);
|
||||
// see README.md for examples
|
||||
if (channel == 0) {
|
||||
args[4] = "1";
|
||||
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.gossip.GossipSettings;
|
||||
@ -37,7 +38,7 @@ public class StandAloneDatacenterAndRack extends StandAloneExampleBase {
|
||||
initGossipManager(args);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException, IOException {
|
||||
public static void main(String[] args) throws IOException {
|
||||
StandAloneDatacenterAndRack example = new StandAloneDatacenterAndRack(args);
|
||||
boolean willRead = true;
|
||||
example.exec(willRead);
|
||||
@ -61,8 +62,7 @@ public class StandAloneDatacenterAndRack extends StandAloneExampleBase {
|
||||
.uri(URI.create(args[0]))
|
||||
.id(args[1])
|
||||
.gossipSettings(s)
|
||||
.gossipMembers(
|
||||
Arrays.asList(new RemoteMember("mycluster", URI.create(args[2]), args[3])))
|
||||
.gossipMembers(List.of(new RemoteMember("mycluster", URI.create(args[2]), args[3])))
|
||||
.properties(props)
|
||||
.build();
|
||||
manager.init();
|
||||
|
@ -23,7 +23,6 @@ import java.io.InputStreamReader;
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.gossip.GossipSettings;
|
||||
import org.apache.gossip.LocalMember;
|
||||
import org.apache.gossip.RemoteMember;
|
||||
|
@ -22,20 +22,17 @@ import org.apache.gossip.manager.GossipManager;
|
||||
|
||||
public class StandAloneNode extends StandAloneExampleBase {
|
||||
|
||||
private static boolean WILL_READ = false;
|
||||
|
||||
StandAloneNode(String[] args) {
|
||||
args = super.checkArgsForClearFlag(args);
|
||||
super.initGossipManager(args);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException, IOException {
|
||||
public static void main(String[] args) throws IOException {
|
||||
StandAloneNode example = new StandAloneNode(args);
|
||||
boolean WILL_READ = false;
|
||||
example.exec(WILL_READ);
|
||||
}
|
||||
|
||||
@Override
|
||||
void printValues(GossipManager gossipService) {
|
||||
}
|
||||
|
||||
void printValues(GossipManager gossipService) {}
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
package org.apache.gossip.examples;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.gossip.crdt.GrowOnlyCounter;
|
||||
import org.apache.gossip.crdt.OrSet;
|
||||
import org.apache.gossip.manager.GossipManager;
|
||||
@ -35,7 +34,7 @@ public class StandAloneNodeCrdtOrSet extends StandAloneExampleBase {
|
||||
super.initGossipManager(args);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException, IOException {
|
||||
public static void main(String[] args) throws IOException {
|
||||
StandAloneNodeCrdtOrSet example = new StandAloneNodeCrdtOrSet(args);
|
||||
boolean willRead = true;
|
||||
example.exec(willRead);
|
||||
@ -53,7 +52,7 @@ public class StandAloneNodeCrdtOrSet extends StandAloneExampleBase {
|
||||
|
||||
private static void gcount(String val, GossipManager gossipManager) {
|
||||
GrowOnlyCounter c = (GrowOnlyCounter) gossipManager.findCrdt(INDEX_KEY_FOR_COUNTER);
|
||||
Long l = Long.valueOf(val);
|
||||
long l = Long.parseLong(val);
|
||||
if (c == null) {
|
||||
c = new GrowOnlyCounter(new GrowOnlyCounter.Builder(gossipManager).increment((l)));
|
||||
} else {
|
||||
@ -73,7 +72,7 @@ public class StandAloneNodeCrdtOrSet extends StandAloneExampleBase {
|
||||
SharedDataMessage m = new SharedDataMessage();
|
||||
m.setExpireAt(Long.MAX_VALUE);
|
||||
m.setKey(INDEX_KEY_FOR_SET);
|
||||
m.setPayload(new OrSet<String>(s, new OrSet.Builder<String>().remove(val)));
|
||||
m.setPayload(new OrSet<>(s, new OrSet.Builder<String>().remove(val)));
|
||||
m.setTimestamp(System.currentTimeMillis());
|
||||
gossipService.merge(m);
|
||||
}
|
||||
@ -82,7 +81,7 @@ public class StandAloneNodeCrdtOrSet extends StandAloneExampleBase {
|
||||
SharedDataMessage m = new SharedDataMessage();
|
||||
m.setExpireAt(Long.MAX_VALUE);
|
||||
m.setKey(INDEX_KEY_FOR_SET);
|
||||
m.setPayload(new OrSet<String>(val));
|
||||
m.setPayload(new OrSet<>(val));
|
||||
m.setTimestamp(System.currentTimeMillis());
|
||||
gossipService.merge(m);
|
||||
}
|
||||
@ -118,7 +117,7 @@ public class StandAloneNodeCrdtOrSet extends StandAloneExampleBase {
|
||||
valid = false;
|
||||
}
|
||||
} else if (op == 'l') {
|
||||
if ((val == INDEX_KEY_FOR_SET) || (val == INDEX_KEY_FOR_COUNTER)) {
|
||||
if ((val.equals(INDEX_KEY_FOR_SET)) || (val.equals(INDEX_KEY_FOR_COUNTER))) {
|
||||
listen(val, getGossipManager());
|
||||
} else {
|
||||
valid = false;
|
||||
|
@ -18,7 +18,6 @@
|
||||
package org.apache.gossip.examples;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.gossip.crdt.PNCounter;
|
||||
import org.apache.gossip.manager.GossipManager;
|
||||
import org.apache.gossip.model.SharedDataMessage;
|
||||
@ -30,7 +29,7 @@ public class StandAlonePNCounter extends StandAloneExampleBase {
|
||||
super.initGossipManager(args);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException, IOException {
|
||||
public static void main(String[] args) throws IOException {
|
||||
StandAlonePNCounter example = new StandAlonePNCounter(args);
|
||||
boolean willRead = true;
|
||||
example.exec(willRead);
|
||||
@ -61,7 +60,7 @@ public class StandAlonePNCounter extends StandAloneExampleBase {
|
||||
if (valid) {
|
||||
if (op == 'i') {
|
||||
increment(l, getGossipManager());
|
||||
} else if (op == 'd') {
|
||||
} else {
|
||||
decrement(l, getGossipManager());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user