Skip to content

Commit 3a0a35a

Browse files
committed
Use JMX support classes only when JMX is enabled to avoid unnecessary proccess.
Change HashMap to ConcurrentHashMap in ProcedureInfo to allow concurrency when JMX is enabled Issue: 106110
1 parent ba1d738 commit 3a0a35a

File tree

3 files changed

+26
-27
lines changed

3 files changed

+26
-27
lines changed

java/src/main/java/com/genexus/GXProcedure.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ public GXProcedure(int remoteHandle, ModelContext context, String location) {
3737

3838
public GXProcedure(boolean inNewUTL, int remoteHandle, ModelContext context, String location) {
3939
//JMX Counter
40-
beginExecute = new Date();
41-
ProcedureInfo pInfo = ProceduresInfo.addProcedureInfo(this.getClass().getName());
42-
pInfo.incCount();
40+
if (Application.isJMXEnabled()) {
41+
beginExecute = new Date();
42+
ProcedureInfo pInfo = ProceduresInfo.addProcedureInfo(this.getClass().getName());
43+
pInfo.incCount();
44+
}
4345

4446
this.remoteHandle = remoteHandle;
4547
this.context = context;
@@ -148,8 +150,10 @@ private void exitApplication(boolean flushBuffers) {
148150
}
149151

150152
public void endExecute(String name) {
151-
ProcedureInfo pInfo = ProceduresInfo.getProcedureInfo(name);
152-
pInfo.setTimeExecute(System.currentTimeMillis() - beginExecute.getTime());
153+
if (Application.isJMXEnabled()) {
154+
ProcedureInfo pInfo = ProceduresInfo.getProcedureInfo(name);
155+
pInfo.setTimeExecute(System.currentTimeMillis() - beginExecute.getTime());
156+
}
153157

154158
if (context != null && context.getSessionContext() != null) {
155159
ApplicationContext.getInstance().setEJB(false);

java/src/main/java/com/genexus/db/DataStoreProvider.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,17 @@ public DataStoreProvider(ModelContext context, int remoteHandle, ILocalDataStore
4747
super(context, remoteHandle);
4848

4949
//JMX Enabled
50-
if (Application.isJMXEnabled())
51-
if (firstTime.get())
52-
{
50+
if (Application.isJMXEnabled()) {
51+
if (firstTime.get()) {
5352
DataStoreProvidersJMX.CreateDataStoreProvidersJMX();
5453
firstTime.set(false);
5554
}
55+
addDataStoreProviderInfo(helper.getClass().getName());
56+
}
5657

5758
this.helper = helper;
5859
this.cursors = helper.getCursors();
5960
setOutputBuffers(buffers);
60-
61-
//JMX
62-
addDataStoreProviderInfo(helper.getClass().getName());
63-
6461
}
6562

6663
public void setErrorBuffers(int cursorIdx, Object[] buffers)
@@ -716,18 +713,20 @@ void beginExecute()
716713

717714
void incSentencesCount(String key, Cursor cursor)
718715
{
719-
720-
DataStoreProviderInfo dsInfo = getDataStoreProviderInfo(key);
721-
dsInfo.incSentenceCount();
722-
SentenceInfo sInfo;
723-
if (cursor.dynStatement) {
724-
sInfo = dsInfo.addSentenceInfo(key + "_" + cursor.mCursorId, key
716+
DataStoreProviderInfo dsInfo = null;
717+
if (Application.isJMXEnabled()) {
718+
dsInfo = getDataStoreProviderInfo(key);
719+
dsInfo.incSentenceCount();
720+
SentenceInfo sInfo;
721+
if (cursor.dynStatement) {
722+
sInfo = dsInfo.addSentenceInfo(key + "_" + cursor.mCursorId, key
725723
+ "_" + cursor.mCursorId + "_" + cursor.mSQLSentence);
726-
} else {
727-
sInfo = dsInfo.addSentenceInfo(key + "_" + cursor.mCursorId,
724+
} else {
725+
sInfo = dsInfo.addSentenceInfo(key + "_" + cursor.mCursorId,
728726
cursor.mSQLSentence);
727+
}
728+
sInfo.incSentenceCount();
729729
}
730-
sInfo.incSentenceCount();
731730

732731
String sqlSnt = cursor.mSQLSentence;
733732
sentenceCount.incrementAndGet();

java/src/main/java/com/genexus/performance/ProceduresInfo.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22

33
import java.io.PrintStream;
44
import java.util.Enumeration;
5-
import java.util.Hashtable;
5+
import java.util.concurrent.ConcurrentHashMap;
66

77
import com.genexus.Application;
88

99
public class ProceduresInfo
1010
{
11-
static private Hashtable<String, ProcedureInfo> procedureInfo = new Hashtable<>();
12-
13-
public ProceduresInfo()
14-
{
15-
}
11+
static private ConcurrentHashMap<String, ProcedureInfo> procedureInfo = new ConcurrentHashMap<>();
1612

1713
static public void dump(PrintStream out)
1814
{

0 commit comments

Comments
 (0)