Mercurial > hg > Database > Christie
annotate src/main/java/christie/codegear/Command.java @ 13:bcd4f2c19185
don't work MessagePack unconvert for remote put
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 10 Jan 2018 20:37:47 +0900 |
parents | b49a926cbdd9 |
children | 186a86dc4c8a |
rev | line source |
---|---|
1
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 package christie.codegear; |
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 |
12
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
3 import christie.daemon.RemoteMessage; |
1
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 import christie.datagear.DataGear; |
12
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
5 import org.msgpack.MessagePack; |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
6 |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
7 import java.io.IOException; |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
8 import java.nio.ByteBuffer; |
1
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 |
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 public class Command { |
12
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
11 public CodeGear cg = null; |
1
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 public DataGear dg; |
12
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
13 public String cgmName = "first"; |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
14 public String dsmName = "local"; |
1
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 public String key; |
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 public CommandType type; |
13
bcd4f2c19185
don't work MessagePack unconvert for remote put
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
12
diff
changeset
|
17 public Class clazz = null; |
12
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
18 private static final MessagePack packer = new MessagePack(); |
1
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 |
12
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
20 //for put |
13
bcd4f2c19185
don't work MessagePack unconvert for remote put
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
12
diff
changeset
|
21 public Command(DataGear dg, String cgmName, String dsmName, String key, CommandType type, Class clazz){ |
1
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 this.dg = dg; |
12
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
23 this.cgmName = cgmName; |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
24 this.dsmName = dsmName; |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
25 this.key = key; |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
26 this.type = type; |
13
bcd4f2c19185
don't work MessagePack unconvert for remote put
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
12
diff
changeset
|
27 this.clazz = clazz; |
12
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
28 } |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
29 |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
30 //for take |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
31 public Command(CodeGear cg, DataGear dg, String cgmName, String dsmName, String key, CommandType type){ |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
32 this.cg = cg; |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
33 this.dg = dg; |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
34 this.cgmName = cgmName; |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
35 this.dsmName = dsmName; |
1
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
36 this.key = key; |
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37 this.type = type; |
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38 } |
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 |
12
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
40 public ByteBuffer convert() { |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
41 ByteBuffer buf = null; |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
42 |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
43 try { |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
44 byte[] command = null; |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
45 byte[] data = null; |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
46 byte[] dataSize = null; |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
47 |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
48 switch (type) { |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
49 case PUT: |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
50 case REPLY: |
13
bcd4f2c19185
don't work MessagePack unconvert for remote put
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
12
diff
changeset
|
51 RemoteMessage mes = new RemoteMessage(type.id, cgmName, key, clazz.getName()); |
12
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
52 |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
53 data = dg.getMessagePack(); |
13
bcd4f2c19185
don't work MessagePack unconvert for remote put
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
12
diff
changeset
|
54 command = packer.write(mes); |
bcd4f2c19185
don't work MessagePack unconvert for remote put
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
12
diff
changeset
|
55 dataSize = packer.write(data.length); |
12
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
56 |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
57 buf = ByteBuffer.allocate(command.length+dataSize.length+data.length); |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
58 buf.put(command); |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
59 buf.put(dataSize); |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
60 buf.put(data); |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
61 break; |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
62 default: |
13
bcd4f2c19185
don't work MessagePack unconvert for remote put
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
12
diff
changeset
|
63 command = packer.write(new RemoteMessage(type.id, cgmName, key, clazz.getName())); |
12
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
64 buf = ByteBuffer.allocate(command.length); |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
65 buf.put(command); |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
66 break; |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
67 } |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
68 |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
69 buf.flip(); |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
70 } catch (IOException e) { |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
71 e.printStackTrace(); |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
72 } |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
73 return buf; |
b49a926cbdd9
add RemotePutTest and that is working
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
1
diff
changeset
|
74 } |
1
3ea61d0bfc34
add dependency proccess but not work
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
75 } |