Package com.opengamma.engine.depgraph

Examples of com.opengamma.engine.depgraph.DependencyNode


    assertFalse(ak.equals(bk));
    assertFalse(bk.equals(ak));
  }

  public void testDependencyNodeKey_outputs() {
    final DependencyNode a = new DependencyNode(new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "A")));
    a.setFunction(new MockFunction("Foo", new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "A"))));
    a.addInputValue(new ValueSpecification("1", ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get()));
    a.addInputValue(new ValueSpecification("2", ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get()));
    a.addOutputValue(new ValueSpecification("1", ComputationTargetSpecification.of(UniqueId.of("Test", "A")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo").get()));
    a.addOutputValue(new ValueSpecification("2", ComputationTargetSpecification.of(UniqueId.of("Test", "A")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo").get()));
    final DependencyNode b = new DependencyNode(new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "A")));
    b.setFunction(new MockFunction("Foo", new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "A"))));
    b.addInputValue(new ValueSpecification("1", ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get()));
    b.addInputValue(new ValueSpecification("2", ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get()));
    b.addOutputValue(new ValueSpecification("1", ComputationTargetSpecification.of(UniqueId.of("Test", "A")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo").get()));
    final DependencyNodeKey ak = new DependencyNodeKey(a);
    final DependencyNodeKey bk = new DependencyNodeKey(b);
    assertFalse(ak.equals(bk));
    assertFalse(bk.equals(ak));
  }
View Full Code Here


  private DependencyGraph createDependencyGraph() {
    final DependencyGraph graph = new DependencyGraph("Default");
    final DependencyNode[] nodes = new DependencyNode[10];
    for (int i = 0; i < nodes.length; i++) {
      final DependencyNode node = new DependencyNode(new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "X")));
      node.setFunction(new MockFunction("Foo" + i, new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "X"))));
      node.addOutputValue(new ValueSpecification(Integer.toString(i), ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo" + i).get()));
      if (i > 0) {
        node.addInputNode(nodes[i - 1]);
        node.addInputValue(new ValueSpecification(Integer.toString(i - 1), ComputationTargetSpecification.of(UniqueId.of("Test", "X")),
            ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo" + (i - 1)).get()));
      }
      graph.addDependencyNode(node);
      nodes[i] = node;
    }
View Full Code Here

    assertFalse(bk.equals(ak));
  }

  public void testDependencyGraphKey_node() {
    final DependencyGraph a = createDependencyGraph();
    final DependencyNode n = new DependencyNode(new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "A")));
    n.setFunction(new MockFunction("Foo", new ComputationTarget(ComputationTargetType.PRIMITIVE, UniqueId.of("Test", "A"))));
    n.addInputValue(new ValueSpecification("1", ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get()));
    n.addInputValue(new ValueSpecification("2", ComputationTargetSpecification.of(UniqueId.of("Test", "X")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Bar").get()));
    n.addOutputValue(new ValueSpecification("1", ComputationTargetSpecification.of(UniqueId.of("Test", "A")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo").get()));
    n.addOutputValue(new ValueSpecification("2", ComputationTargetSpecification.of(UniqueId.of("Test", "A")), ValueProperties.with(ValuePropertyNames.FUNCTION, "Foo").get()));
    a.addDependencyNode(n);
    final DependencyGraph b = createDependencyGraph();
    final DependencyGraphKey ak = new DependencyGraphKey(a, 0);
    final DependencyGraphKey bk = new DependencyGraphKey(b, 0);
    assertFalse(ak.equals(bk));
View Full Code Here

        UniqueId uniqueId;
        if (node.getComputationTarget().getType() == ComputationTargetType.SECURITY) {
          uniqueId = node.getComputationTarget().getUniqueId();
        } else if (node.getComputationTarget().getType() == ComputationTargetType.POSITION) {
          // execute positions with underlying securities
          final DependencyNode securityNode = getSecurityNode(node);
          uniqueId = securityNode.getComputationTarget().getUniqueId();
        } else {
          throw new RuntimeException("Should not get here");
        }
        Collection<DependencyNode> nodeCollection = target2SecurityAndPositionNodes.get(uniqueId);
        if (nodeCollection == null) {
View Full Code Here

        }
        maxPass = Math.max(maxPass, pass);
      }
      return maxPass;
    } else if (node.getComputationTarget().getType().isTargetType(ComputationTargetType.POSITION)) {
      final DependencyNode securityNode = getSecurityNode(node);
      return determinePassNumber(securityNode);
    } else {
      throw new IllegalArgumentException("Unexpected node type " + node);
    }
  }
View Full Code Here

      throw new IllegalArgumentException("Please pass in a POSITION node");
    }
    if (positionNode.getInputNodes().size() != 1) {
      throw new IllegalArgumentException("A POSITION node should only depend on its SECURITY");
    }
    final DependencyNode securityNode = positionNode.getInputNodes().iterator().next();
    if (!securityNode.getComputationTarget().getType().isTargetType(ComputationTargetType.SECURITY)) {
      throw new IllegalArgumentException("A POSITION node should only depend on its SECURITY");
    }
    return securityNode;
  }
View Full Code Here

    while (jobItemItr.hasNext()) {
      assert jobResultItr.hasNext();
      final CalculationJobItem jobItem = jobItemItr.next();
      final CalculationJobResultItem jobResultItem = jobResultItr.next();
      // Mark the node that corresponds to this item
      final DependencyNode node = graph.getNodeProducing(jobItem.getOutputs()[0]);
      if (jobResultItem.isFailed()) {
        getCycle().markFailed(node);
      } else {
        getCycle().markExecuted(node);
      }
      // Process the streamed result fragment
      final ExecutionLogMode executionLogMode = logModes.getLogMode(node);
      final AggregatedExecutionLog aggregatedExecutionLog;
      if (executionLogMode == ExecutionLogMode.FULL) {
        final ExecutionLog log = jobResultItem.getExecutionLog();
        MutableExecutionLog logCopy = null;
        final Set<AggregatedExecutionLog> inputLogs = new LinkedHashSet<AggregatedExecutionLog>();
        Set<ValueSpecification> missing = jobResultItem.getMissingInputs();
        if (!missing.isEmpty()) {
          if (logCopy == null) {
            logCopy = new MutableExecutionLog(log);
          }
          logCopy.add(new SimpleLogEvent(log.hasException() ? LogLevel.WARN : LogLevel.INFO, toString("Missing input", missing)));
        }
        missing = jobResultItem.getMissingOutputs();
        if (!missing.isEmpty()) {
          if (logCopy == null) {
            logCopy = new MutableExecutionLog(log);
          }
          logCopy.add(new SimpleLogEvent(LogLevel.WARN, toString("Failed to produce output", missing)));
        }
        for (final ValueSpecification inputValueSpec : node.getInputValues()) {
          final DependencyNodeJobExecutionResult nodeResult = jobExecutionResultCache.get(inputValueSpec);
          if (nodeResult == null) {
            // Market data
            continue;
          }
          inputLogs.add(nodeResult.getAggregatedExecutionLog());
        }
        aggregatedExecutionLog = DefaultAggregatedExecutionLog.fullLogMode(node, (logCopy != null) ? logCopy : log, inputLogs);
      } else {
        EnumSet<LogLevel> logs = jobResultItem.getExecutionLog().getLogLevels();
        boolean copied = false;
        for (final ValueSpecification inputValueSpec : node.getInputValues()) {
          final DependencyNodeJobExecutionResult nodeResult = jobExecutionResultCache.get(inputValueSpec);
          if (nodeResult == null) {
            // Market data
            continue;
          }
          if (logs.containsAll(nodeResult.getAggregatedExecutionLog().getLogLevels())) {
            continue;
          }
          if (!copied) {
            copied = true;
            logs = EnumSet.copyOf(logs);
          }
          logs.addAll(nodeResult.getAggregatedExecutionLog().getLogLevels());
        }
        aggregatedExecutionLog = DefaultAggregatedExecutionLog.indicatorLogMode(logs);
      }
      final DependencyNodeJobExecutionResult jobExecutionResult = new DependencyNodeJobExecutionResult(computeNodeId, jobResultItem, aggregatedExecutionLog);
      node.gatherTerminalOutputValues(terminalOutputs);
      for (ValueSpecification output : node.getOutputValues()) {
        jobExecutionResultCache.put(output, jobExecutionResult);
      }
    }
    _issueFragmentResults |= !terminalOutputs.isEmpty();
  }
View Full Code Here

    ArgumentChecker.notNull(dependencyGraph, "dependencyGraph");
    final Collection<ValueSpecification> marketDataEntries = dependencyGraph.getAllRequiredMarketData();
    final Map<ValueSpecification, Collection<ValueSpecification>> result = Maps.newHashMapWithExpectedSize(marketDataEntries.size());
    final Set<ValueSpecification> terminalOutputs = dependencyGraph.getTerminalOutputSpecifications();
    for (ValueSpecification marketData : marketDataEntries) {
      final DependencyNode marketDataNode = dependencyGraph.getNodeProducing(marketData);
      Collection<ValueSpecification> aliases = null;
      Collection<DependencyNode> aliasNodes = marketDataNode.getDependentNodes();
      boolean usedDirectly = terminalOutputs.contains(marketData);
      for (DependencyNode aliasNode : aliasNodes) {
        if (aliasNode.getFunction().getFunction() instanceof MarketDataAliasingFunction) {
          if (aliases == null) {
            aliases = new ArrayList<>(aliasNodes.size());
View Full Code Here

            replacements.add(newTarget);
          }
        }
        Iterator<Object> itrReplacements = replacements.iterator();
        while (itrReplacements.hasNext()) {
          final DependencyNode node = (DependencyNode) itrReplacements.next();
          final ComputationTargetSpecification newTarget = (ComputationTargetSpecification) itrReplacements.next();
          s_logger.debug("Rewriting {} to {}", node, newTarget);
          previousGraph.replaceNode(node, newTarget);
        }
        // Rewrite the original value requirements that might have referenced the original nodes
View Full Code Here

    for (ValueSpecification marketData : graph.getAllRequiredMarketData()) {
      if (visit.isFull()) {
        slaveJobs.execute(visit);
        visit = filter.visit(jobSize);
      }
      final DependencyNode node = graph.getNodeProducing(marketData);
      visit.add(marketData, node);
    }
    visit.run();
    try {
      slaveJobs.join();
View Full Code Here

TOP

Related Classes of com.opengamma.engine.depgraph.DependencyNode

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.