Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private CompletableFuture<Result<Long>> connectToSession(Stream stream, long ses
}
}, executor);

// and send session start message with id of previos session (or zero if it's first connect)
// and send session start message with id of previous session (or zero if it's first connect)
return stream.sendSessionStart(sessionID, nodePath, connectTimeout, protectionKey);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package tech.ydb.coordination.recipes.election;

import java.util.Arrays;
import java.util.Objects;

public class ElectionParticipant {
private final long sessionId;
private final byte[] data;
private final boolean isLeader;

public ElectionParticipant(long id, byte[] data, boolean isLeader) {
this.sessionId = id;
this.data = data;
this.isLeader = isLeader;
}

public long getSessionId() {
return sessionId;
}

public byte[] getData() {
return data;
}

public boolean isLeader() {
return isLeader;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ElectionParticipant that = (ElectionParticipant) o;
return sessionId == that.sessionId && isLeader == that.isLeader &&
Objects.deepEquals(data, that.data);
}

@Override
public int hashCode() {
return Objects.hash(sessionId, Arrays.hashCode(data), isLeader);
}

@Override
public String toString() {
return "ElectionParticipant{" +
"sessionId=" + sessionId +
", data=" + Arrays.toString(data) +
", isLeader=" + isLeader +
'}';
}
}
Loading
Loading