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.
15134
@Override
	public void collect(FeatureCollector collector) {
		logBanner("Starting...");
		Long startTime = System.currentTimeMillis();
		
		Set<Project> projects = featureService.getProjectsToUpdate(collector.getId());
		List<Future<UpdateResult>> updateIssuesFutures = updateIssuesForProjects(collector, projects);
		logResults(updateIssuesFutures, startTime);
	}
286723
def publish_for_collection(self, collection_name):
        
        self.revisions = BaseAsyncMotorDocument("%s_revisions" % collection_name, self.settings)

        changes = yield self.__get_pending_revisions()

        if len(changes) > 0:

            self.logger.info("%s revisions will be actioned" % len(changes))

            for change in changes:
                try:
                    self.logger.info("Applying %s action %s - %s to document: %s/%s" % (change.get("action"), change.get("id"), change.get("meta",{}).get("comment", "No Comment"), change.get("collection"), change.get("master_id")))

                    stack = AsyncSchedulableDocumentRevisionStack(
                        change.get("collection"),
                        self.settings,
                        master_id=change.get("master_id")
                    )

                    revision = yield stack.pop()

                    self.logger.debug(revision)

                except Exception as ex:
                    self.logger.error(ex)
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.");
    }
  }
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);
        }
    }
317280
protected Set<Scope> updateProjectInformation(Collector collector) {
        long projectDataStart = System.currentTimeMillis();
        //Add or update teams that we got from api
        Set<Scope> projects = jiraClient.getProjects();

        projects.forEach(jiraScope -> {
            LOGGER.info(String.format("Adding :%s-%s", jiraScope.getpId(), jiraScope.getName()));
            jiraScope.setCollectorId(collector.getId());
            Scope existing = projectRepository.findByCollectorIdAndPId(collector.getId(), jiraScope.getpId());
            if (existing == null) {
                projectRepository.save(jiraScope);
            } else {
                jiraScope.setId(existing.getId());
                projectRepository.save(jiraScope);
            }
        });
        log("Project Data Collected", projectDataStart, projects.size());

        // Delete the ones that are gone from JIRA
        List<Scope> existingProjects = projectRepository.findByCollectorId(collector.getId());
        Set<String> newProjectIds = projects.stream().map(Scope::getpId).collect(Collectors.toSet());
        Set<Scope> toDelete = existingProjects.stream().filter(e -> !newProjectIds.contains(e.getpId())).collect(Collectors.toSet());
        if (!CollectionUtils.isEmpty(toDelete)) {
            toDelete.forEach(td -> {
                LOGGER.info(String.format("Deleting :%s-%s", td.getpId(), td.getName()));
            });
            projectRepository.delete(toDelete);
            log( "Project Data Collected. Deleted ", projectDataStart, toDelete.size());
        }
        return projects;
    }
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
1125498
protected void performUpdate() {

        // Wrap a try-catch around everything, because an escaping exception would cancel the task from which this is called
        List<CmsWaitHandle> waitHandles = new ArrayList<>();
        try {
            ArrayList<Object> work = new ArrayList<>();
            m_workQueue.drainTo(work);
            Set<CmsUUID> updateIds = new HashSet<CmsUUID>();

            for (Object item : work) {
                if (item instanceof CmsUUID) {
                    updateIds.add((CmsUUID)item);
                } else if (item instanceof CmsWaitHandle) {
                    waitHandles.add((CmsWaitHandle)item);
                }
            }
            CmsADEConfigCacheState oldState = m_state;
            if (!updateIds.isEmpty() || (oldState == null)) {
                try {
                    // Although  the updates are performed in a scheduled task, it is still possible
                    // that the task is scheduled immediately after a configuration update event. So
                    // here we ensure that there is at least a small delay between the event and the
                    // actual update. This is required to prevent problems with other caches.
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    // ignore
                }
                if (updateIds.contains(ID_UPDATE_ALL) || (oldState == null)) {
                    m_state = readCompleteConfiguration();
                } else {
                    boolean updateModules = updateIds.remove(ID_UPDATE_MODULES);
                    boolean updateElementViews = updateIds.remove(ID_UPDATE_ELEMENT_VIEWS);
                    updateIds.remove(ID_UPDATE_FOLDERTYPES); // folder types are always updated when the update set is not empty, so at this point we don't care whether the id for folder type updates actually is in the update set
                    Map<CmsUUID, CmsADEConfigDataInternal> updateMap = Maps.newHashMap();
                    for (CmsUUID structureId : updateIds) {
                        CmsADEConfigDataInternal sitemapConfig = parseSitemapConfiguration(structureId);
                        // sitemapConfig may be null at this point
                        updateMap.put(structureId, sitemapConfig);
                    }
                    List<CmsADEConfigDataInternal> moduleConfigs = null;
                    if (updateModules) {
                        moduleConfigs = loadModuleConfiguration();
                    }
                    Map<CmsUUID, CmsElementView> elementViews = null;
                    if (updateElementViews) {
                        elementViews = loadElementViews();
                    }
                    m_state = oldState.createUpdatedCopy(updateMap, moduleConfigs, elementViews);
                }
            }

        } catch (Exception e) {
            LOG.error("Could not perform configuration cache update: " + e.getMessage(), e);
        } finally {
            for (CmsWaitHandle handle : waitHandles) {
                handle.release();
            }
        }
    }
