Package protocols.apps.canvas
Class PaintOp
java.lang.Object
protocols.apps.canvas.PaintOp
A single paint operation: "cell (
x,y) becomes colour
argb". This is the atomic unit the canvas disseminates by gossip and
the unit it stores per cell.
Last-writer-wins (why the canvas converges)
Each op carries atimestamp (the painter's wall clock at paint time)
and the painter's originId. A cell keeps whichever op is the
winner under the total order in isNewerThan(protocols.apps.canvas.PaintOp): higher
timestamp first, ties broken by originId then opId. Because
that order is total and deterministic, any two nodes that have applied the
same set of ops hold the identical winner in every cell —
independent of the order the gossip waves delivered them. Convergence is
therefore a property of dissemination completeness alone, which is exactly
what the experiments harness measures.
opId is a globally-unique identifier for the op, assigned once at
the origin. It is the final tie-breaker, and the stable key the telemetry
uses to correlate "broadcast on node A" with "delivered on node B".
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetArgb()getOpId()longintgetX()intgetY()booleanisNewerThan(PaintOp other) Total, deterministic last-writer-wins order: this op beatsotheriff it has a strictly higher timestamp, or an equal timestamp and a greateroriginId, or equal on both and a greateropId.static PaintOpRead one op previously written bywriteTo(java.io.DataOutputStream).toString()voidwriteTo(DataOutputStream out) Append this op toout(seereadFrom(java.io.DataInputStream)for the inverse).
-
Constructor Details
-
PaintOp
-
-
Method Details
-
getX
public int getX() -
getY
public int getY() -
getArgb
public int getArgb() -
getTimestamp
public long getTimestamp() -
getOriginId
-
getOpId
-
isNewerThan
Total, deterministic last-writer-wins order: this op beatsotheriff it has a strictly higher timestamp, or an equal timestamp and a greateroriginId, or equal on both and a greateropId.othermay benull(an empty cell), which this always wins. -
writeTo
Append this op toout(seereadFrom(java.io.DataInputStream)for the inverse).- Throws:
IOException
-
readFrom
Read one op previously written bywriteTo(java.io.DataOutputStream).- Throws:
IOException
-
toString
-