Mercurial > hg > Database > jungle-network
view src/alice/jungle/datasegment/store/operations/DefaultTreeOperationLogContainer.java @ 62:85bc7416ae02
modified some container using SingletonMessage
author | one |
---|---|
date | Fri, 19 Jul 2013 11:08:04 +0900 |
parents | 1bfd13f831ea |
children | ebf42371454b |
line wrap: on
line source
package alice.jungle.datasegment.store.operations; import java.io.IOException; import java.nio.ByteBuffer; import java.util.Date; import java.util.LinkedList; import java.util.List; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.Command; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.DefaultTreeOperationLog; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.logger.TreeOperationLog; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.DefaultTreeOperation; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.NodeOperation; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.PutAttributeOperation; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; import org.msgpack.MessagePack; import org.msgpack.annotation.Message; import org.msgpack.template.ListTemplate; import org.msgpack.template.ValueTemplate; import org.msgpack.type.Value; import alice.codesegment.SingletonMessage; @Message public class DefaultTreeOperationLogContainer { Value logValue; String treeName; String uuid; String updaterName; String revision; int position; long timestamp; public DefaultTreeOperationLogContainer() { logValue = null; treeName = ""; uuid = ""; updaterName = ""; revision = ""; position = 0; timestamp = Long.MAX_VALUE; } public void setTreeName(String _treeName) { treeName = _treeName; } public String getTreeName() { return treeName; } public void setUUID(String _uuid) { uuid = _uuid; } public String getUUID() { return uuid; } public void setUpdaterName(String _updaterName) { updaterName = _updaterName; } public String getServerName() { return updaterName; } public void setRevision(String _revision) { revision = _revision; } public String getRevision() { return revision; } public void setPosition(int p) { position = p; } public int getPosition() { return position; } public void setTimeStamp(long t) { timestamp = t; } public long getTimeStamp() { return timestamp; } public void unconvert(Iterable<TreeOperation> _log) throws IOException { // MessagePack msgpack = new MessagePack(); MessagePack msgpack = SingletonMessage.getInstance(); List<Value> list = new LinkedList<Value>(); for(TreeOperation op : _log) { NodeOperation nOp = op.getNodeOperation(); NodePath nodePath = op.getNodePath(); DefaultTreeOperation treeOp = new DefaultTreeOperation(nodePath, nOp); DefaultTreeOperationContainer container = new DefaultTreeOperationContainer(); container.unconvert(treeOp); Value v = msgpack.unconvert(container); list.add(v); } Value listValue = msgpack.unconvert(list); logValue = listValue; } public DefaultTreeOperationLog convert() throws IOException { // MessagePack msgpack = new MessagePack(); MessagePack msgpack = SingletonMessage.getInstance(); msgpack.register(List.class, new ListTemplate(ValueTemplate.getInstance())); List<Value> listValue = msgpack.convert(logValue, List.class); List<TreeOperation> logList = new LinkedList<TreeOperation>(); for(Value v: listValue) { DefaultTreeOperationContainer container = msgpack.convert(v, DefaultTreeOperationContainer.class); logList.add(container.convert()); } DefaultTreeOperationLog log = new DefaultTreeOperationLog(logList, logList.size()); return log; } public String getHashLogString() { return treeName + revision + updaterName; } }