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 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 init() throws Exception { String name = triggerConfig.getName(); String s = triggerConfig.getParameter("dateFormat"); SimpleDateFormat dateFormat = s == null ? new SimpleDateFormat() : new SimpleDateFormat(s); log.debug("Date format: " + dateFormat.toPattern()); s = triggerConfig.getParameter("delay"); long delay = s == null ? 0 : Long.parseLong(s); log.debug("Delay: " + delay); s = triggerConfig.getParameter("startTime"); Date startTime = s == null ? new Date(System.currentTimeMillis() + delay * 1000) : dateFormat.parse(s); log.debug("Start time: " + startTime); s = triggerConfig.getParameter("endTime"); Date endTime = s == null ? null : dateFormat.parse(s); log.debug("End time: " + endTime); s = triggerConfig.getParameter("count"); Integer count = s == null ? null : Integer.parseInt(s); log.debug("Count: " + count); s = triggerConfig.getParameter("interval"); long interval = s == null ? 0 : Long.parseLong(s); log.debug("Interval: " + interval); Partition partition = triggerContext.getPartition(); org.quartz.SimpleTrigger simpleTrigger; if (count == null) { // schedule one execution simpleTrigger = new org.quartz.SimpleTrigger(name, partition.getName(), startTime); } else { // schedule multiple executions simpleTrigger = new org.quartz.SimpleTrigger( name, partition.getName(), startTime, endTime, count, interval * 1000); simpleTrigger.setMisfireInstruction( org.quartz.SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT); } quartzTrigger = simpleTrigger; }
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); } */ }
public Directory getDirectory() { Partition partition = getPartition(); if (partition == null) return null; return partition.getDirectory(); }
public SourceManager getSourceManager() { Partition partition = getPartition(); if (partition == null) return null; return partition.getSourceManager(); }