本文整理了Java中java.util.concurrent.BlockingQueue.stream()
方法的一些代码示例,展示了BlockingQueue.stream()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BlockingQueue.stream()
方法的具体详情如下:
包路径:java.util.concurrent.BlockingQueue
类名称:BlockingQueue
方法名:stream
暂无
代码示例来源:origin: debezium/debezium
@Override
public Stream<ConsumerRecord<K, V>> stream() {
return consumed.stream();
}
代码示例来源:origin: apache/incubator-druid
private void filterBufferAndResetFetchRunnable(Set<StreamPartition<String>> partitions) throws InterruptedException
{
scheduledExec.shutdown();
try {
if (!scheduledExec.awaitTermination(EXCEPTION_RETRY_DELAY_MS, TimeUnit.MILLISECONDS)) {
scheduledExec.shutdownNow();
}
}
catch (InterruptedException e) {
log.warn(e, "InterruptedException while shutting down");
throw e;
}
scheduledExec = Executors.newScheduledThreadPool(
fetchThreads,
Execs.makeThreadFactory("KinesisRecordSupplier-Worker-%d")
);
// filter records in buffer and only retain ones whose partition was not seeked
BlockingQueue<OrderedPartitionableRecord<String, String>> newQ = new LinkedBlockingQueue<>(recordBufferSize);
records
.stream()
.filter(x -> !partitions.contains(x.getStreamPartition()))
.forEachOrdered(newQ::offer);
records = newQ;
// restart fetching threads
partitionResources.values().forEach(x -> x.started = false);
checkPartitionsStarted = true;
}
代码示例来源:origin: kiegroup/optaplanner
/**
* Not thread-safe. Can only be called from the solver thread.
* @param stepIndex at least 0
*/
public void startNextStep(int stepIndex) {
synchronized (this) {
if (filterStepIndex >= stepIndex) {
throw new IllegalStateException("The old filterStepIndex (" + filterStepIndex
+ ") must be less than the stepIndex (" + stepIndex + ")");
}
filterStepIndex = stepIndex;
MoveResult<Solution_> exceptionResult = innerQueue.stream().filter(MoveResult::hasThrownException)
.findFirst().orElse(null);
if (exceptionResult != null) {
throw new IllegalStateException("The move thread with moveThreadIndex ("
+ exceptionResult.getMoveThreadIndex() + ") has thrown an exception."
+ " Relayed here in the parent thread.",
exceptionResult.getThrowable());
}
innerQueue.clear();
}
nextMoveIndex = 0;
backlog.clear();
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Returns a stream of all pending tasks. This is similar to {@link #getQueue()} but will expose the originally submitted
* {@link Runnable} instances rather than potentially wrapped ones.
*/
public Stream<Runnable> getTasks() {
return this.getQueue().stream().map(this::unwrap);
}
代码示例来源:origin: de.tudarmstadt.ukp.inception.app/inception-search-core
private Optional<Task> findAlreadyScheduled(Task aTask)
{
return queue.stream().filter(aTask::matches).findAny();
}
}
代码示例来源:origin: inception-project/inception
private Optional<Task> findAlreadyScheduled(Task aTask)
{
return queue.stream().filter(aTask::matches).findAny();
}
}
代码示例来源:origin: org.apache.cassandra/cassandra-all
/**
* This is a helper method for unit testing. Disclaimer: Do not use this method outside unit tests, as
* this method is iterating the queue which can be an expensive operation (CPU time, queue locking).
*
* @return true, if the queue contains at least one expired element
*/
@VisibleForTesting // (otherwise = VisibleForTesting.NONE)
boolean backlogContainsExpiredMessages(long nowNanos)
{
return backlog.stream().anyMatch(entry -> entry.isTimedOut(nowNanos));
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Returns a stream of all pending tasks. This is similar to {@link #getQueue()} but will expose the originally submitted
* {@link Runnable} instances rather than potentially wrapped ones.
*/
public Stream<Runnable> getTasks() {
return this.getQueue().stream().map(this::unwrap);
}
代码示例来源:origin: com.strapdata.cassandra/cassandra-all
/**
* This is a helper method for unit testing. Disclaimer: Do not use this method outside unit tests, as
* this method is iterating the queue which can be an expensive operation (CPU time, queue locking).
*
* @return true, if the queue contains at least one expired element
*/
@VisibleForTesting // (otherwise = VisibleForTesting.NONE)
boolean backlogContainsExpiredMessages(long nowNanos)
{
return backlog.stream().anyMatch(entry -> entry.isTimedOut(nowNanos));
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch
/**
* Returns a stream of all pending tasks. This is similar to {@link #getQueue()} but will expose the originally submitted
* {@link Runnable} instances rather than potentially wrapped ones.
*/
public Stream<Runnable> getTasks() {
return this.getQueue().stream().map(this::unwrap);
}
代码示例来源:origin: jsevellec/cassandra-unit
/**
* This is a helper method for unit testing. Disclaimer: Do not use this method outside unit tests, as
* this method is iterating the queue which can be an expensive operation (CPU time, queue locking).
*
* @return true, if the queue contains at least one expired element
*/
@VisibleForTesting // (otherwise = VisibleForTesting.NONE)
boolean backlogContainsExpiredMessages(long nowNanos)
{
return backlog.stream().anyMatch(entry -> entry.isTimedOut(nowNanos));
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
/**
* Returns a stream of all pending tasks. This is similar to {@link #getQueue()} but will expose the originally submitted
* {@link Runnable} instances rather than potentially wrapped ones.
*/
public Stream<Runnable> getTasks() {
return this.getQueue().stream().map(this::unwrap);
}
代码示例来源:origin: net.anwiba.commons/anwiba-commons-core
@Override
public void remove(final IProcessIdentfier identifier) {
final List<ProcessScheduledFuture<?>> futures = this.executor
.getQueue()
.stream()
.map(r -> (ProcessScheduledFuture<?>) r)
.collect(Collectors.toList());
for (final ProcessScheduledFuture<?> future : futures) {
if (future.getIdentifier().equals(identifier)) {
this.executor.getQueue().remove(future);
return;
}
}
}
代码示例来源:origin: net.anwiba.commons/anwiba-commons-core
@Override
public void cancel(final IProcessIdentfier identifier) {
final List<ProcessScheduledFuture<?>> futures = this.executor
.getQueue()
.stream()
.map(r -> (ProcessScheduledFuture<?>) r)
.collect(Collectors.toList());
for (final ProcessScheduledFuture<?> future : futures) {
if (future.getIdentifier().equals(identifier)) {
future.cancel(true);
return;
}
}
}
代码示例来源:origin: net.anwiba.commons/anwiba-commons-process
@Override
public void remove(final IProcessIdentfier identifier) {
final List<ProcessScheduledFuture<?>> futures = this.executor
.getQueue()
.stream()
.map(r -> (ProcessScheduledFuture<?>) r)
.collect(Collectors.toList());
for (final ProcessScheduledFuture<?> future : futures) {
if (future.getIdentifier().equals(identifier)) {
this.executor.getQueue().remove(future);
return;
}
}
}
代码示例来源:origin: net.anwiba.commons/anwiba-commons-process
@Override
public void cancel(final IProcessIdentfier identifier) {
final List<ProcessScheduledFuture<?>> futures = this.executor
.getQueue()
.stream()
.map(r -> (ProcessScheduledFuture<?>) r)
.collect(Collectors.toList());
for (final ProcessScheduledFuture<?> future : futures) {
if (future.getIdentifier().equals(identifier)) {
future.cancel(true);
return;
}
}
}
代码示例来源:origin: inception-project/inception
public boolean isIndexInProgress(Project aProject)
{
Validate.notNull(aProject, "Project cannot be null");
return queue.stream().anyMatch(task -> aProject.equals(task.getProject())) ||
consumer.getActiveTask().map(t -> aProject.equals(t.getProject())).orElse(false);
}
代码示例来源:origin: de.tudarmstadt.ukp.inception.app/inception-search-core
public boolean isIndexInProgress(Project aProject)
{
Validate.notNull(aProject, "Project cannot be null");
return queue.stream().anyMatch(task -> aProject.equals(task.getProject())) ||
consumer.getActiveTask().map(t -> aProject.equals(t.getProject())).orElse(false);
}
代码示例来源:origin: org.infinispan/infinispan-core
/**
* Assert that all the commands already invoked remotely have been verified and there were no errors.
*/
public void verifyNoErrors() {
assertTrue("Unexpected remote invocations: " +
blockedRequests.stream().map(i -> i.getCommand().toString()).collect(Collectors.joining(", ")),
blockedRequests.isEmpty());
}
代码示例来源:origin: avaire/avaire
/**
* Creates the audio state by copying the currently playing track, the volume,
* voice and channel IDs used for the music, guild ID, as well as all the
* tracks in the queue, the audio state can be used when the bot shuts
* down, to save it all the cache, or when the bot starts back up
* again, to load everything back into the music player.
*
* @param musicManager The guild music manager that the audio state should be created for.
* @param guild The JDA guild object for the current guild music manager.
*/
public AudioState(GuildMusicManager musicManager, Guild guild) {
this.volume = musicManager.getPlayer().getVolume();
this.guildId = guild.getIdLong();
VoiceChannel channel = LavalinkManager.LavalinkManagerHolder.lavalink.getConnectedChannel(guild);
voiceChannelId = channel != null ? channel.getIdLong() : 0L;
messageChannelId = musicManager.getLastActiveMessage() != null ?
musicManager.getLastActiveMessage().getChannel().getIdLong() : 0L;
AudioTrack playingTrack = musicManager.getPlayer().getPlayingTrack();
AudioTrackContainer container = musicManager.getScheduler().getAudioTrackContainer();
this.playingTrack = playingTrack == null ? null : new AudioCache(
playingTrack.getInfo().uri,
container != null ? container.getRequester().getIdLong() : 0L,
playingTrack.getPosition()
);
musicManager.getScheduler().getQueue().stream()
.map(AudioCache::new)
.forEach(queue::add);
}
内容来源于网络,如有侵权,请联系作者删除!