Mercurial > hg > Database > Christie
view 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 |
line wrap: on
line source
package christie.codegear; import christie.daemon.RemoteMessage; import christie.datagear.DataGear; import org.msgpack.MessagePack; import java.io.IOException; import java.nio.ByteBuffer; public class Command { public CodeGear cg = null; public DataGear dg; public String cgmName = "first"; public String dsmName = "local"; public String key; public CommandType type; public Class clazz = null; private static final MessagePack packer = new MessagePack(); //for put public Command(DataGear dg, String cgmName, String dsmName, String key, CommandType type, Class clazz){ this.dg = dg; this.cgmName = cgmName; this.dsmName = dsmName; this.key = key; this.type = type; this.clazz = clazz; } //for take public Command(CodeGear cg, DataGear dg, String cgmName, String dsmName, String key, CommandType type){ this.cg = cg; this.dg = dg; this.cgmName = cgmName; this.dsmName = dsmName; this.key = key; this.type = type; } public ByteBuffer convert() { ByteBuffer buf = null; try { byte[] command = null; byte[] data = null; byte[] dataSize = null; switch (type) { case PUT: case REPLY: RemoteMessage mes = new RemoteMessage(type.id, cgmName, key, clazz.getName()); data = dg.getMessagePack(); command = packer.write(mes); dataSize = packer.write(data.length); buf = ByteBuffer.allocate(command.length+dataSize.length+data.length); buf.put(command); buf.put(dataSize); buf.put(data); break; default: command = packer.write(new RemoteMessage(type.id, cgmName, key, clazz.getName())); buf = ByteBuffer.allocate(command.length); buf.put(command); break; } buf.flip(); } catch (IOException e) { e.printStackTrace(); } return buf; } }