Move executor pool to the DeviceManagementDataHolder

revert-70ac1926
Pahansith 4 years ago
parent 2fa4a6167e
commit 9ef6cfc1e6

@ -33,6 +33,7 @@ import org.wso2.carbon.device.mgt.core.dao.EventConfigDAO;
import org.wso2.carbon.device.mgt.core.dao.EventManagementDAOException;
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.core.geo.task.GeoFenceEventOperationManager;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import java.sql.SQLException;
import java.util.ArrayList;
@ -49,8 +50,6 @@ public class EventConfigurationProviderServiceImpl implements EventConfiguration
public EventConfigurationProviderServiceImpl() {
eventConfigDAO = DeviceManagementDAOFactory.getEventConfigDAO();
EventOperationTaskConfiguration eventConfig = DeviceConfigurationManager.getInstance()
.getDeviceManagementConfig().getEventOperationTaskConfiguration();
}
@Override
@ -249,7 +248,6 @@ public class EventConfigurationProviderServiceImpl implements EventConfiguration
List<Integer> groupIds) {
GeoFenceEventOperationManager geoFenceEventOperationManager = new GeoFenceEventOperationManager(eventType, tenantId, null);
EventOperationExecutor executor = geoFenceEventOperationManager.getEventOperationExecutor(groupIds, eventMeta);
ExecutorService executorService = Executors.newFixedThreadPool(50);
executorService.submit(executor);
DeviceManagementDataHolder.getInstance().getEventConfigExecutors().submit(executor);
}
}

@ -21,8 +21,6 @@ package org.wso2.carbon.device.mgt.core.event.config;
import com.google.gson.Gson;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.json.JSONObject;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
@ -36,30 +34,23 @@ import org.wso2.carbon.device.mgt.common.exceptions.InvalidDeviceException;
import org.wso2.carbon.device.mgt.common.geo.service.GeoFenceEventMeta;
import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationBasedServiceException;
import org.wso2.carbon.device.mgt.common.geo.service.GeoLocationProviderService;
import org.wso2.carbon.device.mgt.common.geo.service.GeofenceData;
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.dao.EventConfigDAO;
import org.wso2.carbon.device.mgt.core.dao.EventManagementDAOException;
import org.wso2.carbon.device.mgt.core.dao.GeofenceDAO;
import org.wso2.carbon.device.mgt.core.geo.task.EventCreateCallback;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationMgtConstants;
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**

@ -50,6 +50,7 @@ import org.wso2.carbon.utils.ConfigurationContextService;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutorService;
public class DeviceManagementDataHolder {
@ -79,6 +80,7 @@ public class DeviceManagementDataHolder {
private EventConfigurationProviderService eventConfigurationService;
private GeoLocationProviderService geoLocationProviderService;
private GeoFenceEventOperationManager geoFenceEventOperationManager;
private ExecutorService eventConfigExecutors;
private final Map<DeviceType, DeviceStatusTaskPluginConfig> deviceStatusTaskPluginConfigs = Collections.synchronizedMap(
new HashMap<>());
@ -328,4 +330,12 @@ public class DeviceManagementDataHolder {
public void setGeoFenceEventOperationManager(GeoFenceEventOperationManager geoFenceEventOperationManager) {
this.geoFenceEventOperationManager = geoFenceEventOperationManager;
}
public ExecutorService getEventConfigExecutors() {
return eventConfigExecutors;
}
public void setEventConfigExecutors(ExecutorService eventConfigExecutors) {
this.eventConfigExecutors = eventConfigExecutors;
}
}

@ -89,6 +89,7 @@ import org.wso2.carbon.utils.ConfigurationContextService;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@ -372,6 +373,9 @@ public class DeviceManagementServiceComponent {
DeviceManagementDataHolder.getInstance().setDeviceInformationManager(deviceInformationManager);
bundleContext.registerService(SearchManagerService.class, new SearchManagerServiceImpl(), null);
ExecutorService executorService = Executors.newFixedThreadPool(50);
DeviceManagementDataHolder.getInstance().setEventConfigExecutors(executorService);
}
private void setupDeviceManagementSchema(DataSourceConfig config) throws DeviceManagementException {

@ -1068,9 +1068,11 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
GeoFenceEventOperationManager eventManager = new GeoFenceEventOperationManager(eventOperationCode, tenantId, null);
GroupAssignmentEventOperationExecutor eventOperationExecutor = eventManager
.getGroupAssignmentEventExecutor(groupId, deviceIdentifiers);
ExecutorService executorService = Executors.newFixedThreadPool(50);
if (eventOperationExecutor != null) {
executorService.submit(eventOperationExecutor);
ExecutorService eventConfigExecutors = DeviceManagementDataHolder.getInstance().getEventConfigExecutors();
if (eventConfigExecutors != null) {
eventConfigExecutors.submit(eventOperationExecutor);
}
} else {
if (log.isDebugEnabled()) {
log.debug("Ignoring event creation since not enabled. Tenant id: " + tenantId + " Group Id: " + groupId);

Loading…
Cancel
Save