• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java StateModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.helix.participant.statemachine.StateModel的典型用法代码示例。如果您正苦于以下问题:Java StateModel类的具体用法?Java StateModel怎么用?Java StateModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StateModel类属于org.apache.helix.participant.statemachine包,在下文中一共展示了StateModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: registerStateModelFactory

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
@Override
public boolean registerStateModelFactory(String stateModelName,
    StateModelFactory<? extends StateModel> factory, String factoryName) {
  if (stateModelName == null || factory == null || factoryName == null) {
    throw new HelixException("stateModelDef|stateModelFactory|factoryName cannot be null");
  }

  logger.info("Register state model factory for state model " + stateModelName
      + " using factory name " + factoryName + " with " + factory);

  if (!_stateModelFactoryMap.containsKey(stateModelName)) {
    _stateModelFactoryMap.put(stateModelName,
        new ConcurrentHashMap<String, StateModelFactory<? extends StateModel>>());
  }

  if (_stateModelFactoryMap.get(stateModelName).containsKey(factoryName)) {
    logger.warn("stateModelFactory for " + stateModelName + " using factoryName " + factoryName
        + " has already been registered.");
    return false;
  }

  _stateModelFactoryMap.get(stateModelName).put(factoryName, factory);
  sendNopMessage();
  return true;
}
 
开发者ID:apache,项目名称:helix,代码行数:26,代码来源:HelixStateMachineEngine.java


