Mercurial > hg > Database > jungle-network
comparison src/alice/jungle/codesegment/LogUpdateCodeSegment.java @ 47:686057add8a4
confirmed LogUpdateCodeSegment
author | one |
---|---|
date | Fri, 12 Jul 2013 11:45:12 +0900 |
parents | fd3643699f83 |
children | a89c3539bff2 |
comparison
equal
deleted
inserted
replaced
46:fd3643699f83 | 47:686057add8a4 |
---|---|
15 import alice.jungle.transaction.NetworkDefaultJungleTreeEditor; | 15 import alice.jungle.transaction.NetworkDefaultJungleTreeEditor; |
16 | 16 |
17 public class LogUpdateCodeSegment extends CodeSegment { | 17 public class LogUpdateCodeSegment extends CodeSegment { |
18 | 18 |
19 public Receiver arg1 = ids.create(CommandType.PEEK); | 19 public Receiver arg1 = ids.create(CommandType.PEEK); |
20 private final String rh; | 20 public Receiver host = ids.create(CommandType.PEEK); |
21 private final String key; | |
22 | 21 |
23 public LogUpdateCodeSegment(String _rh, String _key) { | 22 public LogUpdateCodeSegment() { |
24 rh = _rh; | 23 host.setKey("host",0); |
25 key = _key; | |
26 } | 24 } |
27 | 25 |
28 public void run() { | 26 public void run() { |
29 System.out.println("--LogUpdateCodeSegment--"); | 27 System.out.println("--LogUpdateCodeSegment--"); |
30 int index = arg1.index; | 28 int index = arg1.index; |
29 String h = host.asString(); | |
31 DefaultTreeOperationLogContainer container = arg1.asClass(DefaultTreeOperationLogContainer.class); | 30 DefaultTreeOperationLogContainer container = arg1.asClass(DefaultTreeOperationLogContainer.class); |
32 if(updaterIsMe(container)) { | 31 if(updaterIsMe(h, container)) { |
33 LogUpdateCodeSegment updateCS = new LogUpdateCodeSegment(rh, key); | 32 LogUpdateCodeSegment updateCS = new LogUpdateCodeSegment(); |
34 updateCS.arg1.setKey(rh, key, index+1); | 33 updateCS.arg1.setKey("log", index+1); |
35 return; | 34 return; |
36 } | 35 } |
37 DefaultTreeOperationLog log = null; | 36 DefaultTreeOperationLog log = null; |
38 try { | 37 try { |
39 log = container.convert(); | 38 log = container.convert(); |
49 editor = either.b(); | 48 editor = either.b(); |
50 either = editor.success(); | 49 either = editor.success(); |
51 if(either.isA()) { | 50 if(either.isA()) { |
52 throw new IllegalStateException(); | 51 throw new IllegalStateException(); |
53 } | 52 } |
54 LogUpdateCodeSegment updateCS = new LogUpdateCodeSegment(rh, key); | 53 LogUpdateCodeSegment updateCS = new LogUpdateCodeSegment(); |
55 updateCS.arg1.setKey(rh, key, index+1); | 54 updateCS.arg1.setKey("log", index+1); |
56 } | 55 } |
57 | 56 |
58 private boolean updaterIsMe(DefaultTreeOperationLogContainer container) { | 57 private boolean updaterIsMe(String host, DefaultTreeOperationLogContainer container) { |
59 | 58 return host.equals(container.getServerName()); |
60 return false; | |
61 } | 59 } |
62 | 60 |
63 | 61 |
64 | 62 |
65 } | 63 } |