Search in sources :

Example 1 with ProgramRuntimeProvider

use of co.cask.cdap.app.runtime.ProgramRuntimeProvider in project cdap by caskdata.

the class ProgramRuntimeProviderLoader method getSupportedTypesForProvider.

@Override
public Set<ProgramType> getSupportedTypesForProvider(ProgramRuntimeProvider programRuntimeProvider) {
    // See if the provide supports the required program type
    ProgramRuntimeProvider.SupportedProgramType supportedTypes = programRuntimeProvider.getClass().getAnnotation(ProgramRuntimeProvider.SupportedProgramType.class);
    ImmutableSet.Builder<ProgramType> types = ImmutableSet.builder();
    for (ProgramType programType : supportedTypes.value()) {
        if (programRuntimeProvider.isSupported(programType, cConf)) {
            types.add(programType);
        }
    }
    return types.build();
}
Also used : ProgramRuntimeProvider(co.cask.cdap.app.runtime.ProgramRuntimeProvider) ImmutableSet(com.google.common.collect.ImmutableSet) ProgramType(co.cask.cdap.proto.ProgramType)

Example 2 with ProgramRuntimeProvider

use of co.cask.cdap.app.runtime.ProgramRuntimeProvider in project cdap by caskdata.

the class DefaultProgramRunnerFactory method create.

@Override
public ProgramRunner create(ProgramType programType) {
    ProgramRuntimeProvider provider = runtimeProviderLoader.get(programType);
    if (provider != null) {
        LOG.debug("Using runtime provider {} for program type {}", provider, programType);
        return provider.createProgramRunner(programType, mode, injector);
    }
    Provider<ProgramRunner> defaultProvider = defaultRunnerProviders.get(programType);
    if (defaultProvider == null) {
        throw new IllegalArgumentException("Unsupported program type: " + programType);
    }
    return defaultProvider.get();
}
Also used : ProgramRuntimeProvider(co.cask.cdap.app.runtime.ProgramRuntimeProvider) ProgramRunner(co.cask.cdap.app.runtime.ProgramRunner)

Aggregations

ProgramRuntimeProvider (co.cask.cdap.app.runtime.ProgramRuntimeProvider)2 ProgramRunner (co.cask.cdap.app.runtime.ProgramRunner)1 ProgramType (co.cask.cdap.proto.ProgramType)1 ImmutableSet (com.google.common.collect.ImmutableSet)1