コード例 #1
0
  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);
  }
コード例 #2
0
  public void destroy() throws Exception {
    SourceConfigManager sourceConfigManager = getSourceConfigManager();
    for (String sourceName : sourceConfigManager.getSourceNames()) {
      removeSourceService(sourceName);
    }

    super.destroy();
  }
コード例 #3
0
  public void init() throws Exception {

    super.init();

    SourceConfigManager sourceConfigManager = getSourceConfigManager();
    for (String sourceName : sourceConfigManager.getSourceNames()) {
      createSourceService(sourceName);
    }
  }
コード例 #4
0
  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;
  }
コード例 #5
0
  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);
  }
コード例 #6
0
  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);
  }
コード例 #7
0
  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);
            }
    */
  }