Search in sources :

Example 6 with WrappingRuntimeException

use of org.apache.flink.util.WrappingRuntimeException in project flink by apache.

the class StreamExecutionEnvironment method registerCustomListeners.

private void registerCustomListeners(final ClassLoader classLoader, final List<String> listeners) {
    for (String listener : listeners) {
        try {
            final JobListener jobListener = InstantiationUtil.instantiate(listener, JobListener.class, classLoader);
            jobListeners.add(jobListener);
        } catch (FlinkException e) {
            throw new WrappingRuntimeException("Could not load JobListener : " + listener, e);
        }
    }
}
Also used : WrappingRuntimeException(org.apache.flink.util.WrappingRuntimeException) JobListener(org.apache.flink.core.execution.JobListener) FlinkException(org.apache.flink.util.FlinkException)

Example 7 with WrappingRuntimeException

use of org.apache.flink.util.WrappingRuntimeException in project flink by apache.

the class GlueSchemaRegistryAvroSerializationSchema method serialize.

/**
 * Serializes the incoming element to a byte array containing bytes of AWS Glue Schema registry
 * information.
 *
 * @param object The incoming element to be serialized
 * @return The serialized bytes.
 */
@Override
public byte[] serialize(T object) {
    checkAvroInitialized();
    if (object == null) {
        return null;
    } else {
        try {
            ByteArrayOutputStream outputStream = getOutputStream();
            outputStream.reset();
            Encoder encoder = getEncoder();
            getDatumWriter().write(object, encoder);
            schemaCoder.writeSchema(getSchema(), outputStream);
            encoder.flush();
            return outputStream.toByteArray();
        } catch (IOException e) {
            throw new WrappingRuntimeException("Failed to serialize schema registry.", e);
        }
    }
}
Also used : WrappingRuntimeException(org.apache.flink.util.WrappingRuntimeException) Encoder(org.apache.avro.io.Encoder) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Example 8 with WrappingRuntimeException

use of org.apache.flink.util.WrappingRuntimeException in project flink by apache.

the class AvroSerializationSchema method serialize.

@Override
public byte[] serialize(T object) {
    checkAvroInitialized();
    if (object == null) {
        return null;
    } else {
        try {
            datumWriter.write(object, encoder);
            encoder.flush();
            byte[] bytes = arrayOutputStream.toByteArray();
            arrayOutputStream.reset();
            return bytes;
        } catch (IOException e) {
            throw new WrappingRuntimeException("Failed to serialize schema registry.", e);
        }
    }
}
Also used : WrappingRuntimeException(org.apache.flink.util.WrappingRuntimeException) IOException(java.io.IOException)

Example 9 with WrappingRuntimeException

use of org.apache.flink.util.WrappingRuntimeException in project flink by apache.

the class ExecutionEnvironment method registerCustomListeners.

private void registerCustomListeners(final ClassLoader classLoader, final List<String> listeners) {
    for (String listener : listeners) {
        try {
            final JobListener jobListener = InstantiationUtil.instantiate(listener, JobListener.class, classLoader);
            jobListeners.add(jobListener);
        } catch (FlinkException e) {
            throw new WrappingRuntimeException("Could not load JobListener : " + listener, e);
        }
    }
}
Also used : WrappingRuntimeException(org.apache.flink.util.WrappingRuntimeException) JobListener(org.apache.flink.core.execution.JobListener) FlinkException(org.apache.flink.util.FlinkException)

Aggregations

WrappingRuntimeException (org.apache.flink.util.WrappingRuntimeException)9 IOException (java.io.IOException)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Encoder (org.apache.avro.io.Encoder)2 JobListener (org.apache.flink.core.execution.JobListener)2 FlinkException (org.apache.flink.util.FlinkException)2 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 TypeInformation (org.apache.flink.api.common.typeinfo.TypeInformation)1 RowTypeInfo (org.apache.flink.api.java.typeutils.RowTypeInfo)1 Configuration (org.apache.flink.configuration.Configuration)1 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)1 GenericInMemoryCatalog (org.apache.flink.table.catalog.GenericInMemoryCatalog)1 ObjectPath (org.apache.flink.table.catalog.ObjectPath)1 StreamTableSource (org.apache.flink.table.sources.StreamTableSource)1 Row (org.apache.flink.types.Row)1