示例2: reset

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
@Override
public void reset() {
  for (Map<String, StateModelFactory<? extends StateModel>> ftyMap : _stateModelFactoryMap
      .values()) {
    for (StateModelFactory<? extends StateModel> stateModelFactory : ftyMap.values()) {
      for (String resourceName : stateModelFactory.getResourceSet()) {
        for (String partitionKey : stateModelFactory.getPartitionSet(resourceName)) {
          StateModel stateModel = stateModelFactory.getStateModel(resourceName, partitionKey);
          stateModel.reset();
          String initialState = _stateModelParser.getInitialState(stateModel.getClass());
          stateModel.updateState(initialState);
          // TODO probably should update the state on ZK. Shi confirm what needs
          // to be done here.
        }
      }
    }
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:19,代码来源:HelixStateMachineEngine.java


示例3: createNewStateModel

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
@Override
public StateModel createNewStateModel(String resourceName, String partitionName) {
  MasterSlaveStateModel stateModel = new MasterSlaveStateModel();
  stateModel.setInstanceName(_instanceName);
  stateModel.setDelay(_delay);
  stateModel.setPartitionName(partitionName);
  return stateModel;
}
 
开发者ID:apache,项目名称:helix,代码行数:9,代码来源:MasterSlaveStateModelFactory.java


示例4: createNewStateModel

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
@Override
public StateModel createNewStateModel(String resourceName, String stateUnitKey) {
  OnlineOfflineStateModel stateModel = new OnlineOfflineStateModel();
  stateModel.setDelay(_delay);
  stateModel.setInstanceName(_instanceName);
  return stateModel;
}
 
开发者ID:apache,项目名称:helix,代码行数:8,代码来源:OnlineOfflineStateModelFactory.java


示例5: createNewStateModel

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
@Override public StateModel createNewStateModel(String resourceName, String partitionName) {
  LeaderStandbyStateModel stateModel = new LeaderStandbyStateModel();
  stateModel.setDelay(_delay);
  stateModel.setInstanceName(_instanceName);
  stateModel.setPartitionName(partitionName);
  return stateModel;
}
 
开发者ID:apache,项目名称:helix,代码行数:8,代码来源:LeaderStandbyStateModelFactory.java


示例6: HelixStateMachineEngine

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
public HelixStateMachineEngine(HelixManager manager) {
  _stateModelParser = new StateModelParser();
  _manager = manager;

  _stateModelFactoryMap =
      new ConcurrentHashMap<String, Map<String, StateModelFactory<? extends StateModel>>>();
  _stateModelDefs = new ConcurrentHashMap<String, StateModelDefinition>();
}
 
开发者ID:apache,项目名称:helix,代码行数:9,代码来源:HelixStateMachineEngine.java


示例7: getStateModelFactory

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
@Override
public StateModelFactory<? extends StateModel> getStateModelFactory(String stateModelName,
    String factoryName) {
  if (!_stateModelFactoryMap.containsKey(stateModelName)) {
    return null;
  }
  return _stateModelFactoryMap.get(stateModelName).get(factoryName);
}
 
开发者ID:apache,项目名称:helix,代码行数:9,代码来源:HelixStateMachineEngine.java


示例8: HelixStateTransitionHandler

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
public HelixStateTransitionHandler(StateModelFactory<? extends StateModel> stateModelFactory,
    StateModel stateModel, Message message, NotificationContext context,
    CurrentState currentStateDelta) {
  super(message, context);
  _stateModel = stateModel;
  _statusUpdateUtil = new StatusUpdateUtil();
  _transitionMethodFinder = new StateModelParser();
  _currentStateDelta = currentStateDelta;
  _manager = _notificationContext.getManager();
  _stateModelFactory = stateModelFactory;
}
 
开发者ID:apache,项目名称:helix,代码行数:12,代码来源:HelixStateTransitionHandler.java


示例9: checkStateModelMap

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
/**
 * check state-model factory contains state-models same as in expect-state-model map
 * @param fty
 * @param expectStateModelMap
 */
static void checkStateModelMap(StateModelFactory<? extends StateModel> fty,
    Map<String, String> expectStateModelMap) {
  Assert.assertEquals(fty.getPartitionSet("TestDB0").size(), expectStateModelMap.size());
  for (String partition : fty.getPartitionSet("TestDB0")) {
    StateModel stateModel = fty.getStateModel("TestDB0", partition);
    String actualState = stateModel.getCurrentState();
    String expectState = expectStateModelMap.get(partition);
    LOG.debug(partition + " actual state: " + actualState + ", expect state: " + expectState);
    Assert.assertEquals(actualState, expectState, "partition: " + partition
        + " should be in state: " + expectState + " but was " + actualState);
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:18,代码来源:TestStateModelLeak.java


示例10: createNewStateModel

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
@Override
public StateModel createNewStateModel(String resourceName, String stateUnitKey) {
  TestOnlineOfflineStateModel stateModel = new TestOnlineOfflineStateModel(_instanceId);
  stateModel.setDelay(_delay);
  return stateModel;
}
 
开发者ID:uber,项目名称:uReplicator,代码行数:7,代码来源:TestOnlineOfflineStateModelFactory.java


示例11: createNewStateModel

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
@Override
public StateModel createNewStateModel(String resource, String stateModelUnit) {
  OnlineOfflineStateModel stateModel = new OnlineOfflineStateModel();
  return stateModel;
}
 
开发者ID:pinterest-attic,项目名称:terrapin,代码行数:6,代码来源:OnlineOfflineStateModelFactory.java


示例12: createNewStateModel

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
@Override
public StateModel createNewStateModel(String partitionName) {
  final EmptySegmentOnlineOfflineStateModel SegmentOnlineOfflineStateModel = new EmptySegmentOnlineOfflineStateModel();
  return SegmentOnlineOfflineStateModel;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:6,代码来源:EmptySegmentOnlineOfflineStateModelFactory.java


示例13: createNewStateModel

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
@Override
public StateModel createNewStateModel(String partitionName) {
  final EmptyBrokerOnlineOfflineStateModel SegmentOnlineOfflineStateModel = new EmptyBrokerOnlineOfflineStateModel();
  return SegmentOnlineOfflineStateModel;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:6,代码来源:EmptyBrokerOnlineOfflineStateModelFactory.java


示例14: createNewStateModel

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
@Override
public StateModel createNewStateModel(String resourceName) {
  return new BrokerResourceOnlineOfflineStateModel();
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:5,代码来源:BrokerResourceOnlineOfflineStateModelFactory.java


示例15: createNewStateModel

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
@Override
public StateModel createNewStateModel(String partitionName) {
  final SegmentOnlineOfflineStateModel SegmentOnlineOfflineStateModel =
      new SegmentOnlineOfflineStateModel(HELIX_CLUSTER_NAME, INSTANCE_ID);
  return SegmentOnlineOfflineStateModel;
}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:7,代码来源:SegmentOnlineOfflineStateModelFactory.java


示例16: createNewStateModel

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
@Override
public StateModel createNewStateModel(String resourceName, String stateUnitKey) {
  return new BootstrapStateModel(stateUnitKey);
}
 
开发者ID:apache,项目名称:helix,代码行数:5,代码来源:BootstrapHandler.java


示例17: removeStateModelFactory

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
@Override
public boolean removeStateModelFactory(String stateModelDef,
    StateModelFactory<? extends StateModel> factory) {
  throw new UnsupportedOperationException("Remove not yet supported");
}
 
开发者ID:apache,项目名称:helix,代码行数:6,代码来源:HelixStateMachineEngine.java


示例18: HelixStateTransitionCancellationHandler

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
public HelixStateTransitionCancellationHandler(StateModel stateModel, Message message,
    NotificationContext context) {
  super(message, context);
  _stateModel = stateModel;
}
 
开发者ID:apache,项目名称:helix,代码行数:6,代码来源:HelixStateTransitionCancellationHandler.java


示例19: testDrop

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
/**
 * test drop resource should remove all state models
 * @throws Exception
 */
@Test
public void testDrop() throws Exception {
  // Logger.getRootLogger().setLevel(Level.INFO);
  String className = TestHelper.getTestClassName();
  String methodName = TestHelper.getTestMethodName();
  String clusterName = className + "_" + methodName;
  int n = 2;

  System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));

  TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant port
      "localhost", // participant name prefix
      "TestDB", // resource name prefix
      1, // resources
      4, // partitions per resource
      n, // number of nodes
      2, // replicas
      "MasterSlave", true); // do rebalance

  // start controller
  ClusterControllerManager controller =
      new ClusterControllerManager(ZK_ADDR, clusterName, "controller");
  controller.syncStart();

  MockParticipantManager[] participants = new MockParticipantManager[n];
  for (int i = 0; i < n; i++) {
    final String instanceName = "localhost_" + (12918 + i);

    participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
    participants[i].syncStart();
  }

  boolean result =
      ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
          clusterName));
  Assert.assertTrue(result);

  // check state-models in state-machine
  HelixStateMachineEngine stateMachine =
      (HelixStateMachineEngine) participants[0].getStateMachineEngine();
  StateModelFactory<? extends StateModel> fty = stateMachine.getStateModelFactory("MasterSlave");
  Map<String, String> expectStateModelMap = new TreeMap<String, String>();
  expectStateModelMap.put("TestDB0_0", "SLAVE");
  expectStateModelMap.put("TestDB0_1", "MASTER");
  expectStateModelMap.put("TestDB0_2", "SLAVE");
  expectStateModelMap.put("TestDB0_3", "MASTER");
  checkStateModelMap(fty, expectStateModelMap);

  // drop resource
  HelixAdmin admin = new ZKHelixAdmin(_gZkClient);
  admin.dropResource(clusterName, "TestDB0");

  result =
      ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
          clusterName));
  Assert.assertTrue(result);

  // check state models have been dropped also
  Assert.assertTrue(fty.getPartitionSet("TestDB0").isEmpty(),
      "All state-models should be dropped, but was " + fty.getPartitionSet("TestDB0"));

  // cleanup
  controller.syncStop();
  for (int i = 0; i < n; i++) {
    participants[i].syncStop();
  }

  System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
 
开发者ID:apache,项目名称:helix,代码行数:74,代码来源:TestStateModelLeak.java


示例20: createNewStateModel

import org.apache.helix.participant.statemachine.StateModel; //导入依赖的package包/类
@Override
public StateModel createNewStateModel(String resourceName, String partitionName) {
  return new FakeSegmentStateModel();
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:5,代码来源:SegmentCompletionIntegrationTests.java



注:本文中的org.apache.helix.participant.statemachine.StateModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SettingsEditorGroup类代码示例发布时间:2022-05-22
下一篇:
Java RC2WrapEngine类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap