Mercurial > hg > Database > jungle-network
comparison src/alice/jungle/codesegment/LogUpdateCodeSegment.java @ 46:fd3643699f83
modified pom.xml. fix conflict log4j libraries
author | one |
---|---|
date | Fri, 12 Jul 2013 11:27:00 +0900 |
parents | 12d87bb4b84d |
children | 686057add8a4 |
comparison
equal
deleted
inserted
replaced
45:bf3dc481cc9b | 46:fd3643699f83 |
---|---|
10 import jungle.test.bbs.JungleManager; | 10 import jungle.test.bbs.JungleManager; |
11 import alice.codesegment.CodeSegment; | 11 import alice.codesegment.CodeSegment; |
12 import alice.datasegment.CommandType; | 12 import alice.datasegment.CommandType; |
13 import alice.datasegment.Receiver; | 13 import alice.datasegment.Receiver; |
14 import alice.jungle.datasegment.store.operations.DefaultTreeOperationLogContainer; | 14 import alice.jungle.datasegment.store.operations.DefaultTreeOperationLogContainer; |
15 import alice.jungle.transaction.NetworkDefaultJungleTreeEditor; | |
15 | 16 |
16 public class LogUpdateCodeSegment extends CodeSegment { | 17 public class LogUpdateCodeSegment extends CodeSegment { |
17 | 18 |
18 public Receiver arg1 = ids.create(CommandType.PEEK); | 19 public Receiver arg1 = ids.create(CommandType.PEEK); |
19 private final String rh; | 20 private final String rh; |
26 | 27 |
27 public void run() { | 28 public void run() { |
28 System.out.println("--LogUpdateCodeSegment--"); | 29 System.out.println("--LogUpdateCodeSegment--"); |
29 int index = arg1.index; | 30 int index = arg1.index; |
30 DefaultTreeOperationLogContainer container = arg1.asClass(DefaultTreeOperationLogContainer.class); | 31 DefaultTreeOperationLogContainer container = arg1.asClass(DefaultTreeOperationLogContainer.class); |
31 if(!updaterIsMe(container)) { | 32 if(updaterIsMe(container)) { |
32 LogUpdateCodeSegment updateCS = new LogUpdateCodeSegment(rh, key); | 33 LogUpdateCodeSegment updateCS = new LogUpdateCodeSegment(rh, key); |
33 updateCS.arg1.setKey(rh, key, index+1); | 34 updateCS.arg1.setKey(rh, key, index+1); |
34 return; | 35 return; |
35 } | 36 } |
36 DefaultTreeOperationLog log = null; | 37 DefaultTreeOperationLog log = null; |
37 try { | 38 try { |
38 log = container.convert(); | 39 log = container.convert(); |
39 } catch (IOException e) { | 40 } catch (IOException e) { |
40 e.printStackTrace(); | 41 e.printStackTrace(); |
41 } | 42 } |
42 //JungleManager jm = new JungleManager(); | |
43 JungleTree tree = JungleManager.getJungle().getTreeByName("boards"); | 43 JungleTree tree = JungleManager.getJungle().getTreeByName("boards"); |
44 JungleTreeEditor editor = tree.getTreeEditor(); | 44 JungleTreeEditor editor = tree.getTreeEditor(); |
45 Either<Error, JungleTreeEditor> either = JungleManager.edit(editor, log); | 45 Either<Error, JungleTreeEditor> either = JungleManager.edit(editor, log); |
46 if(either.isA()) { | 46 if(either.isA()) { |
47 throw new IllegalStateException(); | 47 throw new IllegalStateException(); |
48 } | 48 } |
49 editor = either.b(); | 49 editor = either.b(); |
50 editor.success(); | 50 either = editor.success(); |
51 if(either.isA()) { | |
52 throw new IllegalStateException(); | |
53 } | |
51 LogUpdateCodeSegment updateCS = new LogUpdateCodeSegment(rh, key); | 54 LogUpdateCodeSegment updateCS = new LogUpdateCodeSegment(rh, key); |
52 updateCS.arg1.setKey(rh, key, index+1); | 55 updateCS.arg1.setKey(rh, key, index+1); |
53 } | 56 } |
54 | 57 |
55 private boolean updaterIsMe(DefaultTreeOperationLogContainer container) { | 58 private boolean updaterIsMe(DefaultTreeOperationLogContainer container) { |
56 | 59 |
57 return true; | 60 return false; |
58 } | 61 } |
59 | 62 |
60 | 63 |
61 | 64 |
62 } | 65 } |