Search in sources :

Example 1 with ProgramRuntimeProvider

use of io.cdap.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(io.cdap.cdap.app.runtime.ProgramRuntimeProvider) ImmutableSet(com.google.common.collect.ImmutableSet) ProgramType(io.cdap.cdap.proto.ProgramType)

Example 2 with ProgramRuntimeProvider

use of io.cdap.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);
    ProgramRunner runner;
    if (provider != null) {
        LOG.trace("Using runtime provider {} for program type {}", provider, programType);
        runner = provider.createProgramRunner(programType, mode, injector);
    } else {
        Provider<ProgramRunner> defaultProvider = defaultRunnerProviders.get(programType);
        if (defaultProvider == null) {
            throw new IllegalArgumentException("Unsupported program type: " + programType);
        }
        runner = defaultProvider.get();
    }
    // In distributed mode, program state changes are recorded in the event handler by Twill AM.
    return (mode == ProgramRuntimeProvider.Mode.LOCAL || publishProgramState) ? wrapProgramRunner(runner) : runner;
}
Also used : ProgramRuntimeProvider(io.cdap.cdap.app.runtime.ProgramRuntimeProvider) ProgramRunner(io.cdap.cdap.app.runtime.ProgramRunner)

Aggregations

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