@Test public void testDifferentStateModelDefs() { AmbryStateModelFactory factory = new AmbryStateModelFactory(config, new PartitionStateChangeListener() { @Override public void onPartitionBecomeBootstrapFromOffline(String partitionName) { } @Override public void onPartitionBecomeStandbyFromBootstrap(String partitionName) { } @Override public void onPartitionBecomeLeaderFromStandby(String partitionName) { } @Override public void onPartitionBecomeStandbyFromLeader(String partitionName) { } @Override public void onPartitionBecomeInactiveFromStandby(String partitionName) { } @Override public void onPartitionBecomeOfflineFromInactive(String partitionName) { } @Override public void onPartitionBecomeDroppedFromOffline(String partitionName) { } }); StateModel stateModel; switch (config.clustermapStateModelDefinition) { case ClusterMapConfig.OLD_STATE_MODEL_DEF: stateModel = factory.createNewStateModel("0", "1"); assertTrue("Unexpected state model def", stateModel instanceof DefaultLeaderStandbyStateModel); break; case ClusterMapConfig.AMBRY_STATE_MODEL_DEF: stateModel = factory.createNewStateModel("0", "1"); assertTrue("Unexpected state model def", stateModel instanceof AmbryPartitionStateModel); break; default: } }
@Override public StateModel createNewStateModel(String resourceName, String partitionName) { StateModel stateModelToReturn; switch (clustermapConfig.clustermapStateModelDefinition) { case AmbryStateModelDefinition.AMBRY_LEADER_STANDBY_MODEL: stateModelToReturn = new AmbryPartitionStateModel(resourceName, partitionName, partitionStateChangeListener, clustermapConfig); break; case LeaderStandbySMD.name: stateModelToReturn = new DefaultLeaderStandbyStateModel(); break; default: throw new IllegalArgumentException( "Unsupported state model definition: " + clustermapConfig.clustermapStateModelDefinition); } return stateModelToReturn; }
AmbryStateModelFactory extends StateModelFactory<StateModel> { @Override public StateModel createNewStateModel(String resourceName, String partitionName) { StateModel stateModelToReturn; switch (clustermapConfig.clustermapStateModelDefinition) { case AmbryStateModelDefinition.AMBRY_LEADER_STANDBY_MODEL: stateModelToReturn = new AmbryPartitionStateModel(resourceName, partitionName, partitionStateChangeListener, clustermapConfig); break; case LeaderStandbySMD.name: stateModelToReturn = new DefaultLeaderStandbyStateModel(); break; default: throw new IllegalArgumentException( "Unsupported state model definition: " + clustermapConfig.clustermapStateModelDefinition); } return stateModelToReturn; } }
AmbryStateModelFactory extends StateModelFactory<StateModel> { @Override public StateModel createNewStateModel(String resourceName, String partitionName) { StateModel stateModelToReturn; switch (clustermapConfig.clustermapStateModelDefinition) { case AmbryStateModelDefinition.AMBRY_LEADER_STANDBY_MODEL: stateModelToReturn = new AmbryPartitionStateModel(resourceName, partitionName, partitionStateChangeListener, clustermapConfig); break; case LeaderStandbySMD.name: stateModelToReturn = new DefaultLeaderStandbyStateModel(); break; default: throw new IllegalArgumentException( "Unsupported state model definition: " + clustermapConfig.clustermapStateModelDefinition); } return stateModelToReturn; } AmbryStateModelFactory(ClusterMapConfig clusterMapConfig, PartitionStateChangeListener partitionStateChangeListener); }
AmbryStateModelFactory extends StateModelFactory<StateModel> { @Override public StateModel createNewStateModel(String resourceName, String partitionName) { StateModel stateModelToReturn; switch (clustermapConfig.clustermapStateModelDefinition) { case AmbryStateModelDefinition.AMBRY_LEADER_STANDBY_MODEL: stateModelToReturn = new AmbryPartitionStateModel(resourceName, partitionName, partitionStateChangeListener, clustermapConfig); break; case LeaderStandbySMD.name: stateModelToReturn = new DefaultLeaderStandbyStateModel(); break; default: throw new IllegalArgumentException( "Unsupported state model definition: " + clustermapConfig.clustermapStateModelDefinition); } return stateModelToReturn; } AmbryStateModelFactory(ClusterMapConfig clusterMapConfig, PartitionStateChangeListener partitionStateChangeListener); @Override StateModel createNewStateModel(String resourceName, String partitionName); }
AmbryStateModelFactory extends StateModelFactory<StateModel> { @Override public StateModel createNewStateModel(String resourceName, String partitionName) { StateModel stateModelToReturn; switch (clustermapConfig.clustermapStateModelDefinition) { case AmbryStateModelDefinition.AMBRY_LEADER_STANDBY_MODEL: stateModelToReturn = new AmbryPartitionStateModel(resourceName, partitionName, partitionStateChangeListener, clustermapConfig); break; case LeaderStandbySMD.name: stateModelToReturn = new DefaultLeaderStandbyStateModel(); break; default: throw new IllegalArgumentException( "Unsupported state model definition: " + clustermapConfig.clustermapStateModelDefinition); } return stateModelToReturn; } AmbryStateModelFactory(ClusterMapConfig clusterMapConfig, PartitionStateChangeListener partitionStateChangeListener); @Override StateModel createNewStateModel(String resourceName, String partitionName);  }