The collection action. This is the task which will run on a schedule to
gather data from the feature content source system and update the
repository with retrieved data.
426775
@Override
    public void collect(FeatureCollector collector) {
        LOGGER.info("Starting Feature collection...");

        try {
            TeamDataClient teamData = new TeamDataClient(this.featureCollectorRepository,
                    this.featureSettings, this.teamRepository, this.v1Connection);

            teamData.updateTeamInformation();

            ProjectDataClient projectData = new ProjectDataClient(this.featureSettings,
                    this.projectRepository, this.featureCollectorRepository, this.v1Connection);
            projectData.updateProjectInformation();

            StoryDataClient storyData = new StoryDataClient(this.featureSettings,
                    this.featureRepository, this.featureCollectorRepository, this.v1Connection);
            storyData.updateStoryInformation();
        } catch (HygieiaException he) {
            LOGGER.error("Error in collecting Version One Data: [" + he.getErrorCode() + "] "
                    + he.getMessage());
        }

        LOGGER.info("Feature Data Collection Finished");

    }
535976
def get_action(self, curr_info: BrainInfo) -> ActionInfo:
        
        self.trainer_metrics.start_experience_collection_timer()
        action = self.policy.get_action(curr_info)
        self.trainer_metrics.end_experience_collection_timer()
        return action
1141491
private Void indexUpdate(Collection<Consumer<Void>> state, Consumer<Void> indexAction) {
        if (async) {
            state.add(indexAction);
        } else {
            indexAction.accept(null);
        }
        return null;
    }
601897
@Override
    public void collect(FeatureCollector collector) {
        logBanner(featureSettings.getJiraBaseUrl());

        String proxyUrl = featureSettings.getJiraProxyUrl();
        String proxyPort = featureSettings.getJiraProxyPort();

        if (!StringUtils.isEmpty(proxyUrl) && !StringUtils.isEmpty(proxyPort)) {
            System.setProperty("http.proxyHost", proxyUrl);
            System.setProperty("https.proxyHost", proxyUrl);
            System.setProperty("http.proxyPort", proxyPort);
            System.setProperty("https.proxyPort", proxyPort);
        }

        try {
            long startTime = System.currentTimeMillis();
            long diff = TimeUnit.MILLISECONDS.toHours(startTime - collector.getLastRefreshTime());
            LOGGER.info("JIRA Collector is set to work in " + collector.getMode() + " mode");
            if (diff > featureSettings.getRefreshTeamAndProjectHours()) {
                LOGGER.info("Hours since last run = " + diff + ". Collector is about to refresh Team/Board information");
                List<Team> teams = updateTeamInformation(collector);
                Set<Scope> scopes = updateProjectInformation(collector);
                if (collector.getLastExecuted() > 0) {
                    if (featureSettings.isCollectorItemOnlyUpdate()) {
                        refreshValidIssues(collector, getBoardList(collector.getId()), getScopeList(collector.getId()));
                    } else {
                        refreshValidIssues(collector, teams, scopes);
                    }
                }

                collector.setLastRefreshTime(System.currentTimeMillis());
                featureCollectorRepository.save(collector);
                LOGGER.info("Collected " + teams.size() + " teams and " + scopes.size() + " projects");
            } else {
                LOGGER.info("Hours since last run = " + diff + ". Collector is only collecting updated/new issues.");
            }
            updateStoryInformation(collector);
            log("Finished", startTime);
        } catch (Exception e) {
            // catch exception here so we don't blow up the collector completely
            LOGGER.error("Failed to collect jira information", e);
        }
    }
490263
protected void updateStoryInformation(FeatureCollector collector) {
        long storyDataStart = System.currentTimeMillis();
        AtomicLong count = new AtomicLong();

        if (Objects.equals(collector.getMode(), JiraMode.Team)) {
            List<Scope> projects = new ArrayList<>(getScopeList(collector.getId()));
            projects.forEach(project -> {
                LOGGER.info("Collecting " + count.incrementAndGet() + " of " + projects.size() + " projects.");

                long lastCollection = System.currentTimeMillis();
                FeatureEpicResult featureEpicResult = jiraClient.getIssues(project);
                List<Feature> features = featureEpicResult.getFeatureList();
                saveFeatures(features, collector);
                updateFeaturesWithLatestEpics(featureEpicResult.getEpicList(), collector);
                log("Story Data Collected since " + LocalDateTime.ofInstant(Instant.ofEpochMilli(project.getLastCollected()), ZoneId.systemDefault()), storyDataStart, features.size());

                project.setLastCollected(lastCollection); //set it after everything is successfully done
                projectRepository.save(project);

            });
        } else {
            List<Team> boards = getBoardList(collector.getId());
            boards.forEach(board -> {
                LOGGER.info("Collecting " + count.incrementAndGet() + " of " + boards.size() + " boards.");
                long lastCollection = System.currentTimeMillis();
                FeatureEpicResult featureEpicResult = jiraClient.getIssues(board);
                List<Feature> features = featureEpicResult.getFeatureList();
                saveFeatures(features, collector);
                updateFeaturesWithLatestEpics(featureEpicResult.getEpicList(), collector);
                log("Story Data Collected since " + LocalDateTime.ofInstant(Instant.ofEpochMilli(board.getLastCollected()), ZoneId.systemDefault()), storyDataStart, features.size());

                board.setLastCollected(lastCollection); //set it after everything is successfully done
                teamRepository.save(board);
                FeatureBoard featureBoard = featureBoardRepository.findFeatureBoard(collector.getId(), board.getTeamId());
                if(featureBoard != null){
                     featureBoard.setLastUpdated(System.currentTimeMillis());
                     featureBoardRepository.save(featureBoard);
                }
            });
        }

    }
