public void removeProcessFeedEdge(
      Vertex processVertex, String feedName, RelationshipLabel edgeLabel) {
    Vertex feedVertex = findVertex(feedName, RelationshipType.FEED_ENTITY);
    if (feedVertex == null) {
      LOG.error("Illegal State: Feed entity vertex must exist for {}", feedName);
      throw new IllegalStateException("Feed entity vertex must exist: " + feedName);
    }

    if (edgeLabel == RelationshipLabel.FEED_PROCESS_EDGE) {
      removeEdge(feedVertex, processVertex, edgeLabel.getName());
    } else {
      removeEdge(processVertex, feedVertex, edgeLabel.getName());
    }
  }
  private void updateColoEdge(
      String oldColo, String newColo, Vertex clusterEntityVertex, RelationshipLabel relLabel) {
    if (areSame(oldColo, newColo)) {
      return;
    }

    Vertex oldColoVertex = findVertex(oldColo, RelationshipType.COLO);
    if (oldColoVertex != null) {
      removeEdge(clusterEntityVertex, oldColoVertex, relLabel.getName());
    }
    Vertex newColoVertex = findVertex(newColo, RelationshipType.COLO);
    if (newColoVertex == null) {
      newColoVertex = addVertex(newColo, RelationshipType.COLO);
    }

    addEdge(clusterEntityVertex, newColoVertex, relLabel.getName());
  }
  public void addRelationToDatasource(
      Vertex fromVertex, String datasourceName, RelationshipLabel edgeLabel) {
    Vertex clusterVertex = findVertex(datasourceName, RelationshipType.DATASOURCE_ENTITY);
    if (clusterVertex == null) { // cluster must exist before adding other entities
      LOG.error("Illegal State: Datasource entity vertex must exist for {}", datasourceName);
      throw new IllegalStateException("Datasource entity vertex must exist: " + datasourceName);
    }

    addEdge(fromVertex, clusterVertex, edgeLabel.getName());
  }
  public void addRelationToCluster(
      Vertex fromVertex, String clusterName, RelationshipLabel edgeLabel) {
    Vertex clusterVertex = findVertex(clusterName, RelationshipType.CLUSTER_ENTITY);
    if (clusterVertex == null) { // cluster must exist before adding other entities
      LOG.error("Illegal State: Cluster entity vertex must exist for {}", clusterName);
      throw new IllegalStateException("Cluster entity vertex must exist: " + clusterName);
    }

    addEdge(fromVertex, clusterVertex, edgeLabel.getName());
  }
  private void removeGroupsOrPipelines(
      String groupsOrPipelines, Vertex entityVertex, RelationshipLabel edgeLabel) {
    if (StringUtils.isEmpty(groupsOrPipelines)) {
      return;
    }

    String[] oldGroupOrPipelinesTags = groupsOrPipelines.split(",");
    for (String groupOrPipelineTag : oldGroupOrPipelinesTags) {
      removeEdge(entityVertex, groupOrPipelineTag, edgeLabel.getName());
    }
  }
  public void addInstanceToEntity(
      Vertex instanceVertex,
      String entityName,
      RelationshipType entityType,
      RelationshipLabel edgeLabel,
      String timestamp) {
    Vertex entityVertex = findVertex(entityName, entityType);
    LOG.info("Vertex exists? name={}, type={}, v={}", entityName, entityType, entityVertex);
    if (entityVertex == null) {
      // todo - throw new IllegalStateException(entityType + " entity vertex must exist " +
      // entityName);
      LOG.error("Illegal State: {} vertex must exist for {}", entityType, entityName);
      return;
    }

    addEdge(instanceVertex, entityVertex, edgeLabel.getName(), timestamp);
  }
  private void verifyLineageGraphForReplicationOrEviction(
      String feedName,
      String feedInstanceDataPath,
      WorkflowExecutionContext context,
      RelationshipLabel edgeLabel)
      throws Exception {
    String feedInstanceName =
        InstanceRelationshipGraphBuilder.getFeedInstanceName(
            feedName,
            context.getClusterName(),
            feedInstanceDataPath,
            context.getNominalTimeAsISO8601());
    Vertex feedVertex = getEntityVertex(feedInstanceName, RelationshipType.FEED_INSTANCE);

    Edge edge = feedVertex.getEdges(Direction.OUT, edgeLabel.getName()).iterator().next();
    Assert.assertNotNull(edge);
    Assert.assertEquals(
        edge.getProperty(RelationshipProperty.TIMESTAMP.getName()),
        context.getTimeStampAsISO8601());

    Vertex clusterVertex = edge.getVertex(Direction.IN);
    Assert.assertEquals(
        clusterVertex.getProperty(RelationshipProperty.NAME.getName()), context.getClusterName());
  }
 public void addColoRelation(String colo, Vertex fromVertex, RelationshipLabel relLabel) {
   Vertex coloVertex = addVertex(colo, RelationshipType.COLO);
   addEdge(fromVertex, coloVertex, relLabel.getName());
 }