Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/nfn' into typed-abstractmachine
Browse files Browse the repository at this point in the history
  • Loading branch information
basilkohler committed May 26, 2014
2 parents 6a8563a + 199d8ab commit 0a4c914
Show file tree
Hide file tree
Showing 14 changed files with 237 additions and 128 deletions.
6 changes: 2 additions & 4 deletions krivine.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,7 @@ ZAM_term(struct ccnl_relay_s *ccnl, struct configuration_s *config,
int i1, i2, acc;
char res[1000];
memset(res, 0, sizeof(res));
if(!cp) cp = "NULL";
DEBUGMSG(2, "---to do: OP_CMPEQ <%s>/<%s>\n", cp, pending);
DEBUGMSG(2, "---to do: OP_CMPEQ<%s>\n", pending);
pop2int();
acc = i1 == i2;
if(acc)
Expand All @@ -642,8 +641,7 @@ ZAM_term(struct ccnl_relay_s *ccnl, struct configuration_s *config,
int i1, i2, acc;
char res[1000];
memset(res, 0, sizeof(res));
if(!cp) cp = "NULL";
DEBUGMSG(2, "---to do: OP_CMPLEQ <%s>/%s\n", cp, pending);
DEBUGMSG(2, "---to do: OP_CMPLEQ<%s>\n", pending);
pop2int();
acc = i2 <= i1;
if(acc)
Expand Down
27 changes: 16 additions & 11 deletions nfn/lambdacalc/src/main/scala/lambdacalculus/parser/ast/AST.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object LambdaDSLTest extends App {

val a: Expr = 'x @: "y" @: (('x * 1) - "y")

val b: Call = "/WordCount" call ("/doc/doc1" :: Nil)
val b: Call = "/WordCount" appl ("/doc/doc1" :: Nil)

val l: Expr = ("derp" =: 'a) ~ ('derp)
}
Expand All @@ -41,6 +41,8 @@ object LambdaDSL {
implicit def stringToExpr (str: String): Variable = Variable(str)
implicit def intToConstant(c: Int):Constant = Constant(c)
implicit def listOfStringToListOfExprs(listOfStr: List[String]): List[Expr] = listOfStr map { str => stringToExpr(str) }

def iif(test: Expr, thenn: Expr, otherwise: Expr) = IfElse(test, thenn, otherwise)
}

