mardi 3 mars 2020

TooBox.compile is getting stucked in multi process +multi threaded environment in sprak

Getting this exception :

Blocked by Thread Some(393) Lock(org.apache.spark.util.MutableURLClassLoader@2095250634}) Lock(java.util.concurrent.ThreadPoolExecutor$Worker@29085216}),

code snippet:

def compile[A](code: String): (Map[String, Any]) => A = {
    val tb = runtimeMirror(Thread.currentThread().getContextClassLoader).mkToolBox()
    val tree = tb.parse(
      s"""
         |def evaluate(dataMap: Map[String, Any]): Any = {
         |  $code
         |}
         |evaluate _
      """.stripMargin)
    try {

      tb.eval(tree).asInstanceOf[(Map[String, Any]) => A]
    }
    catch {
      case e: ToolBoxError =>
        throw new Exception(s"Not able to parse expression,please check publishingRules Expression",e)
    }
  }

Code is stucked at tb.eval(tree).asInstanceOf[(Map[String, Any]) => A] Any suggestion how to overcome this ?





Aucun commentaire:

Enregistrer un commentaire