Mercurial > hg > Members > tatsuki > Alice
comparison src/alice/datasegment/DataSegmentKey.java @ 13:30f97d776a3e
implements Alice daemon
author | one |
---|---|
date | Fri, 13 Jan 2012 19:04:59 +0900 |
parents | c4d6ff56b9bf |
children | e3f1b21718b0 |
comparison
equal
deleted
inserted
replaced
12:c4d6ff56b9bf | 13:30f97d776a3e |
---|---|
28 @Override | 28 @Override |
29 public void run() { | 29 public void run() { |
30 while (true) { | 30 while (true) { |
31 try { | 31 try { |
32 Command cmd = cmdQueue.take(); | 32 Command cmd = cmdQueue.take(); |
33 switch (cmd.cmdType) { | 33 switch (cmd.type) { |
34 case UPDATE: | 34 case UPDATE: |
35 if (dataList.size() != 0) { | 35 if (dataList.size() != 0) { |
36 dataList.remove(0); | 36 dataList.remove(0); |
37 } | 37 } |
38 case PUT: | 38 case PUT: |
41 dataList.add(dsv); | 41 dataList.add(dsv); |
42 // run waiting peek and take | 42 // run waiting peek and take |
43 LinkedList<Command> removeList = new LinkedList<Command>(); | 43 LinkedList<Command> removeList = new LinkedList<Command>(); |
44 for (Command waitCmd : waitList) { | 44 for (Command waitCmd : waitList) { |
45 if (waitCmd.index < index) { | 45 if (waitCmd.index < index) { |
46 waitCmd.manager.replyQueue.put(new Command(CommandType.REPLY, null, cmd.val, index, waitCmd.seq, null, null)); | 46 waitCmd.replyQueue.put(new Command(CommandType.REPLY, null, cmd.val, index, waitCmd.seq, null, null)); |
47 removeList.add(waitCmd); | 47 removeList.add(waitCmd); |
48 if (waitCmd.cmdType == CommandType.TAKE) { // delete data, if it run take cmd. | 48 if (waitCmd.type == CommandType.TAKE) { // delete data, if it run take cmd. |
49 dataList.remove(dsv); | 49 dataList.remove(dsv); |
50 break; | 50 break; |
51 } | 51 } |
52 } | 52 } |
53 } | 53 } |
60 waitList.add(cmd); | 60 waitList.add(cmd); |
61 break; | 61 break; |
62 } | 62 } |
63 for (DataSegmentValue data : dataList) { | 63 for (DataSegmentValue data : dataList) { |
64 if (data.index > cmd.index) { | 64 if (data.index > cmd.index) { |
65 cmd.manager.replyQueue.put(new Command(CommandType.REPLY, null, data.val, data.index, cmd.seq, null, null)); | 65 cmd.replyQueue.put(new Command(CommandType.REPLY, null, data.val, data.index, cmd.seq, null, null)); |
66 break; | 66 break; |
67 } | 67 } |
68 } | 68 } |
69 waitList.add(cmd); | 69 waitList.add(cmd); |
70 break; | 70 break; |
73 waitList.add(cmd); | 73 waitList.add(cmd); |
74 break; | 74 break; |
75 } | 75 } |
76 for (DataSegmentValue data : dataList) { | 76 for (DataSegmentValue data : dataList) { |
77 if (data.index > cmd.index) { | 77 if (data.index > cmd.index) { |
78 cmd.manager.replyQueue.put(new Command(CommandType.REPLY, null, data.val, data.index, cmd.seq, null, null)); | 78 cmd.replyQueue.put(new Command(CommandType.REPLY, null, data.val, data.index, cmd.seq, null, null)); |
79 dataList.remove(data); | 79 dataList.remove(data); |
80 break; | 80 break; |
81 } | 81 } |
82 } | 82 } |
83 waitList.add(cmd); | 83 waitList.add(cmd); |