4242import io .trino .spi .QueryId ;
4343import io .trino .spi .TrinoException ;
4444import io .trino .spi .memory .MemoryPoolInfo ;
45+ import io .trino .util .Streamable ;
4546import jakarta .annotation .PreDestroy ;
4647import org .weakref .jmx .JmxException ;
4748import org .weakref .jmx .MBeanExporter ;
6061import java .util .concurrent .atomic .AtomicLong ;
6162import java .util .function .Consumer ;
6263import java .util .function .Function ;
63- import java .util .function .Supplier ;
6464import java .util .stream .Stream ;
6565
6666import static com .google .common .base .Preconditions .checkState ;
@@ -174,7 +174,7 @@ public synchronized void addChangeListener(Consumer<MemoryPoolInfo> listener)
174174 changeListeners .add (listener );
175175 }
176176
177- public synchronized void process (Supplier < Stream < QueryExecution > > allQueries , Function <QueryId , Optional <QueryExecution >> executionInfoSupplier )
177+ public synchronized void process (Streamable < QueryExecution > allQueries , Function <QueryId , Optional <QueryExecution >> executionInfoSupplier )
178178 {
179179 // TODO revocable memory reservations can also leak and may need to be detected in the future
180180 // We are only concerned about the leaks in the memory pool.
@@ -186,7 +186,7 @@ public synchronized void process(Supplier<Stream<QueryExecution>> allQueries, Fu
186186 long totalUserMemoryBytes = 0L ;
187187 long totalMemoryBytes = 0L ;
188188 int queriesCount = 0 ;
189- Iterator <QueryExecution > iterator = allQueries .get ()
189+ Iterator <QueryExecution > iterator = allQueries .stream ()
190190 .filter (query -> query .getState () == QueryState .RUNNING )
191191 .iterator ();
192192
@@ -233,7 +233,7 @@ public synchronized void process(Supplier<Stream<QueryExecution>> allQueries, Fu
233233
234234 if (!lowMemoryKillers .isEmpty () && outOfMemory && !queryKilled ) {
235235 if (isLastKillTargetGone ()) {
236- callOomKiller (allQueries .get (), executionInfoSupplier );
236+ callOomKiller (allQueries .stream (), executionInfoSupplier );
237237 }
238238 else {
239239 log .debug ("Last killed target is still not gone: %s" , lastKillTarget );
0 commit comments