@Override public boolean equals(Object o) { if (o == null || !(o instanceof InProgressTx)) { return false; } if (this == o) { return true; } InProgressTx other = (InProgressTx) o; return Objects.equal(visibilityUpperBound, other.getVisibilityUpperBound()) && Objects.equal(expiration, other.getExpiration()) && Objects.equal(type, other.type) && Objects.equal(checkpointWritePointers, other.checkpointWritePointers); }
@Override public boolean equals(Object o) { if (o == null || !(o instanceof InProgressTx)) { return false; } if (this == o) { return true; } InProgressTx other = (InProgressTx) o; return Objects.equal(visibilityUpperBound, other.getVisibilityUpperBound()) && Objects.equal(expiration, other.getExpiration()) && Objects.equal(type, other.type) && Objects.equal(checkpointWritePointers, other.checkpointWritePointers); }
protected void encodeInProgress(BinaryEncoder encoder, Map<Long, TransactionManager.InProgressTx> inProgress) throws IOException { if (!inProgress.isEmpty()) { encoder.writeInt(inProgress.size()); for (Map.Entry<Long, TransactionManager.InProgressTx> entry : inProgress.entrySet()) { encoder.writeLong(entry.getKey()); // tx id encoder.writeLong(entry.getValue().getExpiration()); encoder.writeLong(entry.getValue().getVisibilityUpperBound()); } } encoder.writeInt(0); // zero denotes end of list as per AVRO spec }
new InProgressTx(entry.getValue().getVisibilityUpperBound(), newExpiration, TransactionType.LONG, entry.getValue().getCheckpointWritePointers()); entry.setValue(compatTx); } else if (entry.getValue().getType() == null) { InProgressTx compatTx = new InProgressTx(entry.getValue().getVisibilityUpperBound(), entry.getValue().getExpiration(), TransactionType.SHORT, entry.getValue().getCheckpointWritePointers()); entry.setValue(compatTx);
new InProgressTx(entry.getValue().getVisibilityUpperBound(), newExpiration, TransactionType.LONG, entry.getValue().getCheckpointWritePointers()); entry.setValue(compatTx); } else if (entry.getValue().getType() == null) { InProgressTx compatTx = new InProgressTx(entry.getValue().getVisibilityUpperBound(), entry.getValue().getExpiration(), TransactionType.SHORT, entry.getValue().getCheckpointWritePointers()); entry.setValue(compatTx);
@Override protected void encodeInProgress(BinaryEncoder encoder, Map<Long, TransactionManager.InProgressTx> inProgress) throws IOException { if (!inProgress.isEmpty()) { encoder.writeInt(inProgress.size()); for (Map.Entry<Long, TransactionManager.InProgressTx> entry : inProgress.entrySet()) { encoder.writeLong(entry.getKey()); // tx id encoder.writeLong(entry.getValue().getExpiration()); encoder.writeLong(entry.getValue().getVisibilityUpperBound()); encoder.writeInt(entry.getValue().getType().ordinal()); // write checkpoint tx IDs LongArrayList checkpointPointers = entry.getValue().getCheckpointWritePointers(); if (checkpointPointers != null && !checkpointPointers.isEmpty()) { encoder.writeInt(checkpointPointers.size()); for (int i = 0; i < checkpointPointers.size(); i++) { encoder.writeLong(checkpointPointers.getLong(i)); } } encoder.writeInt(0); } } encoder.writeInt(0); // zero denotes end of list as per AVRO spec }
@Override protected void encodeInProgress(BinaryEncoder encoder, Map<Long, TransactionManager.InProgressTx> inProgress) throws IOException { if (!inProgress.isEmpty()) { encoder.writeInt(inProgress.size()); for (Map.Entry<Long, TransactionManager.InProgressTx> entry : inProgress.entrySet()) { encoder.writeLong(entry.getKey()); // tx id encoder.writeLong(entry.getValue().getExpiration()); encoder.writeLong(entry.getValue().getVisibilityUpperBound()); encoder.writeInt(entry.getValue().getType().ordinal()); // write checkpoint tx IDs LongArrayList checkpointPointers = entry.getValue().getCheckpointWritePointers(); if (checkpointPointers != null && !checkpointPointers.isEmpty()) { encoder.writeInt(checkpointPointers.size()); for (int i = 0; i < checkpointPointers.size(); i++) { encoder.writeLong(checkpointPointers.getLong(i)); } } encoder.writeInt(0); } } encoder.writeInt(0); // zero denotes end of list as per AVRO spec }
@Override protected void encodeInProgress(BinaryEncoder encoder, Map<Long, TransactionManager.InProgressTx> inProgress) throws IOException { if (!inProgress.isEmpty()) { encoder.writeInt(inProgress.size()); for (Map.Entry<Long, TransactionManager.InProgressTx> entry : inProgress.entrySet()) { encoder.writeLong(entry.getKey()); // tx id encoder.writeLong(entry.getValue().getExpiration()); encoder.writeLong(entry.getValue().getVisibilityUpperBound()); encoder.writeInt(entry.getValue().getType().ordinal()); } } encoder.writeInt(0); // zero denotes end of list as per AVRO spec }
@Override protected void encodeInProgress(BinaryEncoder encoder, Map<Long, TransactionManager.InProgressTx> inProgress) throws IOException { if (!inProgress.isEmpty()) { encoder.writeInt(inProgress.size()); for (Map.Entry<Long, TransactionManager.InProgressTx> entry : inProgress.entrySet()) { encoder.writeLong(entry.getKey()); // tx id encoder.writeLong(entry.getValue().getExpiration()); encoder.writeLong(entry.getValue().getVisibilityUpperBound()); encoder.writeInt(entry.getValue().getType().ordinal()); } } encoder.writeInt(0); // zero denotes end of list as per AVRO spec }
protected void encodeInProgress(BinaryEncoder encoder, Map<Long, TransactionManager.InProgressTx> inProgress) throws IOException { if (!inProgress.isEmpty()) { encoder.writeInt(inProgress.size()); for (Map.Entry<Long, TransactionManager.InProgressTx> entry : inProgress.entrySet()) { encoder.writeLong(entry.getKey()); // tx id encoder.writeLong(entry.getValue().getExpiration()); encoder.writeLong(entry.getValue().getVisibilityUpperBound()); } } encoder.writeInt(0); // zero denotes end of list as per AVRO spec }
@Override public long getVisibilityUpperBound() { // the readPointer of the oldest in-progress tx is the oldest in use // todo: potential problem with not moving visibility upper bound for the whole duration of long-running tx Map.Entry<Long, TransactionManager.InProgressTx> firstInProgress = inProgress.firstEntry(); if (firstInProgress == null) { // using readPointer as smallest visible when non txs are there return readPointer; } return firstInProgress.getValue().getVisibilityUpperBound(); }
@Override public long getVisibilityUpperBound() { // the readPointer of the oldest in-progress tx is the oldest in use // todo: potential problem with not moving visibility upper bound for the whole duration of long-running tx Map.Entry<Long, TransactionManager.InProgressTx> firstInProgress = inProgress.firstEntry(); if (firstInProgress == null) { // using readPointer as smallest visible when non txs are there return readPointer; } return firstInProgress.getValue().getVisibilityUpperBound(); }