Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
METRON-1521: JSONMapParser is no longer serializable closes #991
Browse files Browse the repository at this point in the history
  • Loading branch information
cestella committed Apr 12, 2018
1 parent ea6992f commit eb5b2d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ public JSONObject handle(String key, Map value, JSONObject obj) {
public static final String JSONP_QUERY = "jsonpQuery";

private MapStrategy mapStrategy = MapStrategy.DROP;
private TypeRef<List<Map<String, Object>>> typeRef = new TypeRef<List<Map<String, Object>>>() {
};
private transient TypeRef<List<Map<String, Object>>> typeRef = null;
private String jsonpQuery = null;


Expand All @@ -99,6 +98,7 @@ public void configure(Map<String, Object> config) {
String strategyStr = (String) config.getOrDefault(MAP_STRATEGY_CONFIG, MapStrategy.DROP.name());
mapStrategy = MapStrategy.valueOf(strategyStr);
if (config.containsKey(JSONP_QUERY)) {
typeRef = new TypeRef<List<Map<String, Object>>>() { };
jsonpQuery = (String) config.get(JSONP_QUERY);
Configuration.setDefaults(new Configuration.Defaults() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.metron.parsers.integration;

import com.google.common.collect.ImmutableList;
import org.apache.commons.lang.SerializationUtils;
import org.apache.metron.common.configuration.ConfigurationsUtils;
import org.apache.metron.common.configuration.FieldValidator;
import org.apache.metron.common.configuration.ParserConfigurations;
Expand All @@ -42,6 +43,7 @@

import java.io.Closeable;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand All @@ -54,7 +56,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ParserDriver {
public class ParserDriver implements Serializable {
private static final Logger LOG = LoggerFactory.getLogger(ParserBolt.class);
public static class CollectingWriter implements MessageWriter<JSONObject>{
List<byte[]> output;
Expand Down Expand Up @@ -151,6 +153,8 @@ public ParserDriver(String sensorType, String parserConfig, String globalConfig)

public ProcessorResult<List<byte[]>> run(List<byte[]> in) {
ShimParserBolt bolt = new ShimParserBolt(new ArrayList<>());
byte[] b = SerializationUtils.serialize(bolt);
ShimParserBolt b2 = (ShimParserBolt) SerializationUtils.deserialize(b);
OutputCollector collector = mock(OutputCollector.class);
bolt.prepare(null, null, collector);
for(byte[] record : in) {
Expand Down

0 comments on commit eb5b2d4

Please sign in to comment.