Mercurial > hg > Database > jungle-network
changeset 147:202ea963ec20
Added requestCounter in BulletinBoardJungleManager
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 28 Jan 2014 09:16:39 +0900 |
parents | 29734d7d6521 |
children | 7d248be1d3e4 |
files | src/main/java/app/bbs/BulletinBoardJungleManager.java src/main/java/app/bbs/NetworkJungleBulletinBoard.java |
diffstat | 2 files changed, 23 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/app/bbs/BulletinBoardJungleManager.java Tue Jan 28 08:47:45 2014 +0900 +++ b/src/main/java/app/bbs/BulletinBoardJungleManager.java Tue Jan 28 09:16:39 2014 +0900 @@ -2,8 +2,8 @@ import java.nio.ByteBuffer; import java.util.Date; +import java.util.concurrent.atomic.AtomicInteger; -import javax.naming.directory.Attribute; import alice.jungle.operations.NetworkTreeOperationLog; import alice.jungle.transaction.JungleUpdater; @@ -11,8 +11,6 @@ import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Attributes; -import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Children; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; @@ -23,11 +21,20 @@ public class BulletinBoardJungleManager { private static BulletinBoardJungleManager instance = new BulletinBoardJungleManager(); private Jungle jungle; + private static AtomicInteger requestCounter = new AtomicInteger(0); private BulletinBoardJungleManager() { jungle = new DefaultJungle(null,"default",new DefaultTreeEditor(new DefaultTraverser())); } + public static int requestGetAndIncrement() { + return requestCounter.getAndIncrement(); + } + + public static int requestIncrementAndGet() { + return requestCounter.incrementAndGet(); + } + public static BulletinBoardJungleManager getInstantce() { return instance; } @@ -35,6 +42,9 @@ public static void setJungle(Jungle _j) { instance.jungle = _j; } + public static AtomicInteger getRequestCounter() { + return requestCounter; + } public static Jungle getJungle() { return instance.jungle; @@ -52,8 +62,6 @@ throw new IllegalStateException(); } } - - Either<Error, JungleTreeEditor> either = null; JungleTree tree = jungle.getTreeByName(treeName); @@ -73,6 +81,7 @@ }while(either.isA()); renewBoardTimeStamp(tree); + requestCounter.incrementAndGet(); return either; } @@ -86,10 +95,12 @@ Either<Error, JungleTreeEditor> either = null; do { either = editor.putAttribute(root, "renewtime", tBuffer); + if(either.isA()) { + throw new IllegalStateException(); + } editor = either.b(); either = editor.success(); }while(either.isA()); - } private static int calculatePosition(Node node, long newNodeTimeStamp) {
--- a/src/main/java/app/bbs/NetworkJungleBulletinBoard.java Tue Jan 28 08:47:45 2014 +0900 +++ b/src/main/java/app/bbs/NetworkJungleBulletinBoard.java Tue Jan 28 09:16:39 2014 +0900 @@ -35,7 +35,7 @@ private final NetworkJournal journal; private final String LOG_DIR; private Boolean persistentFlag; - private AtomicInteger requestCounter = new AtomicInteger(0); + private AtomicInteger requestCounter; private NetworkJungleBulletinBoard(String _uuid, NetworkJournal _journal) { @@ -43,6 +43,7 @@ jungle = new NetworkDefaultJungle(journal, _uuid,new DefaultTreeEditor(new DefaultTraverser())); BulletinBoardJungleManager.setJungle(jungle); persistentFlag = false; + requestCounter = BulletinBoardJungleManager.getRequestCounter(); LOG_DIR = "./log"; } @@ -202,7 +203,10 @@ throw new IllegalStateException(); } either.b().success(); - + + /* + * Record latest renew time + */ editor = tree.getLocalTreeEditor(); either = editor.putAttribute(root, "renewtime", tBuffer); either.b().success();