Mercurial > hg > Database > Alice
changeset 459:4419a2415661 dispose
can use compress option
author | sugi |
---|---|
date | Mon, 03 Nov 2014 20:26:05 +0900 |
parents | bcf6f4a6fcd0 |
children | 4e7514007ae1 |
files | src/main/java/alice/codesegment/OutputDataSegment.java src/main/java/alice/daemon/IncomingTcpConnection.java src/main/java/alice/datasegment/Command.java src/main/java/alice/datasegment/RemoteDataSegmentManager.java |
diffstat | 4 files changed, 45 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/alice/codesegment/OutputDataSegment.java Mon Nov 03 17:12:53 2014 +0900 +++ b/src/main/java/alice/codesegment/OutputDataSegment.java Mon Nov 03 20:26:05 2014 +0900 @@ -30,6 +30,10 @@ } } + public void put(String key, ReceiveData rData) { + DataSegment.getLocal().put(key, rData, null); + } + public void put(String key, Object val) { ReceiveData rData = new ReceiveData(val, false, false); DataSegment.getLocal().put(key, rData, null); @@ -43,6 +47,15 @@ /** * for remote */ + public void put(String managerKey, String key, ReceiveData rData) { + if (!managerKey.equals("local")){ + SendOption option = new SendOption(false, compressFlag()); + DataSegment.get(managerKey).put(key, rData, option); + } else { + put(key, rData); + } + } + public void put(String managerKey, String key, Object val) { if (!managerKey.equals("local")){ ReceiveData rData = new ReceiveData(val, false, false); @@ -52,6 +65,15 @@ put(key, val); } } + + public void quickPut(String managerKey, String key, ReceiveData rData) { + if (!managerKey.equals("local")){ + SendOption option = new SendOption(true, compressFlag()); + DataSegment.get(managerKey).put(key, rData, option); + } else { + put(key, rData); + } + } public void quickPut(String managerKey, String key, Object val) { if (!managerKey.equals("local")){ @@ -62,6 +84,15 @@ put(key, val); } } + + public void update(String managerKey, String key, ReceiveData rData) { + if (!managerKey.equals("local")){ + SendOption option = new SendOption(false, compressFlag()); + DataSegment.get(managerKey).update(key, rData, option); + } else { + update(key, rData); + } + } public void update(String managerKey, String key, Object val) { if (!managerKey.equals("local")){ @@ -72,6 +103,15 @@ update(key, val); } } + + public void quickUpdate(String managerKey, String key, ReceiveData rData) { + if (!managerKey.equals("local")){ + SendOption option = new SendOption(true, compressFlag()); + DataSegment.get(managerKey).update(key, rData, option); + } else { + update(key, rData); + } + } public void quickUpdate(String managerKey, String key, Object val) { if (!managerKey.equals("local")){
--- a/src/main/java/alice/daemon/IncomingTcpConnection.java Mon Nov 03 17:12:53 2014 +0900 +++ b/src/main/java/alice/daemon/IncomingTcpConnection.java Mon Nov 03 20:26:05 2014 +0900 @@ -76,9 +76,7 @@ case REPLY: cmd = manager.getAndRemoveCmd(msg.seq); rData = new ReceiveData(getSerializedByteArray(unpacker), msg.compressed, msg.serialized); - Command rCmd = new Command(type, null, null, rData, msg.index, msg.seq, null, null, ""); - rCmd.setCompressFlag(msg.compressed); - rCmd.setSerializeFlag(msg.serialized); + Command rCmd = new Command(type, null, null, rData, msg.index, msg.seq, null, null, ""); cmd.cs.ids.reply(cmd.receiver, rCmd); break; case PING:
--- a/src/main/java/alice/datasegment/Command.java Mon Nov 03 17:12:53 2014 +0900 +++ b/src/main/java/alice/datasegment/Command.java Mon Nov 03 20:26:05 2014 +0900 @@ -26,7 +26,6 @@ public CodeSegment cs; public String reverseKey; private boolean quickFlag = false; - private boolean serializeFlag = false; private boolean compressFlag = false; public Command(CommandType cmdType, Receiver receiver, String key, ReceiveData rData, int index, int seq, BlockingQueue<Command> replyQueue, CodeSegment cs, String reverseKey) { @@ -98,7 +97,7 @@ data = (byte[]) rData.getObj(); serialized = rData.serialized(); } - if (compressFlag) { + if (compressFlag) { data = zip(data); compressed = true; } @@ -112,7 +111,7 @@ buf.put(data); break; default: - header = msg.write(new CommandMessage(type.id, index, seq, key, quickFlag, serializeFlag, compressFlag)); + header = msg.write(new CommandMessage(type.id, index, seq, key, quickFlag, false, compressFlag)); buf = ByteBuffer.allocate(header.length); buf.put(header); break; @@ -141,21 +140,6 @@ } /** - * If this flag is true, DataSegment isn't serialized. - * Alice auto select true or false. - * - * @param flag - */ - - public void setSerializeFlag(boolean flag){ - serializeFlag = flag; - } - - public boolean getSerializeFlag(){ - return serializeFlag; - } - - /** * Before sending Remote DataSegment, DataSegment type is ByteArray. * If this flag true, ByteArray is compressed with ZRLEE(ZRIB) algorithm *
--- a/src/main/java/alice/datasegment/RemoteDataSegmentManager.java Mon Nov 03 17:12:53 2014 +0900 +++ b/src/main/java/alice/datasegment/RemoteDataSegmentManager.java Mon Nov 03 20:26:05 2014 +0900 @@ -53,7 +53,7 @@ @Override public void put(String key, ReceiveData rData, SendOption option) { Command cmd = new Command(CommandType.PUT, null, key, rData, 0, 0, null, null, ""); - cmd.setSerializeFlag(true); + cmd.setCompressFlag(option.isCompress()); if (option.isQuick()){ connection.write(cmd); // put command is executed right now } else { @@ -66,7 +66,7 @@ @Override public void update(String key, ReceiveData rData, SendOption option) { Command cmd = new Command(CommandType.UPDATE, null, key, rData, 0, 0, null, null, ""); - cmd.setSerializeFlag(true); + cmd.setCompressFlag(option.isCompress()); if (option.isQuick()){ connection.write(cmd); } else {