sealed abstract class Expr extends Positional {
Expand All @@ -51,10 +53,11 @@ sealed abstract class Expr extends Positional {
def - (expr: Expr) = BinaryExpr(BinaryOp.Sub, this, expr)
def * (expr: Expr) = BinaryExpr(BinaryOp.Mult, this, expr)
def / (expr: Expr) = BinaryExpr(BinaryOp.Div, this, expr)
def > (expr: Expr) = BinaryExpr(BinaryOp.Gt, this, expr)
def ===(expr: Expr) = BinaryExpr(BinaryOp.Eq, this, expr)
def =:(symbolName: Symbol): Let = Let(symbolName.name, this, None)
def =:(name: String): Let = Let(name, this, None)

def iif(test: Expr, thenn: Expr, otherwise: Expr) = IfElse(test, thenn, otherwise)
}

case class Clos(boundVariable: String, body: Expr) extends Expr {
Expand All @@ -71,15 +74,17 @@ object Variable {
}

case class Variable(name: String, accessValue: Int = -1) extends Expr {
def apply(args: List[Expr]): Call = call(args)
def call(args: List[Expr]): Call = {
import LambdaDSL._
Symbol(this.name) -> args
}
def call(arg1: Expr): Call = {
import LambdaDSL._
Symbol(this.name) -> List(arg1)
}
def apply(args: List[Expr]): Call = appl(args)

import LambdaDSL._
def appl(args: List[Expr]): Call = Symbol(this.name) -> args
def appl(): Call = Symbol(this.name) -> List()
def appl(arg1: Expr): Call = Symbol(this.name) -> List(arg1)
def appl(arg1: Expr, arg2: Expr): Call = Symbol(this.name) -> List(arg1, arg2)
def appl(arg1: Expr, arg2: Expr, arg3: Expr): Call = Symbol(this.name) -> List(arg1, arg2, arg3)
def appl(arg1: Expr, arg2: Expr, arg3: Expr, arg4: Expr): Call = Symbol(this.name) -> List(arg1, arg2, arg3, arg4)
def appl(arg1: Expr, arg2: Expr, arg3: Expr, arg4: Expr, arg5: Expr): Call = Symbol(this.name) -> List(arg1, arg2, arg3, arg4, arg5)
def appl(arg1: Expr, arg2: Expr, arg3: Expr, arg4: Expr, arg5: Expr, arg6: Expr): Call = Symbol(this.name) -> List(arg1, arg2, arg3, arg4, arg5, arg6)
}

object Constant {
Expand Down
22 changes: 15 additions & 7 deletions nfn/src/main/scala/ccn/CCNLiteProcess.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class LogStreamReaderToFile(is: InputStream, logname: String, appendTimestamp: B
* Call start and stop.
* @param nodeConfig
*/
case class CCNLiteProcess(nodeConfig: NodeConfig) extends Logging {
case class CCNLiteProcess(nodeConfig: NodeConfig, withCompute: Boolean) extends Logging {

case class NetworkFace(toHost: String, toPort: Int) {
private val cmdUDPFace = s"../util/ccn-lite-ctrl -x $sockName newUDPface any $toHost $toPort"
Expand Down Expand Up @@ -72,26 +72,34 @@ case class CCNLiteProcess(nodeConfig: NodeConfig) extends Logging {
val sockName = s"/tmp/mgmt.${nodeConfig.prefix.cmps.mkString(".")}.sock"

var udpFaces:Map[(String, Int), NetworkFace] = Map()
val processName = if(withCompute) "CCNLiteNFNProcess" else "CCNLiteProcess"

def start() = {
if(port != 10020) {
// if(port != 10010) {

val cmd = s"../ccn-lite-relay -v 99 -u $port -x $sockName"
println(s"CCNLiteProcess-$prefix: executing: '$cmd'")
val ccnliteExecutable = if(withCompute) "../ccn-nfn-relay" else "../ccn-lite-relay"
val cmd = s"$ccnliteExecutable -v 99 -u $port -x $sockName"
println(s"$processName-$prefix: executing: '$cmd'")
val processBuilder = new ProcessBuilder(cmd.split(" "): _*)
processBuilder.redirectErrorStream(true)
process = processBuilder.start



val lsr = new LogStreamReaderToFile(process.getInputStream, s"ccnlite-$host-$port", appendTimestamp = true)
val thread = new Thread(lsr, s"LogStreamReader-$prefix")
thread.start
thread.start()

}
// }
globalFaceId = 2

if(withCompute) {
addPrefix(CCNName("COMPUTE"), nodeConfig.host, nodeConfig.computePort)
}
}

def stop() = {
println(s"CCNLiteProcess-$prefix: stop")
println(s"$processName-$prefix: stop")
if (process != null) {
process.destroy()
}
Expand Down
2 changes: 1 addition & 1 deletion nfn/src/main/scala/config/AkkaConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import akka.util.Timeout
object AkkaConfig {


val timeoutDuration: FiniteDuration = 5 seconds
val timeoutDuration: FiniteDuration = 10 seconds
implicit val timeout = Timeout( timeoutDuration)

val configInfo =
Expand Down
45 changes: 29 additions & 16 deletions nfn/src/main/scala/evaluation/Experiment2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ object Experiment2 extends App {
val node1 = Node(node1Config, withLocalAM = false)
val node2 = Node(node2Config, withLocalAM = false)
val node3 = Node(node3Config, withLocalAM = false)
val node4 = Node(node4Config, withLocalAM = false)//, withComputeServer = false)
val node4 = Node(node4Config, withLocalAM = false, withComputeServer = false)

node1 <~> node2
node1 <~> node3
Expand All @@ -52,18 +52,27 @@ object Experiment2 extends App {
node3.addNodeFace(node4, node2)
node4.addNodeFace(node1, node2)
node4.addNodeFace(node3, node2)

node4.addPrefixFace(WordCountService().ccnName, node2)

node1 += docContent1
node2 += docContent2
node3 += docContent3
node4 += docContent4

node1.publishServices
node2.publishServices
node3.publishServices
node4.publishServices
// node1.publishServices
// node2.publishServices
// node3.publishServices
// node4.publishServices
// node4.removeLocalServices

// node1.removeLocalServices
// node2.removeLocalServices
// node3.removeLocalServices
// node4.removeLocalServices

node2.publishService(WordCountService())

Thread.sleep(1000)

import LambdaDSL._
Expand All @@ -76,30 +85,34 @@ object Experiment2 extends App {

val exComp: Expr = 'x @: ('x + 10) ! 2

val exSimpleCall: Expr = wc call docname2
val exSimpleCall: Expr = wc appl docname2

val exThunkVsNoThunk: Expr = (wc appl List(docname2)) + (wc appl List(docname3))

val exRouteTowardsData: Expr = wc appl List(docname4)

val exThunkVsNoThunk: Expr = (wc call List(docname2)) + (wc call List(docname3))
val exCallCall: Expr = wc appl (ts appl docname2)

val exRouteTowardsData: Expr = wc call List(docname4)
val exCallCallCall: Expr = wc appl (ts appl (ts appl docname2))

val exCallCall: Expr = wc call (ts call docname2)

val exServ1 = wc appl List(docname3)
val exServ2 = wc appl List(docname2)
val exComposedServ: Expr = ss appl List(exServ1, exServ2)

val exServ1 = wc call List(docname3)
val exServ2 = wc call List(docname2)
val exComposedServ: Expr = ss call List(exServ1, exServ2)
val exAddAdd = ((wc appl docname1) + (wc appl docname2)) + ((wc appl docname3) + (wc appl docname4))

val exAddAdd = ((wc call docname1) + (wc call docname2)) + ((wc call docname3) + (wc call docname4))
val exIf = iif((wc appl docname2) === 2, ts appl docname2, ts appl docname3)

val expr = exCallCall
val expr = exIf

import AkkaConfig.timeout

var startTime = System.currentTimeMillis()
node1 ? exCallCall onComplete {
node1 ? expr onComplete {
case Success(content) => {
val totalTime = System.currentTimeMillis - startTime
println(s"Res(${totalTime}): $content")
println(s"Res($totalTime): $content")
}
case Failure(error) => throw error
}
Expand Down
4 changes: 2 additions & 2 deletions nfn/src/main/scala/evaluation/SingeLocalAMNode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ object SingeLocalAMNode extends App {

val translate = Translate().toString

val wcExpr: Expr = wc call List(docName)
val wcTranslateExpr: Expr = wc call List(translate call List(docName))
val wcExpr: Expr = wc appl List(docName)
val wcTranslateExpr: Expr = wc appl List(translate appl List(docName))

val compExpr: Expr = 'x @: ("y" @: (('x * 1) + "y") ! 2) ! 3

Expand Down
6 changes: 3 additions & 3 deletions nfn/src/main/scala/evaluation/ThreeNodeTwoHopEnv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ object ThreeNodeTwoHopEnv extends App {

val compExpr: Expr = 'x @: ("y" @: (('x * 1) + "y") ! 2) ! 3

val wcExpr: Expr = wc call List(docname1, docname2, docname3)
val wcExpr: Expr = wc appl List(docname1, docname2, docname3)

val pubExpr: Expr = pub call List(docname3, doc3PrefixToAddContent.name, CCNName("node", "node1"))
val pubExpr: Expr = pub appl List(docname3, doc3PrefixToAddContent.name, CCNName("node", "node1"))

val wcTranslateExpr: Expr = wc call List(translate call List(docname3))
val wcTranslateExpr: Expr = wc appl List(translate appl List(docname3))
//
// node1 ? pubExpr onComplete {
// case Success(content) => println(s"ACK ADDED: $content")
Expand Down
2 changes: 1 addition & 1 deletion nfn/src/main/scala/evaluation/WordCountEnv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ object WordCountEnv extends App {
implicit val useThunks = false

printInterestResult(
wc call (docNamesNode1)
wc appl (docNamesNode1)
)

val documents: Set[String] = Set("doc1"*1, "doc2"*2, "doc3"*3)
Expand Down
Loading

0 comments on commit 0a4c914

Please sign in to comment.