Пример #1
0
  /**
   * Checks if a FlowFile is known in this session.
   *
   * @param flowFile the FlowFile to check
   * @return <code>true</code> if the FlowFile is known in this session, <code>false</code>
   *     otherwise.
   */
  boolean isFlowFileKnown(final FlowFile flowFile) {
    final FlowFile curFlowFile = currentVersions.get(flowFile.getId());
    if (curFlowFile == null) {
      return false;
    }

    final String curUuid = curFlowFile.getAttribute(CoreAttributes.UUID.key());
    final String providedUuid = curFlowFile.getAttribute(CoreAttributes.UUID.key());
    if (!curUuid.equals(providedUuid)) {
      return false;
    }

    return true;
  }
Пример #2
0
  /**
   * Inherits the attributes from the given source flow files into the destination flow file. The
   * UUIDs of the sources becomes the parent UUIDs of the destination flow file. Only attributes
   * which is common to all source items is copied into this flow files attributes. Any previously
   * established parent UUIDs will be replaced by the UUIDs of the sources. It will capture the uuid
   * of a certain number of source objects and may not capture all of them. How many it will capture
   * is unspecified.
   *
   * @param sources to inherit common attributes from
   */
  private FlowFile inheritAttributes(
      final Collection<FlowFile> sources, final FlowFile destination) {
    final StringBuilder parentUuidBuilder = new StringBuilder();
    int uuidsCaptured = 0;
    for (final FlowFile source : sources) {
      if (source == destination) {
        continue; // don't want to capture parent uuid of this.  Something can't be a child of
                  // itself
      }
      final String sourceUuid = source.getAttribute(CoreAttributes.UUID.key());
      if (sourceUuid != null && !sourceUuid.trim().isEmpty()) {
        uuidsCaptured++;
        if (parentUuidBuilder.length() > 0) {
          parentUuidBuilder.append(",");
        }
        parentUuidBuilder.append(sourceUuid);
      }

      if (uuidsCaptured > 100) {
        break;
      }
    }

    final FlowFile updated = putAllAttributes(destination, intersectAttributes(sources));
    getProvenanceReporter().join(sources, updated);
    return updated;
  }
 @Override
 public String toString() {
   final ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
   builder.append("uuid", getAttribute(CoreAttributes.UUID.key()));
   builder.append("claim", claim == null ? "" : claim.toString());
   builder.append("offset", claimOffset);
   builder.append("name", getAttribute(CoreAttributes.FILENAME.key())).append("size", size);
   return builder.toString();
 }