Mercurial > hg > Database > Alice
view src/main/java/alice/codesegment/OutputDataSegment.java @ 540:97bd6efa6e69 dispose
ods&ids have AliceDeamon
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 03 Aug 2015 18:39:37 +0900 |
parents | 0832af83583f |
children | bd245df5cba3 |
line wrap: on
line source
package alice.codesegment; import alice.daemon.AliceDaemon; import alice.datasegment.CommandType; import alice.datasegment.DataSegment; import alice.datasegment.ReceiveData; import alice.datasegment.Receiver; import alice.datasegment.SendOption; public class OutputDataSegment { private final CodeSegment cs; private final AliceDaemon alice; public OutputDataSegment(CodeSegment cs){ this.cs = cs; this.alice = cs.getAliceDaemon(); } /** * for local */ /** * input→ds変更→outputのときコピーを防ぐ */ public void flip(Receiver receiver) { if (receiver.isCompressed()){ AliceDaemon.dataSegment.getCompressedLocal().put(receiver.key, receiver.getReceiveData(), false); } else { AliceDaemon.dataSegment.getLocal().put(receiver.key, receiver.getReceiveData(), false); } } public void flip(String managerKey, String key, Receiver receiver){ if (receiver.isCompressed()){ AliceDaemon.dataSegment.get("compressed" + managerKey).put(key, receiver.getReceiveData(), false); } else { AliceDaemon.dataSegment.get(managerKey).put(key, receiver.getReceiveData(), false); } } public void flip(Receiver receiver, CommandType type) { switch (type) { case PUT: if (receiver.isCompressed()){ AliceDaemon.dataSegment.getCompressedLocal().put(receiver.key, receiver.getReceiveData(), false);//localなら全部false。 } else { AliceDaemon.dataSegment.getLocal().put(receiver.key, receiver.getReceiveData(), false); } break; case UPDATE: if (receiver.isCompressed()){ AliceDaemon.dataSegment.getCompressedLocal().update(receiver.key, receiver.getReceiveData(), false); } else { AliceDaemon.dataSegment.getLocal().update(receiver.key, receiver.getReceiveData(), false); } break; default: break; } } public void put(String key, ReceiveData rData) { AliceDaemon.dataSegment.getLocal().put(key, rData, false); } public void put(String key, Object val) { ReceiveData rData = new ReceiveData(val); AliceDaemon.dataSegment.getLocal().put(key, rData, false); } public void update(String key, Object val) { ReceiveData rData = new ReceiveData(val); AliceDaemon.dataSegment.getLocal().update(key, rData, false); } /** * for remote */ public void put(String managerKey, String key, ReceiveData rData) { AliceDaemon.dataSegment.get(managerKey).put(key, rData, false); } public void put(String managerKey, String key, Object val) {//追加 ReceiveData rData = new ReceiveData(val); AliceDaemon.dataSegment.get(managerKey).put(key, rData, false); } public void quickPut(String managerKey, String key, ReceiveData rData) { AliceDaemon.dataSegment.get(managerKey).put(key, rData, true); } public void quickPut(String managerKey, String key, Object val) { ReceiveData rData = new ReceiveData(val); AliceDaemon.dataSegment.get(managerKey).put(key, rData, true); } public void update(String managerKey, String key, ReceiveData rData) { AliceDaemon.dataSegment.get(managerKey).update(key, rData, false); } public void update(String managerKey, String key, Object val) { ReceiveData rData = new ReceiveData(val); AliceDaemon.dataSegment.get(managerKey).update(key, rData, false); } public void quickUpdate(String managerKey, String key, ReceiveData rData) { AliceDaemon.dataSegment.get(managerKey).update(key, rData, true); } public void quickUpdate(String managerKey, String key, Object val, boolean cFlag) { ReceiveData rData = new ReceiveData(val); AliceDaemon.dataSegment.get(managerKey).update(key, rData, true); } /** * kill the Alice process after send other messages. * * @param managerKey */ public void finish(String managerKey) { if (AliceDaemon.dataSegment.contains(managerKey)) AliceDaemon.dataSegment.get(managerKey).finish(); } /** * close socket for RemoteAliceDaemon.dataSegment after send other messages. * * @param managerKey */ public void close(String managerKey) { if (AliceDaemon.dataSegment.contains(managerKey)) AliceDaemon.dataSegment.get(managerKey).close(); } /** * "key" is not remote AliceDaemon.dataSegment's key. * "Ping Response" return in this "key" * * @param managerKey * @param returnKey */ public void ping(String managerKey, String returnKey) { if (AliceDaemon.dataSegment.contains(managerKey)) AliceDaemon.dataSegment.get(managerKey).ping(returnKey); } }