author | dadubrow |
Thu, 11 Feb 2010 11:50:24 -0600 | |
changeset 935 | 3d8a32343ccb |
parent 894 | 48b544aebc83 |
child 1188 | 528b98544660 |
permissions | -rw-r--r-- |
894
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
1 |
/** |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
3 |
* All rights reserved. |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
8 |
* |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
9 |
* Initial Contributors: |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
11 |
* |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
12 |
* Contributors: |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
13 |
* |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
14 |
* Description: |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
15 |
* |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
16 |
*/ |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
17 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
18 |
package com.nokia.carbide.remoteconnections.internal; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
19 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
20 |
import java.util.Collection; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
21 |
import java.util.HashMap; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
22 |
import java.util.HashSet; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
23 |
import java.util.Iterator; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
24 |
import java.util.Map; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
25 |
import java.util.Set; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
26 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
27 |
import com.nokia.carbide.remoteconnections.interfaces.AbstractConnectedService2; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
28 |
import com.nokia.carbide.remoteconnections.interfaces.AbstractSynchronizedConnection; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
29 |
import com.nokia.carbide.remoteconnections.interfaces.AbstractConnectedService2.Status; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
30 |
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
31 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
32 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
33 |
public class ServiceTester { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
34 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
35 |
public class TestRunner extends Thread { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
36 |
private final Collection<Set<AbstractConnectedService2>> connectedServicesSets; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
37 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
38 |
public TestRunner(Collection<Set<AbstractConnectedService2>> connectedServicesSets) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
39 |
this.connectedServicesSets = connectedServicesSets; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
40 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
41 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
42 |
@Override |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
43 |
public void run() { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
44 |
for (Set<AbstractConnectedService2> connectedServices : connectedServicesSets) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
45 |
// test first in the set and set status for others |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
46 |
Iterator<AbstractConnectedService2> iterator = connectedServices.iterator(); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
47 |
AbstractConnectedService2 toTest = iterator.next(); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
48 |
toTest.testStatus(); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
49 |
IStatus status = toTest.getStatus(); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
50 |
while (iterator.hasNext()) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
51 |
AbstractConnectedService2 next = iterator.next(); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
52 |
next.setStatus((Status) status); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
53 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
54 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
55 |
unregisterThread(this); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
56 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
57 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
58 |
@Override |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
59 |
public synchronized void start() { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
60 |
registerThread(this); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
61 |
super.start(); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
62 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
63 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
64 |
public boolean contains(AbstractConnectedService2 connectedService) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
65 |
for (Set<AbstractConnectedService2> csSet : connectedServicesSets) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
66 |
if (csSet.contains(connectedService)) |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
67 |
return true; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
68 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
69 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
70 |
return false; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
71 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
72 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
73 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
74 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
75 |
public interface IEquivalence { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
76 |
Object getRelation(AbstractConnectedService2 cs); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
77 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
78 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
79 |
private static ServiceTester instance; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
80 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
81 |
private Set<AbstractConnectedService2> registry; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
82 |
private Set<TestRunner> runningThreads; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
83 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
84 |
public static ServiceTester getInstance() { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
85 |
if (instance == null) |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
86 |
instance = new ServiceTester(); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
87 |
return instance; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
88 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
89 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
90 |
private ServiceTester() { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
91 |
registry = new HashSet<AbstractConnectedService2>(); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
92 |
runningThreads = new HashSet<TestRunner>(); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
93 |
Thread t = new Thread(new Runnable() { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
94 |
public void run() { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
95 |
while (true) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
96 |
Collection<Set<AbstractConnectedService2>> csSetsByResource = |
935 | 97 |
createConnectedServiceSetsByResource(new HashSet<AbstractConnectedService2>(registry)); |
894
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
98 |
for (Set<AbstractConnectedService2> set : csSetsByResource) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
99 |
Collection<Set<AbstractConnectedService2>> csSetsByService = |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
100 |
createConnectedServiceSetsByService(set); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
101 |
runTests(csSetsByService); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
102 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
103 |
try { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
104 |
Thread.sleep(AbstractConnectedService2.TIMEOUT); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
105 |
} catch (InterruptedException e) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
106 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
107 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
108 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
109 |
}); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
110 |
t.start(); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
111 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
112 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
113 |
private void runTests(Collection<Set<AbstractConnectedService2>> csSetsByResource) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
114 |
if (isRunningTest(csSetsByResource)) |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
115 |
return; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
116 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
117 |
if (csSetsByResource.isEmpty()) |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
118 |
return; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
119 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
120 |
TestRunner runner = new TestRunner(csSetsByResource); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
121 |
runner.start(); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
122 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
123 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
124 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
125 |
private Collection<Set<AbstractConnectedService2>> partition( |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
126 |
Set<AbstractConnectedService2> connectedServices, IEquivalence equivalence) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
127 |
Map<Object, Set<AbstractConnectedService2>> collatedConnectedServiceSetMap = |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
128 |
new HashMap<Object, Set<AbstractConnectedService2>>(); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
129 |
for (AbstractConnectedService2 cs : connectedServices) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
130 |
Object object = equivalence.getRelation(cs); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
131 |
if (object == null) |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
132 |
continue; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
133 |
if (!collatedConnectedServiceSetMap.containsKey(object)) |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
134 |
collatedConnectedServiceSetMap.put(object, new HashSet<AbstractConnectedService2>()); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
135 |
collatedConnectedServiceSetMap.get(object).add(cs); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
136 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
137 |
return collatedConnectedServiceSetMap.values(); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
138 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
139 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
140 |
private Collection<Set<AbstractConnectedService2>> createConnectedServiceSetsByResource(Set<AbstractConnectedService2> connectedServices) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
141 |
return partition(connectedServices, new IEquivalence() { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
142 |
public Object getRelation(AbstractConnectedService2 cs) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
143 |
AbstractSynchronizedConnection connection = (AbstractSynchronizedConnection) cs.getConnection(); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
144 |
if (connection != null) |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
145 |
return connection.getCurrentResource(); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
146 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
147 |
return null; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
148 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
149 |
}); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
150 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
151 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
152 |
protected Collection<Set<AbstractConnectedService2>> createConnectedServiceSetsByService(Set<AbstractConnectedService2> connectedServices) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
153 |
return partition(connectedServices, new IEquivalence() { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
154 |
public Object getRelation(AbstractConnectedService2 cs) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
155 |
return cs.getService(); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
156 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
157 |
}); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
158 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
159 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
160 |
public void register(AbstractConnectedService2 connectedService) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
161 |
registry.add(connectedService); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
162 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
163 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
164 |
public boolean isRegistered(AbstractConnectedService2 connectedService) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
165 |
return registry.contains(connectedService); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
166 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
167 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
168 |
public void unregister(AbstractConnectedService2 connectedService) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
169 |
registry.remove(connectedService); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
170 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
171 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
172 |
public synchronized void registerThread(TestRunner testRunner) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
173 |
runningThreads.add(testRunner); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
174 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
175 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
176 |
public synchronized void unregisterThread(TestRunner testRunner) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
177 |
runningThreads.remove(testRunner); |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
178 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
179 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
180 |
public synchronized boolean isRunningTest(Collection<Set<AbstractConnectedService2>> csSetsByResource) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
181 |
for (Set<AbstractConnectedService2> set : csSetsByResource) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
182 |
for (AbstractConnectedService2 cs : set) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
183 |
if (isRunningTest(cs)) |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
184 |
return true; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
185 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
186 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
187 |
return false; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
188 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
189 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
190 |
private boolean isRunningTest(AbstractConnectedService2 cs) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
191 |
for (TestRunner runner : runningThreads) { |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
192 |
if (runner.contains(cs)) |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
193 |
return true; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
194 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
195 |
|
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
196 |
return false; |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
197 |
} |
48b544aebc83
bug 10493 - only test one service for each physical connection
dadubrow
parents:
diff
changeset
|
198 |
} |