Mercurial > hg > Database > Alice
annotate src/main/java/alice/datasegment/Receiver.java @ 601:30f2c04571c2 dispose
add chat, add Star topology to topology manager&node
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 27 Apr 2016 16:28:10 +0900 |
parents | 0564f38e9bfe |
children |
rev | line source |
---|---|
345 | 1 package alice.datasegment; |
2 | |
3 | |
4 import alice.codesegment.InputDataSegment; | |
5 | |
6 /** | |
523
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
7 * idsコマンド(create, setKey)の処理をする。コマンドの定義はids/LDSM内にある。 |
345 | 8 * MessagePack implementation and DataSegment Receiver |
9 * @author kazz | |
10 * | |
11 */ | |
12 public class Receiver { | |
452 | 13 private ReceiveData data; |
417 | 14 public InputDataSegment ids; |
15 public int index; | |
16 public String from; | |
17 public CommandType type; | |
525
30a74eee59c7
working TestRemoteAlice
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
523
diff
changeset
|
18 public String managerKey;//DSMを一意に特定。localかremoteか、どのremoteからか。 |
417 | 19 public String key; |
600
0564f38e9bfe
change allow using ids only peek from Normal Code Segment
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
599
diff
changeset
|
20 public String meta = ""; |
523
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
21 public boolean compressedFlag = false; |
417 | 22 |
600
0564f38e9bfe
change allow using ids only peek from Normal Code Segment
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
599
diff
changeset
|
23 public Receiver(InputDataSegment ids, CommandType type, String meta) { |
417 | 24 this.ids = ids; |
25 this.type = type; | |
600
0564f38e9bfe
change allow using ids only peek from Normal Code Segment
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
599
diff
changeset
|
26 this.meta = meta; |
417 | 27 ids.register(); |
523
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
28 } |
417 | 29 |
523
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
30 public Receiver(InputDataSegment ids, CommandType type, boolean compressedFlag) { |
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
31 this.ids = ids; |
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
32 this.type = type; |
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
33 ids.register(); |
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
34 this.compressedFlag = compressedFlag; |
417 | 35 } |
36 | |
37 public void setQuickKey(String managerKey, String key){ | |
38 setQuickKey(managerKey, key, 0); | |
523
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
39 }//? |
345 | 40 |
417 | 41 public void setQuickKey(String managerKey, String key, int index) { |
42 this.managerKey = managerKey; | |
43 this.key = key; | |
44 switch (type) { | |
45 case PEEK: | |
46 ids.quickPeek(this); | |
47 break; | |
48 case TAKE: | |
49 ids.quickTake(this); | |
50 break; | |
51 default: | |
52 break; | |
53 } | |
54 ids.setKey(); | |
55 } | |
56 | |
57 public void setKey(String managerKey, String key) { | |
58 setKey(managerKey, key, 0); | |
59 } | |
345 | 60 |
417 | 61 public void setKey(String managerKey, String key, int index) { |
62 this.managerKey = managerKey; | |
63 this.key = key; | |
64 this.index = index; | |
600
0564f38e9bfe
change allow using ids only peek from Normal Code Segment
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
599
diff
changeset
|
65 |
0564f38e9bfe
change allow using ids only peek from Normal Code Segment
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
599
diff
changeset
|
66 if (meta == "" && managerKey == "metalocal"){ |
417 | 67 ids.peek(this); |
600
0564f38e9bfe
change allow using ids only peek from Normal Code Segment
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
599
diff
changeset
|
68 } else{ |
0564f38e9bfe
change allow using ids only peek from Normal Code Segment
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
599
diff
changeset
|
69 switch (type) { |
0564f38e9bfe
change allow using ids only peek from Normal Code Segment
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
599
diff
changeset
|
70 case PEEK: |
0564f38e9bfe
change allow using ids only peek from Normal Code Segment
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
599
diff
changeset
|
71 ids.peek(this); |
0564f38e9bfe
change allow using ids only peek from Normal Code Segment
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
599
diff
changeset
|
72 break; |
0564f38e9bfe
change allow using ids only peek from Normal Code Segment
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
599
diff
changeset
|
73 case TAKE: |
0564f38e9bfe
change allow using ids only peek from Normal Code Segment
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
599
diff
changeset
|
74 ids.take(this); |
0564f38e9bfe
change allow using ids only peek from Normal Code Segment
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
599
diff
changeset
|
75 |
0564f38e9bfe
change allow using ids only peek from Normal Code Segment
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
599
diff
changeset
|
76 break; |
0564f38e9bfe
change allow using ids only peek from Normal Code Segment
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
599
diff
changeset
|
77 default: |
0564f38e9bfe
change allow using ids only peek from Normal Code Segment
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
599
diff
changeset
|
78 break; |
0564f38e9bfe
change allow using ids only peek from Normal Code Segment
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
599
diff
changeset
|
79 } |
417 | 80 } |
600
0564f38e9bfe
change allow using ids only peek from Normal Code Segment
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
599
diff
changeset
|
81 |
417 | 82 ids.setKey(); |
83 } | |
84 | |
85 public void setKey(String key) { | |
86 setKey(key, 0); | |
87 } | |
345 | 88 |
417 | 89 public void setKey(String key, int index) { |
601
30f2c04571c2
add chat, add Star topology to topology manager&node
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
600
diff
changeset
|
90 this.managerKey="local"; |
417 | 91 this.key = key; |
92 this.index = index; | |
93 switch (type) { | |
94 case PEEK: | |
95 ids.peek(this); | |
96 break; | |
97 case TAKE: | |
98 ids.take(this); | |
99 break; | |
100 default: | |
101 break; | |
102 } | |
103 ids.setKey(); | |
104 } | |
345 | 105 |
523
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
106 //以下各型でDS本体を受け取る |
452 | 107 public void setData(ReceiveData r) { |
417 | 108 data = r; |
109 } | |
345 | 110 |
417 | 111 public int asInteger() { |
112 return data.asInteger(); | |
113 } | |
114 | |
115 public String asString() { | |
116 return data.asString(); | |
117 } | |
345 | 118 |
417 | 119 public <T> T asClass(Class<T> clazz) { |
120 return data.asClass(clazz); | |
121 } | |
345 | 122 |
417 | 123 public Object getObj() { |
124 return data.getObj(); | |
125 } | |
126 | |
127 public Object getVal() { | |
128 return data.getVal(); | |
129 } | |
130 | |
458 | 131 public ReceiveData getReceiveData() { |
132 return data; | |
133 } | |
525
30a74eee59c7
working TestRemoteAlice
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
523
diff
changeset
|
134 |
30a74eee59c7
working TestRemoteAlice
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
523
diff
changeset
|
135 public boolean isCompressed(){ |
30a74eee59c7
working TestRemoteAlice
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
523
diff
changeset
|
136 return data.compressed(); |
30a74eee59c7
working TestRemoteAlice
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
523
diff
changeset
|
137 } |
599
3284428f525e
add MetaCodeSegment & MetaDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
525
diff
changeset
|
138 |
3284428f525e
add MetaCodeSegment & MetaDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
525
diff
changeset
|
139 public void setMeta(boolean mFlag){ |
3284428f525e
add MetaCodeSegment & MetaDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
525
diff
changeset
|
140 data.setMeta(mFlag); |
3284428f525e
add MetaCodeSegment & MetaDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
525
diff
changeset
|
141 } |
345 | 142 } |