public void _updateDataSource(DataSourceVO<?> vo) { ejt.update( "update dataSources set xid=?, name=?, dataSourceType=?, data=? where id=?", new Object[] { vo.getXid(), vo.getName(), vo.getDefinition().getDataSourceTypeName(), SerializationHelper.writeObject(vo), vo.getId() }, new int[] {Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BLOB, Types.INTEGER}); }
private void insertDataSource(final DataSourceVO<?> vo) { vo.setId( doInsert( "insert into dataSources (xid, name, dataSourceType, data) values (?,?,?,?)", new Object[] { vo.getXid(), vo.getName(), vo.getDefinition().getDataSourceTypeName(), SerializationHelper.writeObject(vo) }, new int[] {Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BLOB})); AuditEventType.raiseAddedEvent(AuditEventType.TYPE_DATA_SOURCE, vo); }
// // Lifecycle public synchronized void initialize(boolean safe) { if (started) throw new ShouldNeverHappenException("RuntimeManager already started"); // Set the started indicator to true. started = true; // Get the RTM defs from modules List<RuntimeManagerDefinition> defs = ModuleRegistry.getDefinitions(RuntimeManagerDefinition.class); Collections.sort( defs, new Comparator<RuntimeManagerDefinition>() { @Override public int compare(RuntimeManagerDefinition def1, RuntimeManagerDefinition def2) { return def1.getInitializationPriority() - def2.getInitializationPriority(); } }); // Start everything with priority up to and including 4. int rtmdIndex = startRTMDefs(defs, safe, 0, 4); // Initialize data sources that are enabled. Start by organizing all enabled data sources by // start priority. DataSourceDao dataSourceDao = new DataSourceDao(); List<DataSourceVO<?>> configs = dataSourceDao.getDataSources(); Map<DataSourceDefinition.StartPriority, List<DataSourceVO<?>>> priorityMap = new HashMap<DataSourceDefinition.StartPriority, List<DataSourceVO<?>>>(); for (DataSourceVO<?> config : configs) { if (config.isEnabled()) { if (safe) { config.setEnabled(false); dataSourceDao.saveDataSource(config); } else if (config.getDefinition() != null) { List<DataSourceVO<?>> priorityList = priorityMap.get(config.getDefinition().getStartPriority()); if (priorityList == null) { priorityList = new ArrayList<DataSourceVO<?>>(); priorityMap.put(config.getDefinition().getStartPriority(), priorityList); } priorityList.add(config); } } } // Initialize the prioritized data sources. Start the polling later. List<DataSourceVO<?>> pollingRound = new ArrayList<DataSourceVO<?>>(); for (DataSourceDefinition.StartPriority startPriority : DataSourceDefinition.StartPriority.values()) { List<DataSourceVO<?>> priorityList = priorityMap.get(startPriority); if (priorityList != null) { for (DataSourceVO<?> config : priorityList) { if (initializeDataSource(config)) pollingRound.add(config); } } } // Tell the data sources to start polling. Delaying the polling start gives the data points a // chance to // initialize such that point listeners in meta points and set point handlers can run properly. for (DataSourceVO<?> config : pollingRound) startDataSourcePolling(config); // Run everything else. rtmdIndex = startRTMDefs(defs, safe, rtmdIndex, Integer.MAX_VALUE); // Start the publishers that are enabled PublisherDao publisherDao = new PublisherDao(); List<PublisherVO<? extends PublishedPointVO>> publishers = publisherDao.getPublishers(); for (PublisherVO<? extends PublishedPointVO> vo : publishers) { if (vo.isEnabled()) { if (safe) { vo.setEnabled(false); publisherDao.savePublisher(vo); } else startPublisher(vo); } } // Schedule the Backup Task if necessary // No way to set the default value for Bools in SystemSettingsDao so must do here if (SystemSettingsDao.getBooleanValue(SystemSettingsDao.BACKUP_ENABLED, true)) { BackupWorkItem.schedule(); } }