You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@metron.apache.org by rm...@apache.org on 2016/04/26 16:45:52 UTC
[04/51] [partial] incubator-metron git commit: METRON-113 Project
Reorganization (merrimanr) closes apache/incubator-metron#88
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/0117987e/metron-streaming/Metron-Common/src/main/java/org/apache/metron/ise/parser/JavaCharStream.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/ise/parser/JavaCharStream.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/ise/parser/JavaCharStream.java
deleted file mode 100644
index eb3a999..0000000
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/ise/parser/JavaCharStream.java
+++ /dev/null
@@ -1,633 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 5.0 */
-/* JavaCCOptions:STATIC=false,SUPPORT_CLASS_VISIBILITY_PUBLIC=false */
-package org.apache.metron.ise.parser;
-
-/**
- * An implementation of interface CharStream, where the stream is assumed to
- * contain only ASCII characters (with java-like unicode escape processing).
- */
-
-class JavaCharStream
-{
- /** Whether parser is static. */
- public static final boolean staticFlag = false;
-
- static final int hexval(char c) throws java.io.IOException {
- switch(c)
- {
- case '0' :
- return 0;
- case '1' :
- return 1;
- case '2' :
- return 2;
- case '3' :
- return 3;
- case '4' :
- return 4;
- case '5' :
- return 5;
- case '6' :
- return 6;
- case '7' :
- return 7;
- case '8' :
- return 8;
- case '9' :
- return 9;
-
- case 'a' :
- case 'A' :
- return 10;
- case 'b' :
- case 'B' :
- return 11;
- case 'c' :
- case 'C' :
- return 12;
- case 'd' :
- case 'D' :
- return 13;
- case 'e' :
- case 'E' :
- return 14;
- case 'f' :
- case 'F' :
- return 15;
- }
-
- throw new java.io.IOException(); // Should never come here
- }
-
-/** Position in buffer. */
- public int bufpos = -1;
- int bufsize;
- int available;
- int tokenBegin;
- protected int bufline[];
- protected int bufcolumn[];
-
- protected int column = 0;
- protected int line = 1;
-
- protected boolean prevCharIsCR = false;
- protected boolean prevCharIsLF = false;
-
- protected java.io.Reader inputStream;
-
- protected char[] nextCharBuf;
- protected char[] buffer;
- protected int maxNextCharInd = 0;
- protected int nextCharInd = -1;
- protected int inBuf = 0;
- protected int tabSize = 8;
-
- protected void setTabSize(int i) { tabSize = i; }
- protected int getTabSize(int i) { return tabSize; }
-
- protected void ExpandBuff(boolean wrapAround)
- {
- char[] newbuffer = new char[bufsize + 2048];
- int newbufline[] = new int[bufsize + 2048];
- int newbufcolumn[] = new int[bufsize + 2048];
-
- try
- {
- if (wrapAround)
- {
- System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
- System.arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufpos);
- buffer = newbuffer;
-
- System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
- System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
- bufline = newbufline;
-
- System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
- System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
- bufcolumn = newbufcolumn;
-
- bufpos += (bufsize - tokenBegin);
- }
- else
- {
- System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
- buffer = newbuffer;
-
- System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
- bufline = newbufline;
-
- System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
- bufcolumn = newbufcolumn;
-
- bufpos -= tokenBegin;
- }
- }
- catch (Throwable t)
- {
- throw new Error(t.getMessage());
- }
-
- available = (bufsize += 2048);
- tokenBegin = 0;
- }
-
- protected void FillBuff() throws java.io.IOException
- {
- int i;
- if (maxNextCharInd == 4096)
- maxNextCharInd = nextCharInd = 0;
-
- try {
- if ((i = inputStream.read(nextCharBuf, maxNextCharInd,
- 4096 - maxNextCharInd)) == -1)
- {
- inputStream.close();
- throw new java.io.IOException();
- }
- else
- maxNextCharInd += i;
- return;
- }
- catch(java.io.IOException e) {
- if (bufpos != 0)
- {
- --bufpos;
- backup(0);
- }
- else
- {
- bufline[bufpos] = line;
- bufcolumn[bufpos] = column;
- }
- throw e;
- }
- }
-
- protected char ReadByte() throws java.io.IOException
- {
- if (++nextCharInd >= maxNextCharInd)
- FillBuff();
-
- return nextCharBuf[nextCharInd];
- }
-
-/** @return starting character for token. */
- public char BeginToken() throws java.io.IOException
- {
- if (inBuf > 0)
- {
- --inBuf;
-
- if (++bufpos == bufsize)
- bufpos = 0;
-
- tokenBegin = bufpos;
- return buffer[bufpos];
- }
-
- tokenBegin = 0;
- bufpos = -1;
-
- return readChar();
- }
-
- protected void AdjustBuffSize()
- {
- if (available == bufsize)
- {
- if (tokenBegin > 2048)
- {
- bufpos = 0;
- available = tokenBegin;
- }
- else
- ExpandBuff(false);
- }
- else if (available > tokenBegin)
- available = bufsize;
- else if ((tokenBegin - available) < 2048)
- ExpandBuff(true);
- else
- available = tokenBegin;
- }
-
- protected void UpdateLineColumn(char c)
- {
- column++;
-
- if (prevCharIsLF)
- {
- prevCharIsLF = false;
- line += (column = 1);
- }
- else if (prevCharIsCR)
- {
- prevCharIsCR = false;
- if (c == '\n')
- {
- prevCharIsLF = true;
- }
- else
- line += (column = 1);
- }
-
- switch (c)
- {
- case '\r' :
- prevCharIsCR = true;
- break;
- case '\n' :
- prevCharIsLF = true;
- break;
- case '\t' :
- column--;
- column += (tabSize - (column % tabSize));
- break;
- default :
- break;
- }
-
- bufline[bufpos] = line;
- bufcolumn[bufpos] = column;
- }
-
-/** Read a character. */
- public char readChar() throws java.io.IOException
- {
- if (inBuf > 0)
- {
- --inBuf;
-
- if (++bufpos == bufsize)
- bufpos = 0;
-
- return buffer[bufpos];
- }
-
- char c;
-
- if (++bufpos == available)
- AdjustBuffSize();
-
- if ((buffer[bufpos] = c = ReadByte()) == '\\')
- {
- UpdateLineColumn(c);
-
- int backSlashCnt = 1;
-
- for (;;) // Read all the backslashes
- {
- if (++bufpos == available)
- AdjustBuffSize();
-
- try
- {
- if ((buffer[bufpos] = c = ReadByte()) != '\\')
- {
- UpdateLineColumn(c);
- // found a non-backslash char.
- if ((c == 'u') && ((backSlashCnt & 1) == 1))
- {
- if (--bufpos < 0)
- bufpos = bufsize - 1;
-
- break;
- }
-
- backup(backSlashCnt);
- return '\\';
- }
- }
- catch(java.io.IOException e)
- {
- // We are returning one backslash so we should only backup (count-1)
- if (backSlashCnt > 1)
- backup(backSlashCnt-1);
-
- return '\\';
- }
-
- UpdateLineColumn(c);
- backSlashCnt++;
- }
-
- // Here, we have seen an odd number of backslash's followed by a 'u'
- try
- {
- while ((c = ReadByte()) == 'u')
- ++column;
-
- buffer[bufpos] = c = (char)(hexval(c) << 12 |
- hexval(ReadByte()) << 8 |
- hexval(ReadByte()) << 4 |
- hexval(ReadByte()));
-
- column += 4;
- }
- catch(java.io.IOException e)
- {
- throw new Error("Invalid escape character at line " + line +
- " column " + column + ".");
- }
-
- if (backSlashCnt == 1)
- return c;
- else
- {
- backup(backSlashCnt - 1);
- return '\\';
- }
- }
- else
- {
- UpdateLineColumn(c);
- return c;
- }
- }
-
- @Deprecated
- /**
- * @deprecated
- * @see #getEndColumn
- */
- public int getColumn() {
- return bufcolumn[bufpos];
- }
-
- @Deprecated
- /**
- * @deprecated
- * @see #getEndLine
- */
- public int getLine() {
- return bufline[bufpos];
- }
-
-/** Get end column. */
- public int getEndColumn() {
- return bufcolumn[bufpos];
- }
-
-/** Get end line. */
- public int getEndLine() {
- return bufline[bufpos];
- }
-
-/** @return column of token start */
- public int getBeginColumn() {
- return bufcolumn[tokenBegin];
- }
-
-/** @return line number of token start */
- public int getBeginLine() {
- return bufline[tokenBegin];
- }
-
-/** Retreat. */
- public void backup(int amount) {
-
- inBuf += amount;
- if ((bufpos -= amount) < 0)
- bufpos += bufsize;
- }
-
-/** Constructor. */
- public JavaCharStream(java.io.Reader dstream,
- int startline, int startcolumn, int buffersize)
- {
- inputStream = dstream;
- line = startline;
- column = startcolumn - 1;
-
- available = bufsize = buffersize;
- buffer = new char[buffersize];
- bufline = new int[buffersize];
- bufcolumn = new int[buffersize];
- nextCharBuf = new char[4096];
- }
-
-/** Constructor. */
- public JavaCharStream(java.io.Reader dstream,
- int startline, int startcolumn)
- {
- this(dstream, startline, startcolumn, 4096);
- }
-
-/** Constructor. */
- public JavaCharStream(java.io.Reader dstream)
- {
- this(dstream, 1, 1, 4096);
- }
-/** Reinitialise. */
- public void ReInit(java.io.Reader dstream,
- int startline, int startcolumn, int buffersize)
- {
- inputStream = dstream;
- line = startline;
- column = startcolumn - 1;
-
- if (buffer == null || buffersize != buffer.length)
- {
- available = bufsize = buffersize;
- buffer = new char[buffersize];
- bufline = new int[buffersize];
- bufcolumn = new int[buffersize];
- nextCharBuf = new char[4096];
- }
- prevCharIsLF = prevCharIsCR = false;
- tokenBegin = inBuf = maxNextCharInd = 0;
- nextCharInd = bufpos = -1;
- }
-
-/** Reinitialise. */
- public void ReInit(java.io.Reader dstream,
- int startline, int startcolumn)
- {
- ReInit(dstream, startline, startcolumn, 4096);
- }
-
-/** Reinitialise. */
- public void ReInit(java.io.Reader dstream)
- {
- ReInit(dstream, 1, 1, 4096);
- }
-/** Constructor. */
- public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
- int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
- {
- this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
- }
-
-/** Constructor. */
- public JavaCharStream(java.io.InputStream dstream, int startline,
- int startcolumn, int buffersize)
- {
- this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
- }
-
-/** Constructor. */
- public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
- int startcolumn) throws java.io.UnsupportedEncodingException
- {
- this(dstream, encoding, startline, startcolumn, 4096);
- }
-
-/** Constructor. */
- public JavaCharStream(java.io.InputStream dstream, int startline,
- int startcolumn)
- {
- this(dstream, startline, startcolumn, 4096);
- }
-
-/** Constructor. */
- public JavaCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
- {
- this(dstream, encoding, 1, 1, 4096);
- }
-
-/** Constructor. */
- public JavaCharStream(java.io.InputStream dstream)
- {
- this(dstream, 1, 1, 4096);
- }
-
-/** Reinitialise. */
- public void ReInit(java.io.InputStream dstream, String encoding, int startline,
- int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException
- {
- ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
- }
-
-/** Reinitialise. */
- public void ReInit(java.io.InputStream dstream, int startline,
- int startcolumn, int buffersize)
- {
- ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
- }
-/** Reinitialise. */
- public void ReInit(java.io.InputStream dstream, String encoding, int startline,
- int startcolumn) throws java.io.UnsupportedEncodingException
- {
- ReInit(dstream, encoding, startline, startcolumn, 4096);
- }
-/** Reinitialise. */
- public void ReInit(java.io.InputStream dstream, int startline,
- int startcolumn)
- {
- ReInit(dstream, startline, startcolumn, 4096);
- }
-/** Reinitialise. */
- public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException
- {
- ReInit(dstream, encoding, 1, 1, 4096);
- }
-
-/** Reinitialise. */
- public void ReInit(java.io.InputStream dstream)
- {
- ReInit(dstream, 1, 1, 4096);
- }
-
- /** @return token image as String */
- public String GetImage()
- {
- if (bufpos >= tokenBegin)
- return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
- else
- return new String(buffer, tokenBegin, bufsize - tokenBegin) +
- new String(buffer, 0, bufpos + 1);
- }
-
- /** @return suffix */
- public char[] GetSuffix(int len)
- {
- char[] ret = new char[len];
-
- if ((bufpos + 1) >= len)
- System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
- else
- {
- System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
- len - bufpos - 1);
- System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
- }
-
- return ret;
- }
-
- /** Set buffers back to null when finished. */
- public void Done()
- {
- nextCharBuf = null;
- buffer = null;
- bufline = null;
- bufcolumn = null;
- }
-
- /**
- * Method to adjust line and column numbers for the start of a token.
- */
- public void adjustBeginLineColumn(int newLine, int newCol)
- {
- int start = tokenBegin;
- int len;
-
- if (bufpos >= tokenBegin)
- {
- len = bufpos - tokenBegin + inBuf + 1;
- }
- else
- {
- len = bufsize - tokenBegin + bufpos + 1 + inBuf;
- }
-
- int i = 0, j = 0, k = 0;
- int nextColDiff = 0, columnDiff = 0;
-
- while (i < len && bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
- {
- bufline[j] = newLine;
- nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
- bufcolumn[j] = newCol + columnDiff;
- columnDiff = nextColDiff;
- i++;
- }
-
- if (i < len)
- {
- bufline[j] = newLine++;
- bufcolumn[j] = newCol + columnDiff;
-
- while (i++ < len)
- {
- if (bufline[j = start % bufsize] != bufline[++start % bufsize])
- bufline[j] = newLine++;
- else
- bufline[j] = newLine;
- }
- }
-
- line = bufline[j];
- column = bufcolumn[j];
- }
-
-}
-/* JavaCC - OriginalChecksum=96a5b0b0fa09286690f250998f047719 (do not edit this line) */
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/0117987e/metron-streaming/Metron-Common/src/main/java/org/apache/metron/ise/parser/ParseException.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/ise/parser/ParseException.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/ise/parser/ParseException.java
deleted file mode 100644
index 4143060..0000000
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/ise/parser/ParseException.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 */
-/* JavaCCOptions:KEEP_LINE_COL=null */
-package org.apache.metron.ise.parser;
-
-/**
- * This exception is thrown when parse errors are encountered.
- * You can explicitly create objects of this exception type by
- * calling the method generateParseException in the generated
- * parser.
- *
- * You can modify this class to customize your error reporting
- * mechanisms so long as you retain the public fields.
- */
-public class ParseException extends Exception {
-
- /**
- * The version identifier for this Serializable class.
- * Increment only if the <i>serialized</i> form of the
- * class changes.
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * This constructor is used by the method "generateParseException"
- * in the generated parser. Calling this constructor generates
- * a new object of this type with the fields "currentToken",
- * "expectedTokenSequences", and "tokenImage" set.
- */
- public ParseException(Token currentTokenVal,
- int[][] expectedTokenSequencesVal,
- String[] tokenImageVal
- )
- {
- super(initialise(currentTokenVal, expectedTokenSequencesVal, tokenImageVal));
- currentToken = currentTokenVal;
- expectedTokenSequences = expectedTokenSequencesVal;
- tokenImage = tokenImageVal;
- }
-
- /**
- * The following constructors are for use by you for whatever
- * purpose you can think of. Constructing the exception in this
- * manner makes the exception behave in the normal way - i.e., as
- * documented in the class "Throwable". The fields "errorToken",
- * "expectedTokenSequences", and "tokenImage" do not contain
- * relevant information. The JavaCC generated code does not use
- * these constructors.
- */
-
- public ParseException() {
- super();
- }
-
- /** Constructor with message. */
- public ParseException(String message) {
- super(message);
- }
-
-
- /**
- * This is the last token that has been consumed successfully. If
- * this object has been created due to a parse error, the token
- * followng this token will (therefore) be the first error token.
- */
- public Token currentToken;
-
- /**
- * Each entry in this array is an array of integers. Each array
- * of integers represents a sequence of tokens (by their ordinal
- * values) that is expected at this point of the parse.
- */
- public int[][] expectedTokenSequences;
-
- /**
- * This is a reference to the "tokenImage" array of the generated
- * parser within which the parse error occurred. This array is
- * defined in the generated ...Constants interface.
- */
- public String[] tokenImage;
-
- /**
- * It uses "currentToken" and "expectedTokenSequences" to generate a parse
- * error message and returns it. If this object has been created
- * due to a parse error, and you do not catch it (it gets thrown
- * from the parser) the correct error message
- * gets displayed.
- */
- private static String initialise(Token currentToken,
- int[][] expectedTokenSequences,
- String[] tokenImage) {
- String eol = System.getProperty("line.separator", "\n");
- StringBuffer expected = new StringBuffer();
- int maxSize = 0;
- for (int i = 0; i < expectedTokenSequences.length; i++) {
- if (maxSize < expectedTokenSequences[i].length) {
- maxSize = expectedTokenSequences[i].length;
- }
- for (int j = 0; j < expectedTokenSequences[i].length; j++) {
- expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' ');
- }
- if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
- expected.append("...");
- }
- expected.append(eol).append(" ");
- }
- String retval = "Encountered \"";
- Token tok = currentToken.next;
- for (int i = 0; i < maxSize; i++) {
- if (i != 0) retval += " ";
- if (tok.kind == 0) {
- retval += tokenImage[0];
- break;
- }
- retval += " " + tokenImage[tok.kind];
- retval += " \"";
- retval += add_escapes(tok.image);
- retval += " \"";
- tok = tok.next;
- }
- retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
- retval += "." + eol;
- if (expectedTokenSequences.length == 1) {
- retval += "Was expecting:" + eol + " ";
- } else {
- retval += "Was expecting one of:" + eol + " ";
- }
- retval += expected.toString();
- return retval;
- }
-
- /**
- * The end of line string for this machine.
- */
- protected String eol = System.getProperty("line.separator", "\n");
-
- /**
- * Used to convert raw characters to their escaped version
- * when these raw version cannot be used as part of an ASCII
- * string literal.
- */
- static String add_escapes(String str) {
- StringBuffer retval = new StringBuffer();
- char ch;
- for (int i = 0; i < str.length(); i++) {
- switch (str.charAt(i))
- {
- case 0 :
- continue;
- case '\b':
- retval.append("\\b");
- continue;
- case '\t':
- retval.append("\\t");
- continue;
- case '\n':
- retval.append("\\n");
- continue;
- case '\f':
- retval.append("\\f");
- continue;
- case '\r':
- retval.append("\\r");
- continue;
- case '\"':
- retval.append("\\\"");
- continue;
- case '\'':
- retval.append("\\\'");
- continue;
- case '\\':
- retval.append("\\\\");
- continue;
- default:
- if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
- String s = "0000" + Integer.toString(ch, 16);
- retval.append("\\u" + s.substring(s.length() - 4, s.length()));
- } else {
- retval.append(ch);
- }
- continue;
- }
- }
- return retval.toString();
- }
-
-}
-/* JavaCC - OriginalChecksum=f9f7217056f99de5708d01ebd497dede (do not edit this line) */
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/0117987e/metron-streaming/Metron-Common/src/main/java/org/apache/metron/ise/parser/Token.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/ise/parser/Token.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/ise/parser/Token.java
deleted file mode 100644
index 349baf4..0000000
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/ise/parser/Token.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/* Generated By:JavaCC: Do not edit this line. Token.java Version 5.0 */
-/* JavaCCOptions:TOKEN_EXTENDS=,KEEP_LINE_COL=null,SUPPORT_CLASS_VISIBILITY_PUBLIC=false */
-package org.apache.metron.ise.parser;
-
-/**
- * Describes the input token stream.
- */
-
-class Token implements java.io.Serializable {
-
- /**
- * The version identifier for this Serializable class.
- * Increment only if the <i>serialized</i> form of the
- * class changes.
- */
- private static final long serialVersionUID = 1L;
-
- /**
- * An integer that describes the kind of this token. This numbering
- * system is determined by JavaCCParser, and a table of these numbers is
- * stored in the file ...Constants.java.
- */
- public int kind;
-
- /** The line number of the first character of this Token. */
- public int beginLine;
- /** The column number of the first character of this Token. */
- public int beginColumn;
- /** The line number of the last character of this Token. */
- public int endLine;
- /** The column number of the last character of this Token. */
- public int endColumn;
-
- /**
- * The string image of the token.
- */
- public String image;
-
- /**
- * A reference to the next regular (non-special) token from the input
- * stream. If this is the last token from the input stream, or if the
- * token manager has not read tokens beyond this one, this field is
- * set to null. This is true only if this token is also a regular
- * token. Otherwise, see below for a description of the contents of
- * this field.
- */
- public Token next;
-
- /**
- * This field is used to access special tokens that occur prior to this
- * token, but after the immediately preceding regular (non-special) token.
- * If there are no such special tokens, this field is set to null.
- * When there are more than one such special token, this field refers
- * to the last of these special tokens, which in turn refers to the next
- * previous special token through its specialToken field, and so on
- * until the first special token (whose specialToken field is null).
- * The next fields of special tokens refer to other special tokens that
- * immediately follow it (without an intervening regular token). If there
- * is no such token, this field is null.
- */
- public Token specialToken;
-
- /**
- * An optional attribute value of the Token.
- * Tokens which are not used as syntactic sugar will often contain
- * meaningful values that will be used later on by the compiler or
- * interpreter. This attribute value is often different from the image.
- * Any subclass of Token that actually wants to return a non-null value can
- * override this method as appropriate.
- */
- public Object getValue() {
- return null;
- }
-
- /**
- * No-argument constructor
- */
- public Token() {}
-
- /**
- * Constructs a new token for the specified Image.
- */
- public Token(int kind)
- {
- this(kind, null);
- }
-
- /**
- * Constructs a new token for the specified Image and Kind.
- */
- public Token(int kind, String image)
- {
- this.kind = kind;
- this.image = image;
- }
-
- /**
- * Returns the image.
- */
- public String toString()
- {
- return image;
- }
-
- /**
- * Returns a new Token object, by default. However, if you want, you
- * can create and return subclass objects based on the value of ofKind.
- * Simply add the cases to the switch for all those special cases.
- * For example, if you have a subclass of Token called IDToken that
- * you want to create if ofKind is ID, simply add something like :
- *
- * case MyParserConstants.ID : return new IDToken(ofKind, image);
- *
- * to the following switch statement. Then you can cast matchedToken
- * variable to the appropriate type and use sit in your lexical actions.
- */
- public static Token newToken(int ofKind, String image)
- {
- switch(ofKind)
- {
- default : return new Token(ofKind, image);
- }
- }
-
- public static Token newToken(int ofKind)
- {
- return newToken(ofKind, null);
- }
-
-}
-/* JavaCC - OriginalChecksum=99daf0baa94b6c270eea5be0575db6aa (do not edit this line) */
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/0117987e/metron-streaming/Metron-Common/src/main/java/org/apache/metron/ise/parser/TokenMgrError.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/ise/parser/TokenMgrError.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/ise/parser/TokenMgrError.java
deleted file mode 100644
index 2e1f52c..0000000
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/ise/parser/TokenMgrError.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 5.0 */
-/* JavaCCOptions: */
-package org.apache.metron.ise.parser;
-
-/** Token Manager Error. */
-class TokenMgrError extends Error
-{
-
- /**
- * The version identifier for this Serializable class.
- * Increment only if the <i>serialized</i> form of the
- * class changes.
- */
- private static final long serialVersionUID = 1L;
-
- /*
- * Ordinals for various reasons why an Error of this type can be thrown.
- */
-
- /**
- * Lexical error occurred.
- */
- static final int LEXICAL_ERROR = 0;
-
- /**
- * An attempt was made to create a second instance of a static token manager.
- */
- static final int STATIC_LEXER_ERROR = 1;
-
- /**
- * Tried to change to an invalid lexical state.
- */
- static final int INVALID_LEXICAL_STATE = 2;
-
- /**
- * Detected (and bailed out of) an infinite loop in the token manager.
- */
- static final int LOOP_DETECTED = 3;
-
- /**
- * Indicates the reason why the exception is thrown. It will have
- * one of the above 4 values.
- */
- int errorCode;
-
- /**
- * Replaces unprintable characters by their escaped (or unicode escaped)
- * equivalents in the given string
- */
- protected static final String addEscapes(String str) {
- StringBuffer retval = new StringBuffer();
- char ch;
- for (int i = 0; i < str.length(); i++) {
- switch (str.charAt(i))
- {
- case 0 :
- continue;
- case '\b':
- retval.append("\\b");
- continue;
- case '\t':
- retval.append("\\t");
- continue;
- case '\n':
- retval.append("\\n");
- continue;
- case '\f':
- retval.append("\\f");
- continue;
- case '\r':
- retval.append("\\r");
- continue;
- case '\"':
- retval.append("\\\"");
- continue;
- case '\'':
- retval.append("\\\'");
- continue;
- case '\\':
- retval.append("\\\\");
- continue;
- default:
- if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
- String s = "0000" + Integer.toString(ch, 16);
- retval.append("\\u" + s.substring(s.length() - 4, s.length()));
- } else {
- retval.append(ch);
- }
- continue;
- }
- }
- return retval.toString();
- }
-
- /**
- * Returns a detailed message for the Error when it is thrown by the
- * token manager to indicate a lexical error.
- * Parameters :
- * EOFSeen : indicates if EOF caused the lexical error
- * curLexState : lexical state in which this error occurred
- * errorLine : line number when the error occurred
- * errorColumn : column number when the error occurred
- * errorAfter : prefix that was seen before this error occurred
- * curchar : the offending character
- * Note: You can customize the lexical error message by modifying this method.
- */
- protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
- return("Lexical error at line " +
- errorLine + ", column " +
- errorColumn + ". Encountered: " +
- (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
- "after : \"" + addEscapes(errorAfter) + "\"");
- }
-
- /**
- * You can also modify the body of this method to customize your error messages.
- * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
- * of end-users concern, so you can return something like :
- *
- * "Internal Error : Please file a bug report .... "
- *
- * from this method for such cases in the release version of your parser.
- */
- public String getMessage() {
- return super.getMessage();
- }
-
- /*
- * Constructors of various flavors follow.
- */
-
- /** No arg constructor. */
- public TokenMgrError() {
- }
-
- /** Constructor with message and reason. */
- public TokenMgrError(String message, int reason) {
- super(message);
- errorCode = reason;
- }
-
- /** Full Constructor. */
- public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
- this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
- }
-}
-/* JavaCC - OriginalChecksum=5fbf6813c9d6a1d713f1d4a002af1322 (do not edit this line) */
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/0117987e/metron-streaming/Metron-Common/src/main/java/org/apache/metron/json/serialization/JSONDecoderHelper.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/json/serialization/JSONDecoderHelper.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/json/serialization/JSONDecoderHelper.java
deleted file mode 100644
index 366e655..0000000
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/json/serialization/JSONDecoderHelper.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.metron.json.serialization;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-
-/**
- * Helper class used for decoding objects from byte arrays
- *
- * @author kiran
- *
- */
-public class JSONDecoderHelper {
-
- public static String getString(DataInputStream data) throws IOException {
-
- int strSize = data.readInt();
-
- byte[] bytes = new byte[strSize];
- data.read(bytes);
- return new String(bytes);
- }
-
- public static Number getNumber(DataInputStream data) throws IOException {
- // Treating all ints,shorts, long as long.
- // Everything else as Double
- int flag = data.readByte();
- if (flag == 0)
- return data.readDouble();
-
- return data.readLong();
- }
-
- public static Boolean getBoolean(DataInputStream data) throws IOException {
-
- return data.readBoolean();
- }
-
- @SuppressWarnings("unchecked")
- public static JSONArray getArray(DataInputStream data) throws IOException {
- // TODO Auto-generated method stub
- JSONArray output = new JSONArray();
- int size = data.readInt();
-
- for (int i = 0; i < size; i++) {
- Object value = getObject(data);
- output.add(value);
- }
-
- return output;
- }
-
- @SuppressWarnings("unchecked")
- public static JSONObject getJSON(DataInputStream data) throws IOException {
- // TODO Auto-generated method stub
- JSONObject output = new JSONObject();
- int size = data.readInt();
-
- for (int i = 0; i < size; i++) {
- String key = (String) getObject(data);
- Object value = getObject(data);
- output.put(key, value);
- }
-
- return output;
- }
-
- public static Object getObject(DataInputStream data) throws IOException {
- // TODO Auto-generated method stub
- byte objID = data.readByte();
-
- if (objID == JSONKafkaSerializer.StringID)
- return getString(data);
-
- if (objID == JSONKafkaSerializer.JSONObjectID)
- return getJSON(data);
-
- if (objID == JSONKafkaSerializer.NumberID)
- return getNumber(data);
-
- if (objID == JSONKafkaSerializer.BooleanID)
- return getBoolean(data);
-
- if (objID == JSONKafkaSerializer.NULLID)
- return null;
-
- if (objID == JSONKafkaSerializer.JSONArrayID)
- return getArray(data);
-
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/0117987e/metron-streaming/Metron-Common/src/main/java/org/apache/metron/json/serialization/JSONEncoderHelper.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/json/serialization/JSONEncoderHelper.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/json/serialization/JSONEncoderHelper.java
deleted file mode 100644
index 697b7cc..0000000
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/json/serialization/JSONEncoderHelper.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.metron.json.serialization;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.util.Iterator;
-
-import org.apache.commons.configuration.Configuration;
-import org.json.simple.JSONObject;
-
-/**
- * Helper class used for encoding objects into byte arrays
- *
- * @author kiran
- *
- */
-public class JSONEncoderHelper {
-
- public static void putNull(DataOutputStream data, Object value)
- throws IOException {
- // TODO Auto-generated method stub
- data.writeByte(JSONKafkaSerializer.NULLID);
-
- }
-
- public static void putBoolean(DataOutputStream data, Boolean value)
- throws IOException {
- // TODO Auto-generated method stub
- data.writeByte(JSONKafkaSerializer.BooleanID);
- data.writeBoolean(value);
-
- }
-
- public static void putNumber(DataOutputStream data, Number value)
- throws IOException {
- // TODO Auto-generated method stub
- data.writeByte(JSONKafkaSerializer.NumberID);
- if (value instanceof Double) {
- data.writeByte(0);
- data.writeDouble((Double) value);
- return;
- }
- data.writeByte(1);
- data.writeLong((Long) value);
-
- }
-
- public static void putString(DataOutputStream data, String str)
- throws IOException {
- // String ID is 1
- data.writeByte(JSONKafkaSerializer.StringID);
- data.writeInt(str.length());
- data.write(str.getBytes());
-
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public static JSONObject getJSON(Configuration config) {
-
- JSONObject output = new JSONObject();
-
- if (!config.isEmpty()) {
- Iterator it = config.getKeys();
- while (it.hasNext()) {
- String k = (String) it.next();
- // noinspection unchecked
- String v = (String) config.getProperty(k);
- output.put(k, v);
- }
- }
- return output;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/0117987e/metron-streaming/Metron-Common/src/main/java/org/apache/metron/json/serialization/JSONKafkaSerializer.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/json/serialization/JSONKafkaSerializer.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/json/serialization/JSONKafkaSerializer.java
deleted file mode 100644
index 1ecaefb..0000000
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/json/serialization/JSONKafkaSerializer.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.metron.json.serialization;
-
-import static org.apache.metron.json.serialization.JSONDecoderHelper.getObject;
-import static org.apache.metron.json.serialization.JSONEncoderHelper.putBoolean;
-import static org.apache.metron.json.serialization.JSONEncoderHelper.putNull;
-import static org.apache.metron.json.serialization.JSONEncoderHelper.putNumber;
-import static org.apache.metron.json.serialization.JSONEncoderHelper.putString;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import kafka.serializer.Decoder;
-import kafka.serializer.Encoder;
-import kafka.utils.VerifiableProperties;
-
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
-
-/**
- * JSON Serailization class for kafka. Implements kafka Encoder and Decoder
- * String, JSONObject, Number, Boolean,JSONObject.NULL JSONArray
- *
- * @author kiran
- *
- */
-
-public class JSONKafkaSerializer implements Encoder<JSONObject>,
- Decoder<JSONObject> {
-
- // Object ID's for different types
- public static final byte StringID = 1;
- public static final byte JSONObjectID = 2;
- public static final byte NumberID = 3;
- public static final byte BooleanID = 4;
- public static final byte NULLID = 5;
- public static final byte JSONArrayID = 6;
-
- public JSONKafkaSerializer() {
- // Blank constructor needed by Storm
-
- }
-
- public JSONKafkaSerializer(VerifiableProperties props) {
- // Do Nothing. constructor needed by Storm
- }
-
- /*
- * Main Method for unit testing
- */
- public static void main(String args[]) throws IOException {
-
- //String Input = "/home/kiran/git/metron-streaming/Metron-Common/BroExampleOutput";
- String Input = "/tmp/test";
-
- BufferedReader reader = new BufferedReader(new FileReader(Input));
-
- // String jsonString =
- // "{\"dns\":{\"ts\":[14.0,12,\"kiran\"],\"uid\":\"abullis@mail.csuchico.edu\",\"id.orig_h\":\"10.122.196.204\", \"endval\":null}}";
- String jsonString ="";// reader.readLine();
- JSONParser parser = new JSONParser();
- JSONObject json = null;
- int count = 1;
-
- if (args.length > 0)
- count = Integer.parseInt(args[0]);
-
- //while ((jsonString = reader.readLine()) != null)
- jsonString = reader.readLine();
- {
- try {
- json = (JSONObject) parser.parse(jsonString);
- System.out.println(json);
- } catch (ParseException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- String jsonString2 = null;
-
- JSONKafkaSerializer ser = new JSONKafkaSerializer();
-
- for (int i = 0; i < count; i++) {
- byte[] bytes = ser.toBytes(json);
-
- jsonString2 = ((JSONObject)ser.fromBytes(bytes)).toJSONString();
- }
- System.out.println((jsonString2));
- System.out
- .println(jsonString2.equalsIgnoreCase(json.toJSONString()));
- }
-
- }
-
- @SuppressWarnings("unchecked")
- public JSONObject fromBytes(byte[] input) {
-
- ByteArrayInputStream inputBuffer = new ByteArrayInputStream(input);
- DataInputStream data = new DataInputStream(inputBuffer);
-
- JSONObject output = new JSONObject();
-
- try {
- int mapSize = data.readInt();
-
- for (int i = 0; i < mapSize; i++) {
- String key = (String) getObject(data);
- // System.out.println("Key Found"+ key);
- Object val = getObject(data);
- output.put(key, val);
- }
-
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return null;
- }
-
- return output;
- }
-
- @SuppressWarnings("unchecked")
- public JSONObject fromBytes1(DataInputStream data) {
-
- //ByteArrayInputStream inputBuffer = new ByteArrayInputStream(input);
- //DataInputStream data = new DataInputStream(inputBuffer);
-
- JSONObject output = new JSONObject();
-
- try {
- int mapSize = data.readInt();
-
- for (int i = 0; i < mapSize; i++) {
- String key = (String) getObject(data);
- // System.out.println("Key Found"+ key);
- Object val = getObject(data);
- output.put(key, val);
- }
-
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return null;
- }
-
- return output;
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public byte[] toBytes(JSONObject input) {
-
- ByteArrayOutputStream outputBuffer = new ByteArrayOutputStream();
- DataOutputStream data = new DataOutputStream(outputBuffer);
-
- Iterator it = input.entrySet().iterator();
- try {
-
- // write num of entries into output.
- //each KV pair is counted as an entry
- data.writeInt(input.size());
-
- // Write every single entry in hashmap
- //Assuming key to be String.
- while (it.hasNext()) {
- Map.Entry<String, Object> entry = (Entry<String, Object>) it
- .next();
- putObject(data, entry.getKey());
- putObject(data, entry.getValue());
- }
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
-
- return outputBuffer.toByteArray();
- }
-
- private void putObject(DataOutputStream data, Object value)
- throws IOException {
-
- //Check object type and invoke appropriate method
- if (value instanceof JSONObject) {
- putJSON(data, (JSONObject) value);
- return;
-
- }
-
- if (value instanceof String) {
- putString(data, (String) value);
- return;
- }
-
- if (value instanceof Number) {
- putNumber(data, (Number) value);
- return;
- }
-
- if (value instanceof Boolean) {
- putBoolean(data, (Boolean) value);
- return;
- }
-
- if (value == null) {
- putNull(data, value);
- return;
- }
-
- if (value instanceof JSONArray) {
- putArray(data, (JSONArray) value);
- return;
- }
-
- }
-
- private void putJSON(DataOutputStream data, JSONObject value)
- throws IOException {
-
- // JSON ID is 2
- data.writeByte(JSONKafkaSerializer.JSONObjectID);
- data.write(toBytes(value));
-
- }
-
- public void putArray(DataOutputStream data, JSONArray array)
- throws IOException {
-
- data.writeByte(JSONKafkaSerializer.JSONArrayID);
-
- data.writeInt(array.size());
-
- for (Object o : array)
- putObject(data, o);
-
- }
-
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/0117987e/metron-streaming/Metron-Common/src/main/java/org/apache/metron/json/serialization/JSONKryoSerializer.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/json/serialization/JSONKryoSerializer.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/json/serialization/JSONKryoSerializer.java
deleted file mode 100644
index 37e2265..0000000
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/json/serialization/JSONKryoSerializer.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.metron.json.serialization;
-
-import org.json.simple.JSONObject;
-
-import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryo.io.Input;
-import com.esotericsoftware.kryo.io.Output;
-
-/**
- * @author kiran Custom Serializer to help Storm encode and decode JSONObjects
- */
-
-public class JSONKryoSerializer extends
- com.esotericsoftware.kryo.Serializer<JSONObject> {
-
- // JSONKafkaSerializer object actually does the heavy lifting.
- private JSONKafkaSerializer jsonSerde = new JSONKafkaSerializer();
-
- @Override
- public void write(Kryo kryo, Output output, JSONObject json) {
-
- byte[] bytes = jsonSerde.toBytes(json);
- output.writeInt(bytes.length);
- output.write(bytes);
- }
-
- @Override
- public JSONObject read(Kryo kryo, Input input, Class<JSONObject> type) {
-
- // Get number of Entries
- int size = input.readInt();
- byte[] bytes = input.readBytes(size);
-
- JSONObject json = jsonSerde.fromBytes(bytes);
-
- return json;
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/0117987e/metron-streaming/Metron-Common/src/main/java/org/apache/metron/metrics/MetricReporter.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/metrics/MetricReporter.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/metrics/MetricReporter.java
deleted file mode 100644
index a36fed7..0000000
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/metrics/MetricReporter.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.metron.metrics;
-
-import com.codahale.metrics.ConsoleReporter;
-import com.codahale.metrics.Counter;
-import com.codahale.metrics.JmxReporter;
-import com.codahale.metrics.MetricRegistry;
-import com.codahale.metrics.graphite.Graphite;
-import com.codahale.metrics.graphite.GraphiteReporter;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.log4j.Logger;
-
-public class MetricReporter {
-
- final MetricRegistry metrics = new MetricRegistry();
- private ConsoleReporter consoleReporter = null;
- private JmxReporter jmxReporter = null;
- private GraphiteReporter graphiteReporter = null;
-
- private Class _klas;
- private String _topologyname = "topology";
-
- /** The Constant LOGGER. */
- private static final Logger _Logger = Logger
- .getLogger(MetricReporter.class);
-
- public void initialize(Map config, Class klas) {
-
- _Logger.debug("===========Initializing Reporter");
- this._klas = klas;
- if (config.get("topologyname")!=null)
- _topologyname = (String) config.get("topologyname");
-
- this.start(config);
-
- }
-
- public Counter registerCounter(String countername) {
- return metrics.counter(MetricRegistry.name(_topologyname,_klas.getCanonicalName(), countername));
- }
-
- public void start(Map config) {
- try {
- if (config.get("reporter.jmx").equals("true")) {
- jmxReporter = JmxReporter.forRegistry(metrics).build();
- jmxReporter.start();
- }
-
- if (config.get("reporter.console").equals("true")) {
- consoleReporter = ConsoleReporter.forRegistry(metrics).build();
- consoleReporter.start(1, TimeUnit.SECONDS);
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- try {
- if (config.get("reporter.graphite").equals("true")) {
- String address = (String) config.get("graphite.address");
- int port = Integer.parseInt((String) config
- .get("graphite.port"));
-
- _Logger.debug("===========Graphite ADDRESS: " + address + ":"
- + port);
-
- Graphite graphite = new Graphite(new InetSocketAddress(address,
- port));
- // Check if graphite connectivity works
- graphite.connect();
- graphite.close();
-
- graphiteReporter = GraphiteReporter.forRegistry(metrics).build(
- graphite);
-
- _Logger.debug("---------******STARTING GRAPHITE*********---------");
- graphiteReporter.start(1, TimeUnit.SECONDS);
- }
- }
-
- catch (IOException io) {
- _Logger.warn("Unable to Connect to Graphite");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/0117987e/metron-streaming/Metron-Common/src/main/java/org/apache/metron/metrics/MyMetricReporter.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/metrics/MyMetricReporter.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/metrics/MyMetricReporter.java
deleted file mode 100644
index 8175487..0000000
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/metrics/MyMetricReporter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.metron.metrics;
-
-import com.codahale.metrics.ConsoleReporter;
-import com.codahale.metrics.JmxReporter;
-import com.codahale.metrics.MetricRegistry;
-import com.codahale.metrics.graphite.GraphiteReporter;
-
-public class MyMetricReporter extends MetricReporter {
-
- final MetricRegistry metrics = new MetricRegistry();
- private ConsoleReporter consoleReporter = null;
- private JmxReporter jmxReporter=null;
- private GraphiteReporter graphiteReporter = null;
-
-
- public MyMetricReporter(boolean withConsole, boolean withJMX, boolean witGraphite)
- {
- consoleReporter = ConsoleReporter.forRegistry(metrics).build();
- jmxReporter = JmxReporter.forRegistry(metrics).build();
- graphiteReporter = GraphiteReporter.forRegistry(metrics).build(null);
- }
-
-
- public static void main(String[] args) {
- // TODO Auto-generated method stub
-
- }
-
- public void report() {
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/0117987e/metron-streaming/Metron-Common/src/main/java/org/apache/metron/metrics/NullReporter.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/metrics/NullReporter.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/metrics/NullReporter.java
deleted file mode 100644
index 148ea94..0000000
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/metrics/NullReporter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.metron.metrics;
-
-public class NullReporter extends MetricReporter {
-
- public void report()
- {
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/0117987e/metron-streaming/Metron-Common/src/main/java/org/apache/metron/parser/interfaces/MessageFilter.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/parser/interfaces/MessageFilter.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/parser/interfaces/MessageFilter.java
deleted file mode 100644
index 2590570..0000000
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/parser/interfaces/MessageFilter.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.metron.parser.interfaces;
-
-public interface MessageFilter<T> {
-
- boolean emitTuple(T message);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/0117987e/metron-streaming/Metron-Common/src/main/java/org/apache/metron/parser/interfaces/MessageParser.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/parser/interfaces/MessageParser.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/parser/interfaces/MessageParser.java
deleted file mode 100644
index 2db0db6..0000000
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/parser/interfaces/MessageParser.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.metron.parser.interfaces;
-
-import java.util.List;
-
-public interface MessageParser<T> {
-
- void init();
- List<T> parse(byte[] rawMessage);
- boolean validate(T message);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/0117987e/metron-streaming/Metron-Common/src/main/java/org/apache/metron/pcap/Constants.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/pcap/Constants.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/pcap/Constants.java
deleted file mode 100644
index 99945cb..0000000
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/pcap/Constants.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.metron.pcap;
-
-
-/**
-* The Interface Constants.
-*
-* @author sheetal
-* @version $Revision: 1.0 $
-*/
-public interface Constants {
-
-/** The protocol tcp. */
-public static final int PROTOCOL_TCP = 6;
-
-/** The protocol udp. */
-public static final int PROTOCOL_UDP = 17;
-
-/** The document key separator. */
-public static final char DOCUMENT_KEY_SEPARATOR = '-';
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/0117987e/metron-streaming/Metron-Common/src/main/java/org/apache/metron/pcap/IEEE_802_1Q.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/pcap/IEEE_802_1Q.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/pcap/IEEE_802_1Q.java
deleted file mode 100644
index 27fae51..0000000
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/pcap/IEEE_802_1Q.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.metron.pcap;
-
-public class IEEE_802_1Q {
-
- int priorityCodePoint = 0;
- int dropEligibleIndicator = 0;
- int vLANIdentifier = 0;
-
- public IEEE_802_1Q(int priorityCodePoint, int dropEligibleIndicator,
- int vLANIdentifier) {
- this.priorityCodePoint = priorityCodePoint;
- this.dropEligibleIndicator = dropEligibleIndicator;
- this.vLANIdentifier = vLANIdentifier;
- }
-
- public int getPriorityCodePoint() {
- return priorityCodePoint;
- }
-
- public int getDropEligibleIndicator() {
- return dropEligibleIndicator;
- }
-
- public int getvLANIdentifier() {
- return vLANIdentifier;
- }
- }
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/0117987e/metron-streaming/Metron-Common/src/main/java/org/apache/metron/pcap/MetronEthernetDecoder.java
----------------------------------------------------------------------
diff --git a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/pcap/MetronEthernetDecoder.java b/metron-streaming/Metron-Common/src/main/java/org/apache/metron/pcap/MetronEthernetDecoder.java
deleted file mode 100644
index 1609887..0000000
--- a/metron-streaming/Metron-Common/src/main/java/org/apache/metron/pcap/MetronEthernetDecoder.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.metron.pcap;
-
-import java.util.BitSet;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArraySet;
-
-import org.krakenapps.pcap.decoder.ethernet.EthernetDecoder;
-import org.krakenapps.pcap.decoder.ethernet.EthernetFrame;
-import org.krakenapps.pcap.decoder.ethernet.EthernetProcessor;
-import org.krakenapps.pcap.decoder.ethernet.MacAddress;
-import org.krakenapps.pcap.packet.PcapPacket;
-import org.krakenapps.pcap.util.Buffer;
-
-public class MetronEthernetDecoder extends EthernetDecoder {
-
- private Set<EthernetProcessor> callbacks;
- private Map<Integer, Set<EthernetProcessor>> typeCallbacks;
-
- public MetronEthernetDecoder() {
- callbacks = new CopyOnWriteArraySet<EthernetProcessor>();
- typeCallbacks = new ConcurrentHashMap<Integer, Set<EthernetProcessor>>();
- }
-
- public void register(EthernetProcessor processor) {
- this.callbacks.add(processor);
- }
-
- public void register(int type, EthernetProcessor processor) {
- Set<EthernetProcessor> processors = typeCallbacks.get(type);
- if (processors == null) {
- processors = new HashSet<EthernetProcessor>();
- typeCallbacks.put(type, processors);
- }
-
- processors.add(processor);
- }
-
- public void unregister(EthernetProcessor processor) {
- this.callbacks.remove(processor);
- }
-
- public void unregister(int type, EthernetProcessor processor) {
- Set<EthernetProcessor> processors = typeCallbacks.get(type);
- if (processors == null)
- return;
-
- processors.remove(processor);
- }
-
- public void decode(PcapPacket packet) {
- // do not reorder following codes (parse sequence)
- MacAddress destination = getMacAddress(packet.getPacketData());
- MacAddress source = getMacAddress(packet.getPacketData());
- int type = getEtherType(packet.getPacketData());
-
- if (type == 0x8100) {
- // It is 802.1Q VLAN tag
- IEEE_802_1Q iee802_1qTag = get802_1qTag(packet.getPacketData());
- // Now get the type
- type = getEtherType(packet.getPacketData());
- }
-
- Buffer buffer = packet.getPacketData();
- buffer.discardReadBytes();
-
- EthernetFrame frame = new EthernetFrame(source, destination, type, buffer);
- frame.setPcapPacket(packet);
- dispatch(frame);
- }
-
- private MacAddress getMacAddress(Buffer data) {
- byte[] mac = new byte[6];
- data.gets(mac, 0, 6);
- return new MacAddress(mac);
- }
-
- private int getEtherType(Buffer data) {
- return ((int) data.getShort()) & 0x0000FFFF;
- }
-
- private IEEE_802_1Q get802_1qTag(Buffer data) {
-
- // reference http://en.wikipedia.org/wiki/EtherType &
- // http://en.wikipedia.org/wiki/IEEE_802.1Q
- byte[] b802_1qTag = new byte[2];
- data.gets(b802_1qTag, 0, 2);
- BitSet bits = BitSet.valueOf(b802_1qTag);
- int pcp = convertBitToInt(bits.get(0, 3));
- int dei = convertBitToInt(bits.get(3, 4));
- int vid = convertBitToInt(bits.get(4, 16));
-
- return new IEEE_802_1Q(pcp, dei, vid);
- }
-
- public static int convertBitToInt(BitSet bits) {
- int value = 0;
- for (int i = 0; i < bits.length(); ++i) {
- value += bits.get(i) ? (1 << i) : 0;
- }
- return value;
- }
-
- private void dispatch(EthernetFrame frame) {
- for (EthernetProcessor processor : callbacks)
- processor.process(frame);
-
- Set<EthernetProcessor> processors = typeCallbacks.get(frame.getType());
- if (processors == null)
- return;
-
- for (EthernetProcessor processor : processors)
- processor.process(frame.dup());
- }
-}