|
|
@ -21,6 +21,7 @@ import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.w3c.dom.Document;
|
|
|
|
import org.w3c.dom.Document;
|
|
|
|
import org.wso2.carbon.base.MultitenantConstants;
|
|
|
|
import org.wso2.carbon.base.MultitenantConstants;
|
|
|
|
|
|
|
|
import org.wso2.carbon.caching.impl.CacheImpl;
|
|
|
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|
|
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|
|
|
import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService;
|
|
|
|
import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService;
|
|
|
|
import org.wso2.carbon.device.mgt.common.Device;
|
|
|
|
import org.wso2.carbon.device.mgt.common.Device;
|
|
|
@ -492,6 +493,7 @@ public final class DeviceManagerUtil {
|
|
|
|
public static void initializeDeviceCache() {
|
|
|
|
public static void initializeDeviceCache() {
|
|
|
|
DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
|
|
|
|
DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
|
|
|
|
int deviceCacheExpiry = config.getDeviceCacheConfiguration().getExpiryTime();
|
|
|
|
int deviceCacheExpiry = config.getDeviceCacheConfiguration().getExpiryTime();
|
|
|
|
|
|
|
|
long deviceCacheCapacity = config.getDeviceCacheConfiguration().getCapacity();
|
|
|
|
CacheManager manager = getCacheManager();
|
|
|
|
CacheManager manager = getCacheManager();
|
|
|
|
if (config.getDeviceCacheConfiguration().isEnabled()) {
|
|
|
|
if (config.getDeviceCacheConfiguration().isEnabled()) {
|
|
|
|
if(!isDeviceCacheInitialized) {
|
|
|
|
if(!isDeviceCacheInitialized) {
|
|
|
@ -502,6 +504,10 @@ public final class DeviceManagerUtil {
|
|
|
|
setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration(TimeUnit.SECONDS,
|
|
|
|
setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration(TimeUnit.SECONDS,
|
|
|
|
deviceCacheExpiry)).setExpiry(CacheConfiguration.ExpiryType.ACCESSED, new CacheConfiguration.
|
|
|
|
deviceCacheExpiry)).setExpiry(CacheConfiguration.ExpiryType.ACCESSED, new CacheConfiguration.
|
|
|
|
Duration(TimeUnit.SECONDS, deviceCacheExpiry)).setStoreByValue(true).build();
|
|
|
|
Duration(TimeUnit.SECONDS, deviceCacheExpiry)).setStoreByValue(true).build();
|
|
|
|
|
|
|
|
if(deviceCacheCapacity > 0 ) {
|
|
|
|
|
|
|
|
((CacheImpl)(manager.<DeviceCacheKey, Device>getCache(DeviceManagementConstants.DEVICE_CACHE))).
|
|
|
|
|
|
|
|
setCapacity(deviceCacheCapacity);
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
manager.<DeviceCacheKey, Device>getCache(DeviceManagementConstants.DEVICE_CACHE);
|
|
|
|
manager.<DeviceCacheKey, Device>getCache(DeviceManagementConstants.DEVICE_CACHE);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -512,6 +518,8 @@ public final class DeviceManagerUtil {
|
|
|
|
setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration(TimeUnit.SECONDS,
|
|
|
|
setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration(TimeUnit.SECONDS,
|
|
|
|
deviceCacheExpiry)).setExpiry(CacheConfiguration.ExpiryType.ACCESSED, new CacheConfiguration.
|
|
|
|
deviceCacheExpiry)).setExpiry(CacheConfiguration.ExpiryType.ACCESSED, new CacheConfiguration.
|
|
|
|
Duration(TimeUnit.SECONDS, deviceCacheExpiry)).setStoreByValue(true).build();
|
|
|
|
Duration(TimeUnit.SECONDS, deviceCacheExpiry)).setStoreByValue(true).build();
|
|
|
|
|
|
|
|
((CacheImpl)(manager.<DeviceCacheKey, Device>getCache(DeviceManagementConstants.DEVICE_CACHE))).
|
|
|
|
|
|
|
|
setCapacity(deviceCacheCapacity);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Caching.getCacheManager().<DeviceCacheKey, Device>getCache(DeviceManagementConstants.DEVICE_CACHE);
|
|
|
|
Caching.getCacheManager().<DeviceCacheKey, Device>getCache(DeviceManagementConstants.DEVICE_CACHE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|