org.opencms.monitor
Class CmsMemoryMonitor

java.lang.Object
  extended by org.opencms.monitor.CmsMemoryMonitor
All Implemented Interfaces:
I_CmsScheduledJob

public class CmsMemoryMonitor
extends java.lang.Object
implements I_CmsScheduledJob

Monitors OpenCms memory consumption.

The memory monitor also provides all kind of caches used in the OpenCms core.

Since:
6.0.0
Version:
$Revision: 1.72 $
Author:
Carsten Weinholz, Michael Emmerich, Alexander Kandzior, Michael Moossen

Nested Class Summary
static class CmsMemoryMonitor.CacheType
          Cache types.
 
Constructor Summary
CmsMemoryMonitor()
          Empty constructor, required by OpenCms scheduler.
 
Method Summary
 void cacheACL(java.lang.String key, CmsAccessControlList acl)
          Caches the given acl under the given cache key.
 void cacheContentDefinition(java.lang.String key, CmsXmlContentDefinition contentDefinition)
          Caches the given content definition under the given cache key.
 void cacheGroup(CmsGroup group)
          Caches the given group under its id AND fully qualified name.
 void cacheLocale(java.lang.String key, java.util.Locale locale)
          Caches the given locale under the given cache key.
 void cacheLock(CmsLock lock)
          Caches the given lock.
 void cacheMemObject(java.lang.String key, java.lang.Object obj)
          Caches the given object under the given cache key.
 void cacheOrgUnit(CmsOrganizationalUnit orgUnit)
          Caches the given organizational under its id AND the fully qualified name.
 void cachePermission(java.lang.String key, I_CmsPermissionHandler.CmsPermissionCheckResult permission)
          Caches the given permission check result under the given cache key.
 void cacheProject(CmsProject project)
          Caches the given project under its id AND the fully qualified name.
 void cacheProjectResources(java.lang.String key, java.util.List<CmsResource> projectResources)
          Caches the given project resource list under the given cache key.
 void cacheProperty(java.lang.String key, CmsProperty property)
          Caches the given property under the given cache key.
 void cachePropertyList(java.lang.String key, java.util.List<CmsProperty> propertyList)
          Caches the given property list under the given cache key.
 void cachePublishedResources(java.lang.String cacheKey, java.util.List<CmsPublishedResource> publishedResources)
          Caches the given published resources list under the given cache key.
 void cachePublishJob(CmsPublishJobInfoBean publishJob)
          Caches the given publish job.
 void cachePublishJobInHistory(CmsPublishJobInfoBean publishJob)
          Caches the given publish job in the publish job history.
 void cacheResource(java.lang.String key, CmsResource resource)
          Caches the given resource under the given cache key.
 void cacheResourceList(java.lang.String key, java.util.List<CmsResource> resourceList)
          Caches the given resource list under the given cache key.
 void cacheRole(java.lang.String key, boolean hasRole)
          Caches the given value under the given cache key.
 void cacheRoleList(java.lang.String key, java.util.List<CmsRole> roles)
          Caches the given value under the given cache key.
 void cacheUser(CmsUser user)
          Caches the given user under its id AND the fully qualified name.
 void cacheUserGroups(java.lang.String key, java.util.List<CmsGroup> userGroups)
          Caches the given list of user groups under the given cache key.
 void cacheVfsObject(java.lang.String key, java.lang.Object obj)
          Caches the given vfs object under the given cache key.
 void cacheXmlPermanentEntity(java.lang.String systemId, byte[] content)
          Caches the given xml entity under the given system id.
 void cacheXmlTemporaryEntity(java.lang.String key, byte[] content)
          Caches the given xml entity under the given cache key.
 void clearAccessControlListCache()
          Clears the access control list cache when access control entries are changed.
 void clearCache()
          Clears almost all internal caches.
