The management of the temporary resource life cycle takes the following measures: Extend the resource life cycle as long as possible in terms of limited server memory and disk space size; Or place the temporary resources into MongoDB.
In addition, after restart the service, the temporary resources in the local server will be cleaned.
- Use local to store temporary resources
- Use MongoDB to store temporary resources
- Use HSQLDB to store temporary resources
Use local to store temporary resources
You can set to use local storage temporary resources in the system configuration file ([SuperMap iPortal installation directory]\webapps\iportal\WEB-INF\iserver-system.xml),
- <maxBytesOnHeap>:memory space threshold maxBytesOnHeap, default:100M, You can set the space according to your requirements. You need to set an appropriate threshold for memory space, as too large memory space for temporary resources result in the efficiency of the server, though the temporary resources stored in memory will enhance their reading/writing efficiency. The server will adopt LRU (Least Recently Used) algorithm to process temporary resources when the temporary resources over occupy its memory space threshold. In other words, the rarely used temporary resources will be deleted. The LRU algorithm is the default algorithm to clear temporary resources. You can set using the <memoryStoreEvictionPolicy> parameter.
- <maxBytesLocalDisk>:Disk space threshold maxBytesLocalDisk, default: 10G. You can set the space according to your requirements.
- <diskStorePath>:set the storage path of the temporary resources in the disk. The default path is [SuperMap iPortal Java installation directory]\temp\tmpResources.The algorithm to clear temporary resources can be set using the <memoryStoreEvictionPolicy> parameter.To ensure the temporary resources life cycle, iPortal supports storing temporary resources on the hard disk, as the memory space is limited. The client side will search the resources from hard disk if it cannot find them from the memory. Those temporary resources affect the efficiency of the server, too, if too many resources are cached on the hard disk. So, you need to set a threshold for the hard disk. The system will clean the caches when the occupied resources take up over-threshold space. The LRU algorithm will also be used to clean those caches.
For more parameter settings, please see EhcacheRepoSetting.
<!-- Storage configure of temporary resources--> <repository class="com.supermap.services.rest.repository.EhcacheRepoProvider" name="localRepository"> <!-- Temporary resources are stored in local side. --> <config class="com.supermap.services.rest.repository.EhcacheRepoSetting"> <!--Max memory size for occupation--> <maxBytesOnHeap>100m</maxBytesOnHeap> <!--Max hard disk that allows to occupy--> <maxBytesLocalDisk>10g</maxBytesLocalDisk> <!-- Disk storage path --> <diskStorePath>D:\SuperMapiServer8C\temp\tmpResources</diskStorePath> <!-- Algorithm for cleaning temporary resources --> <memoryStoreEvictionPolicy>LRU</memoryStoreEvictionPolicy> <!--Scan storage data to check whether it is expired or not, in seconds--> <diskExpiryThreadIntervalSeconds>120</diskExpiryThreadIntervalSeconds> </config> </repository>
Use MongoDB to store temporary resources
Because the resource storage space of the local storage temporary resource is limited, the survival time is restricted. SuperMap iPortal supports the use of MongDB to store temporary resources, which can effectively prolong the lifetime of temporary resources. In addition, MongoDB can be used for temporary resource storage in a multiple-process mode, enabling resources to be shared among processes.
The way of storing temporary resources using MongoDB: in the system configure file, start "Temporary resource configure on the basis of MongoDB", and mark it as local storage configure. It is shown as follows:
<!-- Temporary resource configure on the basis of MongoDB --> <repository class="com.supermap.services.rest.repository.MongoDBRepoProvider" name="mongoRepository"> <config class="com.supermap.services.rest.repository.MongoDBRepoSetting"> <host>localhost</host> <port>27017</port> </config> </repository>
For the host parameter, you should input MongoDB service URl you use, and input port number in the port parameter.
- <host>: MongoDB service URl you use.
- <port>: Port number.
- <dbName>: Database name.
- <username> and <password>: If security control is enabled in MongoDB, you should add parameters of and for the database username and password.
For more parameter settings, please see MongoDBRepoSetting.
Use HSQLDB to store temporary resources
In multiple-process mode, HSQLDB will be employed to store temporary resource by default if there is no temporary resource storage configuration in the iPortal system configuration file, or the specified temporary resource storage configuration (such as local storage) does not supported multiple-process mode. In single process mode, you can also configure and use HSQLDB storage to allow multiple iPortal in the same machine to share temporary resources.
The way of storing temporary resources using HSQLDB: in the system configure file, start "Temporary resource configure on the basis of HSQLDB", and comment it as local storage configuration. It is shown as follows:
<!-- Temporary resource configure on the basis of HSQLDB --> <repository class="com.supermap.services.rest.repository.HsqldbRepoProvider" name="localRepository"> <config class="com.supermap.services.rest.repository.HsqldbRepoSetting"> <port>10070</port> <startServer>true</startServer> </config> </repository>
- <port>: set the HSQLDB storage port. The default value is 10070.
- <startServer>: whether to start HSQLDB. When multiple iPortal are started on one machine, simply set the parameter in one iPortal to true.
Note: The first type in the file will be used if multiple temporary resource storage methods are set in the configuration file.