annotate src/fdl/MetaLinda.java @ 33:64071f8e2e0d

*** empty log message ***
author kono
date Sun, 24 Aug 2008 03:23:08 +0900
parents 846c6c14cf04
children d5bca4b5ee95
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;
31
846c6c14cf04 worked?
kono
parents: 30
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
25
330fa49bc4fd *** empty log message ***
kono
parents: 23
diff changeset
29 public class MetaLinda implements PSXLinda {
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;
21
fac6e0073b1a *** empty log message ***
kono
parents: 19
diff changeset
33 public FederatedLinda fdl=null;
25
330fa49bc4fd *** empty log message ***
kono
parents: 23
diff changeset
34 public PSXLinda next=null;
31
846c6c14cf04 worked?
kono
parents: 30
diff changeset
35 private LinkedList<MetaReply> replies=new LinkedList<MetaReply>();
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) {
31
846c6c14cf04 worked?
kono
parents: 30
diff changeset
52 replies.add(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);
33
64071f8e2e0d *** empty log message ***
kono
parents: 31
diff changeset
103 if (replies.size()>0) {
64071f8e2e0d *** empty log message ***
kono
parents: 31
diff changeset
104 // copy replies to avoid insert during r.ready()
64071f8e2e0d *** empty log message ***
kono
parents: 31
diff changeset
105 LinkedList<MetaReply> list = replies;
64071f8e2e0d *** empty log message ***
kono
parents: 31
diff changeset
106 replies = new LinkedList<MetaReply>();
64071f8e2e0d *** empty log message ***
kono
parents: 31
diff changeset
107 for(MetaReply r:list) {
64071f8e2e0d *** empty log message ***
kono
parents: 31
diff changeset
108 if (!r.ready()) {
64071f8e2e0d *** empty log message ***
kono
parents: 31
diff changeset
109 addReply(r);
64071f8e2e0d *** empty log message ***
kono
parents: 31
diff changeset
110 }
19
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
111 }
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
112 }
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
113 if (fdl!=null) {
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
114 try {
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
115 fdl.sync(timeout);
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
116 } catch (IOException e) {
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
117 e.printStackTrace();
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
118 }
0243987383b7 Meta Protocol Engine and sample implementation of event logger.
kono
parents: 17
diff changeset
119 }
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
120 return 0;
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
121 }
25
330fa49bc4fd *** empty log message ***
kono
parents: 23
diff changeset
122
330fa49bc4fd *** empty log message ***
kono
parents: 23
diff changeset
123 public void send(ByteBuffer command, ByteBuffer data) {
330fa49bc4fd *** empty log message ***
kono
parents: 23
diff changeset
124
330fa49bc4fd *** empty log message ***
kono
parents: 23
diff changeset
125 }
15
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
126 }
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
127
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
128
aced4bfc15af add Meta Linda Interface for debugger.
kono
parents:
diff changeset
129 /* end */