This method gets the source information associated with the supplied
traces.

@param tenantId The tenant id
@param items The trace instances
@return The source info
@throws RetryAttemptException Failed to initialise source information
14805
public static List<SourceInfo> getSourceInfo(String tenantId, List<Trace> items)
                                throws RetryAttemptException {
        List<SourceInfo> sourceInfoList = new ArrayList<SourceInfo>();

        int curpos=0;

        // This method initialises the deriver with a list of trace fragments
        // that will need to be referenced when correlating a consumer with a producer
        for (int i = 0; i < items.size(); i++) {

            // Need to check for Producer nodes
            Trace trace = items.get(i);
            StringBuffer nodeId = new StringBuffer(trace.getFragmentId());

            for (int j = 0; j < trace.getNodes().size(); j++) {
                Node node = trace.getNodes().get(j);
                int len = nodeId.length();

                initialiseSourceInfo(sourceInfoList, tenantId, trace, nodeId, j,
                        node);

                // Trim the node id for use with next node
                nodeId.delete(len, nodeId.length());
            }

            // Apply origin information to the source info
            EndpointRef ep = EndpointUtil.getSourceEndpoint(trace);
            for (int j=curpos; j < sourceInfoList.size(); j++) {
                SourceInfo si = sourceInfoList.get(j);
                si.setEndpoint(ep);
            }

            curpos = sourceInfoList.size();
        }

        return sourceInfoList;
    }
280206
protected ItemData getCachedCleanItemData(String identifier) throws RepositoryException
   {
      ItemData data = getCachedItemData(identifier);

      if (data != null && !data.isNode() && !(data instanceof NullItemData) && forceLoad((PropertyData)data))
      {
         cache.remove(data.getIdentifier(), data);
         data = null;
      }
      return data;
   }
1060774
@Override
    public Set<Span> getChildren(String tenant, String id) {
        if (id == null) {
            throw new NullPointerException("Id should not be null!");
        }

        Set<Span> children = childrenCache.get(id);

        return children == null ? null : Collections.unmodifiableSet(children);
    }
341685
@Override
    public ItemProcessor getProcessor(Item item) {
        for (Map.Entry<String, ItemProcessor> mapping : patternToProcessorMappings.entrySet()) {
            if (item.getUrl().matches(mapping.getKey())) {
                return mapping.getValue();
            }
        }

        return null;
    }
959873
private InputStream getSourceContent(final String spaceId,
                                         final String contentId)
        throws TaskExecutionFailedException {
        try {
            return new Retrier().execute(new Retriable() {
                @Override
                public InputStream retry() throws Exception {
                    // Retrieve from source
                    return sourceStore.getContent(spaceId, contentId).getContentStream();
                }
            });
        } catch (Exception e) {
            String msg = "Error attempting to get source content: " + e.getMessage();
            throw new DuplicationTaskExecutionFailedException(buildFailureMessage(msg), e);
        }
    }
1262126
public List<ItemReference> getItemReference(int itemId) {
		return getResourceFactory().getApiResource(
				"/item/" + itemId + "/reference/").get(
				new GenericType<List<ItemReference>>() {
				});
	}
582411
@Override
    public java.util.List<DataSlice> getData() throws PersistentDataEncodingException, SevereMessageStoreException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "getData");

        java.util.List<DataSlice> retval = null;

        synchronized (this)
        {
            if (_link != null)
            {
                retval = _link.getMemberData();
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "getData", "return=" + retval);
        return retval;
    }
1328122
@Override
    protected RecoverableUnitSection recordOtherResourceTypes(JTAResource resource) throws SystemException
    {
        final boolean traceOn = TraceComponent.isAnyTracingEnabled();

        if (traceOn && tc.isEntryEnabled())
            Tr.entry(tc, "recordOtherResourceTypes", new Object[] { resource, this });

        RecoverableUnitSection rus = null;

        if (resource instanceof WSATParticipantWrapper)
        {
            if (_wsatAsyncSection == null)
            {
                _wsatAsyncSection = createLogSection(TransactionImpl.WSAT_ASYNC_RESOURCE_SECTION, _logUnit);
            }
            rus = _wsatAsyncSection;
        }

        if (traceOn && tc.isEntryEnabled())
            Tr.exit(tc, "recordOtherResourceTypes", rus);
        return rus;
    }
203403
@Override
    public ItemStream findByStreamId(long itemStreamId) throws SevereMessageStoreException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "findByIdInRoot", Long.valueOf(itemStreamId));

        ItemStream item = (ItemStream) _findById(itemStreamId);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "findByIdInRoot", item);
        return item;
    }
642013
protected void submitTraces() {
        if (!traces.isEmpty()) {
            // Locally store list and create new list for subsequent traces
            List<Trace> toSend = traces;
            traces = new ArrayList<>(batchSize + 1);

            executor.execute(new Runnable() {
                @Override
                public void run() {
                    try {
                        tracePublisher.publish(tenantId, toSend);
                    } catch (Exception e) {
                        // TODO: Retain for retry
                        log.log(Level.SEVERE, "Failed to publish traces", e);
                    }
                }
            });
        }
    }
