DEVCON 2026    |    2-5 November 2026 – QEII Centre – London, UK    |    Register now! 

Blogs

How to diagnose and recover Liferay cluster

Mariano Alvaro
Mariano Alvaro
15 Minuutin Luku
Odottamaton virhe tapahtui.
Sivun kommentit

A 7.4 MultiVMPool version import com.liferay.portal.kernel.cache.MultiVMPool; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; import com.liferay.portal.kernel.module.util.SystemBundleUtil; import com.liferay.portal.kernel.cache.PortalCache; import com.liferay.portal.kernel.util.PortalUtil; 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);

    BundleContext bundleContext = SystemBundleUtil.getBundleContext();     ServiceReference serviceReference = bundleContext.getServiceReference(MultiVMPool.class.name)     return bundleContext.getService(serviceReference) }

try {     // Get local cluster node information     String localClusterNode = ClusterExecutorUtil.getLocalClusterNode();     boolean isMaster = ClusterMasterExecutorUtil.isMaster();          // Check if clustering information is available     if (localClusterNode != null) {         println("=== Execution in: " + localClusterNode);     } else {         println("=== Clustering information is not available.");     }

    println("=== isMaster: " + isMaster);

    MultiVMPool multiVMPool = getMultiVMPool();     if (multiVMPool != null) {         now = new Date()         println(now)         PortalCache<String, String> portalCache1 = multiVMPool.getPortalCache("CACHE-TEST-1");         println("=== Value for testKey before: " + portalCache1.get("testKey"));         portalCache1.put("testKey", "testValue:"+now);         println("=== Value for testKey after: " + portalCache1.get("testKey"));     } else {         println("MultiVMPool service is not available.");     }

} catch (Exception e) {     println(e) }

Related Assets...

Tuloksia Ei Löytynyt

More Blog Entries...

Victor Ware
syyskuuta 15, 2026
Ben Turner
syyskuuta 02, 2026
David H Nebinger
elokuuta 18, 2026