IDEMPIERE-1044 Load testing. Fixed synchronization issue for m_instances.
This commit is contained in:
parent
0d3d95ecbc
commit
1d1782a02c
|
|
@ -103,7 +103,7 @@ public class CacheMgt
|
||||||
* @param instance Cache
|
* @param instance Cache
|
||||||
* @return true if removed
|
* @return true if removed
|
||||||
*/
|
*/
|
||||||
public boolean unregister (CacheInterface instance)
|
public synchronized boolean unregister (CacheInterface instance)
|
||||||
{
|
{
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -223,9 +223,9 @@ public class CacheMgt
|
||||||
{
|
{
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for (int i = 0; i < m_instances.size(); i++)
|
CacheInterface[] instances = getInstancesAsArray();
|
||||||
|
for (CacheInterface stored : instances)
|
||||||
{
|
{
|
||||||
CacheInterface stored = (CacheInterface)m_instances.get(i);
|
|
||||||
if (stored != null && stored.size() > 0)
|
if (stored != null && stored.size() > 0)
|
||||||
{
|
{
|
||||||
if (log.isLoggable(Level.FINE)) log.fine(stored.toString());
|
if (log.isLoggable(Level.FINE)) log.fine(stored.toString());
|
||||||
|
|
@ -236,6 +236,13 @@ public class CacheMgt
|
||||||
if (log.isLoggable(Level.FINE)) log.fine("#" + counter + " (" + total + ")");
|
if (log.isLoggable(Level.FINE)) log.fine("#" + counter + " (" + total + ")");
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected synchronized CacheInterface[] getInstancesAsArray() {
|
||||||
|
return m_instances.toArray(new CacheInterface[0]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset local Cache
|
* Reset local Cache
|
||||||
|
|
@ -252,9 +259,9 @@ public class CacheMgt
|
||||||
//
|
//
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for (int i = 0; i < m_instances.size(); i++)
|
CacheInterface[] instances = getInstancesAsArray();
|
||||||
|
for (CacheInterface stored : instances)
|
||||||
{
|
{
|
||||||
CacheInterface stored = (CacheInterface)m_instances.get(i);
|
|
||||||
if (stored != null && stored instanceof CCache)
|
if (stored != null && stored instanceof CCache)
|
||||||
{
|
{
|
||||||
CCache<?, ?> cc = (CCache<?, ?>)stored;
|
CCache<?, ?> cc = (CCache<?, ?>)stored;
|
||||||
|
|
@ -287,9 +294,9 @@ public class CacheMgt
|
||||||
if (!m_tableNames.contains(tableName))
|
if (!m_tableNames.contains(tableName))
|
||||||
return;
|
return;
|
||||||
//
|
//
|
||||||
for (int i = 0; i < m_instances.size(); i++)
|
CacheInterface[] instances = getInstancesAsArray();
|
||||||
|
for (CacheInterface stored : instances)
|
||||||
{
|
{
|
||||||
CacheInterface stored = (CacheInterface)m_instances.get(i);
|
|
||||||
if (stored != null && stored instanceof CCache)
|
if (stored != null && stored instanceof CCache)
|
||||||
{
|
{
|
||||||
CCache<?, ?> cc = (CCache<?, ?>)stored;
|
CCache<?, ?> cc = (CCache<?, ?>)stored;
|
||||||
|
|
@ -308,11 +315,11 @@ public class CacheMgt
|
||||||
* @return count
|
* @return count
|
||||||
*/
|
*/
|
||||||
public int getElementCount()
|
public int getElementCount()
|
||||||
{
|
{
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for (int i = 0; i < m_instances.size(); i++)
|
CacheInterface[] instances = getInstancesAsArray();
|
||||||
|
for (CacheInterface stored : instances)
|
||||||
{
|
{
|
||||||
CacheInterface stored = (CacheInterface)m_instances.get(i);
|
|
||||||
if (stored != null && stored.size() > 0)
|
if (stored != null && stored.size() > 0)
|
||||||
{
|
{
|
||||||
if (log.isLoggable(Level.FINE)) log.fine(stored.toString());
|
if (log.isLoggable(Level.FINE)) log.fine(stored.toString());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue