Mercurial > hg > Database > Alice
view src/main/java/alice/codesegment/OutputDataSegment.java @ 458:bcf6f4a6fcd0 dispose
need set Meta DataSegment PUT API
author | sugi |
---|---|
date | Mon, 03 Nov 2014 17:12:53 +0900 |
parents | b004f62b83e5 |
children | 4419a2415661 |
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, Object val) { ReceiveData rData = new ReceiveData(val, false, false); DataSegment.getLocal().put(key, rData, null); } public void update(String key, Object val) { ReceiveData rData = new ReceiveData(val, false, false); DataSegment.getLocal().update(key, rData, null); } /** * for remote */ public void put(String managerKey, String key, Object val) { if (!managerKey.equals("local")){ 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, Object val) { if (!managerKey.equals("local")){ 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, Object val) { if (!managerKey.equals("local")){ 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, Object val) { if (!managerKey.equals("local")){ 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) { DataSegment.get(managerKey).finish(); } /** * close socket for RemoteDataSegment after send other messages. * * @param managerKey */ public void close(String 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) { DataSegment.get(managerKey).ping(returnKey); } /** * this method is to forcibly close socket * * @param managerKey */ public void shutdown(String managerKey){ DataSegment.get(managerKey).shutdown(); } public boolean compressFlag() { return compressFlag; } public void setCompressFlag(boolean cFlag) { compressFlag = cFlag; } }