761388
def process_actions(action_ids=None):
    
    actions_taken = 0
    action_list = PublishAction.objects.prefetch_related(
        'content_object',
    ).filter(
        scheduled_time__lte=timezone.now(),
    )

    if action_ids is not None:
        action_list = action_list.filter(id__in=action_ids)

    for action in action_list:
        action.process_action()
        action.delete()
        actions_taken += 1

    return actions_taken
861553
public void collect(AWSCloudCollector collector) {
        log("Starting AWS collection...");
        log("Collecting AWS Cloud Data...");

        Map<String, List<CloudInstance>> accountToInstanceMap = collectInstances();

        Map<String, String> instanceToAccountMap = new HashMap<>();
        for (String account : accountToInstanceMap.keySet()) {
            Collection<CloudInstance> instanceList = accountToInstanceMap.get(account);
            for (CloudInstance ci : instanceList) {
                instanceToAccountMap.put(ci.getInstanceId(), account);
            }
        }
        collectVolume(instanceToAccountMap);

        log("Finished Cloud collection.");
    }
296702
function updateCollection(id, collID, collObj) {
  return updateItem(id, item => {
    const pos = item.dataset.findIndex(e => e.collectionID === collID);
    if (_.isFunction(collObj)) {
      collObj(item.dataset[pos]);
    } else {
      item.dataset[pos] = collObj;
    }
  });
}
1352990
def _run(self):
        
        try:
            start_time = time.time()

            # Collect Data
            self.collect()

            end_time = time.time()
            collector_time = int((end_time - start_time) * 1000)

            self.log.debug('Collection took %s ms', collector_time)

            if 'measure_collector_time' in self.config:
                if self.config['measure_collector_time']:
                    metric_name = 'collector_time_ms'
                    metric_value = collector_time
                    self.publish(metric_name, metric_value)
        finally:
            # After collector run, invoke a flush
            # method on each handler.
            for handler in self.handlers:
                handler._flush()
602051
protected void fetchData() throws IOException {
    // if not connected to the collector, wait for a while then try connecting
    if (rpcCollector == null) {
      try {
        Thread.sleep(RECONNECT_PERIOD);
      } catch (InterruptedException e) {
        // do nothing
      }
      connect();
    }
    try {
      clusterUtil = rpcCollector.getClusterUtilization();
      for (JobUtilization job:
        rpcCollector.getAllRunningJobUtilization()) {
        allJobUtil.put(job.getJobId(), job);
      }
      for (TaskTrackerUtilization tt :
        rpcCollector.getAllTaskTrackerUtilization()) {
        allTaskTrackerUtil.put(tt.getHostName(), tt);
      }
    } catch (Exception e) {
        // When the Collector is down, clear the old data
        clusterUtil = null;
        allJobUtil.clear();
        allTaskTrackerUtil.clear();
        LOG.warn("Error obtaining data from Collector.");
    }
  }
