-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTTP Pool data added to JMX management (#793)
* Add HTTP connection pool info to JMX Issue:104837 * Call creation and destruction of mbeans * Various fixes * Better positioning of beans in monitoring console * Check used connections every 30 seconds * Shutdown runnable when no longer needed * Revert "Check used connections every 30 seconds" This reverts commit a15eaa7. * Set difference to find closed connections * Destroy connection pool manager after cleanup * Identify each http route by an unique id * Various fixes * Remove usage of custom connection pool * Manage JMX operation in a single separate thread * Remove usage of IdentifiableHttpRoute and prevent concurrency exception * Use apache logger instead of system.out
- Loading branch information
1 parent
62b3c40
commit fc148fd
Showing
6 changed files
with
381 additions
and
294 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
41 changes: 41 additions & 0 deletions
41
java/src/main/java/com/genexus/management/HTTPConnectionJMX.java
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,41 @@ | ||
package com.genexus.management; | ||
|
||
import org.apache.http.conn.routing.HttpRoute; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
public class HTTPConnectionJMX implements HTTPConnectionJMXBean{ | ||
|
||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(HTTPConnectionJMX.class); | ||
|
||
HttpRoute httpRoute; | ||
|
||
public HTTPConnectionJMX(HttpRoute httpRoute) { | ||
this.httpRoute = httpRoute; | ||
} | ||
|
||
static public void CreateHTTPConnectionJMX(HttpRoute connection) { | ||
try { | ||
MBeanUtils.createMBean(connection); | ||
} | ||
catch (Exception e) { | ||
log.error("Failed to register HTTP connection MBean.", e); | ||
} | ||
} | ||
|
||
static public void DestroyHTTPConnectionJMX(HttpRoute connection) { | ||
try { | ||
MBeanUtils.destroyMBean(connection); | ||
} | ||
catch (Exception e) { | ||
log.error("Failed to destroy HTTP connection MBean.", e); | ||
} | ||
} | ||
|
||
public int getPort() { | ||
return httpRoute.getTargetHost().getPort(); | ||
} | ||
|
||
public String getHost() { | ||
return httpRoute.getTargetHost().getHostName(); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
java/src/main/java/com/genexus/management/HTTPConnectionJMXBean.java
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,6 @@ | ||
package com.genexus.management; | ||
|
||
public interface HTTPConnectionJMXBean { | ||
int getPort(); | ||
String getHost(); | ||
} |
58 changes: 58 additions & 0 deletions
58
java/src/main/java/com/genexus/management/HTTPPoolJMX.java
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,58 @@ | ||
package com.genexus.management; | ||
|
||
import javax.management.MBeanNotificationInfo; | ||
import javax.management.Notification; | ||
import javax.management.NotificationBroadcasterSupport; | ||
|
||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; | ||
import org.apache.logging.log4j.Logger; | ||
public class HTTPPoolJMX extends NotificationBroadcasterSupport implements HTTPPoolJMXMBean{ | ||
|
||
private long sequenceNumber=0; | ||
PoolingHttpClientConnectionManager connectionPool; | ||
private long lastUserWaitingForLongTimeNotif = 0L; | ||
private long lastPoollsFullNotif = 0L; | ||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(HTTPPoolJMX.class); | ||
|
||
public HTTPPoolJMX(PoolingHttpClientConnectionManager connectionPool) { | ||
this.connectionPool = connectionPool; | ||
} | ||
|
||
static public void CreateHTTPPoolJMX(PoolingHttpClientConnectionManager httpConnectionPool) { | ||
try { | ||
MBeanUtils.createMBean(httpConnectionPool); | ||
} | ||
catch(Exception e) { | ||
log.error("Failed to register HTTP connection pool MBean.", e); | ||
} | ||
} | ||
|
||
public int getNumberOfConnectionsInUse(){ | ||
return connectionPool.getTotalStats().getLeased(); | ||
} | ||
|
||
public int getNumberOfRequestsWaiting(){ | ||
return connectionPool.getTotalStats().getPending(); | ||
} | ||
|
||
public int getNumberOfAvailableConnections(){ | ||
return connectionPool.getTotalStats().getAvailable(); | ||
} | ||
|
||
public int getMaxNumberOfConnections(){ | ||
return connectionPool.getTotalStats().getMax(); | ||
} | ||
|
||
public MBeanNotificationInfo[] getNotificationInfo() { | ||
String[] types = new String[] {"com.genexus.managment.fullpool"}; | ||
String name = Notification.class.getName(); | ||
String description = "The Connection Pool does not have available connections "; | ||
MBeanNotificationInfo info = new MBeanNotificationInfo(types, name, description); | ||
|
||
types = new String[] {"com.genexus.managment.longtimeuserwaiting"}; | ||
description = "User waiting a connection for a long time"; | ||
MBeanNotificationInfo info1 = new MBeanNotificationInfo(types, name, description); | ||
|
||
return new MBeanNotificationInfo[] {info, info1}; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
java/src/main/java/com/genexus/management/HTTPPoolJMXMBean.java
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,8 @@ | ||
package com.genexus.management; | ||
|
||
public interface HTTPPoolJMXMBean { | ||
int getNumberOfConnectionsInUse(); | ||
int getNumberOfRequestsWaiting(); | ||
int getNumberOfAvailableConnections(); | ||
int getMaxNumberOfConnections(); | ||
} |
Oops, something went wrong.