assertNull(_state.getStrategy("service-1", "http"));
// Use the _clusterRegistry.put to populate the _state.clusterProperties, used by
// _state.refreshServiceStrategies
_clusterRegistry.put("cluster-1", new ClusterProperties("cluster-1"));
_serviceRegistry.put("service-1", new ServiceProperties("service-1",
"cluster-1",
"/test",
"unusedInThisConstructor",
strategyList,
Collections.<String, Object>emptyMap(),
Collections.<String, Object>emptyMap(),
Collections.<String, String>emptyMap(),
schemes,
Collections.<URI>emptySet()));
LoadBalancerStrategy strategy = _state.getStrategy("service-1", "http");
assertNotNull(strategy, "got null strategy in setup");
// test serial to make sure things are working before concurrent test
TransportClient resultTC = _state.getClient("service-1", "http");
assertNotNull(resultTC, "got null tracker client in non-concurrent env");
ExecutorService myExecutor = Executors.newCachedThreadPool();
ArrayList<TcCallable> cArray = new ArrayList<TcCallable>();
List<TrackerClient> clients = new ArrayList<TrackerClient>();
Map<Integer, PartitionData> partitionDataMap = new HashMap<Integer, PartitionData>(2);
partitionDataMap.put(DefaultPartitionAccessor.DEFAULT_PARTITION_ID, new PartitionData(1d));
clients.add(new TrackerClient(uri, partitionDataMap, new DegraderLoadBalancerTest.TestLoadBalancerClient(uri),
SystemClock.instance(), null));
for (int i = 0; i < 20; i++)
{
cArray.add(i, new TcCallable(clients, _state));
}
Runnable refreshTask = new Runnable()
{
@Override
public void run()
{
while(true)
{
List<String> myStrategyList = new LinkedList<String>();
myStrategyList.add("degraderV3");
_state.refreshServiceStrategies(new ServiceProperties("service-1",
"cluster-1",
"/test",
"unusedInThisConstructor",
myStrategyList,
Collections.<String, Object>emptyMap(),