protected  void clearCaches()
          Clears the OpenCms caches.
 void clearPrincipalsCache()
          Clears all internal principal-related caches.
 void clearResourceCache()
          Clears all the depending caches when a resource was changed.
 void clearUserCache(CmsUser user)
          Clears the user cache for the given user.
 void disableCache(CmsMemoryMonitor.CacheType... types)
          Disables the given cache.
 void enableCache(CmsMemoryMonitor.CacheType... types)
          Enables the given cache.
 boolean enabled()
          Returns if monitoring is enabled.
 void flushACLs()
          Deprecated. use flushCache(CacheType[]) instead
 void flushCache(CmsMemoryMonitor.CacheType... types)
          Flushes the given cache.
 void flushContentDefinitions()
          Deprecated. use flushCache(CacheType[]) instead
 void flushGroups()
          Deprecated. use flushCache(CacheType[]) instead
 void flushLocales()
          Deprecated. use flushCache(CacheType[]) instead
 void flushLocks(java.util.Map<java.lang.String,CmsLock> newLocks)
          Flushes the locks cache.
 void flushMemObjects()
          Deprecated. use flushCache(CacheType[]) instead
 void flushOrgUnits()
          Deprecated. use flushCache(CacheType[]) instead
 void flushPermissions()
          Deprecated. use flushCache(CacheType[]) instead
 void flushProjectResources()
          Deprecated. use flushCache(CacheType[]) instead
 void flushProjects()
          Deprecated. use flushCache(CacheType[]) instead
 void flushProperties()
          Deprecated. use flushCache(CacheType[]) instead
 void flushPropertyLists()
          Deprecated. use flushCache(CacheType[]) instead
 void flushPublishedResources()
          Deprecated. use flushCache(CacheType[]) instead
 void flushPublishJobHistory()
          Deprecated. use flushCache(CacheType[]) instead
 void flushPublishJobs()
          Deprecated. use flushCache(CacheType[]) instead
 void flushResourceLists()
          Deprecated. use flushCache(CacheType[]) instead
 void flushResources()
          Deprecated. use flushCache(CacheType[]) instead
 void flushRoleLists()
          Deprecated. use flushCache(CacheType[]) instead
 void flushRoles()
          Deprecated. use flushCache(CacheType[]) instead
 void flushUserGroups()
          Deprecated. use flushCache(CacheType[]) instead
 void flushUsers()
          Deprecated. use flushCache(CacheType[]) instead
 void flushVfsObjects()
          Deprecated. use flushCache(CacheType[]) instead
 void flushXmlPermanentEntities()
          Deprecated. use flushCache(CacheType[]) instead
 void flushXmlTemporaryEntities()
          Deprecated. use flushCache(CacheType[]) instead
 java.util.List<java.lang.String> getAllCachedLockPaths()
          Returns all cached lock root paths.
 java.util.List<CmsLock> getAllCachedLocks()
          Returns all cached locks.
 java.util.List<CmsPublishJobInfoBean> getAllCachedPublishJobs()
          Returns all cached publish jobs in the queue as ordered list.
 java.util.List<CmsPublishJobInfoBean> getAllCachedPublishJobsInHistory()
          Returns all cached publish jobs in the history as ordered list.
 CmsAccessControlList getCachedACL(java.lang.String key)
          Returns the ACL cached with the given cache key or null if not found.
 CmsXmlContentDefinition getCachedContentDefinition(java.lang.String key)
          Returns the xml content definition cached with the given cache key or null if not found.
 CmsGroup getCachedGroup(java.lang.String key)
          Returns the group cached with the given cache key or null if not found.
 java.util.Locale getCachedLocale(java.lang.String key)
          Returns the locale cached with the given cache key or null if not found.
 CmsLock getCachedLock(java.lang.String rootPath)
          Returns the lock cached with the given root path or null if not found.
 java.lang.Object getCachedMemObject(java.lang.String key)
          Returns the memory object cached with the given cache key or null if not found.
 CmsOrganizationalUnit getCachedOrgUnit(java.lang.String key)
          Returns the organizational unit cached with the given cache key or null if not found.
 I_CmsPermissionHandler.CmsPermissionCheckResult getCachedPermission(java.lang.String key)
          Returns the permission check result cached with the given cache key or null if not found.
 CmsProject getCachedProject(java.lang.String key)
          Returns the project cached with the given cache key or null if not found.
 java.util.List<CmsResource> getCachedProjectResources(java.lang.String key)
          Returns the project resources list cached with the given cache key or null if not found.
 CmsProperty getCachedProperty(java.lang.String key)
          Returns the property cached with the given cache key or null if not found.
 java.util.List<CmsProperty> getCachedPropertyList(java.lang.String key)
          Returns the property list cached with the given cache key or null if not found.
 java.util.List<CmsPublishedResource> getCachedPublishedResources(java.lang.String cacheKey)
          Returns the published resources list cached with the given cache key or null if not found.
 CmsPublishJobInfoBean getCachedPublishJob(java.lang.String key)
          Returns the publish job with the given cache key or null if not found.
 CmsPublishJobInfoBean getCachedPublishJobInHistory(java.lang.String key)
          Returns the publish job from the history with the given cache key or null if not found.
 CmsResource getCachedResource(java.lang.String key)
          Returns the resource cached with the given cache key or null if not found.
 java.util.List<CmsResource> getCachedResourceList(java.lang.String key)
          Returns the resource list cached with the given cache key or null if not found.
 java.lang.Boolean getCachedRole(java.lang.String key)
          Returns the value cached with the given cache key or null if not found.
 java.util.List<CmsRole> getCachedRoleList(java.lang.String key)
          Returns the value cached with the given cache key or null if not found.
 CmsUser getCachedUser(java.lang.String key)
          Returns the user cached with the given cache key or null if not found.
 java.util.List<CmsGroup> getCachedUserGroups(java.lang.String key)
          Returns the user groups list cached with the given cache key or null if not found.
 java.lang.Object getCachedVfsObject(java.lang.String key)
          Returns the vfs object cached with the given cache key or null if not found.
 byte[] getCachedXmlPermanentEntity(java.lang.String systemId)
          Returns the xml permanent entity content cached with the given systemId or null if not found.
 byte[] getCachedXmlTemporaryEntity(java.lang.String key)
          Returns the xml temporary entity content cached with the given cache key or null if not found.
 CmsMemoryMonitorConfiguration getConfiguration()
          Returns the configuration.
