java.util.concurrent.ConcurrentSkipListSet.first()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中java.util.concurrent.ConcurrentSkipListSet.first()方法的一些代码示例,展示了ConcurrentSkipListSet.first()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ConcurrentSkipListSet.first()方法的具体详情如下:
包路径:java.util.concurrent.ConcurrentSkipListSet
类名称:ConcurrentSkipListSet
方法名:first

ConcurrentSkipListSet.first介绍

暂无

代码示例

代码示例来源:origin: Graylog2/graylog2-server

@Override
  public void run() {
    try {
      // loop until we've either evicted all outdated chunk entries, or the set is completely empty.
      // this task will run every second by default (see constant in constructor)
      while (true) {
        // Check if eviction set is empty to avoid a NoElementException when calling first().
        if (sortedEvictionSet.isEmpty()) {
          break;
        }
        final ChunkEntry oldestChunkEntry = sortedEvictionSet.first();
        if (isOutdated(oldestChunkEntry)) {
          expireEntry(oldestChunkEntry.id);
        } else {
          log.debug("No more outdated chunk entries found to evict, leaving cleanup loop.");
          break;
        }
      }
    } catch (Exception e) {
      // Make sure to never throw an exception out of this runnable, it's being run in an executor.
      log.warn("Error while expiring GELF chunk entries", e);
    }
  }
}

代码示例来源:origin: de.dentrassi.eclipse.neoscada.utils/org.eclipse.scada.utils

@Override
public E first ()
{
  return this.internalSet.first ();
}

代码示例来源:origin: de.dentrassi.eclipse.neoscada.utils/org.eclipse.scada.utils

@Override
public E element ()
{
  return this.internalSet.first ();
}

代码示例来源:origin: de.dentrassi.eclipse.neoscada.utils/org.eclipse.scada.utils

@Override
public E peek ()
{
  try
  {
    return this.internalSet.first ();
  }
  catch ( final NoSuchElementException e )
  {
    return null;
  }
}

代码示例来源:origin: org.tentackle/tentackle-core

/**
 * Determines the next task to execute.
 *
 * @return the task, null if no more tasks
 */
protected Task nextTask() {
 try {
  return queue.first();
 }
 catch (NoSuchElementException nse) {
  return null;
 }
}

代码示例来源:origin: org.axonframework/axon-kafka

/**
 * Retrieves, but does not remove, the first message of this buffer, or returns null if this buffer is empty.
 *
 * @return the message.
 */
