Mercurial > hg > Database > Christie
changeset 26:bf8ac57409af
make dg package
line wrap: on
line diff
--- a/src/main/java/christie/codegear/CodeGear.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/codegear/CodeGear.java Sat Jan 27 00:56:13 2018 +0900 @@ -4,9 +4,10 @@ import christie.annotation.RemoteTake; import christie.annotation.Take; import christie.datagear.*; -import christie.datagear.Command.Command; -import christie.datagear.Command.PeekCommand; -import christie.datagear.Command.TakeCommand; +import christie.datagear.command.Command; +import christie.datagear.command.PeekCommand; +import christie.datagear.command.TakeCommand; +import christie.datagear.dg.DataGear; import java.lang.reflect.Field; import java.util.ArrayList;
--- a/src/main/java/christie/codegear/InputDataGear.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/codegear/InputDataGear.java Sat Jan 27 00:56:13 2018 +0900 @@ -3,8 +3,8 @@ import christie.annotation.Peek; import christie.annotation.RemoteTake; import christie.annotation.Take; -import christie.datagear.Command.Command; -import christie.datagear.DataGear; +import christie.datagear.command.Command; +import christie.datagear.dg.DataGear; import java.lang.reflect.Field; import java.util.ArrayList;
--- a/src/main/java/christie/codegear/OutputDataGear.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/codegear/OutputDataGear.java Sat Jan 27 00:56:13 2018 +0900 @@ -1,7 +1,5 @@ package christie.codegear; -import christie.datagear.DataGear; - /** * Created by e125769 on 12/7/17. */
--- a/src/main/java/christie/daemon/Connection.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/daemon/Connection.java Sat Jan 27 00:56:13 2018 +0900 @@ -4,7 +4,7 @@ import java.nio.ByteBuffer; import java.util.concurrent.LinkedBlockingQueue; -import christie.datagear.Command.Command; +import christie.datagear.command.Command; public class Connection {
--- a/src/main/java/christie/daemon/IncomingTcpConnection.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/daemon/IncomingTcpConnection.java Sat Jan 27 00:56:13 2018 +0900 @@ -4,10 +4,11 @@ import christie.codegear.CodeGearManager; import christie.datagear.*; -import christie.datagear.Command.Command; -import christie.datagear.Command.CommandType; +import christie.datagear.command.Command; +import christie.datagear.command.CommandType; import christie.datagear.RemoteMessage; -import christie.datagear.Command.RemoteTakeCommand; +import christie.datagear.command.RemoteTakeCommand; +import christie.datagear.dg.MessagePackDataGear; import org.msgpack.MessagePack; import org.msgpack.unpacker.Unpacker;
--- a/src/main/java/christie/daemon/OutboundTcpConnection.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/daemon/OutboundTcpConnection.java Sat Jan 27 00:56:13 2018 +0900 @@ -1,6 +1,6 @@ package christie.daemon; -import christie.datagear.Command.Command; +import christie.datagear.command.Command; public class OutboundTcpConnection extends Thread {
--- a/src/main/java/christie/datagear/Command/Command.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/datagear/Command/Command.java Sat Jan 27 00:56:13 2018 +0900 @@ -1,8 +1,8 @@ -package christie.datagear.Command; +package christie.datagear.command; import christie.codegear.CodeGear; import christie.daemon.Connection; -import christie.datagear.DataGear; +import christie.datagear.dg.DataGear; import christie.datagear.RemoteMessage; import java.nio.ByteBuffer;
--- a/src/main/java/christie/datagear/Command/CommandType.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/datagear/Command/CommandType.java Sat Jan 27 00:56:13 2018 +0900 @@ -1,4 +1,4 @@ -package christie.datagear.Command; +package christie.datagear.command; import java.util.HashMap;
--- a/src/main/java/christie/datagear/Command/PeekCommand.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/datagear/Command/PeekCommand.java Sat Jan 27 00:56:13 2018 +0900 @@ -1,7 +1,7 @@ -package christie.datagear.Command; +package christie.datagear.command; import christie.codegear.CodeGear; -import christie.datagear.DataGear; +import christie.datagear.dg.DataGear; public class PeekCommand extends TakeCommand{ public PeekCommand(CodeGear cg, int cgmID, String toDgmName, String key, DataGear dg) {
--- a/src/main/java/christie/datagear/Command/PutCommand.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/datagear/Command/PutCommand.java Sat Jan 27 00:56:13 2018 +0900 @@ -1,9 +1,7 @@ -package christie.datagear.Command; +package christie.datagear.command; -import christie.datagear.Command.Command; -import christie.datagear.Command.CommandType; -import christie.datagear.DataGear; -import christie.datagear.MessagePackDataGear; +import christie.datagear.dg.DataGear; +import christie.datagear.dg.MessagePackDataGear; import org.msgpack.MessagePack; import java.io.IOException;
--- a/src/main/java/christie/datagear/Command/RemotePeekCommand.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/datagear/Command/RemotePeekCommand.java Sat Jan 27 00:56:13 2018 +0900 @@ -1,4 +1,4 @@ -package christie.datagear.Command; +package christie.datagear.command; import christie.daemon.Connection;
--- a/src/main/java/christie/datagear/Command/RemoteTakeCommand.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/datagear/Command/RemoteTakeCommand.java Sat Jan 27 00:56:13 2018 +0900 @@ -1,8 +1,7 @@ -package christie.datagear.Command; +package christie.datagear.command; import christie.daemon.Connection; -import christie.datagear.DataGear; -import christie.datagear.MessagePackDataGear; +import christie.datagear.dg.MessagePackDataGear; import org.msgpack.MessagePack; import java.io.IOException;
--- a/src/main/java/christie/datagear/Command/ReplyCommand.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/datagear/Command/ReplyCommand.java Sat Jan 27 00:56:13 2018 +0900 @@ -1,7 +1,7 @@ -package christie.datagear.Command; +package christie.datagear.command; import christie.daemon.Connection; -import christie.datagear.DataGear; +import christie.datagear.dg.DataGear; public class ReplyCommand extends PutCommand {
--- a/src/main/java/christie/datagear/Command/TakeCommand.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/datagear/Command/TakeCommand.java Sat Jan 27 00:56:13 2018 +0900 @@ -1,7 +1,7 @@ -package christie.datagear.Command; +package christie.datagear.command; import christie.codegear.CodeGear; -import christie.datagear.DataGear; +import christie.datagear.dg.DataGear; import java.nio.ByteBuffer;
--- a/src/main/java/christie/datagear/DataGear.java Fri Jan 26 18:03:36 2018 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -package christie.datagear; - -import org.msgpack.MessagePack; - -import java.io.IOException; - -public class DataGear<T>{ - protected T data = null; - protected Class<T> clazz = null; - - public DataGear(T data, Class clazz) {//for normal - setClazz(clazz); - setData(data); - } - - public DataGear(T... dg) {//for input DataGear init - @SuppressWarnings("unchecked") - Class<T> type = (Class<T>) dg.getClass().getComponentType(); - this.clazz = type; - } - - public void setData(T data) { - if (data.getClass() == this.clazz){ - this.data = data; - } - } - - public void setClazz(Class clazz){ - this.clazz = clazz; - }; - - public Class getClazz(){ - return clazz; - }; - - public T getData() { - return data; - } - - -}
--- a/src/main/java/christie/datagear/DataGearManager.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/datagear/DataGearManager.java Sat Jan 27 00:56:13 2018 +0900 @@ -1,9 +1,6 @@ package christie.datagear; -import christie.datagear.Command.Command; - -import java.util.TreeMap; -import java.util.concurrent.LinkedBlockingQueue; +import christie.datagear.command.Command; /** * Created by e125769 on 12/7/17.
--- a/src/main/java/christie/datagear/DataGears.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/datagear/DataGears.java Sat Jan 27 00:56:13 2018 +0900 @@ -1,5 +1,7 @@ package christie.datagear; +import christie.datagear.dg.DataGear; + import java.util.TreeMap; import java.util.concurrent.LinkedBlockingQueue;
--- a/src/main/java/christie/datagear/LocalDataGearManager.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/datagear/LocalDataGearManager.java Sat Jan 27 00:56:13 2018 +0900 @@ -1,8 +1,7 @@ package christie.datagear; -import christie.datagear.Command.*; - -import java.util.concurrent.LinkedBlockingQueue; +import christie.datagear.command.*; +import christie.datagear.dg.DataGear; /** * Created by e125769 on 12/7/17.
--- a/src/main/java/christie/datagear/MessagePackDataGear.java Fri Jan 26 18:03:36 2018 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -package christie.datagear; - -import org.msgpack.MessagePack; - -import java.io.IOException; - -public class MessagePackDataGear<T> extends DataGear {//必ずmessagePack形式を持つDataGear - private byte[] messagePack = null; - private int dataSize; - private MessagePack packer = new MessagePack(); - - public MessagePackDataGear(T data, Class clazz){ - setClazz(clazz); - setData(data); - getMessagePack(); - } - - public MessagePackDataGear(Class clazz){ - setClazz(clazz); - } - - public MessagePackDataGear(byte[] messagePack, Class clazz){ - setClazz(clazz); - this.messagePack = messagePack; - } - - public byte[] getMessagePack(){ - if (messagePack != null){ - return messagePack; - } else { - try { - messagePack = packer.write(data); - setDataSize(messagePack.length); - } catch (IOException e) { - e.printStackTrace(); - } - - return messagePack; - } - } - - public synchronized T getData(){ - if (data == null){ - try { - setData(packer.read(messagePack, clazz)); - } catch (IOException e) { - e.printStackTrace(); - } - } - return (T) super.getData(); - } - - public void setDataSize(int dataSize) { - this.dataSize = dataSize; - } -}
--- a/src/main/java/christie/datagear/RemoteDataGearManager.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/datagear/RemoteDataGearManager.java Sat Jan 27 00:56:13 2018 +0900 @@ -4,7 +4,8 @@ import christie.daemon.Connection; import christie.daemon.IncomingTcpConnection; import christie.daemon.OutboundTcpConnection; -import christie.datagear.Command.*; +import christie.datagear.command.*; +import christie.datagear.dg.DataGear; import java.io.IOException; import java.net.InetSocketAddress;
--- a/src/main/java/christie/datagear/WaitList.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/datagear/WaitList.java Sat Jan 27 00:56:13 2018 +0900 @@ -1,6 +1,6 @@ package christie.datagear; -import christie.datagear.Command.Command; +import christie.datagear.command.Command; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.LinkedBlockingQueue;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/christie/datagear/dg/DataGear.java Sat Jan 27 00:56:13 2018 +0900 @@ -0,0 +1,41 @@ +package christie.datagear.dg; + +import org.msgpack.MessagePack; + +import java.io.IOException; + +public class DataGear<T>{ + protected T data = null; + protected Class<T> clazz = null; + + public DataGear(T data, Class clazz) {//for normal + setClazz(clazz); + setData(data); + } + + public DataGear(T... dg) {//for input DataGear init + @SuppressWarnings("unchecked") + Class<T> type = (Class<T>) dg.getClass().getComponentType(); + this.clazz = type; + } + + public void setData(T data) { + if (data.getClass() == this.clazz){ + this.data = data; + } + } + + public void setClazz(Class clazz){ + this.clazz = clazz; + }; + + public Class getClazz(){ + return clazz; + }; + + public T getData() { + return data; + } + + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/christie/datagear/dg/MessagePackDataGear.java Sat Jan 27 00:56:13 2018 +0900 @@ -0,0 +1,56 @@ +package christie.datagear.dg; + +import org.msgpack.MessagePack; + +import java.io.IOException; + +public class MessagePackDataGear<T> extends DataGear {//必ずmessagePack形式を持つDataGear + private byte[] messagePack = null; + private int dataSize; + private MessagePack packer = new MessagePack(); + + public MessagePackDataGear(T data, Class clazz){ + setClazz(clazz); + setData(data); + getMessagePack(); + } + + public MessagePackDataGear(Class clazz){ + setClazz(clazz); + } + + public MessagePackDataGear(byte[] messagePack, Class clazz){ + setClazz(clazz); + this.messagePack = messagePack; + } + + public byte[] getMessagePack(){ + if (messagePack != null){ + return messagePack; + } else { + try { + messagePack = packer.write(data); + setDataSize(messagePack.length); + } catch (IOException e) { + e.printStackTrace(); + } + + return messagePack; + } + } + + public synchronized T getData(){ + if (data == null){ + try { + setData(packer.read(messagePack, clazz)); + } catch (IOException e) { + e.printStackTrace(); + } + } + return (T) super.getData(); + } + + public void setDataSize(int dataSize) { + this.dataSize = dataSize; + } +}
--- a/src/main/java/christie/test/Remote/RemotePutTest.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/test/Remote/RemotePutTest.java Sat Jan 27 00:56:13 2018 +0900 @@ -3,8 +3,7 @@ import christie.annotation.Take; import christie.codegear.CodeGear; import christie.codegear.CodeGearManager; -import christie.datagear.DataGear; -import christie.test.TestLocal.TestCodeGear; +import christie.datagear.dg.DataGear; public class RemotePutTest extends CodeGear {
--- a/src/main/java/christie/test/Remote/StartRemotePut.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/test/Remote/StartRemotePut.java Sat Jan 27 00:56:13 2018 +0900 @@ -15,7 +15,7 @@ CodeGearManager cgm = createCGM(10000); new StartRemotePut(cgm); - cgm.setup(new CreateRemotePutTest()); + cgm.setup(new CreateRemotePutTest());//この中身をここに直接書くとなぜか通らない cgm.createRemoteDGM("remote", "localhost", 10001); CodeGearManager cgm2 = createCGM(10001);
--- a/src/main/java/christie/test/RemoteTake/RemoteTakeTest.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/test/RemoteTake/RemoteTakeTest.java Sat Jan 27 00:56:13 2018 +0900 @@ -3,7 +3,7 @@ import christie.annotation.RemoteTake; import christie.codegear.CodeGear; import christie.codegear.CodeGearManager; -import christie.datagear.DataGear; +import christie.datagear.dg.DataGear; public class RemoteTakeTest extends CodeGear{
--- a/src/main/java/christie/test/TestLocal/TestCodeGear.java Fri Jan 26 18:03:36 2018 +0900 +++ b/src/main/java/christie/test/TestLocal/TestCodeGear.java Sat Jan 27 00:56:13 2018 +0900 @@ -3,7 +3,7 @@ import christie.annotation.Take; import christie.codegear.CodeGear; import christie.codegear.CodeGearManager; -import christie.datagear.DataGear; +import christie.datagear.dg.DataGear; /**