synchronized (_liveDataClient) {
synchronized (_activeSubscriptions) {
for (final ValueSpecification valueSpecification : valueSpecifications) {
Subscription subscription = _allSubscriptions.get(valueSpecification);
if (subscription == null) {
final LiveDataSpecification liveDataSpecification = LiveMarketDataAvailabilityProvider.getLiveDataSpecification(valueSpecification);
subscription = _activeSubscriptions.get(liveDataSpecification);
if (subscription == null) {
// Start a new subscription
subscription = new Subscription(valueSpecification, liveDataSpecification);
_allSubscriptions.put(valueSpecification, subscription);
_activeSubscriptions.put(liveDataSpecification, subscription);
toSubscribe.add(liveDataSpecification);
continue;
}
_allSubscriptions.put(valueSpecification, subscription);
}
// Increment the count on an open subscription
subscription.incrementCount(valueSpecification);
// If the subscription previously failed, try again -- is this the behavior we want; or should we be a bit less eager to retry?
if (subscription.getRequestedLiveData() == null) {
final LiveDataSpecification liveDataSpecification = LiveMarketDataAvailabilityProvider.getLiveDataSpecification(valueSpecification);
subscription.retry(liveDataSpecification);
toSubscribe.add(liveDataSpecification);
} else /*if (subscription.getFullyQualifiedLiveData() != null)*/ {
alreadySubscribed.add(valueSpecification);
}