use of org.apache.helix.participant.StateMachineEngine in project pinot by linkedin.
the class SegmentCompletionIntegrationTests method startFakeServer.
// Start a fake server that only implements helix part, does not consume any rows.
private void startFakeServer() throws Exception {
String hostName = NetUtil.getHostAddress();
_serverInstance = CommonConstants.Helix.PREFIX_OF_SERVER_INSTANCE + hostName + "_" + CommonConstants.Helix.DEFAULT_SERVER_NETTY_PORT;
_helixManager = HelixManagerFactory.getZKHelixManager(_clusterName, _serverInstance, InstanceType.PARTICIPANT, ZkStarter.DEFAULT_ZK_STR);
final StateMachineEngine stateMachineEngine = _helixManager.getStateMachineEngine();
_helixManager.connect();
ZkHelixPropertyStore<ZNRecord> zkPropertyStore = ZkUtils.getZkPropertyStore(_helixManager, _clusterName);
final StateModelFactory<?> stateModelFactory = new FakeServerSegmentStateModelFactory(_clusterName, _serverInstance, zkPropertyStore);
stateMachineEngine.registerStateModelFactory(SegmentOnlineOfflineStateModelFactory.getStateModelName(), stateModelFactory);
_helixAdmin = _helixManager.getClusterManagmentTool();
_helixAdmin.addInstanceTag(_clusterName, _serverInstance, TableNameBuilder.REALTIME_TABLE_NAME_BUILDER.forTable(ControllerTenantNameBuilder.DEFAULT_TENANT_NAME));
ControllerLeaderLocator.create(_helixManager);
}
use of org.apache.helix.participant.StateMachineEngine 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);
}
}
use of org.apache.helix.participant.StateMachineEngine in project bookkeeper by apache.
the class HelixStorageContainerManager method doStart.
@Override
protected void doStart() {
// create the controller
try (HelixStorageController controller = new HelixStorageController(zkServers)) {
controller.addNode(clusterName, endpoint, endpointName);
}
StateMachineEngine sme = this.manager.getStateMachineEngine();
StateModelFactory<StateModel> smFactory = new WriteReadStateModelFactory(registry);
sme.registerStateModelFactory(WriteReadSMD.NAME, smFactory);
try {
manager.connect();
manager.addExternalViewChangeListener(rtProvider);
} catch (Exception e) {
throw new StorageRuntimeException(e);
}
}
use of org.apache.helix.participant.StateMachineEngine in project helix by apache.
the class HelixControllerMain method startHelixController.
public static HelixManager startHelixController(final String zkConnectString, final String clusterName, final String controllerName, final String controllerMode) {
HelixManager manager = null;
try {
if (controllerMode.equalsIgnoreCase(STANDALONE)) {
manager = HelixManagerFactory.getZKHelixManager(clusterName, controllerName, InstanceType.CONTROLLER, zkConnectString);
manager.connect();
} else if (controllerMode.equalsIgnoreCase(DISTRIBUTED)) {
manager = HelixManagerFactory.getZKHelixManager(clusterName, controllerName, InstanceType.CONTROLLER_PARTICIPANT, zkConnectString);
DistClusterControllerStateModelFactory stateModelFactory = new DistClusterControllerStateModelFactory(zkConnectString);
StateMachineEngine stateMach = manager.getStateMachineEngine();
stateMach.registerStateModelFactory("LeaderStandby", stateModelFactory);
manager.connect();
} else {
logger.error("cluster controller mode:" + controllerMode + " NOT supported");
}
} catch (Exception e) {
logger.error("Exception while starting controller", e);
}
return manager;
}
use of org.apache.helix.participant.StateMachineEngine in project helix by apache.
the class DummyParticipant method main.
public static void main(String[] args) {
if (args.length < 3) {
System.err.println("USAGE: DummyParticipant zkAddress clusterName instanceName");
System.exit(1);
}
String zkAddr = args[0];
String clusterName = args[1];
String instanceName = args[2];
HelixManager manager = null;
try {
manager = HelixManagerFactory.getZKHelixManager(clusterName, instanceName, InstanceType.PARTICIPANT, zkAddr);
StateMachineEngine stateMach = manager.getStateMachineEngine();
DummyMSModelFactory msModelFactory = new DummyMSModelFactory();
stateMach.registerStateModelFactory("MasterSlave", msModelFactory);
manager.connect();
Thread.currentThread().join();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (manager != null) {
manager.disconnect();
}
}
}
Aggregations