Exemplo n.º 1
0
  public ModuleRegistry moduleRegistry() {
    ModuleRegistry registry = mock(ModuleRegistry.class);
    Resource resource = mock(Resource.class);
    ArrayList<ModuleDefinition> definitions = new ArrayList<ModuleDefinition>();
    definitions.add(
        new ModuleDefinition(ModuleType.TAP.getTypeName(), ModuleType.TAP.getTypeName(), resource));
    when(registry.findDefinitions(ModuleType.TAP.getTypeName())).thenReturn(definitions);

    definitions = new ArrayList<ModuleDefinition>();
    definitions.add(
        new ModuleDefinition(
            ModuleType.SINK.getTypeName(), ModuleType.SINK.getTypeName(), resource));
    when(registry.findDefinitions("file")).thenReturn(definitions);

    when(registry.lookup("file", ModuleType.SINK.getTypeName()))
        .thenReturn(
            new ModuleDefinition(
                ModuleType.SINK.getTypeName(), ModuleType.SINK.getTypeName(), resource));
    when(registry.lookup("tap", ModuleType.SOURCE.getTypeName()))
        .thenReturn(
            new ModuleDefinition(
                ModuleType.SOURCE.getTypeName(), ModuleType.SOURCE.getTypeName(), resource));

    return registry;
  }
Exemplo n.º 2
0
  private ModuleType determineType(ModuleDeploymentRequest request, int lastIndex) {
    ModuleType moduleType = getNamedChannelModuleType(request, lastIndex);
    if (moduleType != null) {
      return moduleType;
    }
    String type = null;
    String name = request.getModule();
    int index = request.getIndex();
    List<ModuleDefinition> defs = moduleRegistry.findDefinitions(name);

    if (defs.size() == 0) {
      throw new RuntimeException("Module definition is missing for " + name);
    }
    if (defs.size() == 1) {
      type = defs.get(0).getType();
    }
    if (lastIndex == 0) {
      for (ModuleDefinition def : defs) {
        if (def.getType().equals(ModuleType.JOB.getTypeName())) {
          type = def.getType();
        }
      }
    } else if (index == 0) {
      type = ModuleType.SOURCE.getTypeName();
    } else if (index == lastIndex) {
      type = ModuleType.SINK.getTypeName();
    }
    if (type == null) {
      throw new NoSuchModuleException(name);
    }
    return verifyModuleOfTypeExists(request, name, type);
  }
Exemplo n.º 3
0
 private ModuleType getNamedChannelModuleType(ModuleDeploymentRequest request, int lastIndex) {
   String type = null;
   String moduleName = request.getModule();
   int index = request.getIndex();
   if (request.getSourceChannelName() != null) {
     if (index == lastIndex) {
       if (request.getSinkChannelName() != null) {
         type = ModuleType.PROCESSOR.getTypeName();
       } else {
         type = ModuleType.SINK.getTypeName();
       }
     } else {
       type = ModuleType.PROCESSOR.getTypeName();
     }
   } else if (request.getSinkChannelName() != null) {
     if (index == 0) {
       type = ModuleType.SOURCE.getTypeName();
     } else {
       type = ModuleType.PROCESSOR.getTypeName();
     }
   }
   return (type == null) ? null : verifyModuleOfTypeExists(request, moduleName, type);
 }