488979
protected List<ItemState> reindexSameNameSiblings(NodeData cause, ItemDataConsumer dataManager)
      throws RepositoryException
   {
      List<ItemState> changes = new ArrayList<ItemState>();

      NodeData parentNodeData = (NodeData)dataManager.getItemData(cause.getParentIdentifier());

      NodeData nextSibling =
         (NodeData)dataManager.getItemData(parentNodeData, new QPathEntry(cause.getQPath().getName(), cause.getQPath()
            .getIndex() + 1), ItemType.NODE);

      String reindexedId = null;
      // repeat till next sibling exists and it's not a caused Node (deleted or moved to) or just
      // reindexed
      while (nextSibling != null && !nextSibling.getIdentifier().equals(cause.getIdentifier())
         && !nextSibling.getIdentifier().equals(reindexedId))
      {
         QPath siblingOldPath =
            QPath.makeChildPath(nextSibling.getQPath().makeParentPath(), nextSibling.getQPath().getName(), nextSibling
               .getQPath().getIndex());

         // update with new index
         QPath siblingPath =
            QPath.makeChildPath(nextSibling.getQPath().makeParentPath(), nextSibling.getQPath().getName(), nextSibling
               .getQPath().getIndex() - 1);

         NodeData reindexed =
            new TransientNodeData(siblingPath, nextSibling.getIdentifier(), nextSibling.getPersistedVersion(),
               nextSibling.getPrimaryTypeName(), nextSibling.getMixinTypeNames(), nextSibling.getOrderNumber(),
               nextSibling.getParentIdentifier(), nextSibling.getACL());

         reindexedId = reindexed.getIdentifier();

         ItemState reindexedState = ItemState.createUpdatedState(reindexed);
         changes.add(reindexedState);

         itemsPool.reload(reindexed);

         reloadDescendants(siblingOldPath, siblingPath);

         // next...
         nextSibling =
            (NodeData)dataManager.getItemData(parentNodeData, new QPathEntry(nextSibling.getQPath().getName(),
               nextSibling.getQPath().getIndex() + 1), ItemType.NODE);
      }

      return changes;
   }
1304767
@Nullable
  public List<Span> getTrace(String traceId) {
    try {
      return storage.spanStore().getTrace(traceId).execute();
    } catch (IOException e) {
      throw Platform.get().assertionError("I/O exception in in-memory storage", e);
    }
  }
1271303
public static  <T> T executeWithRetry(Supplier<T> supplier) {
		boolean retry = false;
		int retries = 0;

		do {

			try {

				return supplier.get();

			} catch (RetryException ex) {

				logger.info("Caught RetryException in executeWithRetry. Waiting " + (retries > 0 ? retryDelay : firstRetryDelay) + " ms and then performing retry #" + retries);

				try {

					Thread.sleep(retries > 0 ? retryDelay : firstRetryDelay);
				} catch (InterruptedException iex) {

					break;
				}

				retry = true;
				retries ++;

			}

		} while (retry && retries < maxRetries);

		throw new RetryException("executeWithRetry exceeded maximum amount of retries.");
	}
836453
@Override
    public void onWriteError(Exception exception, List<? extends ContentProperties> items) {
        log.error("firing onWriteError: currrently not handling: exception message=" + exception.getMessage(),
                  exception);
        for (ContentProperties props : items) {
            addError("item failed: " + props + "; exception=" + exception.getMessage());
        }
    }
94478
@Override
    public SourceProtocolItemStream getSourceProtocolItemStream()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "getSourceProtocolItemStream");

        SourceProtocolItemStream sourceProtocolItemStream = _targetDestinationHandler.getSourceProtocolItemStream();

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "getSourceProtocolItemStream", sourceProtocolItemStream);

        return sourceProtocolItemStream;
    }
610371
public String getCauseStackTraceAsString(final List<String> packages, final String suffix) {
        return getCauseStackTraceAsString(packages, PlainTextRenderer.getInstance(), suffix);
    }
1207571
def CollectionItemToClientPath(item, client_id=None):
  """"""
  if isinstance(item, rdf_flows.GrrMessage):
    client_id = item.source
    item = item.payload
  elif isinstance(item, rdf_flow_objects.FlowResult):
    client_id = item.client_id
    item = item.payload

  if client_id is None:
    raise ValueError("Could not determine client_id.")
  elif isinstance(client_id, rdfvalue.RDFURN):
    client_id = client_id.Basename()

  if isinstance(item, rdf_client_fs.StatEntry):
    return db.ClientPath.FromPathSpec(client_id, item.pathspec)
  elif isinstance(item, rdf_file_finder.FileFinderResult):
    return db.ClientPath.FromPathSpec(client_id, item.stat_entry.pathspec)
  elif isinstance(item, collectors.ArtifactFilesDownloaderResult):
    if item.HasField("downloaded_file"):
      return db.ClientPath.FromPathSpec(client_id,
                                        item.downloaded_file.pathspec)

  raise ItemNotExportableError(item)