1029847
protected function updateCollection(){
        $responseBody = $this->Response->getBody();
        if (is_array($responseBody)){
            if (isset($this->model)){
                $modelIdKey = $this->buildModel()->modelIdKey();
                foreach($responseBody as $key => $model){
                    if (isset($model[$modelIdKey])){
                        $this->collection[$model[$modelIdKey]] = $model;
                    } else {
                        $this->collection[] = $model;
                    }
                }
            } else {
                $this->collection = $responseBody;
            }
        }
    }
586304
def collect(self, force=False):
        

        if force or not self.changes:
            self.changes = tuple(self.collect_impl())
        return self.changes
1131847
public void run() {
		
		task.setSetTimerTransactionalAction(null);
		
		if (!canceled) {
			
			TimerTask previousTask = scheduler.getLocalRunningTasksMap().putIfAbsent(task.getData().getTaskID(), task);
			if(previousTask != null) {
				if (logger.isDebugEnabled()) {
					logger.debug("A task with id " + task.getData().getTaskID() + " has already been added to the local tasks, not rescheduling");
				}
			}
			
			final TimerTaskData taskData = task.getData();
			// calculate delay
			long delay = taskData.getStartTime() - System.currentTimeMillis();
			if (delay < 0) {
				delay = 0;
			}
			
			try {
				// schedule runnable
				if (taskData.getPeriod() < 0) {
					if (logger.isDebugEnabled()) {
						logger.debug("Scheduling one-shot timer with id "
								+ task.getData().getTaskID() + ", delay " + delay);
					}
					task.setScheduledFuture(scheduler.getExecutor().schedule(task, delay, TimeUnit.MILLISECONDS));
				} else {
					if (logger.isDebugEnabled()) {
						logger.debug("Scheduling periodic timer with id "
								+ task.getData().getTaskID() + ", scheduling strategy " + taskData.getPeriodicScheduleStrategy() + ", delay " + delay + ", period " + taskData.getPeriod());
					}
					if (taskData.getPeriodicScheduleStrategy() == PeriodicScheduleStrategy.withFixedDelay) {
						task.setScheduledFuture(scheduler.getExecutor().scheduleWithFixedDelay(task, delay, taskData.getPeriod(),TimeUnit.MILLISECONDS));
					}
					else {
						// default
						task.setScheduledFuture(scheduler.getExecutor().scheduleAtFixedRate(task, delay, taskData.getPeriod(),TimeUnit.MILLISECONDS));
					}					
				}		
			} catch (Throwable e) {
				logger.error(e.getMessage(), e);
				scheduler.remove(taskData.getTaskID(),true);
			}
		} else {
			if (logger.isDebugEnabled()) {
				logger.debug("Canceled scheduling periodic timer with id "
						+ task.getData().getTaskID());
			}
		}
	}
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())
656974
def resource_collections_update(self, data, **kwargs):
        ""
        api_path = "/api/v2/resource_collections.json"
        return self.call(api_path, method="PUT", data=data, **kwargs)
356045
public function executeCollectionAction($action, Request $request)
    {
        $ids = $request->query->get('ids');

        /** @var ResourceNode[] $resourceNodes */
        $resourceNodes = $this->om->findList(ResourceNode::class, 'uuid', $ids);
        $responses = [];

        // read request and get user query
        $parameters = $request->query->all();
        $content = null;

        if (!empty($request->getContent())) {
            $content = json_decode($request->getContent(), true);
        }
        $files = $request->files->all();

        $this->om->startFlushSuite();

        foreach ($resourceNodes as $resourceNode) {
            // check the requested action exists
            if (!$this->actionManager->support($resourceNode, $action, $request->getMethod())) {
                // undefined action
                throw new NotFoundHttpException(
                    sprintf('The action %s with method [%s] does not exist for resource type %s.', $action, $request->getMethod(), $resourceNode->getResourceType()->getName())
                );
            }

            // check current user rights
            $this->checkAccess($this->actionManager->get($resourceNode, $action), [$resourceNode]);

            // dispatch action event
            $responses[] = $this->actionManager->execute($resourceNode, $action, $parameters, $content, $files);
        }

        $this->om->endFlushSuite();

        return new JsonResponse(array_map(function (Response $response) {
            return json_decode($response->getContent(), true);
        }, $responses));
    }
741552
def collect(self):
        

        content = self._load()
        result = dict((self.STATE[num], 0) for num in self.STATE)

        for line in content:
            line_array = self._remove_empty(line.split(' '))
            state = self.STATE[line_array[3]]

            result[state] += 1

        for state in result:
            self.publish(state, result[state])
1229648
public void setActions(java.util.Collection<DatasetActionSummary> actions) {
        if (actions == null) {
            this.actions = null;
            return;
        }

        this.actions = new java.util.ArrayList<DatasetActionSummary>(actions);
    }
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
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());
					}
				}
			}
		}
	}