EMMA Coverage Report (generated Tue Apr 17 08:51:20 BST 2007)
[all classes][org.jtoolkit.essence.data.impl]

COVERAGE SUMMARY FOR SOURCE FILE [ClusterStore.java]

nameclass, %method, %block, %line, %
ClusterStore.java100% (1/1)46%  (6/13)33%  (37/111)41%  (11/27)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ClusterStore100% (1/1)46%  (6/13)33%  (37/111)41%  (11/27)
asMap (): Map 0%   (0/1)0%   (0/6)0%   (0/1)
getName (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getQueueView (): Queue 0%   (0/1)0%   (0/6)0%   (0/1)
isClosed (): boolean 0%   (0/1)0%   (0/3)0%   (0/1)
removeMatching (Predicate): int 0%   (0/1)0%   (0/7)0%   (0/1)
selectMatching (Predicate): Map 0%   (0/1)0%   (0/7)0%   (0/1)
visit (Visitor): Object 0%   (0/1)0%   (0/42)0%   (0/10)
ClusterStore (String, Cluster): void 100% (1/1)100% (12/12)100% (5/5)
close (): void 100% (1/1)100% (4/4)100% (2/2)
getCacheView (): Cache 100% (1/1)100% (6/6)100% (1/1)
getCluster (): Cluster 100% (1/1)100% (3/3)100% (1/1)
getListenerSet (): Event$ListenerSet 100% (1/1)100% (6/6)100% (1/1)
getMapView (): ConcurrentMap 100% (1/1)100% (6/6)100% (1/1)

1package org.jtoolkit.essence.data.impl;
2 
3import org.jetbrains.annotations.NotNull;
4import org.jtoolkit.essence.concurrency.Concurrency;
5import org.jtoolkit.essence.concurrency.ThreadSafe;
6import org.jtoolkit.essence.concurrency.Timeout;
7import org.jtoolkit.essence.data.*;
8 
9import javax.cache.Cache;
10import java.util.Map;
11import java.util.Queue;
12import java.util.concurrent.ConcurrentMap;
13import java.util.concurrent.locks.Lock;
14 
15/*
16   Copyright 2006 Peter Lawrey
17 
18   Licensed under the Apache License, Version 2.0 (the "License");
19   you may not use this file except in compliance with the License.
20   You may obtain a copy of the License at
21 
22       http://www.apache.org/licenses/LICENSE-2.0
23 
24   Unless required by applicable law or agreed to in writing, software
25   distributed under the License is distributed on an "AS IS" BASIS,
26   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27   See the License for the specific language governing permissions and
28   limitations under the License.
29*/
30/**
31 * The purpose of ClusterStore to act as a Store for a Cluster
32 *
33 * @author Peter Lawrey
34 * @since 25-Nov-2006
35 */
36@ThreadSafe(Concurrency.CONCURRENT_READ_WRITE)
37public class ClusterStore<K, V> implements Store<K, V> {
38    private final Cluster cluster;
39    private final String name;
40    private boolean closed = false;
41 
42    public ClusterStore(String name, Cluster cluster) {
43        this.name = name;
44        this.cluster = cluster;
45    }
46 
47    public Cluster getCluster() {
48        return cluster;
49    }
50 
51    @NotNull public Event.ListenerSet getListenerSet() {
52        return cluster.getListenerSet(name);
53    }
54 
55    @NotNull public Cache<K, V> getCacheView() {
56        return cluster.getMapView(name);
57    }
58 
59    @NotNull public ConcurrentMap<K, V> getMapView() {
60        return cluster.getMapView(name);
61    }
62 
63    @NotNull public Queue<V> getQueueView() {
64        return cluster.getQueueView(name);
65    }
66 
67    @NotNull public Map<K, V> asMap() {
68        return cluster.getMapView(name);
69    }
70 
71    public Map<K, V> selectMatching(Predicate<Map.Entry<K, V>> predicate) {
72        return cluster.selectMatching(name, predicate);
73    }
74 
75    public int removeMatching(Predicate<Map.Entry<K, V>> predicate) {
76        return cluster.removeMatching(name, predicate);
77    }
78 
79    public void close() {
80        closed = true;
81    }
82 
83    public boolean isClosed() {
84        return closed;
85    }
86 
87    @NotNull public String getName() {
88        return name;
89    }
90 
91    public <R> R visit(@NotNull Visitor<Store<K, V>, R> visitor) throws VisitorException {
92        Lock writeLock = ((ClusterImpl) cluster).getBackingStore(name).getLock().writeLock();
93        Transaction t = Transaction.start("visit ClusterStore", Timeout.NEVER);
94        try {
95            writeLock.lockInterruptibly();
96            R ret = visitor.visit(this);
97            t.commit();
98            return ret;
99        } catch (InterruptedException ie) {
100            throw new VisitorException(ie);
101        } finally {
102            writeLock.unlock();
103            t.complete();
104        }
105    }
106}

[all classes][org.jtoolkit.essence.data.impl]
EMMA 2.0.5312 (C) Vladimir Roubtsov