use of org.apache.flink.api.common.io.InitializeOnMaster in project flink by apache.
the class OutputFormatVertex method initializeOnMaster.
@Override
public void initializeOnMaster(ClassLoader loader) throws Exception {
final TaskConfig cfg = new TaskConfig(getConfiguration());
UserCodeWrapper<OutputFormat<?>> wrapper;
try {
wrapper = cfg.<OutputFormat<?>>getStubWrapper(loader);
} catch (Throwable t) {
throw new Exception("Deserializing the OutputFormat (" + formatDescription + ") failed: " + t.getMessage(), t);
}
if (wrapper == null) {
throw new Exception("No input format present in InputFormatVertex's task configuration.");
}
OutputFormat<?> outputFormat;
try {
outputFormat = wrapper.getUserCodeObject(OutputFormat.class, loader);
} catch (Throwable t) {
throw new Exception("Instantiating the OutputFormat (" + formatDescription + ") failed: " + t.getMessage(), t);
}
try {
outputFormat.configure(cfg.getStubParameters());
} catch (Throwable t) {
throw new Exception("Configuring the OutputFormat (" + formatDescription + ") failed: " + t.getMessage(), t);
}
if (outputFormat instanceof InitializeOnMaster) {
((InitializeOnMaster) outputFormat).initializeGlobal(getParallelism());
}
}
Aggregations