protected  long getCosts(java.lang.Object obj)
          Returns the cache costs of a monitored object.
 CmsPublishJobInfoBean getFirstCachedPublishJob()
          Returns the next publish job from the publish job queue.
protected  java.lang.String getItems(java.lang.Object obj)
          Returns the number of items within a monitored object.
protected  long getKeySize(java.util.Map<?,?> map, int depth)
          Returns the total size of key strings within a monitored map.
protected  long getKeySize(java.lang.Object obj)
          Returns the total size of key strings within a monitored object.
protected  java.lang.String getLimit(java.lang.Object obj)
          Returns the max costs for all items within a monitored object.
 int getLogCount()
          Returns the log count.
static int getMemorySize(java.lang.Object obj)
          Returns the size of objects that are instances of byte[], String, CmsFile,I_CmsLruCacheObject.
static long getValueSize(java.util.List<?> listValue, int depth)
          Returns the total value size of a list object.
static long getValueSize(java.util.Map<?,?> mapValue, int depth)
          Returns the total value size of a map object.
static long getValueSize(java.lang.Object obj)
          Returns the value sizes of value objects within the monitored object.
 void initialize(CmsSystemConfiguration configuration)
          Initializes the monitor with the provided configuration.
 boolean isCacheProperty()
          Deprecated. use isEnabled(CacheType) instead
 boolean isCachePropertyList()
          Deprecated. use isEnabled(CacheType) instead
 boolean isCacheResource()
          Deprecated. use isEnabled(CacheType) instead
 boolean isCacheResourceList()
          Deprecated. use isEnabled(CacheType) instead
 boolean isEnabled(CmsMemoryMonitor.CacheType type)
          Checks if the given cache is enabled.
 boolean isMonitoring(java.lang.String key)
          Checks if there is a registered monitored object with the given key.
 java.lang.String launch(CmsObject cms, java.util.Map parameters)
          This method will be called when this scheduled job is executed.
 boolean lowMemory()
          Returns true if the system runs low on memory.
protected  void monitorSendEmail(boolean warning)
          Sends a warning or status email with OpenCms Memory information.
protected  void monitorWriteLog(boolean warning)
          Write a warning or status log entry with OpenCms Memory information.
 void register(java.lang.String objectName, java.lang.Object object)
          Adds a new object to the monitor.
 boolean requiresPersistency()
          Checks if some kind of persistence is required.
 void setCacheProperty(boolean cacheProperty)
          Deprecated. use enableCache(CacheType[]) or disableCache(CacheType[]) instead
 void setCachePropertyList(boolean cachePropertyList)
          Deprecated. use enableCache(CacheType[]) or disableCache(CacheType[]) instead
 void setCacheResource(boolean cacheResource)
          Deprecated. use enableCache(CacheType[]) or disableCache(CacheType[]) instead
 void setCacheResourceList(boolean cacheResourceList)
          Deprecated. use enableCache(CacheType[]) or disableCache(CacheType[]) instead
 void shutdown()
          Flushes all cached objects.
 void uncacheContentDefinition(java.lang.String key)
          Removes the given xml content definition from the cache.
 void uncacheGroup(CmsGroup group)
          Removes the given group from the cache.
 void uncacheLock(java.lang.String rootPath)
          Removes the cached lock for the given root path from the cache.
 void uncacheOrgUnit(CmsOrganizationalUnit orgUnit)
          Removes the given organizational unit from the cache.
 void uncacheProject(CmsProject project)
          Removes the given project from the cache.
 void uncachePublishJob(CmsPublishJobInfoBean publishJob)
          Removes the given publish job from the cache.
 void uncachePublishJobInHistory(CmsPublishJobInfoBean publishJob)
          Removes the given publish job from the history.
 void uncacheUser(CmsUser user)
          Removes the given user from the cache.
 void uncacheVfsObject(java.lang.String key)
          Removes the given vfs object from the cache.
 void uncacheXmlTemporaryEntity(java.lang.String key)
          Removes the given xml temporary entity from the cache.
protected  void updateStatus()
          Updates the memory information of the memory monitor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmsMemoryMonitor

public CmsMemoryMonitor()
Empty constructor, required by OpenCms scheduler.

Method Detail

getMemorySize

public static int getMemorySize(java.lang.Object obj)
Returns the size of objects that are instances of byte[], String, CmsFile,I_CmsLruCacheObject.

For other objects, a size of 0 is returned.

Parameters:
obj - the object
Returns:
the size of the object

getValueSize

