From f2672ba5ac7f2b66d6977537e1ebec4cc8c44ae1 Mon Sep 17 00:00:00 2001 From: justinjleet Date: Wed, 18 Jul 2018 12:14:39 -0400 Subject: [PATCH] fixing formatting of code blocks --- .../metron-parsers/3rdPartyParser.md | 408 +++++++++--------- 1 file changed, 204 insertions(+), 204 deletions(-) diff --git a/metron-platform/metron-parsers/3rdPartyParser.md b/metron-platform/metron-parsers/3rdPartyParser.md index 739328f116..0c2409e9d7 100644 --- a/metron-platform/metron-parsers/3rdPartyParser.md +++ b/metron-platform/metron-parsers/3rdPartyParser.md @@ -54,180 +54,180 @@ project. We'll call it `extra_parsers`, so in your workspace, let's set up the maven project: * Create the maven infrastructure for `extra_parsers` via - ``` - mkdir -p extra_parsers/src/{main,test}/java - ``` + ``` + mkdir -p extra_parsers/src/{main,test}/java + ``` * Create a pom file indicating how we should build our parsers by editing `extra_parsers/pom.xml` with the following content: - ``` - - 4.0.0 - com.3rdparty - extra-parsers - jar - 1.0-SNAPSHOT - extra-parsers - http://thirdpartysoftware.org - - - 1.8 - - 0.4.1 - - 19.0 - - 2.4.3 - - - - - org.apache.metron - metron-parsers - ${metron_version} - provided - - - com.google.guava - guava - ${guava_version} - - - junit - junit - 3.8.1 - test - - - - - + 1.8 + + 0.4.1 + + 19.0 + + 2.4.3 + + + - - - org.apache.maven.plugins - maven-shade-plugin - ${shade_version} - - true - - - - *slf4j* - - - - - - package - - shade - - - true - uber - - - - *:* + + org.apache.metron + metron-parsers + ${metron_version} + provided + + + com.google.guava + guava + ${guava_version} + + + junit + junit + 3.8.1 + test + + + + + + + + org.apache.maven.plugins + maven-shade-plugin + ${shade_version} + + true + + + + *slf4j* + + + + + + package + + shade + + + true + uber + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + com.google + com.thirdparty.guava + + + - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA + + storm:storm-core:* + storm:storm-lib:* + org.slf4j.impl* + org.slf4j:slf4j-log4j* - - - - - - com.google - com.thirdparty.guava - - - - - - storm:storm-core:* - storm:storm-lib:* - org.slf4j.impl* - org.slf4j:slf4j-log4j* - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.5.1 - - true - ${java_version} - -Xlint:unchecked - ${java_version} - true - - - - - - ``` + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + true + ${java_version} + -Xlint:unchecked + ${java_version} + true + + + + + + ``` * Now let's create our parser `com.thirdparty.SimpleParser` by creating the file `extra-parsers/src/main/java/com/thirdparty/SimpleParser.java` with the following content: - ``` - package com.thirdparty; - - import com.google.common.base.Splitter; - import com.google.common.collect.ImmutableList; - import com.google.common.collect.Iterables; - import org.apache.metron.parsers.BasicParser; - import org.json.simple.JSONObject; - - import java.util.List; - import java.util.Map; - - public class SimpleParser extends BasicParser { - @Override - public void init() { - - } - - @Override - public List parse(byte[] bytes) { - String input = new String(bytes); - Iterable it = Splitter.on(",").split(input); - JSONObject ret = new JSONObject(); - ret.put("original_string", input); - ret.put("timestamp", System.currentTimeMillis()); - ret.put("first", Iterables.getFirst(it, "missing")); - ret.put("last", Iterables.getLast(it, "missing")); - return ImmutableList.of(ret); + ``` + package com.thirdparty; + + import com.google.common.base.Splitter; + import com.google.common.collect.ImmutableList; + import com.google.common.collect.Iterables; + import org.apache.metron.parsers.BasicParser; + import org.json.simple.JSONObject; + + import java.util.List; + import java.util.Map; + + public class SimpleParser extends BasicParser { + @Override + public void init() { + + } + + @Override + public List parse(byte[] bytes) { + String input = new String(bytes); + Iterable it = Splitter.on(",").split(input); + JSONObject ret = new JSONObject(); + ret.put("original_string", input); + ret.put("timestamp", System.currentTimeMillis()); + ret.put("first", Iterables.getFirst(it, "missing")); + ret.put("last", Iterables.getLast(it, "missing")); + return ImmutableList.of(ret); + } + + @Override + public void configure(Map map) { + + } } - - @Override - public void configure(Map map) { - - } - } - ``` + ``` * Compile the parser via `mvn clean package` in `extra_parsers` * This will create a jar containing your parser and its dependencies (sans Metron dependencies) in `extra-parsers/target/extra-parsers-1.0-SNAPSHOT-uber.jar` @@ -289,52 +289,52 @@ $METRON_HOME/bin/zk_load_configs.sh -m PUSH -i $METRON_HOME/config/zookeeper/ -z Now we can start the parser and send some data through: * Start the parser - ``` - $METRON_HOME/bin/start_parser_topology.sh -k $BROKERLIST -z $ZOOKEEPER -s test - ``` + ``` + $METRON_HOME/bin/start_parser_topology.sh -k $BROKERLIST -z $ZOOKEEPER -s test + ``` * Send example data through: - ``` - echo "apache,metron" | /usr/hdp/current/kafka-broker/bin/kafka-console-producer.sh --broker-list $BROKERLIST --topic test - ``` + ``` + echo "apache,metron" | /usr/hdp/current/kafka-broker/bin/kafka-console-producer.sh --broker-list $BROKERLIST --topic test + ``` * Validate data was written in ES: - ``` - curl -XPOST "http://$ES_HOST/test*/_search?pretty" -d ' - { - "_source" : [ "original_string", "timestamp", "first", "last"] - } - ' - ``` + ``` + curl -XPOST "http://$ES_HOST/test*/_search?pretty" -d ' + { + "_source" : [ "original_string", "timestamp", "first", "last"] + } + ' + ``` * This should yield something like: - ``` - { - "took" : 23, - "timed_out" : false, - "_shards" : { - "total" : 1, - "successful" : 1, - "failed" : 0 - }, - "hits" : { - "total" : 1, - "max_score" : 1.0, - "hits" : [ { - "_index" : "test_index_2017.10.04.17", - "_type" : "test_doc", - "_id" : "3ae4dd4d-8c09-4f2a-93c0-26ec5508baaa", - "_score" : 1.0, - "_source" : { - "original_string" : "apache,metron", - "last" : "metron", - "first" : "apache", - "timestamp" : 1507138373223 - } - } ] + ``` + { + "took" : 23, + "timed_out" : false, + "_shards" : { + "total" : 1, + "successful" : 1, + "failed" : 0 + }, + "hits" : { + "total" : 1, + "max_score" : 1.0, + "hits" : [ { + "_index" : "test_index_2017.10.04.17", + "_type" : "test_doc", + "_id" : "3ae4dd4d-8c09-4f2a-93c0-26ec5508baaa", + "_score" : 1.0, + "_source" : { + "original_string" : "apache,metron", + "last" : "metron", + "first" : "apache", + "timestamp" : 1507138373223 + } + } ] + } } - } - ``` + ``` ### Via the Management UI