IDEMPIERE-5047 iDempiere Server Monitor Improvements (#988)

This commit is contained in:
hengsin 2021-11-19 23:04:54 +08:00 committed by GitHub
parent 2c5efb3031
commit 29f5186d41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 83 additions and 29 deletions

View File

@ -311,7 +311,7 @@ public class GridTabVO implements Evaluatee, Serializable
return true;
} // loadTabDetails
private static final CCache<String, ArrayList<GridFieldVO>> s_gridFieldCache = new CCache<String, ArrayList<GridFieldVO>>(MField.Table_Name, "GridFieldVO Cache", 100, 60, false, 1000);
private static final CCache<String, ArrayList<GridFieldVO>> s_gridFieldCache = new CCache<String, ArrayList<GridFieldVO>>(MField.Table_Name, "GridFieldVO Cache", 100, CCache.DEFAULT_EXPIRE_MINUTE, false, 1000);
/**************************************************************************
* Create Tab Fields

View File

@ -49,7 +49,7 @@ public class MAttribute extends X_M_Attribute implements ImmutablePOSupport
/** Logger */
private static CLogger s_log = CLogger.getCLogger (MAttribute.class);
private static CCache<Integer, MAttribute> s_cache = new CCache<Integer, MAttribute>(Table_Name, 30, 60);
private static CCache<Integer, MAttribute> s_cache = new CCache<Integer, MAttribute>(Table_Name, 30, CCache.DEFAULT_EXPIRE_MINUTE);
/** Values */
private MAttributeValue[] m_values = null;

View File