public static long getValueSize(java.util.List<?> listValue,
                                int depth)
Returns the total value size of a list object.

Parameters:
listValue - the list object
depth - the max recursion depth for calculation the size
Returns:
the size of the list object

getValueSize

public static long getValueSize(java.util.Map<?,?> mapValue,
                                int depth)
Returns the total value size of a map object.

Parameters:
mapValue - the map object
depth - the max recursion depth for calculation the size
Returns:
the size of the map object

getValueSize

public static long getValueSize(java.lang.Object obj)
Returns the value sizes of value objects within the monitored object.

Parameters:
obj - the object
Returns:
the value sizes of value objects or "-"-fields

cacheACL

public void cacheACL(java.lang.String key,
                     CmsAccessControlList acl)
Caches the given acl under the given cache key.

Parameters:
key - the cache key
acl - the acl to cache

cacheContentDefinition

public void cacheContentDefinition(java.lang.String key,
                                   CmsXmlContentDefinition contentDefinition)
Caches the given content definition under the given cache key.

Parameters:
key - the cache key
contentDefinition - the content definition to cache

cacheGroup

public void cacheGroup(CmsGroup group)
Caches the given group under its id AND fully qualified name.

Parameters:
group - the group to cache

cacheLocale

public void cacheLocale(java.lang.String key,
                        java.util.Locale locale)
Caches the given locale under the given cache key.

Parameters:
key - the cache key
locale - the locale to cache

cacheLock

public void cacheLock(CmsLock lock)
Caches the given lock.

The lock is cached by it resource's root path.

Parameters:
lock - the lock to cache

cacheMemObject

public void cacheMemObject(java.lang.String key,
                           java.lang.Object obj)
Caches the given object under the given cache key.

Parameters:
key - the cache key
obj - the object to cache

cacheOrgUnit

public void cacheOrgUnit(CmsOrganizationalUnit orgUnit)
Caches the given organizational under its id AND the fully qualified name.

Parameters:
orgUnit - the organizational unit to cache

cachePermission

public void cachePermission(java.lang.String key,
                            I_CmsPermissionHandler.CmsPermissionCheckResult permission)
Caches the given permission check result under the given cache key.

Parameters:
key - the cache key
permission - the permission check result to cache

cacheProject

public void cacheProject(CmsProject project)
Caches the given project under its id AND the fully qualified name.

Parameters:
project - the project to cache

cacheProjectResources

public void cacheProjectResources(java.lang.String key,
                                  java.util.List<CmsResource> projectResources)
Caches the given project resource list under the given cache key.

Parameters:
key - the cache key
projectResources - the project resources to cache

cacheProperty

public void cacheProperty(java.lang.String key,
                          CmsProperty property)
Caches the given property under the given cache key.

Parameters:
key - the cache key
property - the property to cache

cachePropertyList

public void cachePropertyList(java.lang.String key,
                              java.util.List<CmsProperty> propertyList)
Caches the given property list under the given cache key.

Parameters:
key - the cache key
propertyList - the property list to cache

cachePublishedResources

public void cachePublishedResources(java.lang.String cacheKey,
                                    java.util.List<CmsPublishedResource> publishedResources)
Caches the given published resources list under the given cache key.

Parameters:
cacheKey - the cache key
publishedResources - the published resources list to cache

cachePublishJob

public void cachePublishJob(CmsPublishJobInfoBean publishJob)
Caches the given publish job.

Parameters:
publishJob - the publish job

cachePublishJobInHistory

public void cachePublishJobInHistory(CmsPublishJobInfoBean publishJob)
Caches the given publish job in the publish job history.

Parameters:
publishJob - the publish job

cacheResource

public void cacheResource(java.lang.String key,
                          CmsResource resource)
Caches the given resource under the given cache key.

Parameters:
key - the cache key
resource - the resource to cache

cacheResourceList

public void cacheResourceList(java.lang.String key,
                              java.util.List<CmsResource> resourceList)
Caches the given resource list under the given cache key.

Parameters:
key - the cache key
resourceList - the resource list to cache

cacheRole

public void cacheRole(java.lang.String key,
                      boolean hasRole)
Caches the given value under the given cache key.

Parameters:
key - the cache key
hasRole - if the user has the given role

cacheRoleList

public void cacheRoleList(java.lang.String key,
                          java.util.List<CmsRole> roles)
Caches the given value under the given cache key.

Parameters:
key - the cache key
roles - the roles of the user

cacheUser

public void cacheUser(CmsUser user)
Caches the given user under its id AND the fully qualified name.

Parameters:
user - the user to cache

cacheUserGroups

public void cacheUserGroups(java.lang.String key,
                            java.util.List<CmsGroup> userGroups)
Caches the given list of user groups under the given cache key.

Parameters:
key - the cache key
userGroups - the list of user groups to cache

cacheVfsObject

public void cacheVfsObject(java.lang.String key,
                           java.lang.Object obj)
Caches the given vfs object under the given cache key.

