iota-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rutv...@apache.org
Subject [1/2] incubator-iota git commit: [IOTA-39] - Adding build and run instructions
Date Thu, 09 Feb 2017 21:32:12 GMT
Repository: incubator-iota
Updated Branches:
  refs/heads/master 9db70ca0a -> b84f86a64


[IOTA-39] - Adding build and run instructions


Project: http://git-wip-us.apache.org/repos/asf/incubator-iota/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-iota/commit/74fbdbd6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-iota/tree/74fbdbd6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-iota/diff/74fbdbd6

Branch: refs/heads/master
Commit: 74fbdbd64948a29b250dbfd41cb04d2ee526a99b
Parents: 9db70ca
Author: Barbara Gomes <barbaramaltagomes@gmail.com>
Authored: Thu Feb 9 12:39:01 2017 -0800
Committer: Barbara Gomes <barbaramaltagomes@gmail.com>
Committed: Thu Feb 9 12:39:01 2017 -0800

----------------------------------------------------------------------
 Readme.md                                       | 137 +++++++++++++++++++
 .../src/main/scala/GlobalWatchService.scala     | 106 --------------
 .../apache/iota/fey/GlobalWatchService.scala    | 106 ++++++++++++++
 images/Fey-Active-Actors-Monitoring.png         | Bin 0 -> 23879 bytes
 images/Fey-Active-Actors.png                    | Bin 0 -> 25124 bytes
 5 files changed, 243 insertions(+), 106 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/74fbdbd6/Readme.md
----------------------------------------------------------------------
diff --git a/Readme.md b/Readme.md
index a8cff21..be1a69b 100644
--- a/Readme.md
+++ b/Readme.md
@@ -11,3 +11,140 @@ iota components found in the folders in this code repository and they
include:
 ## iota architecture
 
  ![iota architecture](./images/iota.png)
