Search in sources :

Example 1 with ProcessorWrapper

use of com.hazelcast.jet.impl.processor.ProcessorWrapper in project hazelcast by hazelcast.

the class ProcessorTasklet method init.

@Override
public void init() {
    ManagedContext managedContext = serializationService.getManagedContext();
    if (managedContext != null) {
        Processor toInit = processor instanceof ProcessorWrapper ? ((ProcessorWrapper) processor).getWrapped() : processor;
        Object initialized = null;
        try {
            initialized = managedContext.initialize(toInit);
            toInit = (Processor) initialized;
        } catch (ClassCastException e) {
            throw new IllegalArgumentException(String.format("The initialized object(%s) should be an instance of %s", initialized, Processor.class), e);
        }
        if (processor instanceof ProcessorWrapper) {
            ((ProcessorWrapper) processor).setWrapped(toInit);
        } else {
            processor = toInit;
        }
    }
    try {
        doWithClassLoader(context.classLoader(), () -> processor.init(outbox, context));
    } catch (Exception e) {
        throw sneakyThrow(e);
    }
}
Also used : Processor(com.hazelcast.jet.core.Processor) ProcessorWrapper(com.hazelcast.jet.impl.processor.ProcessorWrapper) ManagedContext(com.hazelcast.core.ManagedContext) JetException(com.hazelcast.jet.JetException)

Aggregations

ManagedContext (com.hazelcast.core.ManagedContext)1 JetException (com.hazelcast.jet.JetException)1 Processor (com.hazelcast.jet.core.Processor)1 ProcessorWrapper (com.hazelcast.jet.impl.processor.ProcessorWrapper)1