Parameters:
key - the cache key
obj - the vfs object to cache

cacheXmlPermanentEntity

public void cacheXmlPermanentEntity(java.lang.String systemId,
                                    byte[] content)
Caches the given xml entity under the given system id.

Parameters:
systemId - the cache key
content - the content to cache

cacheXmlTemporaryEntity

public void cacheXmlTemporaryEntity(java.lang.String key,
                                    byte[] content)
Caches the given xml entity under the given cache key.

Parameters:
key - the cache key
content - the content to cache

clearAccessControlListCache

public void clearAccessControlListCache()
Clears the access control list cache when access control entries are changed.


clearCache

public void clearCache()
Clears almost all internal caches.


clearPrincipalsCache

public void clearPrincipalsCache()
Clears all internal principal-related caches.


clearResourceCache

public void clearResourceCache()
Clears all the depending caches when a resource was changed.


clearUserCache

public void clearUserCache(CmsUser user)
Clears the user cache for the given user.

Parameters:
user - the user

disableCache

public void disableCache(CmsMemoryMonitor.CacheType... types)
Disables the given cache.

Parameters:
types - the cache type to disable

enableCache

public void enableCache(CmsMemoryMonitor.CacheType... types)
Enables the given cache.

Parameters:
types - the cache type to disable

enabled

public boolean enabled()
Returns if monitoring is enabled.

Returns:
true if monitoring is enabled

flushACLs

public void flushACLs()
Deprecated. use flushCache(CacheType[]) instead

Flushes the ACL cache.


flushCache

public void flushCache(CmsMemoryMonitor.CacheType... types)
Flushes the given cache.

Parameters:
types - the cache types to flush

flushContentDefinitions

@Deprecated
public void flushContentDefinitions()
Deprecated. use flushCache(CacheType[]) instead

Flushes the xml content definitions cache.


flushGroups

@Deprecated
public void flushGroups()
Deprecated. use flushCache(CacheType[]) instead

Flushes the group cache.


flushLocales

@Deprecated
public void flushLocales()
Deprecated. use flushCache(CacheType[]) instead

Flushes the locale cache.


flushLocks

public void flushLocks(java.util.Map<java.lang.String,CmsLock> newLocks)
Flushes the locks cache.

Parameters:
newLocks - if not null the lock cache is replaced by the given map

flushMemObjects

@Deprecated
public void flushMemObjects()
Deprecated. use flushCache(CacheType[]) instead

Flushes the memory object cache.


flushOrgUnits

@Deprecated
public void flushOrgUnits()
Deprecated. use flushCache(CacheType[]) instead

Flushes the organizational unit cache.


flushPermissions

@Deprecated
public void flushPermissions()
Deprecated. use flushCache(CacheType[]) instead

Flushes the permission check result cache.


flushProjectResources

@Deprecated
public void flushProjectResources()
Deprecated. use flushCache(CacheType[]) instead

Flushes the project resources cache.


flushProjects

@Deprecated
public void flushProjects()
Deprecated. use flushCache(CacheType[]) instead

Flushes the project cache.


flushProperties

@Deprecated
public void flushProperties()
Deprecated. use flushCache(CacheType[]) instead

Flushes the property cache.


flushPropertyLists

@Deprecated
public void flushPropertyLists()
Deprecated. use flushCache(CacheType[]) instead

Flushes the property list cache.


flushPublishedResources

@Deprecated
public void flushPublishedResources()
Deprecated. use flushCache(CacheType[]) instead

Flushes the published resources cache.


flushPublishJobHistory

@Deprecated
public void flushPublishJobHistory()
Deprecated. use flushCache(CacheType[]) instead

Flushes the publish history.


flushPublishJobs

@Deprecated
public void flushPublishJobs()
Deprecated. use flushCache(CacheType[]) instead

Flushes the publish queue.


flushResourceLists

@Deprecated
public void flushResourceLists()
Deprecated. use flushCache(CacheType[]) instead

Flushes the resource list cache.


flushResources

@Deprecated
public void flushResources()
Deprecated. use flushCache(CacheType[]) instead

Flushes the resource cache.


flushRoleLists

@Deprecated
public void flushRoleLists()
Deprecated. use flushCache(CacheType[]) instead

Flushes the role lists cache.


flushRoles

@Deprecated
public void flushRoles()
Deprecated. use flushCache(CacheType[]) instead

Flushes the roles cache.


flushUserGroups

@Deprecated
public void flushUserGroups()
Deprecated. use flushCache(CacheType[]) instead

Flushes the user groups cache.


flushUsers

@Deprecated
public void flushUsers()
Deprecated. use flushCache(CacheType[]) instead

Flushes the users cache.


flushVfsObjects

@Deprecated
public void flushVfsObjects()
Deprecated. use flushCache(CacheType[]) instead

Flushes the vfs object cache.


flushXmlPermanentEntities

@Deprecated
public void flushXmlPermanentEntities()
Deprecated. use flushCache(CacheType[]) instead

