4 import java.util.HashSet;
7 import java.util.ArrayList;
10 class ArbitrationRound {
12 public static final int MAX_PARTS = 10;
14 Set<Abort> abortsBefore = null;
15 List<Entry> parts = null;
18 boolean didSendPart = false;
19 boolean didGenerateParts = false;
21 public ArbitrationRound(Commit _commit, Set<Abort> _abortsBefore) {
23 parts = new ArrayList<Entry>();
26 abortsBefore = _abortsBefore;
30 commit.createCommitParts();
31 currentSize += commit.getNumberOfParts();
34 currentSize += abortsBefore.size();
37 public void generateParts() {
38 if (didGenerateParts) {
41 parts = new ArrayList<Entry>(abortsBefore);
43 parts.addAll(commit.getParts().values());
48 public List<Entry> getParts() {
52 public void removeParts(List<Entry> removeParts) {
53 parts.removeAll(removeParts);
57 public boolean isDoneSending() {
58 if ((commit == null) && abortsBefore.isEmpty()) {
62 return parts.isEmpty();
65 public Commit getCommit() {
69 public void setCommit(Commit _commit) {
71 currentSize -= commit.getNumberOfParts();
76 currentSize += commit.getNumberOfParts();
80 public void addAbort(Abort abort) {
81 abortsBefore.add(abort);
85 public void addAborts(Set<Abort> aborts) {
86 abortsBefore.addAll(aborts);
87 currentSize += aborts.size();
91 public Set<Abort> getAborts() {
95 public int getAbortsCount() {
96 return abortsBefore.size();
99 public int getCurrentSize() {
103 public boolean isFull() {
104 return currentSize >= MAX_PARTS;
107 public boolean didSendPart() {