Search in sources :

Example 1 with AmbryHealthReport

use of com.github.ambry.server.AmbryHealthReport in project ambry by linkedin.

the class HelixParticipant method initialize.

/**
 * Initialize the participant by registering via the {@link HelixManager} as a participant to the associated Helix
 * cluster.
 * @param hostName the hostname to use when registering as a participant.
 * @param port the port to use when registering as a participant.
 * @param ambryHealthReports {@link List} of {@link AmbryHealthReport} to be registered to the participant.
 * @throws IOException if there is an error connecting to the Helix cluster.
 */
@Override
public void initialize(String hostName, int port, List<AmbryHealthReport> ambryHealthReports) throws IOException {
    logger.info("Initializing participant");
    instanceName = ClusterMapUtils.getInstanceName(hostName, port);
    manager = helixFactory.getZKHelixManager(clusterName, instanceName, InstanceType.PARTICIPANT, zkConnectStr);
    StateMachineEngine stateMachineEngine = manager.getStateMachineEngine();
    stateMachineEngine.registerStateModelFactory(LeaderStandbySMD.name, new AmbryStateModelFactory());
    registerHealthReportTasks(stateMachineEngine, ambryHealthReports);
    try {
        manager.connect();
    } catch (Exception e) {
        throw new IOException("Exception while connecting to the Helix manager", e);
    }
    for (AmbryHealthReport ambryHealthReport : ambryHealthReports) {
        manager.getHealthReportCollector().addHealthReportProvider((HealthReportProvider) ambryHealthReport);
    }
}
Also used : StateMachineEngine(org.apache.helix.participant.StateMachineEngine) IOException(java.io.IOException) IOException(java.io.IOException) JSONException(org.json.JSONException) AmbryHealthReport(com.github.ambry.server.AmbryHealthReport)

Aggregations

AmbryHealthReport (com.github.ambry.server.AmbryHealthReport)1 IOException (java.io.IOException)1 StateMachineEngine (org.apache.helix.participant.StateMachineEngine)1 JSONException (org.json.JSONException)1