Flushes the xml permanent entities cache.


flushXmlTemporaryEntities

@Deprecated
public void flushXmlTemporaryEntities()
Deprecated. use flushCache(CacheType[]) instead

Flushes the xml temporary entities cache.


getAllCachedLockPaths

public java.util.List<java.lang.String> getAllCachedLockPaths()
Returns all cached lock root paths.

Returns:
a list of String objects

getAllCachedLocks

public java.util.List<CmsLock> getAllCachedLocks()
Returns all cached locks.

Returns:
a list of CmsLock objects

getAllCachedPublishJobs

public java.util.List<CmsPublishJobInfoBean> getAllCachedPublishJobs()
Returns all cached publish jobs in the queue as ordered list.

Returns:
all cached publish jobs

getAllCachedPublishJobsInHistory

public java.util.List<CmsPublishJobInfoBean> getAllCachedPublishJobsInHistory()
Returns all cached publish jobs in the history as ordered list.

Returns:
all cached publish jobs

getCachedACL

public CmsAccessControlList getCachedACL(java.lang.String key)
Returns the ACL cached with the given cache key or null if not found.

Parameters:
key - the cache key to look for
Returns:
the ACL cached with the given cache key

getCachedContentDefinition

public CmsXmlContentDefinition getCachedContentDefinition(java.lang.String key)
Returns the xml content definition cached with the given cache key or null if not found.

Parameters:
key - the cache key to look for
Returns:
the xml content definition cached with the given cache key

getCachedGroup

public CmsGroup getCachedGroup(java.lang.String key)
Returns the group cached with the given cache key or null if not found.

Parameters:
key - the cache key to look for, this may be the group's uuid or the fqn
Returns:
the group cached with the given cache key

getCachedLocale

public java.util.Locale getCachedLocale(java.lang.String key)
Returns the locale cached with the given cache key or null if not found.

Parameters:
key - the cache key to look for
Returns:
the locale cached with the given cache key

getCachedLock

public CmsLock getCachedLock(java.lang.String rootPath)
Returns the lock cached with the given root path or null if not found.

Parameters:
rootPath - the root path to look for
Returns:
the lock cached with the given root path

getCachedMemObject

public java.lang.Object getCachedMemObject(java.lang.String key)
Returns the memory object cached with the given cache key or null if not found.

Parameters:
key - the cache key to look for
Returns:
the memory object cached with the given cache key

getCachedOrgUnit

public CmsOrganizationalUnit getCachedOrgUnit(java.lang.String key)
Returns the organizational unit cached with the given cache key or null if not found.

Parameters:
key - the cache key to look for, this may be the organizational unit's uuid or the fqn
Returns:
the organizational unit cached with the given cache key

getCachedPermission

public I_CmsPermissionHandler.CmsPermissionCheckResult getCachedPermission(java.lang.String key)
Returns the permission check result cached with the given cache key or null if not found.

Parameters:
key - the cache key to look for
Returns:
the permission check result cached with the given cache key

getCachedProject

public CmsProject getCachedProject(java.lang.String key)
Returns the project cached with the given cache key or null if not found.

Parameters:
key - the cache key to look for, this may be the project's uuid or the fqn
Returns:
the project cached with the given cache key

getCachedProjectResources

public java.util.List<CmsResource> getCachedProjectResources(java.lang.String key)
Returns the project resources list cached with the given cache key or null if not found.

Parameters:
key - the cache key to look for
Returns:
the project resources list cached with the given cache key

getCachedProperty

public CmsProperty getCachedProperty(java.lang.String key)
Returns the property cached with the given cache key or null if not found.

Parameters:
key - the cache key to look for
Returns:
the property cached with the given cache key

getCachedPropertyList

public java.util.List<CmsProperty> getCachedPropertyList(java.lang.String key)
Returns the property list cached with the given cache key or null if not found.

Parameters:
key - the cache key to look for
Returns:
the property list cached with the given cache key

getCachedPublishedResources

public java.util.List<CmsPublishedResource> getCachedPublishedResources(java.lang.String cacheKey)
Returns the published resources list cached with the given cache key or null if not found.

Parameters:
cacheKey - the cache key to look for
Returns:
the published resources list cached with the given cache key

getCachedPublishJob

public CmsPublishJobInfoBean getCachedPublishJob(java.lang.String key)
Returns the publish job with the given cache key or null if not found.

Parameters:
key - the cache key to look for
Returns:
the publish job with the given cache key

getCachedPublishJobInHistory

public CmsPublishJobInfoBean getCachedPublishJobInHistory(java.lang.String key)
Returns the publish job from the history with the given cache key or null if not found.

Parameters:
key - the cache key to look for
Returns:
the publish job with the given cache key

getCachedResource

public CmsResource getCachedResource(java.lang.String key)
Returns the resource cached with the given cache key or null if not found.

Parameters:
key - the cache key to look for
Returns:
the resource cached with the given cache key

