Package com.opengamma.master.marketdatasnapshot

Examples of com.opengamma.master.marketdatasnapshot.MarketDataSnapshotMaster


    snapshot.setUniqueId(uid);
    return new MarketDataSnapshotDocument(snapshot);
  }

  private static MarketDataSnapshotListResource createResource(MarketDataSnapshotDocument... docs) {
    MarketDataSnapshotMaster snapshotMaster = mock(MarketDataSnapshotMaster.class);
    List<MarketDataSnapshotDocument> documents = Arrays.asList(docs);
    MarketDataSnapshotSearchResult result = new MarketDataSnapshotSearchResult(documents);
    when(snapshotMaster.search(any(MarketDataSnapshotSearchRequest.class))).thenReturn(result);
    return new MarketDataSnapshotListResource(snapshotMaster);
  }
View Full Code Here


    removeUserViewDefinitions(userName, clientName);
    removeUserMarketDataSnapshot(userName, clientName);
  }

  private void removeUserMarketDataSnapshot(String userName, String clientName) {
    MarketDataSnapshotMaster marketDataSnapshotMaster = getServices().getSnapshotMaster();
    if (marketDataSnapshotMaster != null) {
      Set<ObjectId> snapshotIds = _marketDataSnapShots.remove(ExternalId.of(userName, clientName));
      for (ObjectId oid : snapshotIds) {
        marketDataSnapshotMaster.remove(oid);
        s_logger.debug("market data snapshot {} discarded for {}/{}", new Object[]{oid, userName, clientName});
      }
    }
  }
