public void renameSource(String name, String newName) throws Exception { boolean debug = log.isDebugEnabled(); if (debug) { log.debug(TextUtil.repeat("-", 70)); log.debug("Renaming source " + name + " to " + newName + "."); } Partition partition = getPartition(); boolean running = false; if (partition != null) { SourceManager sourceManager = partition.getSourceManager(); running = sourceManager.isRunning(name); if (running) sourceManager.stopSource(name); } removeSourceService(name); PartitionConfig partitionConfig = getPartitionConfig(); SourceConfigManager sourceConfigManager = partitionConfig.getSourceConfigManager(); sourceConfigManager.renameSourceConfig(name, newName); if (partition != null) { SourceManager sourceManager = partition.getSourceManager(); if (running) sourceManager.startSource(newName); } createSourceService(newName); }
public void destroy() throws Exception { SourceConfigManager sourceConfigManager = getSourceConfigManager(); for (String sourceName : sourceConfigManager.getSourceNames()) { removeSourceService(sourceName); } super.destroy(); }
public void init() throws Exception { super.init(); SourceConfigManager sourceConfigManager = getSourceConfigManager(); for (String sourceName : sourceConfigManager.getSourceNames()) { createSourceService(sourceName); } }
public Collection<String> getSourceNames() throws Exception { PartitionConfig partitionConfig = getPartitionConfig(); SourceConfigManager sourceConfigManager = partitionConfig.getSourceConfigManager(); Collection<String> list = new ArrayList<String>(); list.addAll(sourceConfigManager.getSourceNames()); return list; }
public void createSource(SourceConfig sourceConfig) throws Exception { String sourceName = sourceConfig.getName(); PartitionConfig partitionConfig = getPartitionConfig(); SourceConfigManager sourceConfigManager = partitionConfig.getSourceConfigManager(); sourceConfigManager.addSourceConfig(sourceConfig); Partition partition = getPartition(); if (partition != null) { SourceManager sourceManager = partition.getSourceManager(); sourceManager.startSource(sourceName); } createSourceService(sourceName); }
public void removeSource(String name) throws Exception { Partition partition = getPartition(); Directory directory = partition.getDirectory(); Collection<Entry> entries = directory.getEntriesBySourceName(name); if (entries != null && !entries.isEmpty()) { throw new Exception("Source " + name + " is in use."); } SourceManager sourceManager = partition.getSourceManager(); sourceManager.stopSource(name); SourceConfigManager sourceConfigManager = sourceManager.getSourceConfigManager(); sourceConfigManager.removeSourceConfig(name); removeSourceService(name); }
public void updateSource(String sourceName, SourceConfig sourceConfig) throws Exception { boolean debug = log.isDebugEnabled(); if (debug) { log.debug(TextUtil.repeat("-", 70)); log.debug("Updating source " + sourceName + "."); } Partition partition = getPartition(); if (partition == null) { PartitionConfig partitionConfig = getPartitionConfig(); SourceConfigManager sourceConfigManager = partitionConfig.getSourceConfigManager(); sourceConfigManager.updateSourceConfig(sourceConfig); } else { SourceManager sourceManager = partition.getSourceManager(); sourceManager.updateSource(sourceConfig); } /* Partition partition = getPartition(); boolean running = false; if (partition != null) { SourceManager sourceManager = partition.getSourceManager(); running = sourceManager.isRunning(sourceName); if (running) sourceManager.stopSource(sourceName); } PartitionConfig partitionConfig = getPartitionConfig(); SourceConfigManager sourceConfigManager = partitionConfig.getSourceConfigManager(); sourceConfigManager.updateSourceConfig(sourceConfig); if (partition != null) { SourceManager sourceManager = partition.getSourceManager(); if (running) sourceManager.startSource(sourceName); } */ }