Examples of LiveDataValueUpdateBean


Examples of com.opengamma.livedata.LiveDataValueUpdateBean

  public List<Collection<SubscriptionHandle>> getSubscriptionRequests() {
    return _subscriptionRequests;
  }
 
  public void marketDataReceived(LiveDataSpecification fullyQualifiedSpecification, FudgeMsg fields) {
    LiveDataValueUpdateBean bean = new LiveDataValueUpdateBean(_sequenceGenerator.incrementAndGet(), fullyQualifiedSpecification, fields);
    getValueDistributor().notifyListeners(bean);
  }
View Full Code Here

Examples of com.opengamma.livedata.LiveDataValueUpdateBean

    assertEquals(1, _collectingReceiver.getMessages().size());
   
    FudgeDeserializer deserializer = new FudgeDeserializer(fudgeContext);
    for (byte[] byteArray : _collectingReceiver.getMessages()) {
      FudgeMsgEnvelope msgEnvelope = fudgeContext.deserialize(byteArray);
      LiveDataValueUpdateBean update = LiveDataValueUpdateBeanFudgeBuilder.fromFudgeMsg(deserializer, msgEnvelope.getMessage());
      assertEquals(msg, update.getFields());
    }
  }
View Full Code Here

Examples of com.opengamma.livedata.LiveDataValueUpdateBean

    LiveDataValueUpdateBean[] updates = new LiveDataValueUpdateBean[3];
   
    FudgeDeserializer deserializer = new FudgeDeserializer(fudgeContext);
    for (int i = 0; i < _collectingReceiver.getMessages().size(); i++) {
      FudgeMsgEnvelope msgEnvelope = fudgeContext.deserialize(_collectingReceiver.getMessages().get(i));
      LiveDataValueUpdateBean update = LiveDataValueUpdateBeanFudgeBuilder.fromFudgeMsg(deserializer, msgEnvelope.getMessage());
      updates[i] = update;
    }
   
    assertEquals(msg1, updates[0].getFields());
    assertEquals(1, updates[0].getSequenceNumber()); // starts from 1 because simpleScenario() already sent 1
View Full Code Here

Examples of com.opengamma.livedata.LiveDataValueUpdateBean

   
    // Find the LAST reset (in theory, there could be multiple resets although
    // this is a highly theoretical case)
    Integer resetIndex = null;
    for (int i = 0; i < _ticksOnHold.size(); i++) {
      LiveDataValueUpdateBean tick = _ticksOnHold.get(i);
      if (tick.getSequenceNumber() == LiveDataValueUpdate.SEQUENCE_START) {
        resetIndex = i;               
      }
    }
   
    if (resetIndex == null) {
      s_logger.debug("{}: Sending snapshot and {} ticks on hold to {}",
          new Object[] {getRequestedSpecification(), _ticksOnHold.size(), getListener() });
     
      // No resets. This is the normal case. Use the snapshot
      // and any subsequent ticks. The subsequent ticks
      // are not sorted, but are played back in the order received,
      // which hopefully should be the sequence number order (i.e., no sorting necessary).
      _listener.valueUpdate(_snapshotOnHold);
     
      for (LiveDataValueUpdateBean tick : _ticksOnHold) {
        if (tick.getSequenceNumber() > snapshotSequenceNo) {
          _listener.valueUpdate(tick);
        }
      }
    } else {
      s_logger.debug("{}: Reset detected. Sending {} ticks on hold to {}",
          new Object[] {getRequestedSpecification(), _ticksOnHold.size() - resetIndex, getListener() });
     
      // This happens when the server is reset (rebooted/migrated) while subscribing.
      // We assume that the tick with sequence number = 0
      // is a full update (as LiveDataValueUpdate.getSequenceNumber() specifies).
      // Using this assumption, we first use the tick with sequence number = 0, which
      // acts as the snapshot, and then simply send any subsequent ticks in order.
      for (int i = resetIndex; i < _ticksOnHold.size(); i++) {
        LiveDataValueUpdateBean tick = _ticksOnHold.get(i);
        _listener.valueUpdate(tick);
      }
    }
     
    _ticksOnHold.clear();
View Full Code Here

Examples of com.opengamma.livedata.LiveDataValueUpdateBean

  // until we can get a handle on the construction of receivers based on responses.
  @Override
  public void messageReceived(FudgeContext fudgeContext,
      FudgeMsgEnvelope msgEnvelope) {
    FudgeMsg fudgeMsg = msgEnvelope.getMessage();
    LiveDataValueUpdateBean update = LiveDataValueUpdateBeanFudgeBuilder.fromFudgeMsg(new FudgeDeserializer(fudgeContext), fudgeMsg);
    valueUpdate(update);
  }
View Full Code Here

