Return-Path: X-Original-To: apmail-atlas-commits-archive@minotaur.apache.org Delivered-To: apmail-atlas-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7E8D018D7B for ; Thu, 18 Feb 2016 01:22:28 +0000 (UTC) Received: (qmail 72569 invoked by uid 500); 18 Feb 2016 01:22:23 -0000 Delivered-To: apmail-atlas-commits-archive@atlas.apache.org Received: (qmail 72533 invoked by uid 500); 18 Feb 2016 01:22:23 -0000 Mailing-List: contact commits-help@atlas.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@atlas.incubator.apache.org Delivered-To: mailing list commits@atlas.incubator.apache.org Received: (qmail 72524 invoked by uid 99); 18 Feb 2016 01:22:23 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Feb 2016 01:22:23 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 02A89C0C0D for ; Thu, 18 Feb 2016 01:22:23 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -3.226 X-Spam-Level: X-Spam-Status: No, score=-3.226 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.006] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id f6noZ19BYHyS for ; Thu, 18 Feb 2016 01:22:21 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with SMTP id 834885F620 for ; Thu, 18 Feb 2016 01:22:20 +0000 (UTC) Received: (qmail 72509 invoked by uid 99); 18 Feb 2016 01:22:19 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Feb 2016 01:22:19 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 156F5E020D; Thu, 18 Feb 2016 01:22:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sumasai@apache.org To: commits@atlas.incubator.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: incubator-atlas git commit: ATLAS-471 Atlas Server could run out of memory due to Scala memory leak(yhemanth via sumasai) Date: Thu, 18 Feb 2016 01:22:19 +0000 (UTC) Repository: incubator-atlas Updated Branches: refs/heads/master 60ebe8bea -> 64bda5a41 ATLAS-471 Atlas Server could run out of memory due to Scala memory leak(yhemanth via sumasai) Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/64bda5a4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/64bda5a4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/64bda5a4 Branch: refs/heads/master Commit: 64bda5a419cf43c2cdac08d54eee24610b8ad002 Parents: 60ebe8b Author: Suma Shivaprasad Authored: Wed Feb 17 17:22:14 2016 -0800 Committer: Suma Shivaprasad Committed: Wed Feb 17 17:22:14 2016 -0800 ---------------------------------------------------------------------- .../graph/GraphBackedDiscoveryService.java | 3 +- .../org/apache/atlas/query/QueryParser.scala | 4 +- .../org/apache/atlas/query/GremlinTest.scala | 10 ++--- .../org/apache/atlas/query/GremlinTest2.scala | 4 +- .../org/apache/atlas/query/LexerTest.scala | 9 ++-- .../org/apache/atlas/query/ParserTest.scala | 43 +++++++------------- 6 files changed, 29 insertions(+), 44 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/64bda5a4/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java b/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java index 5e84644..f97b83d 100755 --- a/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java +++ b/repository/src/main/java/org/apache/atlas/discovery/graph/GraphBackedDiscoveryService.java @@ -128,8 +128,7 @@ public class GraphBackedDiscoveryService implements DiscoveryService { public GremlinQueryResult evaluate(String dslQuery) throws DiscoveryException { LOG.info("Executing dsl query={}", dslQuery); try { - QueryParser queryParser = new QueryParser(); - Either either = queryParser.apply(dslQuery); + Either either = QueryParser.apply(dslQuery); if (either.isRight()) { Expressions.Expression expression = either.right().get(); return evaluate(expression); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/64bda5a4/repository/src/main/scala/org/apache/atlas/query/QueryParser.scala ---------------------------------------------------------------------- diff --git a/repository/src/main/scala/org/apache/atlas/query/QueryParser.scala b/repository/src/main/scala/org/apache/atlas/query/QueryParser.scala index 8583371..b6bbbd3 100755 --- a/repository/src/main/scala/org/apache/atlas/query/QueryParser.scala +++ b/repository/src/main/scala/org/apache/atlas/query/QueryParser.scala @@ -107,7 +107,7 @@ trait ExpressionUtils { } } -class QueryParser extends StandardTokenParsers with QueryKeywords with ExpressionUtils with PackratParsers { +object QueryParser extends StandardTokenParsers with QueryKeywords with ExpressionUtils with PackratParsers { import scala.language.higherKinds @@ -119,7 +119,7 @@ class QueryParser extends StandardTokenParsers with QueryKeywords with Expressio override val lexical = new QueryLexer(queryreservedWords, querydelims) - def apply(input: String): Either[NoSuccess, Expression] = { + def apply(input: String): Either[NoSuccess, Expression] = synchronized { phrase(queryWithPath)(new lexical.Scanner(input)) match { case Success(r, x) => Right(r) case f@Failure(m, x) => Left(f) http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/64bda5a4/repository/src/test/scala/org/apache/atlas/query/GremlinTest.scala ---------------------------------------------------------------------- diff --git a/repository/src/test/scala/org/apache/atlas/query/GremlinTest.scala b/repository/src/test/scala/org/apache/atlas/query/GremlinTest.scala index 0b57df3..0068364 100755 --- a/repository/src/test/scala/org/apache/atlas/query/GremlinTest.scala +++ b/repository/src/test/scala/org/apache/atlas/query/GremlinTest.scala @@ -899,7 +899,7 @@ class GremlinTest extends BaseGremlinTest { } @Test def testArrayComparision { - val p = new QueryParser + val p = QueryParser val e = p("Partition as p where values = ['2015-01-01']," + " table where name = 'sales_fact_daily_mv'," + " db where name = 'Reporting' and clusterName = 'test' select p").right.get @@ -937,7 +937,7 @@ class GremlinTest extends BaseGremlinTest { } @Test def testArrayComparisionWithSelectOnArray { - val p = new QueryParser + val p = QueryParser val e = p("Partition as p where values = ['2015-01-01']," + " table where name = 'sales_fact_daily_mv'," + " db where name = 'Reporting' and clusterName = 'test' select p.values").right.get @@ -976,7 +976,7 @@ class GremlinTest extends BaseGremlinTest { } @Test def testArrayInWhereClause { - val p = new QueryParser + val p = QueryParser val e = p("Partition as p where values = ['2015-01-01']").right.get val r = QueryProcessor.evaluate(e, g, gp) validateJson(r, """{ @@ -1045,13 +1045,13 @@ class GremlinTest extends BaseGremlinTest { @Test(expectedExceptions = Array(classOf[ExpressionException])) def testNegativeInvalidType { - val p = new QueryParser + val p = QueryParser val e = p("from blah").right.get QueryProcessor.evaluate(e, g, gp) } @Test def testJoinAndSelect5 { - val p = new QueryParser + val p = QueryParser val e = p("Table as t where name = 'sales_fact' db where name = 'Sales' and owner = 'John ETL' select t").right.get val r = QueryProcessor.evaluate(e, g, gp) validateJson(r) http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/64bda5a4/repository/src/test/scala/org/apache/atlas/query/GremlinTest2.scala ---------------------------------------------------------------------- diff --git a/repository/src/test/scala/org/apache/atlas/query/GremlinTest2.scala b/repository/src/test/scala/org/apache/atlas/query/GremlinTest2.scala index b6c1455..79ebfae 100755 --- a/repository/src/test/scala/org/apache/atlas/query/GremlinTest2.scala +++ b/repository/src/test/scala/org/apache/atlas/query/GremlinTest2.scala @@ -89,7 +89,7 @@ class GremlinTest2 extends BaseGremlinTest { } @Test def testLineageAllSelectWithPathFromParser { - val p = new QueryParser + val p = QueryParser val e = p("Table as src loop (LoadProcess outputTable) as dest " + "select src.name as srcTable, dest.name as destTable withPath").right.get //Table as src loop (LoadProcess where LoadProcess.outputTable) as dest select src.name as srcTable, dest.name as destTable withPath @@ -98,7 +98,7 @@ class GremlinTest2 extends BaseGremlinTest { } @Test def testLineageAllSelectWithPathFromParser2 { - val p = new QueryParser + val p = QueryParser val e = p("Table as src loop (`LoadProcess->outputTable` inputTables) as dest " + "select src.name as srcTable, dest.name as destTable withPath").right.get http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/64bda5a4/repository/src/test/scala/org/apache/atlas/query/LexerTest.scala ---------------------------------------------------------------------- diff --git a/repository/src/test/scala/org/apache/atlas/query/LexerTest.scala b/repository/src/test/scala/org/apache/atlas/query/LexerTest.scala index 10e966e..8d9cdaf 100755 --- a/repository/src/test/scala/org/apache/atlas/query/LexerTest.scala +++ b/repository/src/test/scala/org/apache/atlas/query/LexerTest.scala @@ -25,8 +25,8 @@ import scala.util.parsing.input.CharArrayReader class LexerTest { - def scan(p: QueryParser, str: String): p.lexical.ParseResult[_] = { - val l = p.lexical + def scan(str: String): QueryParser.lexical.ParseResult[_] = { + val l = QueryParser.lexical var s: l.Input = new CharArrayReader(str.toCharArray) var r = (l.whitespace.? ~ l.token)(s) s = r.next @@ -37,12 +37,11 @@ class LexerTest { r = (l.whitespace.? ~ l.token)(s) } } - r.asInstanceOf[p.lexical.ParseResult[_]] + r.asInstanceOf[QueryParser.lexical.ParseResult[_]] } @Test def testSimple { - val p = new QueryParser - val r = scan(p, """DB where db1.name""") + val r = scan("""DB where db1.name""") Assert.assertTrue(r.successful) } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/64bda5a4/repository/src/test/scala/org/apache/atlas/query/ParserTest.scala ---------------------------------------------------------------------- diff --git a/repository/src/test/scala/org/apache/atlas/query/ParserTest.scala b/repository/src/test/scala/org/apache/atlas/query/ParserTest.scala index 1655607..8f277fc 100755 --- a/repository/src/test/scala/org/apache/atlas/query/ParserTest.scala +++ b/repository/src/test/scala/org/apache/atlas/query/ParserTest.scala @@ -31,74 +31,61 @@ class ParserTest extends BaseTest { } @Test def testFrom: Unit = { - val p = new QueryParser - println(p("from DB").right.get.toString) + println(QueryParser.apply("from DB").right.get.toString) } @Test def testFrom2: Unit = { - val p = new QueryParser - println(p("DB").right.get.toString) + println(QueryParser.apply("DB").right.get.toString) } @Test def testJoin1: Unit = { - val p = new QueryParser - println(p("DB, Table").right.get.toString) + println(QueryParser.apply("DB, Table").right.get.toString) } @Test def testWhere1: Unit = { - val p = new QueryParser - println(p("DB as db1 Table where db1.name ").right.get.toString) + println(QueryParser.apply("DB as db1 Table where db1.name ").right.get.toString) } @Test def testWhere2: Unit = { - val p = new QueryParser - println(p("DB name = \"Reporting\"").right.get.toString) + println(QueryParser.apply("DB name = \"Reporting\"").right.get.toString) } @Test def testIsTrait: Unit = { - val p = new QueryParser - println(p("Table isa Dimension").right.get.toString) - println(p("Table is Dimension").right.get.toString) + println(QueryParser.apply("Table isa Dimension").right.get.toString) + println(QueryParser.apply("Table is Dimension").right.get.toString) } @Test def test4: Unit = { - val p = new QueryParser - println(p("DB where (name = \"Reporting\") select name as _col_0, (createTime + 1) as _col_1").right.get.toString) + println(QueryParser.apply("DB where (name = \"Reporting\") select name as _col_0, (createTime + 1) as _col_1").right.get.toString) } @Test def testJoin2: Unit = { - val p = new QueryParser - println(p("DB as db1 where (createTime + 1) > 0 and (db1.name = \"Reporting\") or DB has owner Table as tab " + + println(QueryParser.apply("DB as db1 where (createTime + 1) > 0 and (db1.name = \"Reporting\") or DB has owner Table as tab " + " select db1.name as dbName, tab.name as tabName").right.get.toString) } @Test def testLoop: Unit = { - val p = new QueryParser - println(p("Table loop (LoadProcess outputTable)").right.get.toString) + println(QueryParser.apply("Table loop (LoadProcess outputTable)").right.get.toString) } @Test def testNegInvalidateType: Unit = { - val p = new QueryParser - val x = p("from blah") - println(p("from blah").left) + val x = QueryParser.apply("from blah") + println(QueryParser.apply("from blah").left) } @Test def testPath1: Unit = { - val p = new QueryParser - println(p("Table loop (LoadProcess outputTable) withPath").right.get.toString) + println(QueryParser.apply("Table loop (LoadProcess outputTable) withPath").right.get.toString) } @Test def testPath2: Unit = { - val p = new QueryParser - println(p( + println(QueryParser.apply( "Table as src loop (LoadProcess outputTable) as dest " + "select src.name as srcTable, dest.name as destTable withPath").right.get.toString ) } @Test def testList: Unit = { - val p = new QueryParser - println(p( + println(QueryParser.apply( "Partition as p where values = ['2015-01-01']," + " table where name = 'tableoq8ty'," + " db where name = 'default' and clusterName = 'test'").right.get.toString