Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wakamori
committed
Nov 9, 2011
1 parent
19ff923
commit 030babc
Showing
4 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
wakamori/dscript/converter/converter.k → wakamori/dscript/converter/converter
100644 → 100755
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#!/usr/local/bin/konoha | ||
|
||
void main(String[] args) | ||
{ | ||
assert |args| == 1; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using konoha.actor.*; | ||
|
||
a = actor:localhost:2000; | ||
a.startTask("foo"); | ||
a.eval("print \"hi\""); | ||
a.endTask(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using konoha.memcached.*; | ||
using konoha.json.*; | ||
|
||
class Log { | ||
String time; | ||
String host; | ||
int pid; | ||
String trace; | ||
String name; | ||
Map val; | ||
|
||
Log(String time, String host, int pid, String trace, String name, Map val) { | ||
_time = time; | ||
_host = host; | ||
_pid = pid; | ||
_trace = trace; | ||
_name = name; | ||
_val = val; | ||
} | ||
} | ||
|
||
class Logcache { | ||
Memcache mcd; | ||
String trace; | ||
//String log_name; | ||
int ctxid; | ||
Map<int> seq; | ||
} | ||
|
||
Logcache Logcache.new(String host, int port, String task_name) { | ||
_mcd = new Memcache(host, port); | ||
_trace = mcd[task_name]; | ||
if (trace == null) throw new Script!!("cannot trace " + task_name); | ||
_task_name = task_name; | ||
//_log_name = log_name; | ||
_ctxid = 0; | ||
_seq = {}; | ||
} | ||
|
||
Log Logcache.readLog() { | ||
String key; | ||
String line; | ||
int i = seq[trace]; | ||
key = trace + "+" + i; | ||
//print key; | ||
//print log_name; | ||
//line = mcd.getByKey(log_name, key); | ||
line = mcd[key]; | ||
if (line == null) return null; | ||
|
||
//print line; | ||
String[] e = line.split(" "); | ||
String logname = e[6]; | ||
//print logname; | ||
String json = line.substring(line.indexOf(logname) + |logname| + 1); | ||
//print json; | ||
|
||
//print line; | ||
seq[trace] += 1; | ||
//print e[4]; | ||
int port = (to int)e[4].replace($/konoha\[(\d+)\]:/, "$1"); | ||
Map m = ((to Bytes)json).readJson(0, |json|); | ||
Log l = new Log(line.substring(0, line.indexof(e[3]) - 1), e[3], port, e[5], e[6], m); | ||
return l; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
include "logcache.k" | ||
|
||
void main(String[] args) | ||
{ | ||
l = new Logcache("localhost", 11211, "foo"); | ||
Log log = l.readLog(); | ||
while (log.val != null) { | ||
print log; | ||
log = l.readLog(); | ||
} | ||
} |