Mercurial > hg > Database > Christie
view src/main/java/christie/datagear/command/RemoteTakeCommand.java @ 198:dd3c0ba6a0a6
fix topology manager
author | akahori |
---|---|
date | Sat, 09 Mar 2019 21:53:37 +0900 |
parents | cd4b67334b17 |
children | 2ecb3a93b8ae |
line wrap: on
line source
package christie.datagear.command; import christie.daemon.Connection; import christie.datagear.RemoteMessage; import christie.datagear.command.Command; import christie.datagear.command.CommandType; import christie.datagear.dg.DataGear; import christie.datagear.dg.MessagePackDataGear; import org.msgpack.MessagePack; import java.io.IOException; import java.nio.ByteBuffer; public class RemoteTakeCommand extends Command { public RemoteTakeCommand(RemoteMessage msg, Connection cn) throws ClassNotFoundException { this(msg.fromDgmName, msg.key, cn, Class.forName(msg.clazz)); } public RemoteTakeCommand(String fromDgmName, Command cm, Connection cn) { this(fromDgmName, cm.key, cn, cm.clazz); } private RemoteTakeCommand(String fromDgmName, String key, Connection cn, Class clazz){ this.type = CommandType.REMOTETAKE; this.fromDgmName = fromDgmName; this.key = key; this.clazz = clazz; this.dg = new MessagePackDataGear(this.clazz); this.connection = cn; } @Override public ByteBuffer convert() { ByteBuffer buf = null; MessagePack packer = new MessagePack(); try { byte[] command = packer.write(createRemoteMessage()); buf = ByteBuffer.allocate(command.length); buf.put(command); buf.flip(); } catch (IOException e) { e.printStackTrace(); } return buf; } }