| package org.apache.airavata.k8s.task.api; |
| |
| import org.apache.kafka.common.serialization.Serializer; |
| |
| import java.io.ByteArrayOutputStream; |
| import java.io.IOException; |
| import java.io.ObjectOutput; |
| import java.io.ObjectOutputStream; |
| import java.util.Map; |
| |
| /** |
| * TODO: Class level comments please |
| * |
| * @author dimuthu |
| * @since 1.0.0-SNAPSHOT |
| */ |
| public class TaskContextSerializer implements Serializer<TaskContext> { |
| @Override |
| public void configure(Map<String, ?> configs, boolean isKey) { |
| |
| } |
| |
| @Override |
| public byte[] serialize(String topic, TaskContext data) { |
| ByteArrayOutputStream bos = new ByteArrayOutputStream(); |
| ObjectOutput out = null; |
| try { |
| out = new ObjectOutputStream(bos); |
| out.writeObject(data); |
| out.flush(); |
| return bos.toByteArray(); |
| } catch (IOException e) { |
| // ignore catch |
| } finally { |
| try { |
| bos.close(); |
| } catch (IOException ex) { |
| // ignore close exception |
| } |
| } |
| return null; |
| } |
| |
| @Override |
| public void close() { |
| |
| } |
| } |