Runs cold hand an in turn hot hand to find eviction candidate.
430038
@Override
  protected Entry findEvictionCandidate(Entry _previous) {
    coldRunCnt++;
    Entry _hand = handCold;
    int _scanCnt = 1;
    if (_hand == null) {
      _hand = refillFromHot(_hand);
    }
    if (_hand.hitCnt > 0) {
      _hand = refillFromHot(_hand);
      do {
        _scanCnt++;
        coldHits += _hand.hitCnt;
        _hand.hitCnt = 0;
        Entry e = _hand;
        _hand = Entry.removeFromCyclicList(e);
        coldSize--;
        e.setHot(true);
        hotSize++;
        handHot = Entry.insertIntoTailCyclicList(handHot, e);
      } while (_hand != null && _hand.hitCnt > 0);
    }

    if (_hand == null) {
      _hand = refillFromHot(_hand);
    }
    coldScanCnt += _scanCnt;
    handCold = _hand.next;
    return _hand;
  }
1009657
def run_one(self, name, migrator, fake=True, downgrade=False, force=False):
        """"""
        try:
            migrate, rollback = self.read(name)
            if fake:
                with mock.patch('peewee.Model.select'):
                    with mock.patch('peewee.Query._execute'):
                        migrate(migrator, self.database, fake=fake)

                if force:
                    self.model.create(name=name)
                    self.logger.info('Done %s', name)

                migrator.clean()
                return migrator

            with self.database.transaction():
                if not downgrade:
                    self.logger.info('Migrate "%s"', name)
                    migrate(migrator, self.database, fake=fake)
                    migrator.run()
                    self.model.create(name=name)
                else:
                    self.logger.info('Rolling back %s', name)
                    rollback(migrator, self.database, fake=fake)
                    migrator.run()
                    self.model.delete().where(self.model.name == name).execute()

                self.logger.info('Done %s', name)

        except Exception:
            self.database.rollback()
            operation = 'Migration' if not downgrade else 'Rollback'
            self.logger.exception('%s failed: %s', operation, name)
            raise
1327963
def _runner(self, classpath, main, jvm_options, args, cwd=None):
    """"""
    command = self._create_command(classpath, main, jvm_options, args)

    class Runner(self.Runner):
      @property
      def executor(this):
        return self

      @property
      def command(self):
        return list(command)

      def run(this, stdout=None, stderr=None, stdin=None, cwd=None):
        nailgun = None
        try:
          nailgun = self._get_nailgun_client(jvm_options, classpath, stdout, stderr, stdin)
          logger.debug('Executing via {ng_desc}: {cmd}'.format(ng_desc=nailgun, cmd=this.cmd))
          return nailgun.execute(main, cwd, *args)
        except (NailgunClient.NailgunError, self.InitialNailgunConnectTimedOut) as e:
          self.terminate()
          raise self.Error('Problem launching via {ng_desc} command {main} {args}: {msg}'
                           .format(ng_desc=nailgun or '<no nailgun connection>',
                                   main=main,
                                   args=' '.join(args),
                                   msg=e))

    return Runner()
1224980
def get_candidate_election(self, candidate):
        """"""
        return CandidateElection.objects.get(
            candidate=candidate, election=self
        )
1368438
public void evictCache(String key) {
        H.Session sess = session();
        if (null != sess) {
            sess.evict(key);
        } else {
            app().cache().evict(key);
        }
    }
207721
def run(self):
        '''
        
        '''
        self._update_opts()
        cmd = self.opts['fun']

        veri = None
        ret = None
        try:
            if cmd in ('accept', 'reject', 'delete'):
                ret = self._run_cmd('name_match')
                if not isinstance(ret, dict):
                    salt.output.display_output(ret, 'key', opts=self.opts)
                    return ret
                ret = self._filter_ret(cmd, ret)
                if not ret:
                    self._print_no_match(cmd, self.opts['match'])
                    return
                print('The following keys are going to be {0}ed:'.format(cmd.rstrip('e')))
                salt.output.display_output(ret, 'key', opts=self.opts)

                if not self.opts.get('yes', False):
                    try:
                        if cmd.startswith('delete'):
                            veri = input('Proceed? [N/y] ')
                            if not veri:
                                veri = 'n'
                        else:
                            veri = input('Proceed? [n/Y] ')
                            if not veri:
                                veri = 'y'
                    except KeyboardInterrupt:
                        raise SystemExit("\nExiting on CTRL-c")
                # accept/reject/delete the same keys we're printed to the user
                self.opts['match_dict'] = ret
                self.opts.pop('match', None)
                list_ret = ret

            if veri is None or veri.lower().startswith('y'):
                ret = self._run_cmd(cmd)
                if cmd in ('accept', 'reject', 'delete'):
                    if cmd == 'delete':
                        ret = list_ret
                    for minions in ret.values():
                        for minion in minions:
                            print('Key for minion {0} {1}ed.'.format(minion,
                                                                     cmd.rstrip('e')))
                elif isinstance(ret, dict):
                    salt.output.display_output(ret, 'key', opts=self.opts)
                else:
                    salt.output.display_output({'return': ret}, 'key', opts=self.opts)
        except salt.exceptions.SaltException as exc:
            ret = '{0}'.format(exc)
            if not self.opts.get('quiet', False):
                salt.output.display_output(ret, 'nested', self.opts)
        return ret
