Posts

Showing posts with the label cluster

Knowing the cluster Node in the server

Sometimes we need to know which server node we are accessing in cluster environment. We know that we can execute the "Groovy" and "BeanShell" script in control panel. So place the following code and execute it, you will be knowing which server we are accessing. Note: Before execution make necessary imports ClusterNode clusterNode =ClusterExecutorUtil.getLocalClusterNode(); if (clusterNode != null) { System.out.println("cluster Node is "+clusterNode.getClusterNodeId()); }

Display server name or node in the cluster configuration

Image
In Cluster configuration if we want to know which cluster server we have accessed it simple. Liferay has provided a property by which we can know which cluster server we have accessed. Add the following property in the portal-ext.properties # # Set this to true to display the server name at the bottom of every page. # This is useful when testing clustering configurations so that you can know # which node you are accessing. # web.server.display.node=true If we see the internally liferay is using to get the computerName. PortalUtil.getComputerName(); Look into the portalImpl class of constructor how liferay is using to get server node name. _computerName = System.getProperty("env.COMPUTERNAME"); if (Validator.isNull(_computerName)) { _computerName = System.getProperty("env.HOST"); } if (Validator.isNull(_computerName)) { _computerName = System.getProperty("env.HOSTNAME"); } After restarting the server we can see the node ...

Quartz scheduler configuration in cluster

  Quartz is a very popular open source scheduler engine. Quartz scheduler stores data related to scheduled jobs in the Liferay database. In clustered environment there will be chance of starting the scheduler for all the nodes at same time which causes duplicate entries in the portal. We should  execute only once for all the nodes. Suppose if we have configured 4 nodes, then 4 scheduler will start at same time. But we need execute 1 scheduler for a job. Hence in a clustered environment, it is possible that multiple nodes start the same job at the same time. This can create havoc. To prevent this situation, we need to configure Quartz for the clustered environment. Add the following property in the portal-ext.properties org.quartz.jobStore.isClustered=true  Drop all the tables starting with QUARTZ_. This step is required if Liferay tables are already created. We just added a property to let the Quartz scheduler know that we are running multiple inst...