-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
113 additions
and
35 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
cluster2/src/main/java/io/scalecube/cluster2/payload/PayloadInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package io.scalecube.cluster2.payload; | ||
|
||
import java.util.StringJoiner; | ||
import java.util.UUID; | ||
|
||
public class PayloadInfo { | ||
|
||
private final UUID memberId; | ||
private final long position; | ||
private final int length; | ||
private int appendOffset; | ||
|
||
public PayloadInfo(UUID memberId, long position, int length, int appendOffset) { | ||
this.memberId = memberId; | ||
this.position = position; | ||
this.length = length; | ||
this.appendOffset = appendOffset; | ||
} | ||
|
||
public UUID memberId() { | ||
return memberId; | ||
} | ||
|
||
public long position() { | ||
return position; | ||
} | ||
|
||
public int length() { | ||
return length; | ||
} | ||
|
||
public int appendOffset() { | ||
return appendOffset; | ||
} | ||
|
||
public PayloadInfo appendOffset(int appendOffset) { | ||
this.appendOffset = appendOffset; | ||
return this; | ||
} | ||
|
||
public long appendPosition() { | ||
return position + appendOffset; | ||
} | ||
|
||
public boolean isCompleted() { | ||
return appendOffset == length; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new StringJoiner(", ", PayloadInfo.class.getSimpleName() + "[", "]") | ||
.add("memberId=" + memberId) | ||
.add("initialPosition=" + position) | ||
.add("length=" + length) | ||
.add("proceedingOffset=" + appendOffset) | ||
.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters