use of com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert in project kylo by Teradata.
the class ActivemqServiceStatusCheck method activemqStatus.
/**
* Check if Activemq is running
*
* @return Status of Activemq
*/
private ServiceComponent activemqStatus() {
String componentName = "Activemq";
String serviceName = SERVICE_NAME;
ServiceComponent component = null;
Connection activemqConnection = null;
/**
* Prepare Alert Message
*/
ServiceAlert alert = null;
alert = new DefaultServiceAlert();
alert.setLabel(componentName);
alert.setServiceName(serviceName);
alert.setComponentName(componentName);
String finalServiceMessage = "";
try {
if (this.activemqPoolConnection != null) {
/**
* Create Instance of Connection from Pool
*/
activemqConnection = this.activemqPoolConnection.createConnection();
/**
* On successful connection , return status to Kylo
*/
finalServiceMessage = "Activemq is running.";
alert.setMessage(finalServiceMessage);
alert.setState(ServiceAlert.STATE.OK);
component = new DefaultServiceComponent.Builder(componentName, ServiceComponent.STATE.UP).message(finalServiceMessage).addAlert(alert).build();
}
} catch (Exception jmsConnectionException) {
finalServiceMessage = "Activemq is down.";
alert.setMessage(finalServiceMessage);
alert.setState(ServiceAlert.STATE.CRITICAL);
component = new DefaultServiceComponent.Builder(componentName, ServiceComponent.STATE.DOWN).message(finalServiceMessage).exception(jmsConnectionException).addAlert(alert).build();
} finally {
if (activemqConnection != null)
try {
activemqConnection.close();
} catch (JMSException e) {
log.error("Unable to close activemq connection", e);
}
}
return component;
}
use of com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert in project kylo by Teradata.
the class AmbariServicesStatusCheck method transformAmbariAlert.
/**
* Transform the ambari alerts to Kylo service alerts
*/
private List<ServiceAlert> transformAmbariAlert(AlertSummary alertSummary) {
List<ServiceAlert> serviceAlerts = new ArrayList<>();
if (alertSummary != null) {
List<AlertItem> alertItems = alertSummary.getItems();
if (alertItems != null) {
for (AlertItem alertItem : alertItems) {
Alert alert = alertItem.getAlert();
ServiceAlert serviceAlert = new DefaultServiceAlert();
serviceAlert.setServiceName(alertItem.getAlert().getServiceName());
serviceAlert.setComponentName(alert.getComponentName());
serviceAlert.setFirstTimestamp(new Date(alert.getOriginalTimestamp()));
serviceAlert.setLatestTimestamp(new Date(alert.getLatestTimestamp()));
serviceAlert.setLabel(alert.getLabel());
serviceAlert.setMessage(alert.getText());
if (StringUtils.isNotBlank(alert.getState())) {
try {
serviceAlert.setState(ServiceAlert.STATE.valueOf(alert.getState()));
} catch (IllegalArgumentException e) {
serviceAlert.setState(ServiceAlert.STATE.UNKNOWN);
}
} else {
serviceAlert.setState(ServiceAlert.STATE.UNKNOWN);
}
serviceAlerts.add(serviceAlert);
}
}
}
return serviceAlerts;
}
use of com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert in project kylo by Teradata.
the class ClusterServiceStatusCheck method healthCheck.
public ServiceStatusResponse healthCheck() {
String serviceName = "Kylo Cluster";
String MEMBER_COUNT_PROPERTY = "member count";
String MEMBERS_PROPERTY = "members";
Map<String, Object> properties = new HashMap<>();
boolean isClustered = clusterService.isClustered();
boolean valid = true;
List<ServiceComponent> components = new ArrayList<>();
String serviceMessage = "";
List<ServiceAlert> serviceAlerts = new ArrayList<>();
if (isClustered) {
int memberCount = clusterService.getMembersAsString().size();
List<String> members = clusterService.getMembersAsString();
if (StringUtils.isNotBlank(expectedNodes)) {
try {
int expectedNodeCount = Integer.valueOf(expectedNodes);
if (expectedNodeCount != memberCount) {
valid = false;
serviceMessage = "Error. Missing " + (expectedNodeCount - memberCount) + " nodes. ";
} else {
serviceMessage = " All " + expectedNodeCount + " nodes are connected. ";
}
} catch (NumberFormatException e) {
valid = false;
serviceMessage = " Unable to validate the expected kylo node count. Ensure the 'kylo.cluster.nodeCount' property is set to a valid number.";
}
}
final boolean isValid = valid;
final String finalServiceMessage = serviceMessage;
members.stream().forEach(member -> {
String componentName = member;
boolean currentlyConnected = member.equalsIgnoreCase(clusterService.getAddressAsString());
properties.put(MEMBER_COUNT_PROPERTY, memberCount);
properties.put(MEMBERS_PROPERTY, members.toString());
String message = "There are " + memberCount + " members in the cluster. ";
if (currentlyConnected) {
message = "Currently connected to this node. " + message;
}
ServiceAlert alert = null;
if (isValid) {
message = finalServiceMessage + message;
} else {
alert = new DefaultServiceAlert();
alert.setLabel(componentName);
alert.setServiceName(serviceName);
alert.setComponentName(componentName);
alert.setMessage(finalServiceMessage);
alert.setState(ServiceAlert.STATE.CRITICAL);
}
ServiceComponent component = new DefaultServiceComponent.Builder(componentName, isValid ? ServiceComponent.STATE.UP : ServiceComponent.STATE.DOWN).message(message).properties(properties).addAlert(alert).build();
components.add(component);
});
} else {
serviceMessage = "Kylo is not configured to be running as a cluster";
ServiceComponent component = new DefaultServiceComponent.Builder(serviceName, ServiceComponent.STATE.UP).message(serviceMessage).properties(properties).build();
components.add(component);
}
return new DefaultServiceStatusResponse(serviceName, components);
}
use of com.thinkbiganalytics.servicemonitor.model.DefaultServiceAlert in project kylo by Teradata.
the class ClouderaServicesStatusCheck method apiHealthCheckToServiceAlert.
private ServiceAlert apiHealthCheckToServiceAlert(String componentName, ApiHealthCheck healthCheck) {
ServiceAlert alert = new DefaultServiceAlert();
alert.setComponentName(componentName);
alert.setLabel(healthCheck.getName());
alert.setMessage(healthCheck.getSummary().name());
alert.setState(apiHealthSummaryAlertState(healthCheck.getSummary()));
return alert;
}
Aggregations