Skip to content

Commit c91693c

Browse files
committed
Merge branch 'develop' into grails7
# Conflicts: # CHANGELOG.md
2 parents 95ce970 + cd13750 commit c91693c

File tree

3 files changed

+33
-17
lines changed

3 files changed

+33
-17
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ part of the Apache Foundation. The main required changes to applications are th
2121
See the grails documentation at https://docs.grails.org/7.0.0-RC2/guide/upgrading.html#upgrading60x
2222
for more information.
2323

24+
### 🐞 Bug Fixes
25+
* Restore display of Timers in Service AdminStats.
26+
2427

2528
## 33.0.0 - 2025-09-26
2629

grails-app/services/io/xh/hoist/admin/MemoryMonitoringService.groovy

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import static io.xh.hoist.json.JSONParser.parseObject
2020
import static io.xh.hoist.util.DateTimeUtils.MINUTES
2121
import static io.xh.hoist.util.DateTimeUtils.intervalElapsed
2222
import static io.xh.hoist.util.Utils.getAppEnvironment
23+
import static io.xh.hoist.util.Utils.getIsLocalDevelopment
2324
import static io.xh.hoist.util.Utils.isProduction
2425
import static io.xh.hoist.cluster.ClusterService.startupTime
2526
import static io.xh.hoist.util.DateTimeUtils.HOURS
@@ -39,7 +40,7 @@ class MemoryMonitoringService extends BaseService {
3940
private Map<Long, Map> _snapshots = new ConcurrentHashMap()
4041
private Date _lastInfoLogged
4142
private final String blobOwner = 'xhMemoryMonitoringService'
42-
private final static String blobType = isProduction ? 'xhMemorySnapshots' : "xhMemorySnapshots_$appEnvironment"
43+
private final static String blobType = isProduction ? 'xhMemorySnapshots' : "xhMemorySnapshots_$appEnvironment"
4344

4445
void init() {
4546
createTimer(
@@ -111,7 +112,7 @@ class MemoryMonitoringService extends BaseService {
111112
logDebug(newSnap)
112113
}
113114

114-
if (config.preservePastInstances) persistSnapshots()
115+
if (preservePastInstances) persistSnapshots()
115116

116117
return newSnap
117118
}
@@ -132,7 +133,8 @@ class MemoryMonitoringService extends BaseService {
132133
* Get list of past instances for which snapshots are available.
133134
*/
134135
List<Map> availablePastInstances() {
135-
if (!config.preservePastInstances) return []
136+
if (!preservePastInstances) return []
137+
136138
jsonBlobService
137139
.list(blobType, blobOwner)
138140
.findAll { !clusterService.isMember(it.name) }
@@ -200,14 +202,6 @@ class MemoryMonitoringService extends BaseService {
200202
]
201203
}
202204

203-
private Map getConfig() {
204-
return configService.getMap('xhMemoryMonitoringConfig')
205-
}
206-
207-
private double roundTo2DP(v) {
208-
return Math.round(v * 100) / 100
209-
}
210-
211205
private void persistSnapshots() {
212206
try {
213207
jsonBlobService.createOrUpdate(
@@ -224,8 +218,7 @@ class MemoryMonitoringService extends BaseService {
224218
@Transactional
225219
private cullPersisted() {
226220
def all = jsonBlobService.list(blobType, blobOwner).sort { it.lastUpdated },
227-
maxKeep = config.maxPastInstances != null ? Math.max(config.maxPastInstances, 0) : 5,
228-
toDelete = all.dropRight(maxKeep)
221+
toDelete = all.dropRight(maxPastInstances)
229222

230223
if (toDelete) {
231224
withInfo(['Deleting memory snapshots', [count: toDelete.size()]]) {
@@ -234,6 +227,22 @@ class MemoryMonitoringService extends BaseService {
234227
}
235228
}
236229

230+
private Map getConfig() {
231+
return configService.getMap('xhMemoryMonitoringConfig')
232+
}
233+
234+
private boolean getPreservePastInstances() {
235+
return config.preservePastInstances && !getIsLocalDevelopment()
236+
}
237+
238+
private int getMaxPastInstances() {
239+
return config.maxPastInstances != null ? Math.max(config.maxPastInstances as int, 0) : 5
240+
}
241+
242+
private double roundTo2DP(v) {
243+
return Math.round(v * 100) / 100
244+
}
245+
237246
void clearCaches() {
238247
_snapshots.clear()
239248
super.clearCaches()

src/main/groovy/io/xh/hoist/util/Timer.groovy

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ package io.xh.hoist.util
1010
import com.hazelcast.replicatedmap.ReplicatedMap
1111
import groovy.transform.NamedParam
1212
import groovy.transform.NamedVariant
13+
import io.xh.hoist.AdminStats
1314
import io.xh.hoist.cluster.ClusterService
1415
import io.xh.hoist.log.LogSupport
1516
import org.slf4j.Logger
@@ -45,7 +46,7 @@ import static org.slf4j.LoggerFactory.getLogger
4546
* A common pattern would be to have the primary instance run a Timer-based job to load data into
4647
* a cache, with the cache then replicated across the cluster.
4748
*/
48-
class Timer implements LogSupport {
49+
class Timer implements LogSupport, AdminStats {
4950

5051
private static Long CONFIG_INTERVAL = 15 * SECONDS
5152
private static boolean shutdownInProgress = false
@@ -224,16 +225,19 @@ class Timer implements LogSupport {
224225
Map getAdminStats() {
225226
[
226227
name : name,
227-
type : 'Timer' + (primaryOnly ? ' (primary only)' : ''),
228+
type : 'Timer',
229+
primaryOnly: primaryOnly,
228230
intervalMs: intervalMs,
229231
isRunning : isRunning,
230232
startTime : isRunning ? _lastRunStarted : null,
231233
last : _lastRunStats
232234
].findAll { it.value != null }
233235
}
234236

235-
236-
//------------------------
237+
List<String> getComparableAdminStats() {
238+
return []
239+
}
240+
//------------------------
237241
// Implementation
238242
//------------------------
239243
private void doRun() {

0 commit comments

Comments
 (0)