Examples of com.opengamma.livedata.LiveDataValueUpdateBean

      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);
        }
      }

      String securityUniqueId = fullyQualifiedSpec.getIdentifier(getUniqueIdDomain());
      if (securityUniqueId == null) {
        String errorMsg = "Qualified spec " + fullyQualifiedSpec + " does not contain ID of domain " + getUniqueIdDomain();
        responses.add(buildErrorMessageResponse(liveDataSpecificationFromClient, LiveDataSubscriptionResult.INTERNAL_ERROR, errorMsg));
        continue;
      }

      snapshotsToActuallyDo.add(securityUniqueId);
      securityUniqueId2LiveDataSpecificationFromClient.put(securityUniqueId, liveDataSpecificationFromClient);
    }

    s_logger.debug("Need to actually snapshot {}", snapshotsToActuallyDo);
    Map<String, FudgeMsg> snapshots = doSnapshot(snapshotsToActuallyDo);
    for (Map.Entry<String, FudgeMsg> snapshotEntry : snapshots.entrySet()) {
      String securityUniqueId = snapshotEntry.getKey();
      FudgeMsg msg = snapshotEntry.getValue();

      LiveDataSpecification liveDataSpecFromClient = securityUniqueId2LiveDataSpecificationFromClient.get(securityUniqueId);

      DistributionSpecification distributionSpec = resolved.get(liveDataSpecFromClient);
      FudgeMsg normalizedMsg = distributionSpec.getNormalizedMessage(msg, securityUniqueId);
      if (normalizedMsg == null) {
        String errorMsg = "When snapshot for " + securityUniqueId + " was run through normalization, the message disappeared. " +
            " This indicates there are buggy normalization rules in place, or that buggy (or unexpected) data was" +
            " received from the underlying market data API. Check your normalization rules. Raw, unnormalized msg = " + msg;
        responses.add(buildErrorMessageResponse(liveDataSpecFromClient, LiveDataSubscriptionResult.INTERNAL_ERROR, errorMsg));
        continue;
      }

      LiveDataValueUpdateBean snapshot = new LiveDataValueUpdateBean(0, distributionSpec.getFullyQualifiedLiveDataSpecification(), normalizedMsg);
      responses.add(buildSnapshotResponse(liveDataSpecFromClient, snapshot));
    }

    return responses;
  }
View Full Code Here

Examples of com.opengamma.livedata.LiveDataValueUpdateBean

   * @param msg  the message, not null
   */
  private void dispatchLiveDataUpdate(FudgeMsg msg) {
    CogdaLiveDataUpdateMessage updateMessage = CogdaLiveDataUpdateBuilder.buildObjectStatic(new FudgeDeserializer(getFudgeContext()), msg);
    LiveDataSpecification ldspec = new LiveDataSpecification(updateMessage.getNormalizationScheme(), updateMessage.getSubscriptionId());
    LiveDataValueUpdateBean valueUpdateBean = new LiveDataValueUpdateBean(0L, ldspec, updateMessage.getValues());
    super.valueUpdate(valueUpdateBean);
  }
View Full Code Here

Examples of com.opengamma.livedata.LiveDataValueUpdateBean

    LiveDataSubscriptionResult ldsResult = responseMessage.getGenericResult().toLiveDataSubscriptionResult();
    LiveDataSubscriptionResponse ldsResponse = new LiveDataSubscriptionResponse(subHandle.getRequestedSpecification(), ldsResult);
    ldsResponse.setFullyQualifiedSpecification(ldSpec);
    ldsResponse.setUserMessage(responseMessage.getUserMessage());
   
    LiveDataValueUpdateBean valueUpdateBean = new LiveDataValueUpdateBean(0L, subHandle.getRequestedSpecification(), responseMessage.getValues());
    ldsResponse.setSnapshot(valueUpdateBean);
    subHandle.subscriptionResultReceived(ldsResponse);
  }
View Full Code Here

Examples of com.opengamma.livedata.LiveDataValueUpdateBean

    LiveDataSubscriptionResult ldsResult = responseMessage.getGenericResult().toLiveDataSubscriptionResult();
    LiveDataSubscriptionResponse ldsResponse = new LiveDataSubscriptionResponse(subHandle.getRequestedSpecification(), ldsResult);
    ldsResponse.setFullyQualifiedSpecification(ldSpec);
    ldsResponse.setUserMessage(responseMessage.getUserMessage());
   
    LiveDataValueUpdateBean valueUpdateBean = new LiveDataValueUpdateBean(0L, subHandle.getRequestedSpecification(), responseMessage.getSnapshot());
    ldsResponse.setSnapshot(valueUpdateBean);
   
    switch (responseMessage.getGenericResult()) {
      case SUCCESSFUL:
        super.subscriptionRequestSatisfied(subHandle, ldsResponse);
View Full Code Here

Examples of com.opengamma.livedata.LiveDataValueUpdateBean

    LiveDataSubscriptionResponseMsg responseMsg = _combiningServer.subscriptionRequestMade(request);
    assertEquals(responseMsg.getRequestingUser(), authorizedUser);
    assertEquals(1, responseMsg.getResponses().size());
    for (LiveDataSubscriptionResponse response : responseMsg.getResponses()) {
      assertEquals(LiveDataSubscriptionResult.SUCCESS, response.getSubscriptionResult());
      LiveDataValueUpdateBean snap = response.getSnapshot();
      assertEquals("VALUE", snap.getFields().getString("FIELD"));
      assertEquals(1, snap.getFields().getNumFields());
    }
   
    assertEquals(0, _serverB.getSubscriptions().size());
    assertEquals(0, _serverC.getSubscriptions().size());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.