@Test public void testBadCases() { props.setProperty("clustermap.state.model.definition", "InvalidStateModelDef"); try { new ClusterMapConfig(new VerifiableProperties(props)); fail("should fail due to invalid state model definition"); } catch (IllegalArgumentException e) { props.setProperty("clustermap.state.model.definition", stateModelDef); } ClusterMapConfig clusterMapConfig = new ClusterMapConfig(new VerifiableProperties(props)); helixManagerFactory.getHelixManager(InstanceType.PARTICIPANT).beBad = true; HelixParticipant helixParticipant = new HelixParticipant(clusterMapConfig, helixManagerFactory, new MetricRegistry(), getDefaultZkConnectStr(clusterMapConfig), true); try { helixParticipant.participate(Collections.emptyList(), null); fail("Participation should have failed"); } catch (IOException e) { } props.setProperty("clustermap.cluster.name", ""); clusterMapConfig = new ClusterMapConfig(new VerifiableProperties(props)); try { new HelixParticipant(clusterMapConfig, helixManagerFactory, new MetricRegistry(), getDefaultZkConnectStr(clusterMapConfig), true); fail("Instantiation should have failed"); } catch (IllegalStateException e) { } props.setProperty("clustermap.cluster.name", "HelixParticipantTestCluster"); props.setProperty("clustermap.dcs.zk.connect.strings", ""); clusterMapConfig = new ClusterMapConfig(new VerifiableProperties(props)); try { new HelixClusterAgentsFactory(clusterMapConfig, new MetricRegistry()).getClusterParticipants(); fail("Instantiation should have failed"); } catch (IOException e) { } }
@Override public void participate(List<AmbryHealthReport> ambryHealthReports, Callback<StatsSnapshot> callback) throws IOException { logger.info("Initiating the participation. The specified state model is {}", clusterMapConfig.clustermapStateModelDefinition); StateMachineEngine stateMachineEngine = manager.getStateMachineEngine(); stateMachineEngine.registerStateModelFactory(clusterMapConfig.clustermapStateModelDefinition, new AmbryStateModelFactory(clusterMapConfig, this)); registerHealthReportTasks(stateMachineEngine, ambryHealthReports, callback); 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); } logger.info("Completed participation in cluster {} at {}", clusterName, zkConnectStr); }
HelixParticipant implements ClusterParticipant, PartitionStateChangeListener { @Override public void participate(List<AmbryHealthReport> ambryHealthReports, Callback<StatsSnapshot> callback) throws IOException { logger.info("Initiating the participation. The specified state model is {}", clusterMapConfig.clustermapStateModelDefinition); StateMachineEngine stateMachineEngine = manager.getStateMachineEngine(); stateMachineEngine.registerStateModelFactory(clusterMapConfig.clustermapStateModelDefinition, new AmbryStateModelFactory(clusterMapConfig, this)); registerHealthReportTasks(stateMachineEngine, ambryHealthReports, callback); 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); } logger.info("Completed participation in cluster {} at {}", clusterName, zkConnectStr); } }
HelixParticipant implements ClusterParticipant, PartitionStateChangeListener { @Override public void participate(List<AmbryHealthReport> ambryHealthReports, Callback<StatsSnapshot> callback) throws IOException { logger.info("Initiating the participation. The specified state model is {}", clusterMapConfig.clustermapStateModelDefinition); StateMachineEngine stateMachineEngine = manager.getStateMachineEngine(); stateMachineEngine.registerStateModelFactory(clusterMapConfig.clustermapStateModelDefinition, new AmbryStateModelFactory(clusterMapConfig, this)); registerHealthReportTasks(stateMachineEngine, ambryHealthReports, callback); 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); } logger.info("Completed participation in cluster {} at {}", clusterName, zkConnectStr); } HelixParticipant(ClusterMapConfig clusterMapConfig, HelixFactory helixFactory, MetricRegistry metricRegistry,
      String zkConnectStr, boolean isSoleParticipant); }
