Skip to content

Commit 4f2da75

Browse files
committed
chore: override state transitions into topic
1 parent 991fa35 commit 4f2da75

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/main/java/com/aws/greengrass/config/Topic.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ private Topic overrideValue(Object nv) {
128128
return withNewerValue(this.modtime, nv);
129129
}
130130

131+
private Topic overrideValue(Object nv, long proposedModTime) {
132+
return withNewerValue(proposedModTime, nv);
133+
}
134+
131135
/**
132136
* Update the value in place without changing the timestamp.
133137
* @param nv new value
@@ -141,6 +145,14 @@ public Topic overrideValue(Number nv) {
141145
return overrideValue((Object) nv);
142146
}
143147

148+
public Topic overrideValueWithCurrentTimestamp(String nv) {
149+
return overrideValue(nv, System.currentTimeMillis());
150+
}
151+
152+
public Topic overrideValueWithCurrentTimestamp(Number nv) {
153+
return overrideValue(nv, System.currentTimeMillis());
154+
}
155+
144156
private Topic withValue(Object nv) {
145157
return withNewerValue(System.currentTimeMillis(), nv);
146158
}

src/main/java/com/aws/greengrass/lifecyclemanager/Lifecycle.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,9 @@ void setState(State current, StateTransitionEvent stateTransitionEvent) {
441441
// Sync on State.class to make sure the order of setValue and globalNotifyStateChanged
442442
// are consistent across different services.
443443
try (LockScope ls = LockScope.lock(globalLock)) {
444-
stateTopic.withValue(newState.ordinal());
445-
statusCodeTopic.withValue(stateTransitionEvent.getStatusCode().name());
446-
statusReasonTopic.withValue(stateTransitionEvent.getStatusReason());
444+
stateTopic.overrideValueWithCurrentTimestamp(newState.ordinal());
445+
statusCodeTopic.overrideValueWithCurrentTimestamp(stateTransitionEvent.getStatusCode().name());
446+
statusReasonTopic.overrideValueWithCurrentTimestamp(stateTransitionEvent.getStatusReason());
447447
greengrassService.getContext().globalNotifyStateChanged(greengrassService, current, newState);
448448
}
449449
}

0 commit comments

Comments
 (0)