Kicks off the job that attempts to clean the throttling submission record history.
172557
@Override
    @Scheduled(initialDelayString = "${cas.authn.throttle.schedule.startDelay:PT10S}",
        fixedDelayString = "${cas.authn.throttle.schedule.repeatInterval:PT15S}")
    public void run() {
        val handlers = authenticationThrottlingExecutionPlan.getAuthenticationThrottleInterceptors();
        handlers
            .stream()
            .filter(handler -> handler instanceof ThrottledSubmissionHandlerInterceptor)
            .map(handler -> (ThrottledSubmissionHandlerInterceptor) handler)
            .forEach(ThrottledSubmissionHandlerInterceptor::decrement);
    }
951626
private void throttledTransfer(MockResponse throttlePolicy, InputStream in, OutputStream out,
            long limit) throws IOException {
        byte[] buffer = new byte[1024];
        int bytesPerPeriod = throttlePolicy.getThrottleBytesPerPeriod();
        long delayMs = throttlePolicy.getThrottleUnit().toMillis(throttlePolicy.getThrottlePeriod());

        while (true) {
            for (int b = 0; b < bytesPerPeriod; ) {
                int toRead = (int) Math.min(Math.min(buffer.length, limit), bytesPerPeriod - b);
                int read = in.read(buffer, 0, toRead);
                if (read == -1) return;

                out.write(buffer, 0, read);
                out.flush();
                b += read;
                limit -= read;

                if (limit == 0) return;
            }

            try {
                if (delayMs != 0) Thread.sleep(delayMs);
            } catch (InterruptedException e) {
                throw new AssertionError();
            }
        }
    }
317905
public void garbageCollect() {
    if (softLimit == 0) {
      reset();
    } else if (data.size() > hardLimit) {
      long boundaryTime = data.get(softLimit).getStartTime();
      data.removeIf((MtasSolrStatus status) -> status.getStartTime() < boundaryTime);
      index.clear();
      data.forEach((MtasSolrStatus status) -> index.put(status.key(), status));
    }
  }
1292604
public void cleanup() {
        cleanupLock.lock();
        try {
            // Clean up the write interface.
            if (null != writeInterface) {
                this.writeInterface.close();
                this.writeInterface = null;
            }
            // Clean up the read interface.
            if (null != readInterface) {
                this.readInterface.close();
                this.readInterface = null;
            }
            // Clean up the SSL engine.
            if (null != getSSLEngine()) {
                //If the channel has already processed the stop signal, it is too late to try and send the write handshake
                if (this.sslChannel.getstop0Called() == true) {
                    this.connected = false;
                }

                SSLUtils.shutDownSSLEngine(this, isInbound, this.connected);

                this.sslEngine = null;
            }
            // mark that we have disconnected
            this.connected = false;
        } finally {
            cleanupLock.unlock();
        }
    }
1230693
protected function job(): void
    {
        while (true) {

            $folders = $this->retrieve([
                'corporation_id' => $this->getCorporationId(),
            ]);

            if ($folders->isCachedLoad()) return;

            collect($folders)->each(function ($folder) {

                CorporationBookmarkFolder::firstOrNew([
                    'corporation_id' => $this->getCorporationId(),
                    'folder_id'      => $folder->folder_id,
                ])->fill([
                    'name'       => $folder->name,
                    'creator_id' => $folder->creator_id ?? null,
                ])->save();
            });

            $this->known_folder_ids->push(collect($folders)
                ->pluck('folder_id')->flatten()->all());

            if (! $this->nextPage($folders->pages))
                break;
        }

        // Cleanup removed folders
        CorporationBookmarkFolder::where('corporation_id', $this->getCorporationId())
            ->whereNotIn('folder_id', $this->known_folder_ids->flatten()->all())
            ->delete();
    }
96726
private void startPurgeTimer() {
        if (null != this.future || null == this.scheduler) {
            return;
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Creating repeating purge event");
        }
        this.future = this.scheduler.schedule(SessionEventHandler.PURGE_EVENT, this.purgeInterval, this.purgeInterval, TimeUnit.SECONDS);
    }
565036
public function postFlush()
    {
        if (!$this->enabled || $this->isHandling) {
            return;
        }

        $this->isHandling = true;

        $aliaser = $this->container->get($this->aliaserServiceId);

        while (list($record, $action) = array_shift($this->records)) {
            $aliaser->createAlias($record, $action);
        }

        $this->isHandling = false;
    }
