annotate src/fdl/MetaLinda.java @ 30:fca6eec8016f

*** empty log message ***
author kono
date Thu, 21 Aug 2008 18:46:40 +0900
parents 132c9bc28d6b
children 846c6c14cf04
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;
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
17
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
18 /**
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
19 MetaLinda
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
20 *
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
21 * @author Shinji Kono
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
22 *
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
23
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
24 meta tuple interface in Linda Server
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
25
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
26 */
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
27
25
330fa49bc4fd *** empty log message ***
kono
parents: 23
diff changeset
28 public class MetaLinda implements PSXLinda {
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
29
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
30 public TupleSpace ts;
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
31 public FDLindaServ fds;
21
fac6e0073b1a *** empty log message ***
kono
parents: 19
diff changeset
32 public FederatedLinda fdl=null;
25
330fa49bc4fd *** empty log message ***
kono
parents: 23
diff changeset
33 public PSXLinda next=null;
26
d7d70edc9c7c META_STOP worked.
kono
parents: 25
diff changeset
34 private MetaReply replies=new MetaReply(0, 0, ts);
d7d70edc9c7c META_STOP worked.
kono
parents: 25
diff changeset
35 private MetaReply last=replies;
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
36
21
fac6e0073b1a *** empty log message ***
kono
parents: 19
diff changeset
37 public MetaLinda(TupleSpace ts,FDLindaServ fds) {
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
38 this.ts = ts;
21
fac6e0073b1a *** empty log message ***
kono
parents: 19
diff changeset
39 this.fds = fds;
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) {
26
d7d70edc9c7c META_STOP worked.
kono
parents: 25
diff changeset
47 MetaReply r = new MetaReply(PSX.PSX_IN,id,ts, callback);
d7d70edc9c7c META_STOP worked.
kono
parents: 25
diff changeset
48 addReply(r);
d7d70edc9c7c META_STOP worked.
kono
parents: 25
diff changeset
49 }
d7d70edc9c7c META_STOP worked.
kono
parents: 25
diff changeset
50
d7d70edc9c7c META_STOP worked.
kono
parents: 25
diff changeset
51 private void addReply(MetaReply r) {
d7d70edc9c7c META_STOP worked.
kono
parents: 25
diff changeset
52 last.next = r; last = r;
15
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 PSXReply ck(int id) {
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
56 MetaReply r = new MetaReply(PSX.PSX_CHECK,id,ts);
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
57 return r;
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
58 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
59
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
60 public void ck(int id, PSXCallback callback) {
26
d7d70edc9c7c META_STOP worked.
kono
parents: 25
diff changeset
61 MetaReply r = new MetaReply(PSX.PSX_CHECK,id,ts,callback);
d7d70edc9c7c META_STOP worked.
kono
parents: 25
diff changeset
62 addReply(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
23
b4fd7fb9135a Simple Test run.
kono
parents: 21
diff changeset
65 public PSXReply out(int id, ByteBuffer data) {
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
66 MetaReply r = new MetaReply(PSX.PSX_OUT,id,ts,data,null);
26
d7d70edc9c7c META_STOP worked.
kono
parents: 25
diff changeset
67 addReply(r);
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
68 return r;
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
69 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
70
23
b4fd7fb9135a Simple Test run.
kono
parents: 21
diff changeset
71 public PSXReply update(int id, ByteBuffer data) {
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
72 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
73 return r;
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
74 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
75
23
b4fd7fb9135a Simple Test run.
kono
parents: 21
diff changeset
76 public void update(int id, ByteBuffer data,PSXCallback callback) {
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
77 MetaReply r = new MetaReply(PSX.PSX_UPDATE,id,ts,data,callback);
26
d7d70edc9c7c META_STOP worked.
kono
parents: 25
diff changeset
78 addReply(r);
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
79 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
80
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
81 public PSXReply rd(int id) {
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
82 MetaReply r = new MetaReply(PSX.PSX_RD,id,ts);
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
83 return r;
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
84 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
85
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
86 public void rd(int id, PSXCallback callback) {
26
d7d70edc9c7c META_STOP worked.
kono
parents: 25
diff changeset
87 MetaReply r = new MetaReply(PSX.PSX_RD,id,ts,callback);
d7d70edc9c7c META_STOP worked.
kono
parents: 25
diff changeset
88 addReply(r);
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
89 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
90
25
330fa49bc4fd *** empty log message ***
kono
parents: 23
diff changeset
91 public PSXLinda add(PSXLinda linda) {
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
92 next = linda;
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
93 return this;
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
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
96
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
97 public int sync() {
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
98 return sync(0);
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
99 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
100
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
101 public int sync(long timeout) {
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
102 fds.checkTuple(timeout);
27
1acf423ffdcb *** empty log message ***
kono
parents: 26
diff changeset
103 PSXReply r;
1acf423ffdcb *** empty log message ***
kono
parents: 26
diff changeset
104 for(r=replies;r!=null&&r.next!=null;r = r.next) {
26
d7d70edc9c7c META_STOP worked.
kono
parents: 25
diff changeset
105 if (r.next.ready()) {
27
1acf423ffdcb *** empty log message ***
kono
parents: 26
diff changeset
106 // ready() may modify replies list
26
d7d70edc9c7c META_STOP worked.
kono
parents: 25
diff changeset
107 r.next = r.next.next;
19
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 }
27
1acf423ffdcb *** empty log message ***
kono
parents: 26
diff changeset
110 last = (MetaReply)r;
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
111 if (fdl!=null) {
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
112 try {
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
113 fdl.sync(timeout);
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
114 } catch (IOException e) {
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
115 e.printStackTrace();
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
116 }
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
117 }
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
118 return 0;
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
119 }
25
330fa49bc4fd *** empty log message ***
kono
parents: 23
diff changeset
120
330fa49bc4fd *** empty log message ***
kono
parents: 23
diff changeset
121 public void send(ByteBuffer command, ByteBuffer data) {
330fa49bc4fd *** empty log message ***
kono
parents: 23
diff changeset
122
330fa49bc4fd *** empty log message ***
kono
parents: 23
diff changeset
123 }
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
124 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
125
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
126
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
127 /* end */