1025484
protected synchronized void startEvictor(long delay)
    {
        if (null != evictor)
        {
            evictor.cancel();
            evictor = null;
        }
        if (delay > 0)
        {
            evictor = new Evictor();
            EVICTION_TIMER.schedule(evictor, delay, delay);
        }
    }
1352441
def _prepare_job(request, candidates):
    
    temp_dir = tempfile.mkdtemp()
    inifiles = []
    arch = request.FILES.get('archive')
    if arch is None:
        # move each file to a new temp dir, using the upload file names,
        # not the temporary ones
        for each_file in request.FILES.values():
            new_path = os.path.join(temp_dir, each_file.name)
            shutil.move(each_file.temporary_file_path(), new_path)
            if each_file.name in candidates:
                inifiles.append(new_path)
        return inifiles
    # else extract the files from the archive into temp_dir
    return readinput.extract_from_zip(arch, candidates)
1087550
async def _runJob(self, user, appt):
        '''
        
        '''
        count = 0
        appt.isrunning = True
        appt.laststarttime = time.time()
        appt.startcount += 1
        await self._storeAppt(appt)

        with s_provenance.claim('cron', iden=appt.iden):
            logger.info('Agenda executing for iden=%s, user=%s, query={%s}', appt.iden, user.name, appt.query)
            starttime = time.time()
            try:
                async for _ in self.core.eval(appt.query, user=user):  # NOQA
                    count += 1
            except asyncio.CancelledError:
                result = 'cancelled'
                raise
            except Exception as e:
                result = f'raised exception {e}'
                logger.exception('Agenda job %s raised exception', appt.iden)
            else:
                result = f'finished successfully with {count} nodes'
            finally:
                finishtime = time.time()
                logger.info('Agenda completed query for iden=%s with result "%s" took %0.3fs',
                            appt.iden, result, finishtime - starttime)
                appt.lastfinishtime = finishtime
                appt.isrunning = False
                appt.lastresult = result
                if not self.isfini:
                    await self._storeAppt(appt)
661658
@Override
    public void evict(Class arg0, Object arg1)
    {
        // TODO Can we use Class with ehcache
        if(isAlive())
        ehcache.remove(arg1);
    }
985889
private void evictIfOverLimit() {
    int numToEvict = mCache.size() - mSoftLimit;

    if (numToEvict <= 0) {
      return;
    }

    if (mEvictLock.tryLock()) {
      try {
        // update the total number to evict while we are holding the lock
        numToEvict = mCache.size() - mSoftLimit;
        // This thread won the race as the evictor
        while (numToEvict > 0) {
          if (!mIterator.hasNext()) {
            mIterator = mCache.entrySet().iterator();
          }
          Map.Entry<K, ValNode> candidateMapEntry = mIterator.next();
          ValNode candidate = candidateMapEntry.getValue();
          if (candidate.mIsAccessed) {
            candidate.mIsAccessed = false;
          } else {
            if (candidate.mRefCount.compareAndSet(0, Integer.MIN_VALUE)) {
              // the value object can be evicted, at the same time we make refCount minValue
              mIterator.remove();
              numToEvict--;
            }
          }
        }
      } finally {
        mEvictLock.unlock();
      }
    }
  }
379122
def run_job(self, **kwds):
        
        template = DrmaaSession.session.createJobTemplate()
        try:
            for key in kwds:
                setattr(template, key, kwds[key])
            with DrmaaSession.session_lock:
                return DrmaaSession.session.runJob(template)
        finally:
            DrmaaSession.session.deleteJobTemplate(template)
1039737
protected synchronized void evictStaleEntries() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            int size = primaryTable.size();
            Tr.debug(tc, "The current cache size is " + size);
        }

        Map<String, Object> secondaryTable = new HashMap<String, Object>();
        secondaryTable.putAll(primaryTable); //create 2nd map to avoid concurrent during entry manipulation
        Set<String> keysToRemove = findExpiredTokens(secondaryTable);
        removeExpiredTokens(keysToRemove);
        secondaryTable.clear();

    }
729237
def fire_running(self, running):
        '''
        
        '''
        load = {'id': self.opts['id'],
                'events': [],
                'cmd': '_minion_event'}
        for stag in sorted(
                running,
                key=lambda k: running[k].get('__run_num__', 0)):
            if running[stag]['result'] and not running[stag]['changes']:
                continue
            tag = 'state_{0}_{1}'.format(
                six.text_type(running[stag]['result']),
                'True' if running[stag]['changes'] else 'False')
            load['events'].append({
                'tag': tag,
                'data': running[stag],
            })
        channel = salt.transport.client.ReqChannel.factory(self.opts)
        try:
            channel.send(load)
        except Exception:
            pass
        finally:
            channel.close()
        return True
786705
def request(self, target="candidate"):
        
        node = new_ele("lock")
        sub_ele(sub_ele(node, "target"), target)
        return self._request(node)
76846
protected function evict()
    {
        while ($this->size > $this->limit && !empty($this->items)) {
            $item = array_shift($this->items);
            $this->size -= strlen($item[0]);
        }
    }
356540
private void evict(Node candidate) {
    if (data.size() > maximumSize) {
      Node victim = policy.findVictim(sentinel, policyStats);
      policyStats.recordEviction();

      boolean admit = admittor.admit(candidate.key, victim.key);
      if (admit) {
        evictEntry(victim);
      } else {
        evictEntry(candidate);
      }
    } else {
      policyStats.recordOperation();
    }
  }