Skip to content

Instantly share code, notes, and snippets.

@CorneAussems
Created January 24, 2023 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CorneAussems/78eeba61181fff321078143fe4581aca to your computer and use it in GitHub Desktop.
Save CorneAussems/78eeba61181fff321078143fe4581aca to your computer and use it in GitHub Desktop.
Liferay Groovy Verify if Master
#https://liferay.dev/blogs/-/blogs/how-to-diagnose-and-recover-liferay-cluster
import com.liferay.portal.kernel.cache.MultiVMPool;
import com.liferay.registry.RegistryUtil;
import com.liferay.registry.Registry;
import com.liferay.portal.kernel.cache.PortalCache;
import com.liferay.registry.ServiceReference;
import com.liferay.portal.kernel.cluster.ClusterExecutorUtil;
import com.liferay.portal.kernel.cluster.ClusterMasterExecutorUtil;
private MultiVMPool getMultiVMPool() {
Registry registry = RegistryUtil.getRegistry();
ServiceReference serviceReference = registry.getServiceReference(MultiVMPool.class);
return registry.getService(serviceReference);
}
out.println("=== Execution in: " + ClusterExecutorUtil.getLocalClusterNode());
out.println("=== isMaster: "+ ClusterMasterExecutorUtil.isMaster());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment