Search in sources :

Example 1 with HealthStat

use of org.apache.helix.model.HealthStat in project helix by apache.

the class ParticipantHealthReportCollectorImpl method transmitHealthReports.

@Override
public synchronized void transmitHealthReports() {
    synchronized (_healthReportProviderList) {
        for (HealthReportProvider provider : _healthReportProviderList) {
            try {
                Map<String, String> report = provider.getRecentHealthReport();
                Map<String, Map<String, String>> partitionReport = provider.getRecentPartitionHealthReport();
                ZNRecord record = new ZNRecord(provider.getReportName());
                if (report != null) {
                    record.setSimpleFields(report);
                }
                if (partitionReport != null) {
                    record.setMapFields(partitionReport);
                }
                record.setSimpleField(HealthStat.TIMESTAMP_NAME, "" + System.currentTimeMillis());
                HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
                Builder keyBuilder = accessor.keyBuilder();
                if (!accessor.setProperty(keyBuilder.healthReport(_instanceName, record.getId()), new HealthStat(record))) {
                    LOG.error("Failed to persist health report to zk!");
                }
                provider.resetStats();
            } catch (Exception e) {
                LOG.error("fail to transmit health report", e);
            }
        }
    }
}
Also used : HelixDataAccessor(org.apache.helix.HelixDataAccessor) Builder(org.apache.helix.PropertyKey.Builder) Map(java.util.Map) HealthStat(org.apache.helix.model.HealthStat) ZNRecord(org.apache.helix.ZNRecord)

Example 2 with HealthStat

use of org.apache.helix.model.HealthStat in project helix by apache.

the class ParticipantHealthReportCollectorImpl method reportHealthReportMessage.

@Override
public void reportHealthReportMessage(ZNRecord healthCheckInfoUpdate) {
    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
    Builder keyBuilder = accessor.keyBuilder();
    if (!accessor.setProperty(keyBuilder.healthReport(_instanceName, healthCheckInfoUpdate.getId()), new HealthStat(healthCheckInfoUpdate))) {
        LOG.error("Failed to persist health report to zk!");
    }
}
Also used : HelixDataAccessor(org.apache.helix.HelixDataAccessor) Builder(org.apache.helix.PropertyKey.Builder) HealthStat(org.apache.helix.model.HealthStat)

Aggregations

HelixDataAccessor (org.apache.helix.HelixDataAccessor)2 Builder (org.apache.helix.PropertyKey.Builder)2 HealthStat (org.apache.helix.model.HealthStat)2 Map (java.util.Map)1 ZNRecord (org.apache.helix.ZNRecord)1