You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Exception in thread "main" java.lang.IllegalArgumentException: Class is not registered: io.atomix.cluster.MemberId
Note: To register this class use: kryo.register(io.atomix.cluster.MemberId.class);
at com.esotericsoftware.kryo.Kryo.getRegistration(Kryo.java:503)
at com.esotericsoftware.kryo.util.DefaultClassResolver.writeClass(DefaultClassResolver.java:97)
at com.esotericsoftware.kryo.Kryo.writeClass(Kryo.java:540)
at com.esotericsoftware.kryo.Kryo.writeClassAndObject(Kryo.java:645)
at io.atomix.utils.serializer.Namespace.lambda$null$0(Namespace.java:347)
at com.esotericsoftware.kryo.pool.KryoPoolQueueImpl.run(KryoPoolQueueImpl.java:58)
at io.atomix.utils.serializer.Namespace.lambda$serialize$1(Namespace.java:346)
at io.atomix.utils.serializer.KryoIOPool.run(KryoIOPool.java:45)
at io.atomix.utils.serializer.Namespace.serialize(Namespace.java:345)
at io.atomix.utils.serializer.Namespace.serialize(Namespace.java:334)
at io.atomix.utils.serializer.Serializer$1.encode(Serializer.java:71)
at io.atomix.core.election.impl.DefaultLeaderElectionBuilder.lambda$null$1(DefaultLeaderElectionBuilder.java:44)
at io.atomix.core.election.impl.TranscodingAsyncLeaderElection.run(TranscodingAsyncLeaderElection.java:52)
at io.atomix.core.election.impl.BlockingLeaderElection.run(BlockingLeaderElection.java:49)
at org.turnera.server.cluster.Server3.main(Server3.java:21)
Minimal yet complete reproducer code (or URL to code)
publicclassAotmixServer {
publicstaticCompletableFuture<Atomix> getServer(intport, Collection<Integer> ports) {
Stringserver = "server" + port;
List<String> servers = ports.stream().map(p -> "server" + p).collect(Collectors.toList());
AtomixBuilderbuilder = Atomix.builder();
builder.withMemberId(server).withAddress("127.0.0.1", port)
.withMembershipProvider(newBootstrapDiscoveryProvider(ports.stream()
.map(p -> Node.builder().withId("server" + p)
.withAddress(p).build())
.collect(Collectors.toList())))
.withManagementGroup(RaftPartitionGroup.builder("system")
.withNumPartitions(1).withMembers(servers)
.withDataDirectory(newFile("mngdir", server))
.withStorageLevel(StorageLevel.MEMORY).build())
.addPartitionGroup(RaftPartitionGroup.builder("data")
.withNumPartitions(1).withMembers(servers)
.withDataDirectory(newFile("datadir", server))
.withStorageLevel(StorageLevel.MEMORY).build());
Atomixatomix = builder.build();
atomix.getMembershipService().addListener(event -> System.out.println(event.toString()));
System.out.println("trying to start " + server + " on port " + port + ".");
returnCompletableFuture.supplyAsync(() -> {
atomix.start().join();
returnatomix;
});
}
}
publicclassServer1 {
publicstaticvoidmain(String[] args) {
List< Integer> ports = Arrays.asList(5002, 5003, 5004);
intcur = 5002;
Atomixatomix = AotmixServer.getServer(cur, ports).join();
AtomicValue<String> value = atomix.getAtomicValue("value");
// Get or create a leader electionLeaderElection<MemberId> election = atomix.getLeaderElection("my-election");
// Enter the electionLeadership<MemberId> leadership = election.run(atomix.getMembershipService().getLocalMember().id());
// Check if the current node is the leaderif (leadership.leader().equals(atomix.getMembershipService().getLocalMember().id())) {
System.out.println("I am the leader!");
}
// Listen for changes in leadershipelection.addListener(event -> {
if (event.newLeadership().leader().equals(atomix.getMembershipService().getLocalMember().id())) {
System.out.println("I am the leader!");
}
});
System.out.println("done");
}
}
Environment
Atomix: [3.0.15]
OS: [macOS 10.14.4 ]
JVM [1.8.0_121]
The text was updated successfully, but these errors were encountered:
@santhoshTpixler Thanks, I'm trying with the last version this same fix: but is a required step? I mean, on the doc I haven't found it to be necessary to get the election to work.
no shouldn't be required, it means the default serializer for the leaderelection code is missing MemberId, setting a custom serializer, especially with reg required false is a hacky work-around.
so after further investigation, I believe the correct fix for this, is to add a new "elementType" configuration to io.atomix.core.election.LeaderElectionConfig and io.atomix.core.election.LeaderElectorConfig then register that in DefaultLeaderElectionBuilder and DefaultLeaderElectorBuilder in a serializer override.
kuujo
added
archived
Archived issues from the legacy Java implementation of Atomix
legacy
Issues from the legacy Java implementation of Atomix
labels
Jan 13, 2023
Expected behavior
Run leader election successful
Actual behavior
When run leader election, i got an error
Minimal yet complete reproducer code (or URL to code)
Environment
The text was updated successfully, but these errors were encountered: