Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.trino.spi.exchange.ExchangeManager;
import io.trino.spi.exchange.ExchangeManagerFactory;

import javax.annotation.PreDestroy;
import javax.inject.Inject;

import java.io.File;
Expand Down Expand Up @@ -106,6 +107,19 @@ public ExchangeManager getExchangeManager()
return exchangeManager;
}

@PreDestroy
public void shutdown()
{
try {
if (this.exchangeManager != null) {
exchangeManager.shutdown();
}
}
catch (Throwable t) {
log.error(t, "Error shutting down exchange manager: %s", exchangeManager);
}
}

private static Map<String, String> loadProperties(File configFile)
{
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,13 @@ public interface ExchangeManager
* @return {@link ExchangeSource} used by the engine to read data from an exchange
*/
ExchangeSource createSource();

/**
* Shutdown the exchange manager by releasing any held resources such as
* threads, sockets, etc. This method will only be called when no
* queries are using the exchange manager. After this method is called,
* no methods will be called on the exchange manager or any objects obtained
* from exchange manager.
*/
default void shutdown() {}
}