266507
private void pruneExcessiveHistoricalRecordsLocked() {
        List<HistoricalRecord> choiceRecords = mHistoricalRecords;
        final int pruneCount = choiceRecords.size() - mHistoryMaxSize;
        if (pruneCount <= 0) {
            return;
        }
        mHistoricalRecordsChanged = true;
        for (int i = 0; i < pruneCount; i++) {
            HistoricalRecord prunedRecord = choiceRecords.remove(0);
            if (DEBUG) {
                Log.i(LOG_TAG, "Pruned: " + prunedRecord);
            }
        }
    }
317476
private void startWorkerIfNeeded() {
    // Perform a compare-and-swap retry loop for synchronization to make sure we don't start more
    // workers than desired.
    int currentCount = mPendingWorkers.get();
    while (currentCount < mMaxConcurrency) {
      int updatedCount = currentCount + 1;
      if (mPendingWorkers.compareAndSet(currentCount, updatedCount)) {
        // Start a new worker.
        FLog.v(TAG, "%s: starting worker %d of %d", mName, updatedCount, mMaxConcurrency);
        mExecutor.execute(mTaskRunner);
        break;
      }
      // else: compareAndSet failed due to race; snapshot the new count and try again
      FLog.v(TAG, "%s: race in startWorkerIfNeeded; retrying", mName);
      currentCount = mPendingWorkers.get();
    }
  }
682042
def submit_jobs(self, link, job_dict=None, job_archive=None, stream=sys.stdout):
        
        if link is None:
            return JobStatus.no_job
        if job_dict is None:
            job_keys = link.jobs.keys()
        else:
            job_keys = sorted(job_dict.keys())

        # copy & reverse the keys b/c we will be popping item off the back of
        # the list
        unsubmitted_jobs = job_keys
        unsubmitted_jobs.reverse()

        failed = False
        if unsubmitted_jobs:
            if stream != sys.stdout:
                sys.stdout.write('Submitting jobs (%i): ' %
                                 len(unsubmitted_jobs))
                sys.stdout.flush()
        while unsubmitted_jobs:
            status = get_lsf_status()
            njob_to_submit = min(self._max_jobs - status['NJOB'],
                                 self._jobs_per_cycle,
                                 len(unsubmitted_jobs))

            if self._dry_run:
                njob_to_submit = len(unsubmitted_jobs)

            for i in range(njob_to_submit):
                job_key = unsubmitted_jobs.pop()

                # job_details = job_dict[job_key]
                job_details = link.jobs[job_key]
                job_config = job_details.job_config
                if job_details.status == JobStatus.failed:
                    clean_job(job_details.logfile, {}, self._dry_run)
                    # clean_job(job_details.logfile,
                    #          job_details.outfiles, self.args['dry_run'])

                job_config['logfile'] = job_details.logfile
                new_job_details = self.dispatch_job(
                    link, job_key, job_archive, stream)
                if new_job_details.status == JobStatus.failed:
                    failed = True
                    clean_job(new_job_details.logfile,
                              new_job_details.outfiles, self._dry_run)
                link.jobs[job_key] = new_job_details

            if unsubmitted_jobs:
                if stream != sys.stdout:
                    sys.stdout.write('.')
                    sys.stdout.flush()
                stream.write('Sleeping %.0f seconds between submission cycles\n' %
                             self._time_per_cycle)
                time.sleep(self._time_per_cycle)

        if failed:
            return JobStatus.failed

        if stream != sys.stdout:
            sys.stdout.write('!\n')

        return JobStatus.done