HelixParticipant implements ClusterParticipant, PartitionStateChangeListener { @Override public void participate(List<AmbryHealthReport> ambryHealthReports, Callback<StatsSnapshot> callback) throws IOException { logger.info("Initiating the participation. The specified state model is {}", clusterMapConfig.clustermapStateModelDefinition); StateMachineEngine stateMachineEngine = manager.getStateMachineEngine(); stateMachineEngine.registerStateModelFactory(clusterMapConfig.clustermapStateModelDefinition, new AmbryStateModelFactory(clusterMapConfig, this)); registerHealthReportTasks(stateMachineEngine, ambryHealthReports, callback); 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); } logger.info("Completed participation in cluster {} at {}", clusterName, zkConnectStr); } HelixParticipant(ClusterMapConfig clusterMapConfig, HelixFactory helixFactory, MetricRegistry metricRegistry,
      String zkConnectStr, boolean isSoleParticipant); @Override void setInitialLocalPartitions(Collection<String> localPartitions); @Override void participate(List<AmbryHealthReport> ambryHealthReports, Callback<StatsSnapshot> callback); @Override void registerPartitionStateChangeListener(StateModelListenerType listenerType,
      PartitionStateChangeListener partitionStateChangeListener); @Override boolean setReplicaSealedState(ReplicaId replicaId, boolean isSealed); @Override boolean setReplicaStoppedState(List<ReplicaId> replicaIds, boolean markStop); @Override void close(); @Override List<String> getSealedReplicas(); @Override List<String> getStoppedReplicas(); @Override List<String> getDisabledReplicas(); @Override ReplicaSyncUpManager getReplicaSyncUpManager(); @Override boolean updateDataNodeInfoInCluster(ReplicaId replicaId, boolean shouldExist); @Override Map<StateModelListenerType, PartitionStateChangeListener> getPartitionStateChangeListeners(); @Override void setReplicaDisabledState(ReplicaId replicaId, boolean disable); @Override boolean resetPartitionState(String partitionName); @Override boolean supportsStateChanges(); HelixAdmin getHelixAdmin(); @Override void onPartitionBecomeBootstrapFromOffline(String partitionName); @Override void onPartitionBecomeStandbyFromBootstrap(String partitionName); @Override void onPartitionBecomeLeaderFromStandby(String partitionName); @Override void onPartitionBecomeStandbyFromLeader(String partitionName); @Override void onPartitionBecomeInactiveFromStandby(String partitionName); @Override void onPartitionBecomeOfflineFromInactive(String partitionName); @Override void onPartitionBecomeDroppedFromOffline(String partitionName); @Override void onPartitionBecomeDroppedFromError(String partitionName); @Override void onPartitionBecomeOfflineFromError(String partitionName); @Override void onReset(String partitionName); }
HelixParticipant implements ClusterParticipant, PartitionStateChangeListener { @Override public void participate(List<AmbryHealthReport> ambryHealthReports, Callback<StatsSnapshot> callback) throws IOException { logger.info("Initiating the participation. The specified state model is {}", clusterMapConfig.clustermapStateModelDefinition); StateMachineEngine stateMachineEngine = manager.getStateMachineEngine(); stateMachineEngine.registerStateModelFactory(clusterMapConfig.clustermapStateModelDefinition, new AmbryStateModelFactory(clusterMapConfig, this)); registerHealthReportTasks(stateMachineEngine, ambryHealthReports, callback); 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); } logger.info("Completed participation in cluster {} at {}", clusterName, zkConnectStr); } HelixParticipant(ClusterMapConfig clusterMapConfig, HelixFactory helixFactory, MetricRegistry metricRegistry,
      String zkConnectStr, boolean isSoleParticipant); @Override void setInitialLocalPartitions(Collection<String> localPartitions); @Override void participate(List<AmbryHealthReport> ambryHealthReports, Callback<StatsSnapshot> callback); @Override void registerPartitionStateChangeListener(StateModelListenerType listenerType,
      PartitionStateChangeListener partitionStateChangeListener); @Override boolean setReplicaSealedState(ReplicaId replicaId, boolean isSealed); @Override boolean setReplicaStoppedState(List<ReplicaId> replicaIds, boolean markStop); @Override void close(); @Override List<String> getSealedReplicas(); @Override List<String> getStoppedReplicas(); @Override List<String> getDisabledReplicas(); @Override ReplicaSyncUpManager getReplicaSyncUpManager(); @Override boolean updateDataNodeInfoInCluster(ReplicaId replicaId, boolean shouldExist); @Override Map<StateModelListenerType, PartitionStateChangeListener> getPartitionStateChangeListeners(); @Override void setReplicaDisabledState(ReplicaId replicaId, boolean disable); @Override boolean resetPartitionState(String partitionName); @Override boolean supportsStateChanges(); HelixAdmin getHelixAdmin(); @Override void onPartitionBecomeBootstrapFromOffline(String partitionName); @Override void onPartitionBecomeStandbyFromBootstrap(String partitionName); @Override void onPartitionBecomeLeaderFromStandby(String partitionName); @Override void onPartitionBecomeStandbyFromLeader(String partitionName); @Override void onPartitionBecomeInactiveFromStandby(String partitionName); @Override void onPartitionBecomeOfflineFromInactive(String partitionName); @Override void onPartitionBecomeDroppedFromOffline(String partitionName); @Override void onPartitionBecomeDroppedFromError(String partitionName); @Override void onPartitionBecomeOfflineFromError(String partitionName); @Override void onReset(String partitionName);  }