View Full Code Here

      }
    }
  }

  private void removeAllUserMarketDataSnapshot(String userName) {
    MarketDataSnapshotMaster marketDataSnapshotMaster = getServices().getSnapshotMaster();
    if (marketDataSnapshotMaster != null) {
      Iterator<Entry<ExternalId, Set<ObjectId>>> iterator = _marketDataSnapShots.entrySet().iterator();
      while (iterator.hasNext()) {
        Entry<ExternalId, Set<ObjectId>> entry = iterator.next();
        ExternalId identifier = entry.getKey();
        if (identifier.getScheme().getName().equals(userName)) {
          Set<ObjectId> oids = entry.getValue();
          for (ObjectId oid : oids) {
            marketDataSnapshotMaster.remove(oid);
            s_logger.debug("market data snapshot {} discarded for {}/{}", new Object[]{oid, userName, identifier.getValue()});
          }
          iterator.remove();
        }
      }
View Full Code Here

    if (marketDataOption != null) {
      return new LiveMarketDataSpecification(marketDataOption);
    }
    String snapshotOption = trimToNull(commandLine.getOptionValue(USER_MARKET_DATA_OPT));
    if (snapshotOption != null) {
      MarketDataSnapshotMaster snapshotMaster = toolContext.getMarketDataSnapshotMaster();
      if (snapshotMaster == null) {
        throw new OpenGammaRuntimeException("MarketDataSnapshotMaster is missing from given Toolcontext");
      }
      MarketDataSnapshotSearchRequest request = new MarketDataSnapshotSearchRequest();
      request.setName(snapshotOption);
      MarketDataSnapshotSearchResult searchResult = snapshotMaster.search(request);
      if (searchResult.getDocuments().isEmpty()) {
        throw new OpenGammaRuntimeException("No matching snapshot for given name [" + marketDataOption + "]");
      }
      return new UserMarketDataSpecification(searchResult.getFirstDocument().getUniqueId());
    }
View Full Code Here

    s_logger.info("loading market data snapshots");
    AbstractTool<ToolContext> remoteServerTool = new AbstractTool<ToolContext>() {

      @Override
      protected void doRun() throws Exception {
        MarketDataSnapshotMaster remoteSnapshotMaster = getToolContext().getMarketDataSnapshotMaster();
        MarketDataSnapshotSearchRequest request = new MarketDataSnapshotSearchRequest();
        for (MarketDataSnapshotDocument snapshotDocument : MarketDataSnapshotSearchIterator.iterable(remoteSnapshotMaster, request)) {
          marketDataSnapshotMaster.add(snapshotDocument);
        }
      }
View Full Code Here

    }
    System.exit(0);
  }

  private static SnapshotReader constructSnapshotReader(UniqueId uniqueId) {
    MarketDataSnapshotMaster marketDataSnapshotMaster = s_context.getMarketDataSnapshotMaster();
    if (marketDataSnapshotMaster == null) {
      s_logger.warn("No market data snapshot masters found at {}", s_context);

    }
    return new MasterSnapshotReader(uniqueId, marketDataSnapshotMaster);
View Full Code Here

    }
    return new MasterSnapshotReader(uniqueId, marketDataSnapshotMaster);
  }

  private static SnapshotWriter constructSnapshotWriter(String filename) {
    MarketDataSnapshotMaster marketDataSnapshotMaster = s_context.getMarketDataSnapshotMaster();
    if (marketDataSnapshotMaster == null) {
      s_logger.warn("No market data snapshot masters found at {}", s_context);

    }
    return new FileSnapshotWriter(filename);
View Full Code Here

    final List<RemoteViewProcessor> viewProcessors = getRemoteComponentFactory().getViewProcessors();
    if (viewProcessors.size() == 0) {
      s_logger.warn("No view processors found at {}", getRemoteComponentFactory().getBaseUri());
      return;
    }
    final MarketDataSnapshotMaster marketDataSnapshotMaster = getRemoteComponentFactory().getMarketDataSnapshotMaster(DEFAULT_PREFERRED_CLASSIFIERS);
    if (marketDataSnapshotMaster == null) {
      s_logger.warn("No market data snapshot masters found at {}", getRemoteComponentFactory().getBaseUri());
      return;
    }
    final Collection<ConfigMaster> configMasters = getRemoteComponentFactory().getConfigMasters().values();
    if (configMasters.size() == 0) {
      s_logger.warn("No config masters found at {}", getRemoteComponentFactory().getBaseUri());
      return;
    }

    final RemoteViewProcessor viewProcessor = viewProcessors.get(0);
    final MarketDataSnapshotter marketDataSnapshotter = viewProcessor.getMarketDataSnapshotter();
   
    Set<ConfigDocument> viewDefinitions = Sets.newHashSet();
   
    for (final ConfigMaster configMaster : configMasters) {
      final ConfigSearchRequest<ViewDefinition> request = new ConfigSearchRequest<ViewDefinition>(ViewDefinition.class);
      request.setName(viewDefinitionName);
      Iterables.addAll(viewDefinitions, ConfigSearchIterator.iterable(configMaster, request));
    }
   
    if (viewDefinitions.isEmpty()) {
      endWithError("Unable to resolve any view definitions with name '%s'", viewDefinitionName);
    }
   
    if (viewDefinitions.size() > 1) {
      endWithError("Multiple view definitions resolved when searching for string '%s': %s", viewDefinitionName, viewDefinitions);
    }
    ConfigItem<?> value = Iterables.get(viewDefinitions, 0).getValue();
    StructuredMarketDataSnapshot snapshot = makeSnapshot(marketDataSnapshotter, viewProcessor, (ViewDefinition) value.getValue(), viewExecutionOptions);
   
    final ManageableMarketDataSnapshot manageableMarketDataSnapshot = new ManageableMarketDataSnapshot(snapshot);
    manageableMarketDataSnapshot.setName(snapshot.getBasisViewName() + "/" + valuationInstant);
    marketDataSnapshotMaster.add(new MarketDataSnapshotDocument(manageableMarketDataSnapshot));
  }
View Full Code Here

  private static SnapshotReader constructSnapshotReader(String filename) {
    return new FileSnapshotReader(filename);
  }

  private static SnapshotWriter constructSnapshotWriter() {
    MarketDataSnapshotMaster marketDataSnapshotMaster = s_context.getMarketDataSnapshotMaster();
    if (marketDataSnapshotMaster == null) {
      s_logger.warn("No market data snapshot masters found at {}", s_context);

    }
    return new MasterSnapshotWriter(marketDataSnapshotMaster);
View Full Code Here

  private boolean _publishRest = true;


  @Override
  public void init(final ComponentRepository repo, final LinkedHashMap<String, String> configuration) {
    final MarketDataSnapshotMaster master = new InMemorySnapshotMaster();
    final ComponentInfo info = new ComponentInfo(MarketDataSnapshotMaster.class, getClassifier());
    info.addAttribute(ComponentInfoAttributes.LEVEL, 1);
    info.addAttribute(ComponentInfoAttributes.REMOTE_CLIENT_JAVA, RemoteMarketDataSnapshotMaster.class);
    info.addAttribute(ComponentInfoAttributes.UNIQUE_ID_SCHEME, InMemorySnapshotMaster.DEFAULT_OID_SCHEME);
    repo.registerComponent(info, master);
View Full Code Here

TOP

Related Classes of com.opengamma.master.marketdatasnapshot.MarketDataSnapshotMaster

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.