本文整理汇总了Java中org.apache.helix.HelixManager.getStateMachineEngine方法的典型用法代码示例。如果您正苦于以下问题:Java HelixManager.getStateMachineEngine方法的具体用法?Java HelixManager.getStateMachineEngine怎么用?Java HelixManager.getStateMachineEngine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.helix.HelixManager
的用法示例。
在下文中一共展示了HelixManager.getStateMachineEngine方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addFakeBrokerInstancesToAutoJoinHelixCluster
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
public static void addFakeBrokerInstancesToAutoJoinHelixCluster(String helixClusterName, String zkServer, int numInstances, boolean isSingleTenant) throws Exception {
for (int i = 0; i < numInstances; ++i) {
final String brokerId = "Broker_localhost_" + i;
final HelixManager helixZkManager =
HelixManagerFactory.getZKHelixManager(helixClusterName, brokerId, InstanceType.PARTICIPANT, zkServer);
final StateMachineEngine stateMachineEngine = helixZkManager.getStateMachineEngine();
final StateModelFactory<?> stateModelFactory = new EmptyBrokerOnlineOfflineStateModelFactory();
stateMachineEngine.registerStateModelFactory(EmptyBrokerOnlineOfflineStateModelFactory.getStateModelDef(),
stateModelFactory);
helixZkManager.connect();
if (isSingleTenant) {
helixZkManager.getClusterManagmentTool().addInstanceTag(helixClusterName, brokerId, ControllerTenantNameBuilder.getBrokerTenantNameForTenant(ControllerTenantNameBuilder.DEFAULT_TENANT_NAME));
} else {
helixZkManager.getClusterManagmentTool().addInstanceTag(helixClusterName, brokerId, UNTAGGED_BROKER_INSTANCE);
}
Thread.sleep(1000);
}
}
示例2: addFakeDataInstancesToAutoJoinHelixCluster
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
public static void addFakeDataInstancesToAutoJoinHelixCluster(String helixClusterName, String zkServer, int numInstances, boolean isSingleTenant) throws Exception {
for (int i = 0; i < numInstances; ++i) {
final String instanceId = "Server_localhost_" + i;
final HelixManager helixZkManager =
HelixManagerFactory.getZKHelixManager(helixClusterName, instanceId, InstanceType.PARTICIPANT, zkServer);
final StateMachineEngine stateMachineEngine = helixZkManager.getStateMachineEngine();
final StateModelFactory<?> stateModelFactory = new EmptySegmentOnlineOfflineStateModelFactory();
stateMachineEngine.registerStateModelFactory(EmptySegmentOnlineOfflineStateModelFactory.getStateModelDef(),
stateModelFactory);
helixZkManager.connect();
if (isSingleTenant) {
helixZkManager.getClusterManagmentTool().addInstanceTag(helixClusterName, instanceId,
TableNameBuilder.OFFLINE_TABLE_NAME_BUILDER.forTable(ControllerTenantNameBuilder.DEFAULT_TENANT_NAME));
helixZkManager.getClusterManagmentTool().addInstanceTag(helixClusterName, instanceId,
TableNameBuilder.REALTIME_TABLE_NAME_BUILDER.forTable(ControllerTenantNameBuilder.DEFAULT_TENANT_NAME));
} else {
helixZkManager.getClusterManagmentTool().addInstanceTag(helixClusterName, instanceId, UNTAGGED_SERVER_INSTANCE);
}
}
}
示例3: ParticipantManager
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
public ParticipantManager(HelixManager manager, ZkClient zkclient, int sessionTimeout,
LiveInstanceInfoProvider liveInstanceInfoProvider, List<PreConnectCallback> preConnectCallbacks) {
_zkclient = zkclient;
_manager = manager;
_clusterName = manager.getClusterName();
_instanceName = manager.getInstanceName();
_keyBuilder = new PropertyKey.Builder(_clusterName);
_sessionId = manager.getSessionId();
_sessionTimeout = sessionTimeout;
_configAccessor = manager.getConfigAccessor();
_instanceType = manager.getInstanceType();
_helixAdmin = manager.getClusterManagmentTool();
_dataAccessor = (ZKHelixDataAccessor) manager.getHelixDataAccessor();
_messagingService = (DefaultMessagingService) manager.getMessagingService();
_stateMachineEngine = manager.getStateMachineEngine();
_liveInstanceInfoProvider = liveInstanceInfoProvider;
_preConnectCallbacks = preConnectCallbacks;
}
示例4: start
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
public HelixManager start() throws Exception {
HelixManager manager = null;
// zk cluster manager
if (_clusterMangerType.equalsIgnoreCase("zk")) {
manager =
HelixManagerFactory.getZKHelixManager(_clusterName, _instanceName,
InstanceType.PARTICIPANT, _zkConnectString);
} else {
throw new IllegalArgumentException("Unsupported cluster manager type:" + _clusterMangerType);
}
MockOnlineOfflineStateModelFactory stateModelFactory2 =
new MockOnlineOfflineStateModelFactory(_transDelayInMs, _resourceName, _resourceTag,
_instanceName);
// genericStateMachineHandler = new StateMachineEngine();
StateMachineEngine stateMach = manager.getStateMachineEngine();
stateMach.registerStateModelFactory("OnlineOffline", stateModelFactory2);
manager.connect();
//manager.getMessagingService().registerMessageHandlerFactory(MessageType.STATE_TRANSITION.name(), genericStateMachineHandler);
return manager;
}
示例5: main
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
CommandLine cmd = processCommandLineArgs(args);
String zkAddress = cmd.getOptionValue(zkAddr);
String clusterName = cmd.getOptionValue(cluster);
String instance = cmd.getOptionValue(instanceName);
String stateModelName = cmd.getOptionValue(stateModel);
HelixManager manager =
new ZKHelixManager(clusterName, instance, InstanceType.PARTICIPANT, zkAddress);
StateMachineEngine stateMach = manager.getStateMachineEngine();
stateMach.registerStateModelFactory(stateModelName, new AgentStateModelFactory());
Runtime.getRuntime().addShutdownHook(new HelixAgentShutdownHook(manager));
try {
manager.connect();
Thread.currentThread().join();
} catch (Exception e) {
LOG.error(e.toString());
} finally {
if (manager != null && manager.isConnected()) {
manager.disconnect();
}
}
}
示例6: addFakeBrokerInstancesToAutoJoinHelixCluster
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
public static void addFakeBrokerInstancesToAutoJoinHelixCluster(String helixClusterName, String zkServer,
int numInstances, boolean isSingleTenant)
throws Exception {
for (int i = 0; i < numInstances; ++i) {
final String brokerId = "Broker_localhost_" + i;
final HelixManager helixZkManager =
HelixManagerFactory.getZKHelixManager(helixClusterName, brokerId, InstanceType.PARTICIPANT, zkServer);
final StateMachineEngine stateMachineEngine = helixZkManager.getStateMachineEngine();
final StateModelFactory<?> stateModelFactory = new EmptyBrokerOnlineOfflineStateModelFactory();
stateMachineEngine
.registerStateModelFactory(EmptyBrokerOnlineOfflineStateModelFactory.getStateModelDef(), stateModelFactory);
helixZkManager.connect();
if (isSingleTenant) {
helixZkManager.getClusterManagmentTool().addInstanceTag(helixClusterName, brokerId,
ControllerTenantNameBuilder.getBrokerTenantNameForTenant(ControllerTenantNameBuilder.DEFAULT_TENANT_NAME));
} else {
helixZkManager.getClusterManagmentTool().addInstanceTag(helixClusterName, brokerId, UNTAGGED_BROKER_INSTANCE);
}
}
}
示例7: main
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
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();
}
}
}
示例8: startHelixController
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
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;
}
示例9: start
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
public HelixManager start() throws Exception {
HelixManager manager = null;
// zk cluster manager
if (_clusterMangerType.equalsIgnoreCase("zk")) {
manager =
HelixManagerFactory.getZKHelixManager(_clusterName, _instanceName,
InstanceType.PARTICIPANT, _zkConnectString);
} else {
throw new IllegalArgumentException("Unsupported cluster manager type:" + _clusterMangerType);
}
stateModelFactory = new DummyStateModelFactory(_transDelayInMs);
DummyLeaderStandbyStateModelFactory stateModelFactory1 =
new DummyLeaderStandbyStateModelFactory(_transDelayInMs);
DummyOnlineOfflineStateModelFactory stateModelFactory2 =
new DummyOnlineOfflineStateModelFactory(_transDelayInMs);
// genericStateMachineHandler = new StateMachineEngine();
StateMachineEngine stateMach = manager.getStateMachineEngine();
stateMach.registerStateModelFactory("MasterSlave", stateModelFactory);
stateMach.registerStateModelFactory("LeaderStandby", stateModelFactory1);
stateMach.registerStateModelFactory("OnlineOffline", stateModelFactory2);
manager.connect();
// manager.getMessagingService().registerMessageHandlerFactory(MessageType.STATE_TRANSITION.name(),
// genericStateMachineHandler);
return manager;
}
示例10: initializeHelixManager
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
private HelixManager initializeHelixManager(String clusterName, String instanceName, String zkAddress,
String stateModelName)
{
HelixManager manager = HelixManagerFactory.getZKHelixManager(clusterName, instanceName,
InstanceType.PARTICIPANT, zkAddress);
MasterSlaveStateModelFactory stateModelFactory = new MasterSlaveStateModelFactory(instanceName);
StateMachineEngine stateMach = manager.getStateMachineEngine();
stateMach.registerStateModelFactory(stateModelName, stateModelFactory);
return manager;
}
示例11: addFakeDataInstancesToAutoJoinHelixCluster
import org.apache.helix.HelixManager; //导入方法依赖的package包/类
public static void addFakeDataInstancesToAutoJoinHelixCluster(String helixClusterName, String zkServer,
int numInstances, boolean isSingleTenant, int adminPort)
throws Exception {
for (int i = 0; i < numInstances; ++i) {
final String instanceId = "Server_localhost_" + i;
final HelixManager helixZkManager =
HelixManagerFactory.getZKHelixManager(helixClusterName, instanceId, InstanceType.PARTICIPANT, zkServer);
final StateMachineEngine stateMachineEngine = helixZkManager.getStateMachineEngine();
final StateModelFactory<?> stateModelFactory = new EmptySegmentOnlineOfflineStateModelFactory();
stateMachineEngine
.registerStateModelFactory(EmptySegmentOnlineOfflineStateModelFactory.getStateModelDef(), stateModelFactory);
helixZkManager.connect();
if (isSingleTenant) {
helixZkManager.getClusterManagmentTool()
.addInstanceTag(helixClusterName, instanceId,
TableNameBuilder.OFFLINE.tableNameWithType(ControllerTenantNameBuilder.DEFAULT_TENANT_NAME));
helixZkManager.getClusterManagmentTool()
.addInstanceTag(helixClusterName, instanceId,
TableNameBuilder.REALTIME.tableNameWithType(ControllerTenantNameBuilder.DEFAULT_TENANT_NAME));
} else {
helixZkManager.getClusterManagmentTool().addInstanceTag(helixClusterName, instanceId, UNTAGGED_SERVER_INSTANCE);
}
HelixConfigScope scope =
new HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.PARTICIPANT, helixClusterName)
.forParticipant(instanceId).build();
Map<String, String> props = new HashMap<>();
props.put(CommonConstants.Helix.Instance.ADMIN_PORT_KEY, String.valueOf(adminPort + i));
helixZkManager.getClusterManagmentTool().setConfig(scope, props);
}
}