mirror of https://github.com/apache/nifi.git
NIFI-8430: Close Atlas client in order to free up resources
This closes #5002 Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
parent
8c66049d1d
commit
2fb05cd8dc
|
@ -74,7 +74,7 @@ import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_INPUT_PORT;
|
|||
import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_OUTPUT_PORT;
|
||||
import static org.apache.nifi.atlas.NiFiTypes.TYPE_NIFI_QUEUE;
|
||||
|
||||
public class NiFiAtlasClient {
|
||||
public class NiFiAtlasClient implements AutoCloseable {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(NiFiAtlasClient.class);
|
||||
|
||||
|
@ -84,6 +84,11 @@ public class NiFiAtlasClient {
|
|||
this.atlasClient = atlasClient;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
atlasClient.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an utility method to delete unused types.
|
||||
* Should be used during development or testing only.
|
||||
|
|
|
@ -814,7 +814,7 @@ public class ReportLineageToAtlas extends AbstractReportingTask {
|
|||
// If standalone or being primary node in a NiFi cluster, this node is responsible for doing primary tasks.
|
||||
final boolean isResponsibleForPrimaryTasks = !isClustered || getNodeTypeProvider().isPrimary();
|
||||
|
||||
final NiFiAtlasClient atlasClient = createNiFiAtlasClient(context);
|
||||
try (final NiFiAtlasClient atlasClient = createNiFiAtlasClient(context)) {
|
||||
|
||||
// Create Entity defs in Atlas if there's none yet.
|
||||
if (!isTypeDefCreated) {
|
||||
|
@ -853,7 +853,7 @@ public class ReportLineageToAtlas extends AbstractReportingTask {
|
|||
// then the notification message will fail due to having a reference to a non-existing entity.
|
||||
nifiAtlasHook.setAtlasClient(atlasClient);
|
||||
consumeNiFiProvenanceEvents(context, nifiFlow);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private NiFiFlow createNiFiFlow(ReportingContext context, NiFiAtlasClient atlasClient) {
|
||||
|
|
Loading…
Reference in New Issue