annotate src/fdl/MetaLinda.java @ 19:0243987383b7

Meta Protocol Engine and sample implementation of event logger. ComDebug_Client needs fixes.
author kono
date Tue, 19 Aug 2008 05:33:32 +0900
parents 609b288f47f9
children fac6e0073b1a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
1
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
2 /*
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
3 * @(#)MetaLinda.java 1.1 06/04/01
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
4 *
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
5 * Copyright 2008 Shinji KONO
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
6 *
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
7
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
8 Meta Lidna
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
9 Trasport layer of Meta Linda API
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
10
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
11 */
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
12
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
13 package fdl;
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
14
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
15 import java.io.IOException;
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
16 import java.nio.ByteBuffer;
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
17 import java.util.LinkedList;
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
18
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
19 /**
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
20 MetaLinda
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
21 *
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
22 * @author Shinji Kono
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
23 *
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
24
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
25 meta tuple interface in Linda Server
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
26
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
27 */
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
28
17
609b288f47f9 *** empty log message ***
kono
parents: 15
diff changeset
29 public class MetaLinda implements PSXLindaInterface {
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
30
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
31 public TupleSpace ts;
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
32 public FDLindaServ fds;
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
33 public FederatedLinda fdl;
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
34 public PSXLindaInterface next;
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
35 public LinkedList<MetaReply> replies;
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
36
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
37 public MetaLinda(TupleSpace ts,FDLindaServ fdl) {
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
38 this.ts = ts;
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
39 this.fds = fdl;
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
40 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
41
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
42 public PSXReply in(int id) {
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
43 return null;
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
44 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
45
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
46 public void in(int id, PSXCallback callback) {
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
47 replies.add(new MetaReply(PSX.PSX_IN,id,ts, callback));
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
48 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
49
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
50 public PSXReply ck(int id) {
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
51 MetaReply r = new MetaReply(PSX.PSX_CHECK,id,ts);
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
52 return r;
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
53 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
54
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
55 public void ck(int id, PSXCallback callback) {
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
56 replies.add(new MetaReply(PSX.PSX_CHECK,id,ts,callback));
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
57 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
58
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
59 public PSXReply out(int id, ByteBuffer data,int size) {
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
60 MetaReply r = new MetaReply(PSX.PSX_OUT,id,ts,data,null);
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
61 replies.add(r);
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
62 return r;
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
63 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
64
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
65 public PSXReply update(int id, ByteBuffer data,int size) {
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
66 MetaReply r = new MetaReply(PSX.PSX_UPDATE,id,ts,data,null);
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
67 return r;
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
68 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
69
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
70 public void update(int id, ByteBuffer data,int size,PSXCallback callback) {
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
71 MetaReply r = new MetaReply(PSX.PSX_UPDATE,id,ts,data,callback);
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
72 replies.add(r);
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
73 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
74
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
75 public PSXReply rd(int id) {
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
76 MetaReply r = new MetaReply(PSX.PSX_RD,id,ts);
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
77 return r;
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
78 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
79
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
80 public void rd(int id, PSXCallback callback) {
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
81 replies.add(new MetaReply(PSX.PSX_RD,id,ts,callback));
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
82 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
83
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
84 public PSXLindaInterface add(PSXLindaInterface linda) {
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
85 next = linda;
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
86 return this;
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
87 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
88
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
89 public void send(ByteBuffer command,ByteBuffer data) {
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
90 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
91
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
92 public int sync() {
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
93 return sync(0);
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
94 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
95
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
96 public int sync(long timeout) {
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
97 fds.checkTuple(timeout);
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
98 for(MetaReply r: replies) {
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
99 if (r.ready()) {
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
100 replies.remove();
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
101 }
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
102 }
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
103 if (fdl!=null) {
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
104 try {
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
105 fdl.sync(timeout);
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
106 } catch (IOException e) {
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
107 e.printStackTrace();
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
108 }
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
109 }
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
110 return 0;
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
111 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
112 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
113
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
114
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
115 /* end */