+ 
+ 
+# Building and Running IOTA
+
+Fey is a Scala framework developed using Akka Actors (<http://akka.io/>). If still
don't know the Actor model offered by Akka, We suggested that you take sometime to look into
it and get at least a basic idea of the Akka Actor model and concepts. The current version
of Akka that is being used on Fey is `2.10.4`
+
+In order to be able to build and run it you will need to install the following on your machine:
+
+## Prerequisites
+
+1. Java **SDK** (Software Development Kit) 1.8+
+2. Scala 2.11.8
+3. **SBT** 0.13.11 (<http://www.scala-sbt.org/>)
+
+Once your environment is ready to go, you will need to download the source code:
+
+## Source code
+
+Choose the directory where you want to download the source code to. Lets call it **IOTA_SOURCE_DIR**.
+
+The source code for IOTA is available at GitHub (<https://github.com/apache/incubator-iota>).
Make sure you have **git** installed.
+
+```shell
+>> cd IOTA_SOURCE_DIR
+>> git clone git@github.com:apache/incubator-iota.git
+
+```
+
+Once the **git clone** command has finished with success, you should see the source code
for IOTA in the folder **incubator-iota**
+
+### Code structure
+
+IOTA project is composed by 3 main components: fey-core, performers and deployments.
+
+1. **fey-core**: Contains the source code of the core component of IOTA, called **Fey**.
We will be mainly talking about how to build and run the fey-core component
+2. **performers**: Fey-core by itself does not do anything, it is only an Actor System. Performers
are the actors of the system, and the actual action executed in the framework. This folder
contain some performer examples.
+3. **deployments**: TBD
+
+We will be focused on the **fey-core** and **performers** components.
+
+## Building fey-core
+
+Fey core uses the SBT tool. In order to build the fey-core **.jar** go to your terminal and:
+
+```shell
+>> cd IOTA_SOURCE_DIR\incubator-iota
+>> sbt 
+>> project fey-core
+>> assembly 
+
+```
+
+The command `assembly` will run all fey-core unit tests and build the **.jar**. If everything
is executed successfuly you should see a message like:
+
+```
+[info] SHA-1: 5644d19b7ebc9dec87646e9327a4c163c62936d3
+[info] Packaging IOTA_SOURCE_DIR/incubator-iota/fey-core/target/scala-2.11/iota-fey-core.jar
...
+[info] Done packaging.
+[success] Total time: 70 s, completed Feb 7, 2017 11:13:30 AM
+```
+
+Check at `IOTA_SOURCE_DIR/incubator-iota/fey-core/target/scala-2.11` for the **iota-fey-core.jar**
+
+## Configuring Fey
+
+Once you have built fey-core, you should configure it propertly.
+Fey-core reads a **.conf** file. The default configuration can be find at ```IOTA_SOURCE_DIR/incubator-iota/fey-core\src\main\resources\application.conf```
+
+The basic configuration you should worry about are the directories used by Fey. Fey core
does not create the directories, therefore, the directories must be already created before
starting Fey.
+
+Let's create a basic configuration for fey.
+
+1. Create a **my-fey.conf** file with the folllowing content:
+
+```javascript
+fey-global-configuration{
+
+enable-checkpoint = true
+
+checkpoint-directory = ${HOME}"/feyCheckpoint"
+
+json-repository = ${HOME}"/feyJSONRepo"
+
+json-extension = ".json"
+
+jar-repository = ${HOME}"/feyJarRepo"
+
+log-level = "INFO"
+}
+
+```
+
+Create the directories that are going to be used by Fey: 
+
+1. ${HOME}"/feyCheckpoint"
+2. ${HOME}"/feyJSONRepo"
+3. ${HOME}"/feyJarRepo"
+
+## Running Fey
+
+Once you have defined the my-fey.conf configuration file for fey, and created all the necessary
directories you should be ready to run Fey.
+
+```sh
+>> java -jar IOTA_SOURCE_DIR/incubator-iota/fey-core/target/scala-2.11/iota-fey-core.jar
PATH_TO/my-fey.conf
+```
+
+You should see an output like:
+
+
+```
+[INFO] [17/02/07 12:11:17] akka.event.slf4j.Slf4jLogger [] : Slf4jLogger started
+[INFO] [17/02/07 12:11:17] org.apache.iota.fey.FeyCore [akka://FEY-MANAGEMENT-SYSTEM/user/FEY-CORE]
: Starting Fey Core
+[INFO] [17/02/07 12:11:17] org.apache.iota.fey.GlobalWatchService [akka://FEY-MANAGEMENT-SYSTEM/user/FEY-CORE/GLOBAL_WATCH_SERVICE]
: Starting Global Watcher from PRE-START
+[INFO] [17/02/07 12:11:17] org.apache.iota.fey.Monitor [akka://FEY-MANAGEMENT-SYSTEM/user/FEY-MONITOR]
: START | 1486498277506 | akka://FEY-MANAGEMENT-SYSTEM/user/FEY-CORE | 
+[INFO] [17/02/07 12:11:17] org.apache.iota.fey.Monitor [akka://FEY-MANAGEMENT-SYSTEM/user/FEY-MONITOR]
: START | 1486498277514 | akka://FEY-MANAGEMENT-SYSTEM/user/FEY-CORE/JSON_RECEIVER | 
+[INFO] [17/02/07 12:11:17] akka.event.slf4j.Slf4jLogger [] : Slf4jLogger started
+[INFO] [17/02/07 12:11:17] play.api.Play [] : Application started (Prod)
+[INFO] [17/02/07 12:11:17] play.core.server.NettyServer [] : Listening for HTTP on /0:0:0:0:0:0:0:0:16666
+```
+
+To make sure everything is running smoothly, check the Fey monitoring end points.
+
+Go to your browser and type in <http://localhost:16666/fey/activeactors>. You should
see one Actor System and 2 Actors running:
+
+![Fey actor hierarchy](./images/Fey-Active-Actors.png)
+
+Open another tab in your browser and go to <http://localhost:16666/fey/monitoringevents>
+
+You should see the START event for the two Actors running on Fey:
+
+![Fey actor hierarchy](./images/Fey-Active-Actors-Monitoring.png)
+
+## Writing Hello World Performer
+
+TBD
+
+

http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/74fbdbd6/fey-core/src/main/scala/GlobalWatchService.scala
----------------------------------------------------------------------
diff --git a/fey-core/src/main/scala/GlobalWatchService.scala b/fey-core/src/main/scala/GlobalWatchService.scala
deleted file mode 100644
index 3d4377c..0000000
--- a/fey-core/src/main/scala/GlobalWatchService.scala
+++ /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.iota.fey
-
-import java.nio.file.{Files, Path, Paths, WatchEvent}
-
-import akka.actor.{Actor, ActorLogging, ActorRef}
-import org.apache.iota.fey.GlobalWatchService.{ENTRY_CREATED, REGISTER_WATCHER_PERFORMER}
-import org.apache.iota.fey.WatchingDirectories.STOPPED
-
-class GlobalWatchService extends Actor with ActorLogging{
-
-  //WatchService
-  var watchThread:Thread = null
-  val watchFileTask:GlobalWatchServiceTask = new GlobalWatchServiceTask(self)
-
-  override def preStart(): Unit = {
-    startWatcher("PRE-START")
-  }
-
-  override def postStop(): Unit = {
-    stopWatcher("POST-STOP")
-  }
-
-  private def startWatcher(from: String) = {
-    log.info(s"Starting Global Watcher from $from")
-    watchThread = new Thread(watchFileTask, "FEY_GLOBAL_WATCH_SERVICE_PERFORMERS")
-    watchThread.setDaemon(true)
-    watchThread.start()
-  }
-
-  private def stopWatcher(from: String) = {
-    log.info(s"Stopping Global Watcher from $from")
-    if(watchThread != null && watchThread.isAlive){
-      watchThread.interrupt()
-      watchThread = null
-    }
-  }
-
-  override def receive: Receive = {
-    case REGISTER_WATCHER_PERFORMER(path, file_name, actor, events, loadExists) =>
-      registerPath(path,file_name,actor,events,loadExists)
-    case STOPPED =>
-      stopWatcher("STOPPED-THREAD")
-      startWatcher("STOPPED-THREAD")
-    case x => log.error(s"Unknown message $x")
-  }
-
-  private def broadcastMessageIfFileExists(actor: ActorRef, pathWithFile: String) = {
-    val filePath = Paths.get(pathWithFile)
-    if(Files.exists(filePath)){
-      log.info(s"File $pathWithFile exists. Broadcasting message to actor ${actor.path.toString}")
-      actor ! GlobalWatchService.ENTRY_CREATED(filePath)
-    }
-  }
-
-  private def registerPath(dir_path: String, file_name:Option[String], actor: ActorRef, events:
Array[WatchEvent.Kind[_]], loadExists: Boolean) = {
-    WatchingDirectories.actorsInfo.get((dir_path,file_name)) match {
-      case Some(info) =>
-        val newInfo:Map[WatchEvent.Kind[_], Array[ActorRef]] = events.map(event => {
-          info.get(event) match {
-            case Some(actors) => (event, (Array(actor) ++ actors))
-            case None => (event, Array(actor))
-          }
-        }).toMap
-        WatchingDirectories.actorsInfo.put((dir_path,file_name), info ++ newInfo)
-        watchFileTask.watch(Paths.get(dir_path),actor.path.toString,events)
-      case None =>
-        val tmpEvents:Map[WatchEvent.Kind[_], Array[ActorRef]] = events.map(event => {(event,
Array(actor))}).toMap
-        WatchingDirectories.actorsInfo.put((dir_path,file_name), tmpEvents)
-        watchFileTask.watch(Paths.get(dir_path),actor.path.toString,events)
-    }
-
-    if(file_name.isDefined && loadExists){
-      log.info(s"Checking if file $dir_path/${file_name.get} already exist")
-      broadcastMessageIfFileExists(actor, s"$dir_path/${file_name.get}")
-    }
-
-  }
-
-}
-
-object GlobalWatchService{
-  sealed case class ENTRY_CREATED(path:Path)
-  sealed case class ENTRY_MODIFIED(path:Path)
-  sealed case class ENTRY_DELETED(path:Path)
-  sealed case class REGISTER_WATCHER_PERFORMER(dir_path: String, file_name:Option[String],
-                                               actor: ActorRef, events: Array[WatchEvent.Kind[_]],
-                                               loadIfExists: Boolean)
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/74fbdbd6/fey-core/src/main/scala/org/apache/iota/fey/GlobalWatchService.scala
----------------------------------------------------------------------
diff --git a/fey-core/src/main/scala/org/apache/iota/fey/GlobalWatchService.scala b/fey-core/src/main/scala/org/apache/iota/fey/GlobalWatchService.scala
new file mode 100644
index 0000000..d3b4d40
--- /dev/null
+++ b/fey-core/src/main/scala/org/apache/iota/fey/GlobalWatchService.scala
@@ -0,0 +1,106 @@
+
+/*
+ * 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.iota.fey
+
+import java.nio.file.{Files, Path, Paths, WatchEvent}
+
+import akka.actor.{Actor, ActorLogging, ActorRef}
+import org.apache.iota.fey.GlobalWatchService.REGISTER_WATCHER_PERFORMER
+import org.apache.iota.fey.WatchingDirectories.STOPPED
+
+class GlobalWatchService extends Actor with ActorLogging{
+
+  //WatchService
+  var watchThread:Thread = null
+  val watchFileTask:GlobalWatchServiceTask = new GlobalWatchServiceTask(self)
+
+  override def preStart(): Unit = {
+    startWatcher("PRE-START")
+  }
+
+  override def postStop(): Unit = {
+    stopWatcher("POST-STOP")
+  }
+
+  private def startWatcher(from: String) = {
+    log.info(s"Starting Global Watcher from $from")
+    watchThread = new Thread(watchFileTask, "FEY_GLOBAL_WATCH_SERVICE_PERFORMERS")
+    watchThread.setDaemon(true)
+    watchThread.start()
+  }
+
+  private def stopWatcher(from: String) = {
+    log.info(s"Stopping Global Watcher from $from")
+    if(watchThread != null && watchThread.isAlive){
+      watchThread.interrupt()
+      watchThread = null
+    }
+  }
+
+  override def receive: Receive = {
+    case REGISTER_WATCHER_PERFORMER(path, file_name, actor, events, loadExists) =>
+      registerPath(path,file_name,actor,events,loadExists)
+    case STOPPED =>
+      stopWatcher("STOPPED-THREAD")
+      startWatcher("STOPPED-THREAD")
+    case x => log.error(s"Unknown message $x")
+  }
+
+  private def broadcastMessageIfFileExists(actor: ActorRef, pathWithFile: String) = {
+    val filePath = Paths.get(pathWithFile)
+    if(Files.exists(filePath)){
+      log.info(s"File $pathWithFile exists. Broadcasting message to actor ${actor.path.toString}")
+      actor ! GlobalWatchService.ENTRY_CREATED(filePath)
+    }
+  }
+
+  private def registerPath(dir_path: String, file_name:Option[String], actor: ActorRef, events:
Array[WatchEvent.Kind[_]], loadExists: Boolean) = {
+    WatchingDirectories.actorsInfo.get((dir_path,file_name)) match {
+      case Some(info) =>
+        val newInfo:Map[WatchEvent.Kind[_], Array[ActorRef]] = events.map(event => {
+          info.get(event) match {
+            case Some(actors) => (event, (Array(actor) ++ actors))
+            case None => (event, Array(actor))
+          }
+        }).toMap
+        WatchingDirectories.actorsInfo.put((dir_path,file_name), info ++ newInfo)
+        watchFileTask.watch(Paths.get(dir_path),actor.path.toString,events)
+      case None =>
+        val tmpEvents:Map[WatchEvent.Kind[_], Array[ActorRef]] = events.map(event => {(event,
Array(actor))}).toMap
+        WatchingDirectories.actorsInfo.put((dir_path,file_name), tmpEvents)
+        watchFileTask.watch(Paths.get(dir_path),actor.path.toString,events)
+    }
+
+    if(file_name.isDefined && loadExists){
+      log.info(s"Checking if file $dir_path/${file_name.get} already exist")
+      broadcastMessageIfFileExists(actor, s"$dir_path/${file_name.get}")
+    }
+
+  }
+
+}
+
+object GlobalWatchService{
+  sealed case class ENTRY_CREATED(path:Path)
+  sealed case class ENTRY_MODIFIED(path:Path)
+  sealed case class ENTRY_DELETED(path:Path)
+  sealed case class REGISTER_WATCHER_PERFORMER(dir_path: String, file_name:Option[String],
+                                               actor: ActorRef, events: Array[WatchEvent.Kind[_]],
+                                               loadIfExists: Boolean)
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/74fbdbd6/images/Fey-Active-Actors-Monitoring.png
----------------------------------------------------------------------
diff --git a/images/Fey-Active-Actors-Monitoring.png b/images/Fey-Active-Actors-Monitoring.png
new file mode 100644
index 0000000..51d2cbe
Binary files /dev/null and b/images/Fey-Active-Actors-Monitoring.png differ

http://git-wip-us.apache.org/repos/asf/incubator-iota/blob/74fbdbd6/images/Fey-Active-Actors.png
----------------------------------------------------------------------
diff --git a/images/Fey-Active-Actors.png b/images/Fey-Active-Actors.png
new file mode 100644
index 0000000..fe69552
Binary files /dev/null and b/images/Fey-Active-Actors.png differ


Mime
View raw message