getCachedResourceList

public java.util.List<CmsResource> getCachedResourceList(java.lang.String key)
Returns the resource list cached with the given cache key or null if not found.

Parameters:
key - the cache key to look for
Returns:
the resource list cached with the given cache key

getCachedRole

public java.lang.Boolean getCachedRole(java.lang.String key)
Returns the value cached with the given cache key or null if not found.

Parameters:
key - the cache key to look for
Returns:
if the user has the given role

getCachedRoleList

public java.util.List<CmsRole> getCachedRoleList(java.lang.String key)
Returns the value cached with the given cache key or null if not found.

Parameters:
key - the cache key to look for
Returns:
list of roles

getCachedUser

public CmsUser getCachedUser(java.lang.String key)
Returns the user cached with the given cache key or null if not found.

Parameters:
key - the cache key to look for, this may be the user's uuid or the fqn
Returns:
the user cached with the given cache key

getCachedUserGroups

public java.util.List<CmsGroup> getCachedUserGroups(java.lang.String key)
Returns the user groups list cached with the given cache key or null if not found.

Parameters:
key - the cache key to look for
Returns:
the user groups list cached with the given cache key

getCachedVfsObject

public java.lang.Object getCachedVfsObject(java.lang.String key)
Returns the vfs object cached with the given cache key or null if not found.

Parameters:
key - the cache key to look for
Returns:
the vfs object cached with the given cache key

getCachedXmlPermanentEntity

public byte[] getCachedXmlPermanentEntity(java.lang.String systemId)
Returns the xml permanent entity content cached with the given systemId or null if not found.

Parameters:
systemId - the cache key to look for
Returns:
the xml permanent entity content cached with the given cache key

getCachedXmlTemporaryEntity

public byte[] getCachedXmlTemporaryEntity(java.lang.String key)
Returns the xml temporary entity content cached with the given cache key or null if not found.

Parameters:
key - the cache key to look for
Returns:
the xml temporary entity content cached with the given cache key

getConfiguration

public CmsMemoryMonitorConfiguration getConfiguration()
Returns the configuration.

Returns:
the configuration

getFirstCachedPublishJob

public CmsPublishJobInfoBean getFirstCachedPublishJob()
Returns the next publish job from the publish job queue.

Returns:
the next publish job

getLogCount

public int getLogCount()
Returns the log count.

Returns:
the log count

initialize

public void initialize(CmsSystemConfiguration configuration)
Initializes the monitor with the provided configuration.

Parameters:
configuration - the configuration to use

isCacheProperty

@Deprecated
public boolean isCacheProperty()
Deprecated. use isEnabled(CacheType) instead

Checks if the property cache is enabled.

Returns:
true if the property cache is enabled

isCachePropertyList

@Deprecated
public boolean isCachePropertyList()
Deprecated. use isEnabled(CacheType) instead

Checks if the property list cache is enabled.

Returns:
true if the property list cache is enabled

isCacheResource

@Deprecated
public boolean isCacheResource()
Deprecated. use isEnabled(CacheType) instead

Checks if the resource cache is enabled.

Returns:
true if the resource cache is enabled

isCacheResourceList

@Deprecated
public boolean isCacheResourceList()
Deprecated. use isEnabled(CacheType) instead

Checks if the resource list cache is enabled.

Returns:
true if the resource list cache is enabled

isEnabled

public boolean isEnabled(CmsMemoryMonitor.CacheType type)
Checks if the given cache is enabled.

Parameters:
type - the cache type to check
Returns:
true if the given cache is enabled

isMonitoring

public boolean isMonitoring(java.lang.String key)
Checks if there is a registered monitored object with the given key.

Parameters:
key - the key to look for
Returns:
true if there is a registered monitored object with the given key

launch

public java.lang.String launch(CmsObject cms,
                               java.util.Map parameters)
                        throws java.lang.Exception
Description copied from interface: I_CmsScheduledJob
This method will be called when this scheduled job is executed.

Depending on the configuration of this job, a new instance of the configured class will be instantiated every time the job is launched, or a new instance will be generated only the first time the job is launched, and re-used afterwards.

The result String will be written to the OpenCms logfile in the org.opencms.scheduler.CmsScheduleManager channel, on INFO log level.

Specified by:
launch in interface I_CmsScheduledJob
Parameters:
cms - will be initialized with the configured users cms context
parameters - the configured parameters
Returns:
a String that will be written to the OpenCms logfile
Throws:
java.lang.Exception - if something goes wrong
See Also:
I_CmsScheduledJob.launch(CmsObject, Map)

lowMemory

public boolean lowMemory()
Returns true if the system runs low on memory.

Returns:
true if the system runs low on memory

register

public void register(java.lang.String objectName,
                     java.lang.Object object)
Adds a new object to the monitor.

Parameters:
objectName - name of the object
object - the object for monitoring

requiresPersistency