@Override
public E peek() {
  final ReentrantLock lock = this.lock;
  lock.lock();
  try {
    return this.count > 0 ? this.delegate.first() : null;
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: org.axonframework.extensions.kafka/axon-kafka

/**
 * Retrieves, but does not remove, the first message of this buffer, or returns null if this buffer is empty.
 *
 * @return the message.
 */
@Override
public E peek() {
  final ReentrantLock lock = this.lock;
  lock.lock();
  try {
    return this.count > 0 ? this.delegate.first() : null;
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: de.dentrassi.eclipse.neoscada.utils/org.eclipse.scada.utils

@Override
public E remove ()
{
  final E result = this.internalSet.first ();
  this.internalSet.remove ( result );
  return result;
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-resourcemanager

public PendingAsk getNextPendingAsk() {
 try {
  readLock.lock();
  SchedulerRequestKey firstRequestKey = schedulerKeys.first();
  return getPendingAsk(firstRequestKey, ResourceRequest.ANY);
 } finally {
  readLock.unlock();
 }
}

代码示例来源:origin: com.orientechnologies/orientdb-core

public OLogSequenceNumber begin() {
 final long first = segments.first();
 return new OLogSequenceNumber(first, OCASWALPage.RECORDS_OFFSET);
}

代码示例来源:origin: org.graylog2/graylog2-inputs

@Override
  public void run() {
    try {
      // loop until we've either evicted all outdated chunk entries, or the set is completely empty.
      // this task will run every second by default (see constant in constructor)
      while (true) {
        // Check if eviction set is empty to avoid a NoElementException when calling first().
        if (sortedEvictionSet.isEmpty()) {
          break;
        }
        final ChunkEntry oldestChunkEntry = sortedEvictionSet.first();
        if (isOutdated(oldestChunkEntry)) {
          expireEntry(oldestChunkEntry.id);
        } else {
          log.debug("No more outdated chunk entries found to evict, leaving cleanup loop.");
          break;
        }
      }
    } catch (Exception e) {
      // Make sure to never throw an exception out of this runnable, it's being run in an executor.
      log.warn("Error while expiring GELF chunk entries", e);
    }
  }
}

代码示例来源:origin: pravega/pravega

/**
 * This method maintains a sorted list of position for requests currently being processed.
 * As processing of each request completes, it is removed from the sorted list and moved to
 * completed list.
 * Completed is also a sorted list that contains all completed requests greater than smallest running position.
 * In other words, we maintain all requests from smallest processing to current position in either running or completed
 * sorted list.
 * Note: Smallest position will always be in the running list.
 * We also maintain a single checkpoint, which is the highest completed position smaller than smallest running position.
 *
 * @param pc position for which processing completed
 */
@Synchronized
private void checkpoint(PositionCounter pc) {
  running.remove(pc);
  completed.add(pc);
  final PositionCounter smallest = running.isEmpty() ? MAX : running.first();
  final List<PositionCounter> checkpointCandidates = completed.stream()
      .filter(x -> positionCounterComparator.compare(x, smallest) < 0).collect(Collectors.toList());
  if (checkpointCandidates.size() > 0) {
    final PositionCounter checkpointPosition = checkpointCandidates.get(checkpointCandidates.size() - 1);
    completed.removeAll(checkpointCandidates);
    checkpoint.set(checkpointPosition);
  }
}

代码示例来源:origin: teiid/teiid

/**
 * Add a delayed task
 * @param task
 * @param delay in ms
 * @return a cancellable Task
 */
public Task add(Runnable task, long delay) {
  Task result = new Task(task, delay);
  try {
    if (this.queue.add(result) 
        && this.queue.first() == result) {
      //only need to synchronize when this is the first task
      synchronized (this) {
        if (!running) {
          start();
        }
        this.notifyAll();
      }
    }
  } catch (NoSuchElementException e) {
    //shouldn't happen
  }
  return result;
}

代码示例来源:origin: cojen/Tupl

@Override
public LogReader openReader(long index) {
  LKey<TermLog> key = new LKey.Finder<>(index);
  acquireShared();
  try {
    if (mClosed) {
      throw new IllegalStateException("Closed");
    }
    TermLog termLog = (TermLog) mTermLogs.floor(key); // findLe
    if (termLog != null) {
      return termLog.openReader(index);
    }
    termLog = (TermLog) mTermLogs.first();
    throw new IllegalStateException
      ("Index is lower than start index: " + index + " < " + termLog.startIndex());
  } finally {
    releaseShared();
  }
}

代码示例来源:origin: co.cask.hbase/hbase

@Override
 protected void chore() {
  ServerName serverToUpdateTimer = null;
  while (!serversInUpdatingTimer.isEmpty() && !stopper.isStopped()) {
   if (serverToUpdateTimer == null) {
    serverToUpdateTimer = serversInUpdatingTimer.first();
   } else {
    serverToUpdateTimer = serversInUpdatingTimer
      .higher(serverToUpdateTimer);
   }
   if (serverToUpdateTimer == null) {
    break;
   }
   updateTimers(serverToUpdateTimer);
   serversInUpdatingTimer.remove(serverToUpdateTimer);
  }
 }
}

代码示例来源:origin: alibaba/wasp

@Override
 protected void chore() {
  ServerName serverToUpdateTimer = null;
  while (!serversInUpdatingTimer.isEmpty() && !stopper.isStopped()) {
   if (serverToUpdateTimer == null) {
    serverToUpdateTimer = serversInUpdatingTimer.first();
   } else {
    serverToUpdateTimer = serversInUpdatingTimer
      .higher(serverToUpdateTimer);
   }
   if (serverToUpdateTimer == null) {
    break;
   }
   updateTimers(serverToUpdateTimer);
   serversInUpdatingTimer.remove(serverToUpdateTimer);
  }
 }
}

代码示例来源:origin: org.apache.gora/gora-jcache

@Override
public Result<K, T> execute(Query<K, T> query) {
 K startKey = query.getStartKey();
 K endKey = query.getEndKey();
 if (startKey == null) {
  if (!cacheEntryList.isEmpty()) {
   startKey = (K) cacheEntryList.first();
  }
 }
 if (endKey == null) {
  if (!cacheEntryList.isEmpty()) {
   endKey = (K) cacheEntryList.last();
  }
 }
 query.setFields(getFieldsToQuery(query.getFields()));
 ConcurrentSkipListSet<K> cacheEntrySubList = null;
 try {
  cacheEntrySubList = (ConcurrentSkipListSet<K>) cacheEntryList.subSet(startKey, true, endKey, true);
 } catch (NullPointerException npe) {
  LOG.error("NPE occurred while executing the query for JCacheStore. Hence returning empty entry set.", npe);
  return new JCacheResult<>(this, query, new ConcurrentSkipListSet<K>());
 }
 return new JCacheResult<>(this, query, cacheEntrySubList);
}

代码示例来源:origin: jsevellec/cassandra-unit

public KeyRangeIterator(ConcurrentSkipListSet<DecoratedKey> keys)
{
  super((Long) keys.first().getToken().getTokenValue(), (Long) keys.last().getToken().getTokenValue(), keys.size());
  this.iterator = new DKIterator(keys.iterator());
}

代码示例来源:origin: com.strapdata.cassandra/cassandra-all

public KeyRangeIterator(ConcurrentSkipListSet<DecoratedKey> keys)
{
  super((Long) keys.first().getToken().getTokenValue(), (Long) keys.last().getToken().getTokenValue(), keys.size());
  this.iterator = new DKIterator(keys.iterator());
}

代码示例来源:origin: org.apache.cassandra/cassandra-all

public KeyRangeIterator(ConcurrentSkipListSet<DecoratedKey> keys)
{
  super((Long) keys.first().getToken().getTokenValue(), (Long) keys.last().getToken().getTokenValue(), keys.size());
  this.iterator = new DKIterator(keys.iterator());
}

相关文章

微信公众号

最新文章

更多