You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iota.apache.org by to...@apache.org on 2016/07/14 19:54:31 UTC
[2/9] incubator-iota git commit: Adding configuration for supporting
dynamic jar download
Adding configuration for supporting dynamic jar download
Project: http://git-wip-us.apache.org/repos/asf/incubator-iota/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-iota/commit/a9698b34
Tree: http://git-wip-us.apache.org/repos/asf/incubator-iota/tree/a9698b34
Diff: http://git-wip-us.apache.org/repos/asf/incubator-iota/diff/a9698b34
Branch: refs/heads/master
Commit: a9698b34f2b3ddf30da538bfb99dfeffbb231c16
Parents: 606fbd2
Author: Barbara Gomes <ba...@gmail.com>
Authored: Wed Jul 13 12:52:09 2016 -0700
Committer: Barbara Gomes <ba...@gmail.com>
Committed: Wed Jul 13 12:52:09 2016 -0700
----------------------------------------------------------------------
fey-core/src/main/resources/application.conf | 13 ++++++++
.../main/scala/org/apache/iota/fey/Utils.scala | 32 ++++++++++++++++----
2 files changed, 39 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/a9698b34/fey-core/src/main/resources/application.conf
----------------------------------------------------------------------
diff --git a/fey-core/src/main/resources/application.conf b/fey-core/src/main/resources/application.conf
index 0ea6092..3816151 100644
--- a/fey-core/src/main/resources/application.conf
+++ b/fey-core/src/main/resources/application.conf
@@ -46,6 +46,19 @@ fey-global-configuration{
// jars that are being specified in the Orchestration JSON
jar-repository = ${HOME}"/feyJarRepo"
+ // Configuration for downloading performers jar at runtime
+ // using the JSON Location property
+ dynamic-jar-population{
+ // Directory where Fey will download the jars that the location is
+ // specified in the JSON
+ downloaded-repository = ${HOME}"/.fey/jars"
+
+ // If enabled, Fey will clean up the jar-downloaded-repository everytime
+ // it starts, forcing the jars to be downloaded again
+ // If false, Fey will only download jars that are not in jar-downloaded-repository
+ force-pull = false
+ }
+
// Fey Log Level
log-level = "DEBUG"
http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/a9698b34/fey-core/src/main/scala/org/apache/iota/fey/Utils.scala
----------------------------------------------------------------------
diff --git a/fey-core/src/main/scala/org/apache/iota/fey/Utils.scala b/fey-core/src/main/scala/org/apache/iota/fey/Utils.scala
index 2cdcff0..58b98d6 100644
--- a/fey-core/src/main/scala/org/apache/iota/fey/Utils.scala
+++ b/fey-core/src/main/scala/org/apache/iota/fey/Utils.scala
@@ -24,9 +24,10 @@ import java.nio.file.{Files, Paths}
import ch.qos.logback.classic.{Level, Logger, LoggerContext}
import ch.qos.logback.core.joran.spi.JoranException
import ch.qos.logback.core.util.StatusPrinter
+import com.eclipsesource.schema.SchemaType
import com.typesafe.config.ConfigFactory
import org.slf4j.LoggerFactory
-import play.api.libs.json.{JsValue, Json}
+import play.api.libs.json.{JsObject, JsValue, Json}
import scala.collection.mutable.HashMap
import scala.io.Source
@@ -71,7 +72,7 @@ protected object Utils {
loadedJars.get(path) match {
case None =>
- val urls:Array[URL] = Array(new URL("jar:file:" + path+"!/"))
+ val urls:Array[URL] = Array(new URL(s"jar:file:$path!/"))
val cl: URLClassLoader = URLClassLoader.newInstance(urls)
val clazz = cl.loadClass(className)
val feyClazz = clazz.asInstanceOf[Class[FeyGenericActor]]
@@ -109,9 +110,10 @@ protected object Utils {
}
}
- def renameProcessedFile(file: File, extension: String) = {
- if(CHEKPOINT_ENABLED)
+ def renameProcessedFile(file: File, extension: String): Unit = {
+ if(CHEKPOINT_ENABLED) {
file.renameTo(new File(s"${file.getAbsoluteFile}.$extension"))
+ }
}
/**
@@ -125,8 +127,9 @@ protected object Utils {
if (CHEKPOINT_ENABLED) {
FEY_CACHE.activeOrchestrations.get(orchestrationID) match {
case None =>
- if (!delete)
+ if (!delete) {
log.warn(s"Could not save state for Orchestration ${orchestrationID}. It is not active on Fey.")
+ }
else {
val file = new File(s"$CHECKPOINT_DIR/${orchestrationID}.json")
if (!file.createNewFile()) {
@@ -161,9 +164,11 @@ protected object Utils {
/**
* timestamp in milliseconds
+ *
* @return Long
*/
def getTimestamp:Long = System.currentTimeMillis()
+
}
object JSON_PATH{
@@ -182,6 +187,7 @@ object JSON_PATH{
val ORCHESTRATION_TIMESTAMP = "timestamp"
val PERFORMER_AUTO_SCALE = "autoScale"
val CONTROL_AWARE = "controlAware"
+ val JAR_LOCATION = "location"
}
object CONFIG{
@@ -199,7 +205,9 @@ object CONFIG{
var CHEKPOINT_ENABLED = true
var LOG_LEVEL = ""
var LOG_APPENDER = ""
- var MESSAGES_PER_RESIZE = 500
+ var MESSAGES_PER_RESIZE:Int = 500
+ var DYNAMIC_JAR_REPO = ""
+ var DYNAMIC_JAR_FORCE_PULL = false
def loadUserConfiguration(path: String) : Unit = {
@@ -221,6 +229,8 @@ object CONFIG{
LOG_LEVEL = app.getString("log-level").toUpperCase()
LOG_APPENDER = app.getString("log-appender").toUpperCase()
MESSAGES_PER_RESIZE = app.getInt("auto-scale.messages-per-resize")
+ DYNAMIC_JAR_REPO = app.getString("dynamic-jar-population.downloaded-repository")
+ DYNAMIC_JAR_FORCE_PULL = app.getBoolean("dynamic-jar-population.force-pull")
setLogbackConfiguration()
}
@@ -266,6 +276,16 @@ object CONFIG{
Level.INFO
}
}
+
+ /**
+ * Loads the specification for validating a Fey JSON
+ */
+ val JSON_SPEC: SchemaType = {
+ Json.fromJson[SchemaType](Json.parse(scala.io.Source
+ .fromInputStream(getClass.getResourceAsStream("/fey-json-schema-validator.json"))
+ .getLines()
+ .mkString(""))).get
+ }
}