public boolean requiresPersistency()
Checks if some kind of persistence is required.

This could be overwritten in a distributed environment.

Returns:
true if some kind of persistence is required

setCacheProperty

@Deprecated
public void setCacheProperty(boolean cacheProperty)
Deprecated. use enableCache(CacheType[]) or disableCache(CacheType[]) instead

Sets if the property cache is enabled.

Parameters:
cacheProperty - if the property cache is enabled

setCachePropertyList

@Deprecated
public void setCachePropertyList(boolean cachePropertyList)
Deprecated. use enableCache(CacheType[]) or disableCache(CacheType[]) instead

Sets if the property list cache is enabled.

Parameters:
cachePropertyList - if the property list cache is enabled

setCacheResource

@Deprecated
public void setCacheResource(boolean cacheResource)
Deprecated. use enableCache(CacheType[]) or disableCache(CacheType[]) instead

Sets if the resource cache is enabled.

Parameters:
cacheResource - if the resource cache is enabled

setCacheResourceList

@Deprecated
public void setCacheResourceList(boolean cacheResourceList)
Deprecated. use enableCache(CacheType[]) or disableCache(CacheType[]) instead

Sets if the resource list cache is enabled.

Parameters:
cacheResourceList - if the resource list cache is enabled

shutdown

public void shutdown()
              throws java.lang.Exception
Flushes all cached objects.

Throws:
java.lang.Exception - if something goes wrong

uncacheContentDefinition

public void uncacheContentDefinition(java.lang.String key)
Removes the given xml content definition from the cache.

Parameters:
key - the cache key to remove from cache

uncacheGroup

public void uncacheGroup(CmsGroup group)
Removes the given group from the cache.

The group is removed by name AND also by uuid.

Parameters:
group - the group to remove from cache

uncacheLock

public void uncacheLock(java.lang.String rootPath)
Removes the cached lock for the given root path from the cache.

Parameters:
rootPath - the root path of the lock to remove from cache

uncacheOrgUnit

public void uncacheOrgUnit(CmsOrganizationalUnit orgUnit)
Removes the given organizational unit from the cache.

The organizational unit is removed by name AND also by uuid.

Parameters:
orgUnit - the organizational unit to remove from cache

uncacheProject

public void uncacheProject(CmsProject project)
Removes the given project from the cache.

The project is removed by name AND also by uuid.

Parameters:
project - the project to remove from cache

uncachePublishJob

public void uncachePublishJob(CmsPublishJobInfoBean publishJob)
Removes the given publish job from the cache.

Parameters:
publishJob - the publish job to remove

uncachePublishJobInHistory

public void uncachePublishJobInHistory(CmsPublishJobInfoBean publishJob)
Removes the given publish job from the history.

Parameters:
publishJob - the publish job to remove

uncacheUser

public void uncacheUser(CmsUser user)
Removes the given user from the cache.

The user is removed by name AND also by uuid.

Parameters:
user - the user to remove from cache

uncacheVfsObject

public void uncacheVfsObject(java.lang.String key)
Removes the given vfs object from the cache.

Parameters:
key - the cache key to remove from cache

uncacheXmlTemporaryEntity

public void uncacheXmlTemporaryEntity(java.lang.String key)
Removes the given xml temporary entity from the cache.

Parameters:
key - the cache key to remove from cache

clearCaches

protected void clearCaches()
Clears the OpenCms caches.


getCosts

protected long getCosts(java.lang.Object obj)
Returns the cache costs of a monitored object.

obj must be of type CmsLruCache.

Parameters:
obj - the object
Returns:
the cache costs or "-"

getItems

protected java.lang.String getItems(java.lang.Object obj)
Returns the number of items within a monitored object.

obj must be of type CmsLruCache or Map.

Parameters:
obj - the object
Returns:
the number of items or "-"

getKeySize

protected long getKeySize(java.util.Map<?,?> map,
                          int depth)
Returns the total size of key strings within a monitored map.

The keys must be of type String.

Parameters:
map - the map
depth - the max recursion depth for calculation the size
Returns:
total size of key strings

getKeySize

protected long getKeySize(java.lang.Object obj)
Returns the total size of key strings within a monitored object.

obj must be of type Map, the keys must be of type String.

Parameters:
obj - the object
Returns:
the total size of key strings

getLimit

protected java.lang.String getLimit(java.lang.Object obj)
Returns the max costs for all items within a monitored object.

obj must be of type CmsLruCache or LRUMap.

Parameters:
obj - the object
Returns:
max cost limit or "-"

monitorSendEmail

protected void monitorSendEmail(boolean warning)
Sends a warning or status email with OpenCms Memory information.

Parameters:
warning - if true, send a memory warning email

monitorWriteLog

protected void monitorWriteLog(boolean warning)
Write a warning or status log entry with OpenCms Memory information.

Parameters:
warning - if true, write a memory warning log entry

updateStatus

protected void updateStatus()
Updates the memory information of the memory monitor.