-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhanced DistributedObjectAdmin to compare for inconsistencies betwee…
…n instances (#426) Co-authored-by: Anselm McClain <[email protected]> Co-authored-by: lbwexler <[email protected]>
- Loading branch information
1 parent
a41282c
commit 4a227d5
Showing
17 changed files
with
449 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
grails-app/controllers/io/xh/hoist/admin/cluster/ClusterObjectsAdminController.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* This file belongs to Hoist, an application development toolkit | ||
* developed by Extremely Heavy Industries (www.xh.io | [email protected]) | ||
* | ||
* Copyright © 2025 Extremely Heavy Industries Inc. | ||
*/ | ||
package io.xh.hoist.admin.cluster | ||
|
||
import io.xh.hoist.BaseController | ||
import io.xh.hoist.security.Access | ||
|
||
@Access(['HOIST_ADMIN_READER']) | ||
class ClusterObjectsAdminController extends BaseController { | ||
def clusterObjectsService | ||
|
||
def getClusterObjectsReport() { | ||
renderJSON(clusterObjectsService.getClusterObjectsReport()) | ||
} | ||
|
||
@Access(['HOIST_ADMIN']) | ||
def clearHibernateCaches() { | ||
def req = parseRequestJSON() | ||
clusterObjectsService.clearHibernateCaches(req.names) | ||
renderJSON([success: true]) | ||
} | ||
|
||
@Access(['HOIST_ADMIN']) | ||
def clearAllHibernateCaches() { | ||
clusterObjectsService.clearHibernateCaches() | ||
renderJSON([success: true]) | ||
} | ||
} |
54 changes: 0 additions & 54 deletions
54
grails-app/controllers/io/xh/hoist/admin/cluster/HzObjectAdminController.groovy
This file was deleted.
Oops, something went wrong.
81 changes: 81 additions & 0 deletions
81
grails-app/services/io/xh/hoist/admin/ClusterObjectsService.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* This file belongs to Hoist, an application development toolkit | ||
* developed by Extremely Heavy Industries (www.xh.io | [email protected]) | ||
* | ||
* Copyright © 2025 Extremely Heavy Industries Inc. | ||
*/ | ||
package io.xh.hoist.admin | ||
|
||
import com.hazelcast.cache.impl.CacheProxy | ||
import com.hazelcast.executor.impl.ExecutorServiceProxy | ||
import io.xh.hoist.AdminStats | ||
import io.xh.hoist.BaseService | ||
import io.xh.hoist.cluster.ClusterRequest | ||
|
||
import static io.xh.hoist.util.Utils.appContext | ||
import static java.lang.System.currentTimeMillis | ||
|
||
class ClusterObjectsService extends BaseService { | ||
def grailsApplication | ||
|
||
ClusterObjectsReport getClusterObjectsReport() { | ||
def startTimestamp = currentTimeMillis(), | ||
info = clusterService | ||
.submitToAllInstances(new ListClusterObjects()) | ||
.collectMany { it.value.value } | ||
|
||
return new ClusterObjectsReport( | ||
info: info, | ||
startTimestamp: startTimestamp, | ||
endTimestamp: currentTimeMillis() | ||
) | ||
} | ||
|
||
/** | ||
* Clear all Hibernate caches, or a specific list of caches by name. | ||
*/ | ||
void clearHibernateCaches(List<String> names = null) { | ||
def caches = clusterService.distributedObjects.findAll {it instanceof CacheProxy} | ||
names ?= caches*.name | ||
names.each { name -> | ||
def obj = caches.find { it.name == name } | ||
if (obj) { | ||
obj.clear() | ||
logInfo('Cleared ' + name) | ||
} else { | ||
logWarn('Cannot find cache', name) | ||
} | ||
} | ||
} | ||
|
||
//-------------------- | ||
// Implementation | ||
//-------------------- | ||
private List<ClusterObjectInfo> listClusterObjects() { | ||
// Services and their AdminStat implementing resources | ||
Map<String, BaseService> svcs = grailsApplication.mainContext.getBeansOfType(BaseService.class, false, false) | ||
def hoistObjs = svcs.collectMany { _, svc -> | ||
[ | ||
new ClusterObjectInfo(name: svc.class.name, type: 'Service', target: svc), | ||
*svc.resources | ||
.findAll { k, v -> v instanceof AdminStats } | ||
.collect { k, v -> new ClusterObjectInfo(name: svc.hzName(k), target: v) } | ||
] | ||
} | ||
|
||
// Hazelcast built-ins | ||
def hzObjs = clusterService | ||
.hzInstance | ||
.distributedObjects | ||
.findAll { !(it instanceof ExecutorServiceProxy) } | ||
.collect { new ClusterObjectInfo(target: new HzAdminStats(it)) } | ||
|
||
return (hzObjs + hoistObjs) as List<ClusterObjectInfo> | ||
} | ||
|
||
static class ListClusterObjects extends ClusterRequest<List<ClusterObjectInfo>> { | ||
List<ClusterObjectInfo> doCall() { | ||
appContext.clusterObjectsService.listClusterObjects() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.