+ this.transactionId = requireNonNull(transactionId, "transactionID can't be null");
+ }
+
+ public boolean isReady() {
+ return ready;
+ }
+
+ public void setReady(Optional<SortedSet<String>> possibleParticipatingShardNames) {
+ this.ready = true;
+ this.participatingShardNames = requireNonNull(possibleParticipatingShardNames).orElse(null);
+ Preconditions.checkArgument(this.participatingShardNames == null || this.participatingShardNames.size() > 1);
+ }
+
+ public void setReady() {
+ setReady(Optional.empty());
+ }
+
+ public Optional<SortedSet<String>> getParticipatingShardNames() {
+ return Optional.ofNullable(participatingShardNames);
+ }
+
+ public boolean isDoCommitOnReady() {
+ return doCommitOnReady;
+ }
+
+ public void setDoCommitOnReady(boolean doCommitOnReady) {
+ this.doCommitOnReady = doCommitOnReady;
+ }
+
+ public int getTotalMessagesSent() {
+ return totalMessagesSent;
+ }
+
+ public void setTotalMessagesSent(int totalMessagesSent) {
+ this.totalMessagesSent = totalMessagesSent;
+ }
+
+ public TransactionIdentifier getTransactionId() {
+ return transactionId;
+ }
+
+ @Override
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ transactionId = TransactionIdentifier.readFrom(in);
+ ready = in.readBoolean();
+ totalMessagesSent = in.readInt();
+ doCommitOnReady = in.readBoolean();
+
+ if (getVersion() >= DataStoreVersions.FLUORINE_VERSION) {
+ final int count = in.readInt();
+ if (count != 0) {
+ SortedSet<String> shardNames = new TreeSet<>();
+ for (int i = 0; i < count; i++) {
+ shardNames.add((String) in.readObject());
+ }
+
+ participatingShardNames = shardNames;
+ }
+ }
+ }
+
+ @Override
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ transactionId.writeTo(out);
+ out.writeBoolean(ready);
+ out.writeInt(totalMessagesSent);
+ out.writeBoolean(doCommitOnReady);
+
+ if (getVersion() >= DataStoreVersions.FLUORINE_VERSION) {
+ if (participatingShardNames != null) {
+ out.writeInt(participatingShardNames.size());
+ for (String shardName: participatingShardNames) {
+ out.writeObject(shardName);
+ }
+ } else {
+ out.writeInt(0);
+ }
+ }