Package com.opengamma.engine.view.compilation

Examples of com.opengamma.engine.view.compilation.CompiledViewDefinitionWithGraphs


  }

  @Override
  public CompiledViewDefinitionWithGraphs getCompiledViewDefinitionWithGraphs(ViewExecutionCacheKey key) {
    CompiledViewDefinitionWithGraphs graphs = _compiledViewDefinitionsFrontCache.get(key);
    if (graphs != null) {
      s_logger.debug("Front cache hit CompiledViewDefinitionWithGraphs for {}", key);
      return graphs;
    }
    final Element element = _compiledViewDefinitions.get(key);
    if (element != null) {
      s_logger.debug("EHCache hit CompiledViewDefinitionWithGraphs for {}", key);
      graphs = ((CompiledViewDefinitionWithGraphsHolder) element.getObjectValue()).get();
      final CompiledViewDefinitionWithGraphs existing = _compiledViewDefinitionsFrontCache.putIfAbsent(key, graphs);
      if (existing != null) {
        graphs = existing;
      }
    } else {
      s_logger.debug("EHCache miss CompiledViewDefinitionWithGraphs for {}", key);
View Full Code Here


    return graphs;
  }

  @Override
  public void setCompiledViewDefinitionWithGraphs(ViewExecutionCacheKey key, CompiledViewDefinitionWithGraphs viewDefinition) {
    CompiledViewDefinitionWithGraphs existing = _compiledViewDefinitionsFrontCache.put(key, viewDefinition);
    if (existing != null) {
      if (existing == viewDefinition) {
        return;
      }
    }
View Full Code Here

    return new EHCacheViewExecutionCache(_cacheManager, configSource, functions);
  }

  public void testCompiledViewDefinitionWithGraphs_serialization() throws Exception {
    final EHCacheViewExecutionCache cache = createCache();
    final CompiledViewDefinitionWithGraphs object = createCompiledViewDefinitionWithGraphs();
    final CompiledViewDefinitionWithGraphsHolder holder = cache.new CompiledViewDefinitionWithGraphsHolder(object);
    assertSame(holder.get(), object);
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(holder);
    final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    final ObjectInputStream ois = new ObjectInputStream(bais);
    final Object newHolder = ois.readObject();
    assertEquals(newHolder.getClass(), CompiledViewDefinitionWithGraphsHolder.class);
    final CompiledViewDefinitionWithGraphs newObject = ((CompiledViewDefinitionWithGraphsHolder) newHolder).get();
    assertEquals(newObject.getCompiledCalculationConfigurations(), object.getCompiledCalculationConfigurations());
    assertEquals(newObject.getComputationTargets(), object.getComputationTargets());
    assertEquals(newObject.getMarketDataRequirements(), object.getMarketDataRequirements());
    assertEquals(newObject.getPortfolio(), object.getPortfolio());
    assertEquals(newObject.getResolvedIdentifiers(), object.getResolvedIdentifiers());
    assertEquals(newObject.getResolverVersionCorrection(), object.getResolverVersionCorrection());
  }
View Full Code Here

    assertEquals(newObject.getResolverVersionCorrection(), object.getResolverVersionCorrection());
  }

  public void testCompiledViewDefinitionWithGraphs_caching() {
    final EHCacheViewExecutionCache cache = createCache();
    final CompiledViewDefinitionWithGraphs object = createCompiledViewDefinitionWithGraphs();
    final ViewExecutionCacheKey key = new ViewExecutionCacheKey(UniqueId.of("Key", "1"), new Serializable[] {"Foo" });
    // Miss
    assertNull(cache.getCompiledViewDefinitionWithGraphs(key));
    // Store
    cache.setCompiledViewDefinitionWithGraphs(key, object);
    // Hit the front cache
    assertSame(cache.getCompiledViewDefinitionWithGraphs(key), object);
    // Hit the EH Cache
    cache.clearFrontCache();
    final CompiledViewDefinitionWithGraphs cachedObject = cache.getCompiledViewDefinitionWithGraphs(key);
    assertNotNull(cachedObject);
    // Hit the front cache
    assertSame(cache.getCompiledViewDefinitionWithGraphs(key), cachedObject);
    // Replacement
    final CompiledViewDefinitionWithGraphs newObject = createCompiledViewDefinitionWithGraphs();
    assertNotSame(newObject, object);
    assertNotSame(newObject, cachedObject);
    cache.setCompiledViewDefinitionWithGraphs(key, newObject);
    assertSame(cache.getCompiledViewDefinitionWithGraphs(key), newObject);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.engine.view.compilation.CompiledViewDefinitionWithGraphs

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.