@ -903,18 +903,18 @@ public final class MLookup extends Lookup implements Serializable
private final static CCache<String, CCache<String, List<KeyNamePair>>> s_keyNamePairCache = new CCache<String, CCache<String, List<KeyNamePair>>>(null, "MLookup.KeyNamePairCache", 100, 60, false, 500);
private final static CCache<String, CCache<String, List<ValueNamePair>>> s_valueNamePairCache = new CCache<String, CCache<String, List<ValueNamePair>>>(null, "MLookup.ValueNamePairCache", 100, 60, false, 500);
private final static CCache<String, CCache<String, List<KeyNamePair>>> s_keyNamePairCache = new CCache<String, CCache<String, List<KeyNamePair>>>(null, "MLookup.KeyNamePairCache", 100, CCache.DEFAULT_EXPIRE_MINUTE, false, 500);
private final static CCache<String, CCache<String, List<ValueNamePair>>> s_valueNamePairCache = new CCache<String, CCache<String, List<ValueNamePair>>>(null, "MLookup.ValueNamePairCache", 100, CCache.DEFAULT_EXPIRE_MINUTE, false, 500);
private final static CCache<String, CCache<Integer, KeyNamePair>> s_directKeyNamePairCache = new CCache<String, CCache<Integer,KeyNamePair>>(null, "MLookup.DirectKeyNamePairCache", 100, 60, false, 500);
private final static CCache<String, CCache<String, ValueNamePair>> s_directValueNamePairCache = new CCache<String, CCache<String,ValueNamePair>>(null, "MLookup.DirectValueNamePairCache", 100, 60, false, 500);
private final static CCache<String, CCache<Integer, KeyNamePair>> s_directKeyNamePairCache = new CCache<String, CCache<Integer,KeyNamePair>>(null, "MLookup.DirectKeyNamePairCache", 100, CCache.DEFAULT_EXPIRE_MINUTE, false, 500);
private final static CCache<String, CCache<String, ValueNamePair>> s_directValueNamePairCache = new CCache<String, CCache<String,ValueNamePair>>(null, "MLookup.DirectValueNamePairCache", 100, CCache.DEFAULT_EXPIRE_MINUTE, false, 500);
private synchronized static List<KeyNamePair> getKeyNamePairCache(MLookupInfo lookupInfo, String cacheKey)
{
CCache<String, List<KeyNamePair>> knpCache = s_keyNamePairCache.get(lookupInfo.TableName);
if (knpCache == null)
{
knpCache = new CCache<String, List<KeyNamePair>>(lookupInfo.TableName, lookupInfo.TableName + " KeyNamePair Cache", 100, 60, false, 500);
knpCache = new CCache<String, List<KeyNamePair>>(lookupInfo.TableName, cacheKey + " KeyNamePair Cache", 100, CCache.DEFAULT_EXPIRE_MINUTE, false, 500);
s_keyNamePairCache.put(lookupInfo.TableName, knpCache);
}
List<KeyNamePair> list = knpCache.get(cacheKey);
@ -931,7 +931,7 @@ public final class MLookup extends Lookup implements Serializable
CCache<String, List<ValueNamePair>> vnpCache = s_valueNamePairCache.get(lookupInfo.TableName);
if (vnpCache == null)
{
vnpCache = new CCache<String, List<ValueNamePair>>(lookupInfo.TableName, lookupInfo.TableName + " ValueNamePair Cache", 100, 60, false, 500);
vnpCache = new CCache<String, List<ValueNamePair>>(lookupInfo.TableName, cacheKey + " ValueNamePair Cache", 100, CCache.DEFAULT_EXPIRE_MINUTE, false, 500);
s_valueNamePairCache.put(lookupInfo.TableName, vnpCache);
}
List<ValueNamePair> list = vnpCache.get(cacheKey);
@ -948,7 +948,7 @@ public final class MLookup extends Lookup implements Serializable
CCache<Integer, KeyNamePair> knpCache = s_directKeyNamePairCache.get(cacheKey);
if (knpCache == null)
{
knpCache = new CCache<Integer, KeyNamePair>(lookupInfo.TableName, lookupInfo.TableName + " DirectKeyNamePairCache", 100, 60, false, MAX_NAMEPAIR_CACHE_SIZE);
knpCache = new CCache<Integer, KeyNamePair>(lookupInfo.TableName, cacheKey + " DirectKeyNamePairCache", 100, CCache.DEFAULT_EXPIRE_MINUTE, false, MAX_NAMEPAIR_CACHE_SIZE);
s_directKeyNamePairCache.put(cacheKey, knpCache);
}
return knpCache;
@ -959,7 +959,7 @@ public final class MLookup extends Lookup implements Serializable
CCache<String, ValueNamePair> vnpCache = s_directValueNamePairCache.get(cacheKey);
if (vnpCache == null)
{
vnpCache = new CCache<String, ValueNamePair>(lookupInfo.TableName, lookupInfo.TableName + " DirectValueNamePairCache", 100, 60, false, MAX_NAMEPAIR_CACHE_SIZE);
vnpCache = new CCache<String, ValueNamePair>(lookupInfo.TableName, cacheKey + " DirectValueNamePairCache", 100, CCache.DEFAULT_EXPIRE_MINUTE, false, MAX_NAMEPAIR_CACHE_SIZE);
s_directValueNamePairCache.put(cacheKey, vnpCache);
}
return vnpCache;

View File

@ -55,9 +55,9 @@ public class MLookupFactory
/** Logging */
private static CLogger s_log = CLogger.getCLogger(MLookupFactory.class);
/** Table Reference Cache */
private static CCache<String,MLookupInfo> s_cacheRefTable = new CCache<String,MLookupInfo>(I_AD_Ref_Table.Table_Name, 30, 60); // 1h
private static CCache<String,MLookupInfo> s_cacheRefTable = new CCache<String,MLookupInfo>(I_AD_Ref_Table.Table_Name, 30, CCache.DEFAULT_EXPIRE_MINUTE); // 1h
/** List Reference Cache */
private static CCache<String,MLookupInfo> s_cacheRefList = new CCache<String,MLookupInfo>(I_AD_Ref_List.Table_Name, 30, 60); // 1h
private static CCache<String,MLookupInfo> s_cacheRefList = new CCache<String,MLookupInfo>(I_AD_Ref_List.Table_Name, 30, CCache.DEFAULT_EXPIRE_MINUTE); // 1h
/**

View File

@ -55,6 +55,28 @@ public class CCache<K,V> implements CacheInterface, Map<K, V>, Serializable
private int m_maxSize = 0;
/** Default cache expire time in minutes **/
public static final int DEFAULT_EXPIRE_MINUTE = getDefaultExpireMinute();
private static int getDefaultExpireMinute()
{
try
{
String property = System.getProperty("Cache.ExpireMinute");
if (property != null && property.trim().length() > 0)
{
int expireMinute = 0;
try
{
expireMinute = Integer.parseInt(property.trim());
} catch (Throwable t) {}
if (expireMinute > 0)
return expireMinute;
}
} catch (Throwable t) {}
return 60;
}
public CCache (String name, int initialCapacity)
{
this(name, name, initialCapacity);
@ -87,7 +109,7 @@ public class CCache<K,V> implements CacheInterface, Map<K, V>, Serializable
public CCache (String tableName, String name, int initialCapacity, boolean distributed)
{
this (tableName, name, initialCapacity, 60, distributed);
this (tableName, name, initialCapacity, DEFAULT_EXPIRE_MINUTE, distributed);
}
public CCache (String tableName, String name, int initialCapacity, int expireMinutes, boolean distributed)

View File

@ -779,9 +779,16 @@ public class AdempiereMonitor extends HttpServlet
para.addElement(link);
font status = null;
if (server.isStarted())
status = new font().setColor(HtmlColor.GREEN).addElement(" (Running)");
{
if (server.isSleeping())
status = new font().setColor(HtmlColor.GREEN).addElement(" (Started)");
else
status = new font().setColor(HtmlColor.GREEN).addElement(" (Running)");
}
else
{
status = new font().setColor(HtmlColor.RED).addElement(" (Stopped)");
}
para.addElement(status);
}
bb.addElement(para);
@ -910,7 +917,7 @@ public class AdempiereMonitor extends HttpServlet
if (serverCount != null) {
builder.append(serverCount.getStarted()+serverCount.getStopped())
.append(" - Running=")
.append(" - Started=")
.append(serverCount.getStarted())
.append(" - Stopped=")
.append(serverCount.getStopped());
@ -1525,6 +1532,8 @@ public class AdempiereMonitor extends HttpServlet
{
if (ccache.getName().endsWith("|CCacheListener"))
continue;
if (ccache.getSize() > 0)
{
line = new tr();
line.addElement(new td().addElement(WebEnv.getCellContent(ccache.getName())));
line.addElement(new td().addElement(WebEnv.getCellContent(ccache.getTableName())));
@ -1540,6 +1549,29 @@ public class AdempiereMonitor extends HttpServlet
}
table.addElement(line);
}
}
for (CacheInfo ccache : instances)
{
if (ccache.getName().endsWith("|CCacheListener"))
continue;
if (ccache.getSize() == 0)
{
line = new tr();
line.addElement(new td().addElement(WebEnv.getCellContent(ccache.getName())));
line.addElement(new td().addElement(WebEnv.getCellContent(ccache.getTableName())));
line.addElement(new td().addElement(WebEnv.getCellContent(ccache.getSize())));
line.addElement(new td().addElement(WebEnv.getCellContent(ccache.getExpireMinutes())));
line.addElement(new td().addElement(WebEnv.getCellContent(ccache.getMaxSize())));
line.addElement(new td().addElement(WebEnv.getCellContent(ccache.getHit())));
line.addElement(new td().addElement(WebEnv.getCellContent(ccache.getMiss())));
line.addElement(new td().addElement(WebEnv.getCellContent(ccache.isDistributed())));
if (ccache.getNodeId() != null)
{
line.addElement(new td().addElement(WebEnv.getCellContent(ccache.getNodeId())));
}
table.addElement(line);
}
}
//
b.addElement(table);
link = new a ("#top", "Top");

View File

@ -135,7 +135,7 @@ public class DB_PostgreSQL implements AdempiereDatabase
private static final String NATIVE_MARKER = "NATIVE_"+Database.DB_POSTGRESQL+"_KEYWORK";
private CCache<String, String> convertCache = new CCache<String, String>(null, "DB_PostgreSQL_Convert_Cache", 1000, 60, false);
private CCache<String, String> convertCache = new CCache<String, String>(null, "DB_PostgreSQL_Convert_Cache", 1000, CCache.DEFAULT_EXPIRE_MINUTE, false);
private Random rand = new Random();

View File

@ -209,7 +209,7 @@ public class AbstractService {
}
private static ImmutablePOCache<String,MWebServiceType> s_WebServiceTypeCache = new ImmutablePOCache<String,MWebServiceType>(MWebServiceType.Table_Name, 10, 60); //60 minutes
private static CCache<String,Boolean> s_RoleAccessCache = new CCache<>(X_WS_WebServiceTypeAccess.Table_Name, 60, 60);
private static CCache<String,Boolean> s_RoleAccessCache = new CCache<>(X_WS_WebServiceTypeAccess.Table_Name, 60, CCache.DEFAULT_EXPIRE_MINUTE);
/**
* Authenticate user for requested service type