ACA Blog

ACA Blog


July 2019
M T W T F S S
« Jun    
1234567
891011121314
15161718192021
22232425262728
293031  

Categories


Where am I? (how to know which cluster node you’re on)

Jan EerdekensJan Eerdekens

When working with a cluster you pretty quickly come to a point where you want/need to know what cluster node you’re on.

what-node-is-this

Liferay already has a simple way to show you this. You just need to add the following line to your portal-ext.properties and hey presto! it shows the current web server node ID in a blue box at the bottom of the page:

node-id

While this works perfectly it has one drawback: customers don’t really want to see this in production, while we need it at times to be able to debug a problem. There are a number of ways to solve this catch 22 type of situation:

I want to present a 3rd option: extend the dockbar with a new icon that allows you to display the node ID (and other cluster node specific data). For this we’ll need to override /html/portlet/dockbar/view.jsp and add some code to it.

First is the button which we’ll add right before the Toggle Edit Controls button:

Secondly we’ll need some CSS and Javascript (which we add to the existing aui:script tag) to be able to add an action to our new button that will show a popover with the information we want:

The Javascript code above also adds a keyboard shortcut, SHIFT+N, to the button so that you can even show the popover without even needing to click the button. You can find the complete file here: https://gist.github.com/planetsizebrain/3f9788a78224be73d80b. This will give you the following result:

new-node-id

If you want something similar, but don’t want to add a button to the dockbar, you could use similar code to make the existing blue bar appear/disappear when a shortcut is pressed.

Belgian Java and Liferay developer with some weird interests, eternal complainer, atheist, skeptic and geocacher.

Leave a Reply

avatar
  Subscribe  
Notify of