Kylo should provide a better error message when it cannot connect to Nifi
@@ -22,7 +22,6 @@ package com.thinkbiganalytics.feedmgr.nifi;
import com.thinkbiganalytics.nifi.rest.client.LegacyNifiRestClient;
-import org.apache.nifi.web.api.dto.AboutDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -59,11 +58,11 @@ public class NifiConnectionService {
}
private void notifyOnConnected() {
- connectionListeners.stream().forEach(nifiConnectionListener -> nifiConnectionListener.onNiFiConnected());
+ connectionListeners.forEach(NifiConnectionListener::onNiFiConnected);
}
private void notifyOnDisconnected() {
- connectionListeners.stream().forEach(nifiConnectionListener -> nifiConnectionListener.onNiFiDisconnected());
+ connectionListeners.forEach(NifiConnectionListener::onNiFiDisconnected);
}
/**
@@ -92,18 +91,13 @@ public class NifiConnectionService {
}
private boolean isConnected() {
- return isConnected(false);
- }
-
- private boolean isConnected(boolean logException) {
try {
- log.debug("Attempt to check isConnection get about entity for {} ", nifiRestClient);
- AboutDTO aboutEntity = nifiRestClient.getNiFiRestClient().about();
- return aboutEntity != null;
+ log.trace("Attempt to check isConnected, getting About entity for {} ", nifiRestClient);
+ nifiRestClient.getNiFiRestClient().about();
+ log.trace("Successfully connected to Nifi with client {} ", nifiRestClient);
+ return true;
} catch (Exception e) {
- if (logException) {
- log.error("Error assessing Nifi Connection {} ", e);
- }
+ log.trace("Error assessing Nifi: {} ", e);
}
return false;
}
@@ -111,11 +105,8 @@ public class NifiConnectionService {
private void initConnectionTimer() {
long millis = 5000L; //every 5 seconds check for a connection
- ScheduledExecutorService service = Executors
- .newSingleThreadScheduledExecutor();
- service.scheduleAtFixedRate(() -> {
- checkConnection();
- }, millis, millis, TimeUnit.MILLISECONDS);
+ ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
+ service.scheduleAtFixedRate(this::checkConnection, millis, millis, TimeUnit.MILLISECONDS);
}