50977
static function cleanup()
    {
        $ini = eZINI::instance();
        $db = eZDB::instance();
        $timeFrame = 1;
        if ( $ini->hasVariable( 'TipAFriend', 'TimeFrame' ) )
            $timeFrame = $ini->variable( 'TipAFriend', 'TimeFrame' );
        $time = time() - $timeFrame * 3600;

        $db->query( "DELETE FROM eztipafriend_request
                      WHERE created < $time " );
    }
792162
def cleanup():
    
    _log.debug("P4P atexit begins")
    # clean provider registry
    from .server import clearProviders, _cleanup_servers
    clearProviders()

    # close client contexts
    from .client.raw import _cleanup_contexts
    _cleanup_contexts()

    # stop servers
    _cleanup_servers()

    # shutdown default work queue
    from .util import _defaultWorkQueue
    _defaultWorkQueue.stop()
    _log.debug("P4P atexit completes")
871255
public function cleanUp()
    {
        // create a separate queue for each priority
        foreach (PriorityKeys::getAll() as $priorityKey) {
            $this->workers[$this->uniqueWorkerName($priorityKey)]->stop();
        }
    }
1042678
public function cleanupAction()
    {
        $params = $this->_processParameters($this->showParameters);
        $params['contentTitle'] = $this->_('Clean up existing appointments?');
        $params['filterOn']     = 'gap_id_procedure';
        $params['filterWhen']   = 'gap_filter';

        $snippets = array(
            'Generic\\ContentTitleSnippet',
            'Agenda\\AppointmentCleanupSnippet',
            'Agenda_CalendarTableSnippet',
            );

        $this->addSnippets($snippets, $params);
    }
1081780
def cleanup_failed_attacks(self):
    """"""
    print_header('Cleaning up failed attacks')
    attacks_to_replace = {}
    self.attack_work.read_all_from_datastore()
    failed_submissions = set()
    error_msg = set()
    for k, v in iteritems(self.attack_work.work):
      if v['error'] is not None:
        attacks_to_replace[k] = dict(v)
        failed_submissions.add(v['submission_id'])
        error_msg.add(v['error'])
        attacks_to_replace[k].update(
            {
                'claimed_worker_id': None,
                'claimed_worker_start_time': None,
                'is_completed': False,
                'error': None,
                'elapsed_time': None,
            })
    self.attack_work.replace_work(attacks_to_replace)
    print('Affected submissions:')
    print(' '.join(sorted(failed_submissions)))
    print('Error messages:')
    print(' '.join(sorted(error_msg)))
    print('')
    inp = input_str('Are you sure? (type "yes" without quotes to confirm): ')
    if inp != 'yes':
      return
    self.attack_work.write_all_to_datastore()
    print('Work cleaned up')
441554
async def Prune(self, max_history_mb, max_history_time):
        '''
        
        '''
        # map input types to rpc msg
        _params = dict()
        msg = dict(type='ActionPruner',
                   request='Prune',
                   version=1,
                   params=_params)
        _params['max-history-mb'] = max_history_mb
        _params['max-history-time'] = max_history_time
        reply = await self.rpc(msg)
        return reply
1319039
public void cullHistory(final int profileId, final String clientUUID, final int limit) throws Exception {

        //Allow only 1 delete thread to run
        if (threadActive) {
            return;
        }

        threadActive = true;
        //Create a thread so proxy will continue to work during long delete
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                PreparedStatement statement = null;

                try (Connection sqlConnection = sqlService.getConnection()) {
                    String sqlQuery = "SELECT COUNT(" + Constants.GENERIC_ID + ") FROM " + Constants.DB_TABLE_HISTORY + " ";

                    // see if profileId is set or not (-1)
                    if (profileId != -1) {
                        sqlQuery += "WHERE " + Constants.GENERIC_PROFILE_ID + "=" + profileId + " ";
                    }

                    if (clientUUID != null && clientUUID.compareTo("") != 0) {
                        sqlQuery += "AND " + Constants.GENERIC_CLIENT_UUID + "='" + clientUUID + "' ";
                    }
                    sqlQuery += ";";

                    Statement query = sqlConnection.createStatement();
                    ResultSet results = query.executeQuery(sqlQuery);
                    if (results.next()) {
                        if (results.getInt("COUNT(" + Constants.GENERIC_ID + ")") < (limit + 10000)) {
                            return;
                        }
                    }
                    //Find the last item in the table
                    statement = sqlConnection.prepareStatement("SELECT " + Constants.GENERIC_ID + " FROM " + Constants.DB_TABLE_HISTORY +
                                                                   " WHERE " + Constants.CLIENT_CLIENT_UUID + " = \'" + clientUUID + "\'" +
                                                                   " AND " + Constants.CLIENT_PROFILE_ID + " = " + profileId +
                                                                   " ORDER BY " + Constants.GENERIC_ID + " ASC LIMIT 1");

                    ResultSet resultSet = statement.executeQuery();
                    if (resultSet.next()) {
                        int currentSpot = resultSet.getInt(Constants.GENERIC_ID) + 100;
                        int finalDelete = currentSpot + 10000;
                        //Delete 100 items at a time until 10000 are deleted
                        //Do this so table is unlocked frequently to allow other proxy items to access it
                        while (currentSpot < finalDelete) {
                            PreparedStatement deleteStatement = sqlConnection.prepareStatement("DELETE FROM " + Constants.DB_TABLE_HISTORY +
                                                                                                   " WHERE " + Constants.CLIENT_CLIENT_UUID + " = \'" + clientUUID + "\'" +
                                                                                                   " AND " + Constants.CLIENT_PROFILE_ID + " = " + profileId +
                                                                                                   " AND " + Constants.GENERIC_ID + " < " + currentSpot);
                            deleteStatement.executeUpdate();
                            currentSpot += 100;
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    try {
                        threadActive = false;
                        if (statement != null) {
                            statement.close();
                        }
                    } catch (Exception e) {
                    }
                }
            }
        });

        t1.start();
    }