Mercurial > hg > Database > Alice
view src/main/java/alice/codesegment/OutputDataSegment.java @ 519:16f44f2060cc dispose
forget implement update method
author | sugi |
---|---|
date | Fri, 23 Jan 2015 14:47:02 +0900 |
parents | 79d5b317b2b6 |
children | b6e663a9a372 |
line wrap: on
line source
package alice.codesegment; import alice.datasegment.CommandType; import alice.datasegment.DataSegment; import alice.datasegment.ReceiveData; import alice.datasegment.Receiver; import alice.datasegment.SendOption; public class OutputDataSegment { private boolean compressFlag = false; /** * for local */ public void flip(Receiver receiver) { DataSegment.getLocal().put(receiver.key, receiver.getReceiveData(), null); } public void flip(Receiver receiver, CommandType type) { switch (type) { case PUT: DataSegment.getLocal().put(receiver.key, receiver.getReceiveData(), null); break; case UPDATE: DataSegment.getLocal().update(receiver.key, receiver.getReceiveData(), null); break; default: break; } } 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); put(key, rData); } public void update(String key, ReceiveData rData) { DataSegment.getLocal().update(key, rData, null); } public void update(String key, Object val) { ReceiveData rData = new ReceiveData(val, false, false); update(key, rData); } /** * for remote */ public void put(String managerKey, String key, ReceiveData rData) { if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ 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") && DataSegment.contains(managerKey)){ ReceiveData rData = new ReceiveData(val, false, false); SendOption option = new SendOption(false, compressFlag()); DataSegment.get(managerKey).put(key, rData, option); } else { put(key, val); } } public void quickPut(String managerKey, String key, ReceiveData rData) { if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ 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") && DataSegment.contains(managerKey)){ ReceiveData rData = new ReceiveData(val, false, false); SendOption option = new SendOption(true, compressFlag()); DataSegment.get(managerKey).put(key, rData, option); } else { put(key, val); } } public void update(String managerKey, String key, ReceiveData rData) { if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ 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") && DataSegment.contains(managerKey)){ ReceiveData rData = new ReceiveData(val, false, false); SendOption option = new SendOption(false, compressFlag()); DataSegment.get(managerKey).update(key, rData, option); } else { update(key, val); } } public void quickUpdate(String managerKey, String key, ReceiveData rData) { if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ 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") && DataSegment.contains(managerKey)){ ReceiveData rData = new ReceiveData(val, false, false); SendOption option = new SendOption(true, compressFlag()); DataSegment.get(managerKey).update(key, rData, option); } else { update(key, val); } } /** * kill the Alice process after send other messages. * * @param managerKey */ public void finish(String managerKey) { if (DataSegment.contains(managerKey)) DataSegment.get(managerKey).finish(); } /** * close socket for RemoteDataSegment after send other messages. * * @param managerKey */ public void close(String managerKey) { if (DataSegment.contains(managerKey)) DataSegment.get(managerKey).close(); } /** * "key" is not remote DataSegment's key. * "Ping Response" return in this "key" * * @param managerKey * @param key */ public void ping(String managerKey, String returnKey) { if (DataSegment.contains(managerKey)) DataSegment.get(managerKey).ping(returnKey); } public boolean compressFlag() { return compressFlag; } public void setCompressFlag(boolean cFlag) { compressFlag = cFlag; } }