/** * Creates an instance of the pluggable SerializationDelegate or falls back to DefaultSerializationDelegate if something goes wrong. * * @param topoConf The config from which to pull the name of the pluggable class. * @return an instance of the class specified by storm.meta.serialization.delegate */ private static SerializationDelegate getSerializationDelegate(Map<String, Object> topoConf) { String delegateClassName = (String) topoConf.get(Config.STORM_META_SERIALIZATION_DELEGATE); SerializationDelegate delegate; try { Class delegateClass = Class.forName(delegateClassName); delegate = (SerializationDelegate) delegateClass.newInstance(); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { throw new RuntimeException("Failed to construct serialization delegate class " + delegateClassName, e); } delegate.prepare(topoConf); return delegate; }
@Before public void setUp() throws Exception { testDelegate = new ThriftSerializationDelegate(); testDelegate.prepare(null); }
/** * Creates an instance of the pluggable SerializationDelegate or falls back to * DefaultSerializationDelegate if something goes wrong. * @param stormConf The config from which to pull the name of the pluggable class. * @return an instance of the class specified by storm.meta.serialization.delegate */ private static SerializationDelegate getSerializationDelegate(Map stormConf) { String delegateClassName = (String)stormConf.get(Config.STORM_META_SERIALIZATION_DELEGATE); SerializationDelegate delegate; try { Class delegateClass = Class.forName(delegateClassName); delegate = (SerializationDelegate) delegateClass.newInstance(); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { LOG.error("Failed to construct serialization delegate, falling back to default", e); delegate = new DefaultSerializationDelegate(); } delegate.prepare(stormConf); return delegate; }