The life cycle of the temporary resource


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

You can set to use local storage temporary resources in the system configuration file ([SuperMap iServer installation directory]\webapps\iserver\WEB-INF\iserver-system.xml), including memory space threshold maxBytesOnHeapand disk space threshold maxBytesLocalDisk. The default value of maxBytesOnHeap is 100M, and the default value of maxBytesLocalDisk is 10G. You can set the space according to your requirements. The <diskStorePath> parameter can be added to set the storage path of the temporary resources in the disk. The default path is [SuperMap iServer Java installation directory]\temp\tmpResources. The algorithm to clear temporary resources can be set using the <memoryStoreEvictionPolicy> parameter. Besides, you can refer to EhcacheRepoSetting for more parameter settings.

  <!-- 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>  
  1. Memory space threshold

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.

  1. Second-level cache threshold on hard disk

To ensure the temporary resources life cycle, iServer 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.

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 iServer 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. If security control is enabled in MongoDB, you should add parameters of <username> and <password> for the database username and password. For detailed 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 iServer 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 iServer 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> 

In the <port> parameter, set the HSQLDB storage port. The default value is 10070. The <startServer> parameter indicates whether to start HSQLDB. When multiple iServer are started on one machine, simply set the parameter in one iServer to true.

Note:

The first type in the file will be used if multiple temporary resource storage methods are set in the configuration file.

 

Set time threshold value to live

No matter the temporary resource cache exist in memory or hard disk, it will be deleted when exceed certain time.

In SuperMap iServer Java 6R(2012) and the previous version, the life cycle of temporary child resources in some resources, such as tempLayersSet, trackingLayer, queryResults, is controlled by the holdTime parameter. The client or the users can set the survival time of the temporary child resources and the default is 15 minutes.

SuperMap iServer Java 6R(2012) SP2 and higher versions support the setting of interface configuration parameter defaultHoldTime in service configuration file iserver-services-interfaces.xml, used to set the default save time of the temporary resource (such as tempLayersSet, trackingLayer and queryResults), and the default is 7 days. It is effective for the survival time of all the temporary resource of the REST interface. The setting method is:

<interface class="com.supermap.services.rest.RestServlet" name="rest">
        <config class="com.supermap.services.rest.RestConfig">
                <accessControlAllowOrigin>*</accessControlAllowOrigin>
                <!--  rest resource default hold time, in minutes-->
                <defaultHoldTime>10080</defaultHoldTime>
        </config>
</interface>
<interface class="com.supermap.services.rest.JaxrsServletForJersey" name="restjsr">
        <config class="com.supermap.services.rest.JaxrsConfigForJersey">
                <accessControlAllowOrigin>*</accessControlAllowOrigin>
                <!--  rest resource default hold time, in minutes-->
                <defaultHoldTime>10080</defaultHoldTime>
        </config>
</interface>

Temporary Resource List

Resources created by POST request are temporary resources. They are shown as follows:

Module Temporary resource Description
map queryResult queryResults Resource POST operation result.
tempLayers tempLayersSet Resource POST operation result.
tempLayer tempLayersSet Resource POST operation result.
highlightTargetSet trackingLayer Resource POST operation result.
data featureResult featureResults Resource POST operation result.
coordtransferResult coordTransfer Resource POST operation result.
spatialAnalyst datasetBufferResult datasetBufferResults Resource POST operation result.
datasetOverlayResult datasetOverlayResults Resource POST operation result.
datasetIsolineResult datasetIsolineResults Resource POST operation result.
datasetIsoregionResult datasetIsoregionResults Resource POST operation result.
interpolationIDWResult interpolationIDW Resource POST operation result.
interpolationDensityResult interpolationDensity Resource POST operation result.
interpolationRBFResult interpolationRBF Resource POST operation result.
interpolationKrigingResult interpolationKriging Resource POST operation result.
spatialDataResult generateSpatialData Resource POST operation result.
datasetGeorelationResult datasetGeorelationResults Resource POST operation result.
datasetThiessenPolygenResult datasetThiessenPolygenResults Resource POST operation result.
geometryBufferResult geometryBufferResults Resource POST operation result.
geometryOverlayResult geometryOverlayResults Resource POST operation result.
geometryIsolineResult geometryIsolineResults Resource POST operation result.
geometryIsoregionResult geometryIsoregionResults Resource POST operation result.