EMMA Coverage Report (generated Tue Oct 27 11:32:50 PDT 2009)
[all classes][net.spy.memcached.protocol.ascii]

COVERAGE SUMMARY FOR SOURCE FILE [AsciiMemcachedNodeImpl.java]

nameclass, %method, %block, %line, %
AsciiMemcachedNodeImpl.java100% (1/1)100% (3/3)94%  (95/101)97%  (17.5/18)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AsciiMemcachedNodeImpl100% (1/1)100% (3/3)94%  (95/101)97%  (17.5/18)
<static initializer> 100% (1/1)75%  (6/8)75%  (0.8/1)
optimize (): void 100% (1/1)95%  (80/84)98%  (14.7/15)
AsciiMemcachedNodeImpl (SocketAddress, SocketChannel, int, BlockingQueue, Blo... 100% (1/1)100% (9/9)100% (2/2)

1package net.spy.memcached.protocol.ascii;
2 
3import java.net.SocketAddress;
4import java.nio.channels.SocketChannel;
5import java.util.concurrent.BlockingQueue;
6 
7import net.spy.memcached.ops.GetOperation;
8import net.spy.memcached.ops.Operation;
9import net.spy.memcached.ops.OperationState;
10import net.spy.memcached.protocol.ProxyCallback;
11import net.spy.memcached.protocol.TCPMemcachedNodeImpl;
12 
13/**
14 * Memcached node for the ASCII protocol.
15 */
16public final class AsciiMemcachedNodeImpl extends TCPMemcachedNodeImpl {
17 
18        public AsciiMemcachedNodeImpl(SocketAddress sa, SocketChannel c,
19                        int bufSize, BlockingQueue<Operation> rq,
20                        BlockingQueue<Operation> wq, BlockingQueue<Operation> iq) {
21                super(sa, c, bufSize, rq, wq, iq);
22        }
23 
24        @Override
25        protected void optimize() {
26                // make sure there are at least two get operations in a row before
27                // attempting to optimize them.
28                if(writeQ.peek() instanceof GetOperation) {
29                        optimizedOp=writeQ.remove();
30                        if(writeQ.peek() instanceof GetOperation) {
31                                OptimizedGetImpl og=new OptimizedGetImpl(
32                                                (GetOperation)optimizedOp);
33                                optimizedOp=og;
34 
35                                while(writeQ.peek() instanceof GetOperation) {
36                                        GetOperationImpl o=(GetOperationImpl) writeQ.remove();
37                                        if(!o.isCancelled()) {
38                                                og.addOperation(o);
39                                        }
40                                }
41 
42                                // Initialize the new mega get
43                                optimizedOp.initialize();
44                                assert optimizedOp.getState() == OperationState.WRITING;
45                                ProxyCallback pcb=(ProxyCallback) og.getCallback();
46                                getLogger().debug("Set up %s with %s keys and %s callbacks",
47                                        this, pcb.numKeys(), pcb.numCallbacks());
48                        }
49                }
50        }
51 
52}

[all classes][net.spy.memcached.protocol.ascii]
EMMA 2.0.5312 (C) Vladimir Roubtsov