1055393
@Override
	public void run() {

		final long currentTime = System.currentTimeMillis();

		synchronized (this.collectedEvents) {

			final Iterator<JobID> it = this.collectedEvents.keySet().iterator();
			while (it.hasNext()) {

				final JobID jobID = it.next();
				final List<AbstractEvent> eventList = this.collectedEvents.get(jobID);
				if (eventList == null) {
					continue;
				}

				final Iterator<AbstractEvent> it2 = eventList.iterator();
				while (it2.hasNext()) {

					final AbstractEvent event = it2.next();
					// If the event is older than TIMERTASKINTERVAL, remove it
					if ((event.getTimestamp() + this.timerTaskInterval) < currentTime) {
						archiveEvent(jobID, event);
						it2.remove();
					}
				}

				if (eventList.isEmpty()) {
					it.remove();
				}
			}
		}

		synchronized (this.recentJobs) {

			final Iterator<Map.Entry<JobID, RecentJobEvent>> it = this.recentJobs.entrySet().iterator();
			while (it.hasNext()) {

				final Map.Entry<JobID, RecentJobEvent> entry = it.next();
				final JobStatus jobStatus = entry.getValue().getJobStatus();

				// Only remove jobs from the list which have stopped running
				if (jobStatus != JobStatus.FINISHED && jobStatus != JobStatus.CANCELED
					&& jobStatus != JobStatus.FAILED) {
					continue;
				}

				// Check time stamp of last job status update
				if ((entry.getValue().getTimestamp() + this.timerTaskInterval) < currentTime) {
					archiveJobevent(entry.getKey(), entry.getValue());
					it.remove();
					synchronized (this.recentManagementGraphs) {
						archiveManagementGraph(entry.getKey(), this.recentManagementGraphs.get(entry.getKey()));
						this.recentManagementGraphs.remove(entry.getValue());
					}
					synchronized (this.recentNetworkTopologies) {
						archiveNetworkTopology(entry.getKey(), this.recentNetworkTopologies.get(entry.getKey()));
						this.recentNetworkTopologies.remove(entry.getValue());
					}
				}
			}
		}
	}
995908
@Trivial
    private void performAction(Runnable action, boolean addToQueue) {
        ExecutorService exec = executorService.getService();

        if (exec == null) {
            // If we can't find the executor service, we have to run it in place.
            action.run();
        } else {
            // If we can find the executor service, we'll add the action to the queue.
            // If the actionFuture is null (no pending actions) and the configFuture is null (no
            // pending configuration updates), we'll submit the actionsRunner to the executor
            // service to drain the queue
            //
            // configFuture is used to avoid bouncing the endpoint multiple times because of a
            // single configuration update.
            //
            // actionFuture is only set to a non-null value by kicking off the executor service here.
            // actionsRunner syncs on actionQueue, so we can't add any new actions while we are
            // draining the queue. When the queue is empty, actionFuture is explicitly set to null.
            //
            // Long story short, it prevents us from kicking off multiple executors which could run in
            // random order.
            if (addToQueue) {
                synchronized (actionQueue) {
                    actionQueue.add(action);
                    if ((actionFuture == null) && (configFuture == null)) {
                        actionFuture = exec.submit(actionsRunner);
                    }
                }
            } else {
                // Schedule immediately
                exec.submit(action);
            }
        }
    }
1000775
public function collectionAction($collection, Request $request = null)
    {
        $action = $this->container->get(CollectionPostArchiveAction::class);

        return $action($this->resolveRequest($request), $collection);
    }
1045608
def _CollectArtifact(self, artifact, apply_parsers):
    """"""
    artifact_result = rdf_artifacts.CollectedArtifact(name=artifact.name)

    if apply_parsers:
      parser_factory = parsers.ArtifactParserFactory(str(artifact.name))
    else:
      parser_factory = None

    for source_result_list in self._ProcessSources(artifact.sources,
                                                   parser_factory):
      for response in source_result_list:
        action_result = rdf_artifacts.ClientActionResult()
        action_result.type = response.__class__.__name__
        action_result.value = response
        artifact_result.action_results.append(action_result)
        self.UpdateKnowledgeBase(response, artifact.provides)

    return artifact_result
1143586
void submit(final LoadAndDisplayImageTask task) {
		taskDistributor.execute(new Runnable() {
			@Override
			public void run() {
				File image = configuration.diskCache.get(task.getLoadingUri());
				boolean isImageCachedOnDisk = image != null && image.exists();
				initExecutorsIfNeed();
				if (isImageCachedOnDisk) {
					taskExecutorForCachedImages.execute(task);
				} else {
					taskExecutor.execute(task);
				}
			}
		});
	}
1257933
def run(self):
        """"""
        while True:
            data = self.queue.get()
            if data is None:
                Logger.get_logger(__name__).info("Stopping collector process ...")
                break

            # updating the report data
            self.store.update(data)
            # writing the report
            generate(self.store, 'html', os.getcwd())
426800
@Override
    public final void run() {
        try {
            registry_.updateCollection();

            final long t0 = System.nanoTime();

            processors_.forEach(p -> {
                try {
                    run_implementation_(p);
                } catch (Exception ex) {
                    logger.log(Level.SEVERE, p.getClass().getName() + " failed to run properly, some or all metrics may be missed this cycle", ex);
                }
            });

            final long t_processor = System.nanoTime();
            registry_.updateProcessorDuration(Duration.millis(TimeUnit.NANOSECONDS.toMillis(t_processor - t0)));
        } catch (Throwable t) {
            /*
             * We catch any and all throwables.
             * If we don't and let an exception or error escape,
             * the scheduled executor service will _silently_ drop our task.
             */
            logger.log(Level.SEVERE, "failed to perform collection", t);
        }
    }