public IPolicyExecutor[] createExecutors(Config config, List<String> streamNames, String executorId) throws Exception { StringBuilder partitionerCls = new StringBuilder(DefaultPolicyPartitioner.class.getCanonicalName()); int numPartitions = loadExecutorConfig(config, executorId, partitionerCls); PolicyDefinitionDAO<AggregateDefinitionAPIEntity> policyDefDao = new PolicyDefinitionEntityDAOImpl<>( new EagleServiceConnector(config), Constants.AGGREGATE_DEFINITION_SERVICE_ENDPOINT_NAME); return newAggregateExecutors(policyDefDao, streamNames, executorId, numPartitions, partitionerCls.toString()); }
/** * Scan & Load Plugins */ private void loadPlugins(){ try { LOG.info("Start loading Plugins from eagle service ..."); AlertNotificationDAO dao = new AlertNotificationDAOImpl(new EagleServiceConnector(config)); List<AlertNotificationEntity> activeNotificationPlugins = dao.findAlertNotificationTypes(); for(AlertNotificationEntity plugin : activeNotificationPlugins){ notificationMapping.put(plugin.getTags().get(NotificationConstants.NOTIFICATION_TYPE), (NotificationPlugin) Class.forName(plugin.getClassName()).newInstance()); } LOG.info("successfully loaded Plugins from eagle service " + activeNotificationPlugins); }catch ( Exception ex ){ LOG.error("Error in loading Notification Plugins: ", ex); throw new IllegalStateException(ex); } }
private void internalInit(){ // iterate all policy ids, keep those notification which belong to plugins PolicyDefinitionDAO policyDefinitionDao = new PolicyDefinitionEntityDAOImpl(new EagleServiceConnector( config ) , Constants.ALERT_DEFINITION_SERVICE_ENDPOINT_NAME); String site = config.getString("eagleProps.site"); String application = config.getString("eagleProps.application"); try{ List<AlertDefinitionAPIEntity> activeAlertDefs = policyDefinitionDao.findActivePolicies( site , application); // initialize all loaded plugins NotificationPluginLoader.getInstance().init(config); for(NotificationPlugin plugin : NotificationPluginLoader.getInstance().getNotificationMapping().values()){ plugin.init(config, activeAlertDefs); } // build policy and plugin mapping for( AlertDefinitionAPIEntity entity : activeAlertDefs ){ Map<String, NotificationPlugin> plugins = pluginsForPolicy(entity); policyNotificationMapping.put(entity.getTags().get(Constants.POLICY_ID) , plugins.values()); } }catch (Exception ex ){ LOG.error("Error initializing policy/notification mapping ", ex); throw new IllegalStateException(ex); } }
list = new HdfsUserCommandPatternByFileImpl().findAllPatterns(); } else { list = new HdfsUserCommandPatternByDBImpl(new EagleServiceConnector(config)).findAllPatterns();