diff options
| author | Paul Buetow <paul@buetow.org> | 2025-06-20 17:26:52 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-06-20 17:26:52 +0300 |
| commit | f6d2a6bbbc37c552accf91a13ccd6ea45ecf8e73 (patch) | |
| tree | b1ec7ce83b348fc76e3f6a21dce6960c457bf765 /src/main/java/core | |
| parent | 5e16f7f37c984d7ee1d1f0484cf0a8154bbb849d (diff) | |
Complete implementation of timestamp event classes
- Add language strings for all timestamp events and demo protocol in VSDefaultPrefs
- Register new timestamp events and protocol in VSRegisteredEvents:
- VSLamportTimestampEvent
- VSVectorTimestampEvent
- VSTimestampMonitorEvent
- VSTimestampTriggeredEvent
- VSTimestampDemoProtocol
- Integrate VSVectorClockMonitor into VSInternalProcess:
- Add vectorClockMonitor field
- Override increaseVectorTime() and updateVectorTime() to trigger monitor
- Clear monitor events on reset
- Add getVectorClockMonitor() accessor
- Add serialization support to VSTimestampTriggeredEvent for persistence
- Fix VSTimestampDemoProtocol to use process's vector clock monitor
- All 132 unit tests pass
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'src/main/java/core')
| -rw-r--r-- | src/main/java/core/VSInternalProcess.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/main/java/core/VSInternalProcess.java b/src/main/java/core/VSInternalProcess.java index 8116471..5442cd1 100644 --- a/src/main/java/core/VSInternalProcess.java +++ b/src/main/java/core/VSInternalProcess.java @@ -6,6 +6,7 @@ import core.time.VSVectorTime; import events.VSAbstractEvent; import events.VSRegisteredEvents; import events.implementations.VSProcessCrashEvent; +import events.implementations.VSVectorClockMonitor; import prefs.VSPrefs; import protocols.VSAbstractProtocol; import simulator.VSLogging; @@ -19,6 +20,9 @@ import utils.VSPriorityQueue; * @author Paul C. Buetow */ public class VSInternalProcess extends VSAbstractProcess { + /** The vector clock monitor for timestamp-triggered events */ + private VSVectorClockMonitor vectorClockMonitor; + /** * Instantiates a new process. * @@ -31,6 +35,7 @@ public class VSInternalProcess extends VSAbstractProcess { VSSimulatorVisualization simulatorVisualization, VSLogging loging) { super(prefs, processNum, simulatorVisualization, loging); + vectorClockMonitor = new VSVectorClockMonitor(this); } /** @@ -116,6 +121,11 @@ public class VSInternalProcess extends VSAbstractProcess { setCurrentColor(getColor("col.process.default")); resetTimeFormats(); + + // Clear any vector clock monitor events + if (vectorClockMonitor != null) { + vectorClockMonitor.clearVectorEvents(); + } } /** @@ -432,4 +442,33 @@ public class VSInternalProcess extends VSAbstractProcess { protected VSAbstractProtocol getProtocolObject_(String protocolClassname) { return getProtocolObject(protocolClassname); } + + /** + * Override to trigger vector clock monitor when vector time is increased + */ + @Override + public synchronized void increaseVectorTime() { + super.increaseVectorTime(); + if (vectorClockMonitor != null) { + vectorClockMonitor.checkVectorEvents(); + } + } + + /** + * Override to trigger vector clock monitor when vector time is updated + */ + @Override + public synchronized void updateVectorTime(VSVectorTime vectorTimeUpdate) { + super.updateVectorTime(vectorTimeUpdate); + if (vectorClockMonitor != null) { + vectorClockMonitor.checkVectorEvents(); + } + } + + /** + * Get the vector clock monitor for adding timestamp events + */ + public VSVectorClockMonitor getVectorClockMonitor() { + return vectorClockMonitor; + } } |
