Package com.opengamma.livedata.server.distribution

Examples of com.opengamma.livedata.server.distribution.MarketDataDistributor


    assertEquals(new HashSet<String>(), server.getActiveSubscriptionIds());
   
    server.subscribe(ticker);
   
    assertEquals(Sets.newHashSet(ticker), server.getActiveSubscriptionIds());
    MarketDataDistributor marketDataDistributor = server.getMarketDataDistributor(ticker);
    assertEquals(false, marketDataDistributor.isPersistent());
   
    subManager.refresh();
    Thread.sleep(1000);
    assertEquals(true, marketDataDistributor.isPersistent());
    assertEquals(Sets.newHashSet(ticker), server.getActiveSubscriptionIds());
    subManager.stop();
    server.stop();
  }
View Full Code Here


    assertEquals(uniqueId, _server.getActiveSubscriptionIds().iterator().next());

    assertEquals(0, _server.getNumLiveDataUpdatesSentPerSecondOverLastMinute(), 0.0001);
    assertEquals(0, _server.getNumMarketDataUpdatesReceived());

    MarketDataDistributor distributor = subscription.getDistributors().iterator().next();

    assertSame(distributor, subscription.getMarketDataDistributor(spec));

    assertSame(distributor, _server.getMarketDataDistributor(spec));

    assertTrue(distributor.isPersistent() == persistent);
    assertNotNull(distributor.getExpiry());
  }
View Full Code Here

    Subscription sub = _server.getSubscription("mysub");
    assertEquals(1, sub.getDistributors().size());

    LiveDataSpecification spec = getSpec("mysub");
    MarketDataDistributor distributor = _server.getMarketDataDistributor(spec);
    assertNotNull(distributor);

    assertFalse(_server.stopDistributor(distributor));
    distributor.setPersistent(false);
    assertTrue(_server.stopDistributor(distributor));
    assertTrue(sub.getDistributors().isEmpty());
    assertFalse(_server.isSubscribedTo("mysub"));
    assertNull(_server.getSubscription("mysub"));
    assertNull(_server.getSubscription(spec));
View Full Code Here

    Map<LiveDataSpecification, DistributionSpecification> resolved = getDistributionSpecificationResolver().resolve(liveDataSpecificationsFromClient);
    for (LiveDataSpecification liveDataSpecificationFromClient : liveDataSpecificationsFromClient) {
      DistributionSpecification distributionSpec = resolved.get(liveDataSpecificationFromClient);
      LiveDataSpecification fullyQualifiedSpec = distributionSpec.getFullyQualifiedLiveDataSpecification();

      MarketDataDistributor currentlyActiveDistributor = getMarketDataDistributor(distributionSpec);
      if (currentlyActiveDistributor != null) {
        if (currentlyActiveDistributor.getSnapshot() != null) {
          //NOTE simon 28/11/2011: We presume that all the fields were provided in one go, all or nothing.
          s_logger.debug("Able to satisfy {} from existing LKV", liveDataSpecificationFromClient);
          LiveDataValueUpdateBean snapshot = currentlyActiveDistributor.getSnapshot();
          responses.add(buildSnapshotResponse(liveDataSpecificationFromClient, snapshot));
          continue;
        } else if (canSatisfySnapshotFromEmptySubscription(currentlyActiveDistributor)) {
          //BBG-91 - don't requery when an existing subscription indicates that the snapshot will fail
          s_logger.debug("Able to satisfy failed snapshot {} from existing LKV", liveDataSpecificationFromClient);
          String errorMsg = "Existing subscription for " + currentlyActiveDistributor.getDistributionSpec().getMarketDataId() +
              " failed to retrieve a snapshot.  Perhaps required fields are unavailable.";
          responses.add(buildErrorMessageResponse(liveDataSpecificationFromClient, LiveDataSubscriptionResult.INTERNAL_ERROR, errorMsg));
          continue;
        } else {
          s_logger.debug("Can't use existing subscription to satisfy {} from existing LKV", liveDataSpecificationFromClient);
View Full Code Here

   */
  public boolean stopDistributor(MarketDataDistributor distributor) {
    ArgumentChecker.notNull(distributor, "Distributor");
    _subscriptionLock.lock();
    try {
      MarketDataDistributor realDistributor = getMarketDataDistributor(distributor.getDistributionSpec());
      if (realDistributor != distributor) {
        return false;
      }
      if (distributor.isPersistent()) {
        return false;
View Full Code Here

      _subscriptionLock.unlock();
    }
  }

  public Subscription getSubscription(LiveDataSpecification fullyQualifiedSpec) {
    MarketDataDistributor distributor = getMarketDataDistributor(fullyQualifiedSpec);
    if (distributor == null) {
      return null;
    }
    return distributor.getSubscription();
  }
View Full Code Here

  private void setPersistenceForAll(boolean persistent) {
    try {
      Set<String> activeSubscriptionIds = getServer().getActiveSubscriptionIds();
      for (String string : activeSubscriptionIds) {
        MarketDataDistributor marketDataDistributor = getServer().getMarketDataDistributor(string);
        marketDataDistributor.setPersistent(persistent);
      }
    } catch (RuntimeException e) {
      s_logger.error("Setting all susbcriptions to persistent=" + persistent + " failed", e);
      throw new RuntimeException(e.getMessage());
    }
View Full Code Here

  @ManagedOperation(description = "Gets the current snapshot of a security. Will not cause an underlying snapshot.")
  @ManagedOperationParameters({
       @ManagedOperationParameter(name = "securityUniqueId", description = "Security unique ID. Server type dependent.)") })
  public String getSnapshot(String securityUniqueId) {
    MarketDataDistributor marketDataDistributor = getServer().getMarketDataDistributor(securityUniqueId);
    return marketDataDistributor != null && marketDataDistributor.getSnapshot() != null ? marketDataDistributor.getSnapshot().toString() : "Unknown";
  }
View Full Code Here

      return;
    }
   
    Set<LiveDataSpecification> resubscriptions = new HashSet<LiveDataSpecification>();
    for (LiveDataSpecification fullyQualifiedSpec : fullyQualifiedSpecs) {
      MarketDataDistributor distributor = server.getMarketDataDistributor(fullyQualifiedSpec);
      if (distributor != null) {
        s_logger.debug("Heartbeat on {}", fullyQualifiedSpec);
        distributor.extendExpiry(getTimeoutExtension());
      } else {
        // We have (presumably erroneously) dropped a subscription that a client is
        // expecting. In lieu of determining the underlying cause of dropping the
        // subscription, we automatically create a new subscription
        s_logger.info("Failed to find distributor for heartbeat on {} from {} - will resubscribe", fullyQualifiedSpec, server);
View Full Code Here

   * @param spec  the format to use
   * @param persistent  whether the distributor should be persistent (survive a server restart)
   * @return the created/modified {@code MarketDataDistributor}
   */
  /*package*/ MarketDataDistributor createDistributor(DistributionSpecification spec, boolean persistent) {
    MarketDataDistributor distributor = getMarketDataDistributor(spec);
    if (distributor == null) {
      distributor = new MarketDataDistributor(spec, this, getMarketDataSenderFactory(), persistent, getLkvStoreProvider());
      MarketDataDistributor previous = _distributors.putIfAbsent(spec, distributor);
      if (previous == null) {
        s_logger.info("Added {} to {}", distributor, this);
      } else {
        s_logger.debug("Lost race to create distributor {} to {}", previous, this);
        distributor = previous;
View Full Code Here

TOP

Related Classes of com.opengamma.livedata.server.distribution.MarketDataDistributor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.