当前位置: 首页>>代码示例>>Java>>正文


Java ConfigAccessor类代码示例

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


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

示例1: onBecomeOnlineFromOffline

import org.apache.helix.ConfigAccessor; //导入依赖的package包/类
@Transition(to = "ONLINE", from = "OFFLINE")
public void onBecomeOnlineFromOffline(Message message, NotificationContext context)
    throws Exception {
  LOG.debug(_workerId + " becomes ONLINE from OFFLINE for " + _partition);
  ConfigAccessor clusterConfig = context.getManager().getConfigAccessor();
  HelixManager manager = context.getManager();
  HelixConfigScope clusterScope =
      new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(
          manager.getClusterName()).build();
  String json = clusterConfig.get(clusterScope, message.getResourceName());
  Dag.Node node = Dag.Node.fromJson(json);
  Set<String> parentIds = node.getParentIds();
  String resourceName = message.getResourceName();
  int numPartitions = node.getNumPartitions();
  Task task = _taskFactory.createTask(resourceName, parentIds, manager, _taskResultStore);
  manager.addExternalViewChangeListener(task);

  LOG.debug("Starting task for " + _partition + "...");
  int partitionNum = Integer.parseInt(_partition.split("_")[1]);
  task.execute(resourceName, numPartitions, partitionNum);
  LOG.debug("Task for " + _partition + " done");
}
 
开发者ID:apache,项目名称:helix,代码行数:23,代码来源:TaskStateModel.java

示例2: beforeSuite

import org.apache.helix.ConfigAccessor; //导入依赖的package包/类
@BeforeSuite
public void beforeSuite() throws Exception {
  if (!_init) {
    // TODO: use logging.properties file to config java.util.logging.Logger levels
    java.util.logging.Logger topJavaLogger = java.util.logging.Logger.getLogger("");
    topJavaLogger.setLevel(Level.WARNING);

    _gZkClient = new ZkClient(ZK_ADDR, ZkClient.DEFAULT_CONNECTION_TIMEOUT,
        ZkClient.DEFAULT_SESSION_TIMEOUT, new ZNRecordSerializer());
    _gZkClientTestNS = new ZkClient(_zkAddrTestNS, ZkClient.DEFAULT_CONNECTION_TIMEOUT, ZkClient.DEFAULT_SESSION_TIMEOUT,
        new ZNRecordSerializer());
    _gSetupTool = new ClusterSetup(_gZkClient);
    _configAccessor = new ConfigAccessor(_gZkClient);
    _baseAccessor = new ZkBaseDataAccessor<>(_gZkClient);
    _baseAccessorTestNS = new ZkBaseDataAccessor<>(_gZkClientTestNS);

    // wait for the web service to start
    Thread.sleep(100);

    setup();
    _init = true;
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:24,代码来源:AbstractTestClass.java

示例3: ZKHelixAdmin

import org.apache.helix.ConfigAccessor; //导入依赖的package包/类
public ZKHelixAdmin(String zkAddress) {
  int timeOutInSec = Integer.parseInt(System.getProperty(CONNECTION_TIMEOUT, "30"));
  _zkClient = new ZkClient(zkAddress, timeOutInSec * 1000);
  _zkClient.setZkSerializer(new ZNRecordSerializer());
  _zkClient.waitUntilConnected(timeOutInSec, TimeUnit.SECONDS);
  _configAccessor = new ConfigAccessor(_zkClient);
}
 
开发者ID:apache,项目名称:helix,代码行数:8,代码来源:ZKHelixAdmin.java

示例4: enableBatchMessageMode

import org.apache.helix.ConfigAccessor; //导入依赖的package包/类
@Override
public void enableBatchMessageMode(String clusterName, boolean enabled) {
  if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
    throw new HelixException("cluster " + clusterName + " is not setup yet");
  }
  ConfigAccessor accessor = new ConfigAccessor(_zkClient);

  ClusterConfig clusterConfig = accessor.getClusterConfig(clusterName);
  clusterConfig.setBatchMessageMode(enabled);
  accessor.setClusterConfig(clusterName, clusterConfig);
}
 
开发者ID:apache,项目名称:helix,代码行数:12,代码来源:ZKHelixAdmin.java

示例5: verifyExternalView

import org.apache.helix.ConfigAccessor; //导入依赖的package包/类
private boolean verifyExternalView(ClusterDataCache dataCache, ExternalView externalView,
    IdealState idealState) {
  Map<String, Map<String, String>> mappingInExtview = externalView.getRecord().getMapFields();
  Map<String, Map<String, String>> idealPartitionState;

  switch (idealState.getRebalanceMode()) {
  case FULL_AUTO:
    ClusterConfig clusterConfig = new ConfigAccessor(_zkClient).getClusterConfig(dataCache.getClusterName());
    if (!clusterConfig.isPersistBestPossibleAssignment() && !clusterConfig.isPersistIntermediateAssignment()) {
      throw new HelixException(String.format("Full-Auto IdealState verifier requires "
          + "ClusterConfig.PERSIST_BEST_POSSIBLE_ASSIGNMENT or ClusterConfig.PERSIST_INTERMEDIATE_ASSIGNMENT "
          + "is enabled."));
    }
    for (String partition : idealState.getPartitionSet()) {
      if (idealState.getPreferenceList(partition) == null || idealState.getPreferenceList(partition).isEmpty()) {
        return false;
      }
    }
    idealPartitionState = computeIdealPartitionState(dataCache, idealState);
    break;
  case SEMI_AUTO:
  case USER_DEFINED:
    idealPartitionState = computeIdealPartitionState(dataCache, idealState);
    break;
  case CUSTOMIZED:
    idealPartitionState = idealState.getRecord().getMapFields();
    break;
  case TASK:
    // ignore jobs
  default:
    return true;
  }

  return mappingInExtview.equals(idealPartitionState);
}
 
开发者ID:apache,项目名称:helix,代码行数:36,代码来源:StrictMatchExternalViewVerifier.java

示例6: beforeClass

import org.apache.helix.ConfigAccessor; //导入依赖的package包/类
@BeforeClass
public void beforeClass() throws Exception {
  _numDbs = 1;
  _numReplicas = 3;
  _numNodes = 5;
  _numParitions = 4;
  super.beforeClass();
  _accessor = new ConfigAccessor(_gZkClient);
}
 
开发者ID:apache,项目名称:helix,代码行数:10,代码来源:TestBatchEnableInstances.java

示例7: beforeClass

import org.apache.helix.ConfigAccessor; //导入依赖的package包/类
@Override
@BeforeClass
public void beforeClass() throws Exception {
  System.out.println("START " + CLASS_NAME + " at " + new Date(System.currentTimeMillis()));

  String namespace = "/" + CLUSTER_NAME;
  if (_gZkClient.exists(namespace)) {
    _gZkClient.deleteRecursive(namespace);
  }
  _setupTool = new ClusterSetup(_gZkClient);

  // setup storage cluster
  _setupTool.addCluster(CLUSTER_NAME, true);

  for (int i = 0; i < NODE_NR; i++) {
    String storageNodeName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
    _setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
  }

  // add dummy participants
  for (int i = 0; i < NODE_NR; i++) {
    String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
    MockParticipantManager participant =
        new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instanceName);
    participant.setTransition(new DelayedTransition());
    _participants[i] = participant;
  }

  _configAccessor = new ConfigAccessor(_gZkClient);

  // start controller
  String controllerName = CONTROLLER_PREFIX + "_0";
  _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
  _controller.syncStart();

  setupThrottleConfig();
}
 
开发者ID:apache,项目名称:helix,代码行数:38,代码来源:TestPartitionMovementThrottle.java

示例8: beforeClass

import org.apache.helix.ConfigAccessor; //导入依赖的package包/类
@BeforeClass
public void beforeClass() throws Exception {
  _numDbs = 3;
  _numParitions = 8;
  _numNodes = 4;
  _numReplicas = 2;
  super.beforeClass();
  _configAccessor = new ConfigAccessor(_gZkClient);
  _accessor = _manager.getHelixDataAccessor();
}
 
开发者ID:apache,项目名称:helix,代码行数:11,代码来源:TestTargetExternalView.java

示例9: beforeClass

import org.apache.helix.ConfigAccessor; //导入依赖的package包/类
@BeforeClass
public void beforeClass()
    throws InterruptedException {
  System.out.println(
      "START " + getShortClassName() + " at " + new Date(System.currentTimeMillis()));

  // setup storage cluster
  _gSetupTool.addCluster(CLUSTER_NAME, true);

  for (int i = 0; i < PARTICIPANT_NUMBER; i++) {
    String instance = PARTICIPANT_PREFIX + "_" + (PARTICIPANT_START_PORT + i);
    _gSetupTool.addInstanceToCluster(CLUSTER_NAME, instance);
    _instances.add(instance);
  }

  // start dummy participants
  for (int i = 0; i < PARTICIPANT_NUMBER; i++) {
    MockParticipantManager participant =
        new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, _instances.get(i));
    participant.syncStart();
    _participants.add(participant);
  }

  createDBInSemiAuto(_gSetupTool, CLUSTER_NAME, DB_NAME_1, _instances,
      BuiltInStateModelDefinitions.MasterSlave.name(), PARTITION_NUMBER, REPLICA_NUMBER);
  createDBInSemiAuto(_gSetupTool, CLUSTER_NAME, DB_NAME_2, _instances,
      BuiltInStateModelDefinitions.MasterSlave.name(), PARTITION_NUMBER, REPLICA_NUMBER);

  // start controller
  String controllerName = CONTROLLER_PREFIX + "_0";
  _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
  _controller.syncStart();

  _clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkClient(_gZkClient).build();
  Assert.assertTrue(_clusterVerifier.verify());

  _configAccessor = new ConfigAccessor(_gZkClient);
  _accessor = new ZKHelixDataAccessor(CLUSTER_NAME, _baseAccessor);
}
 
开发者ID:apache,项目名称:helix,代码行数:40,代码来源:TestP2PMessageSemiAuto.java

示例10: beforeClass

import org.apache.helix.ConfigAccessor; //导入依赖的package包/类
@BeforeClass
public void beforeClass() throws Exception {
  _participants = new MockParticipantManager[_numNodes];
  _numDbs = 1;
  _numParitions = 20;
  _numNodes = 2;
  _numReplicas = 2;
  String namespace = "/" + CLUSTER_NAME;
  if (_gZkClient.exists(namespace)) {
    _gZkClient.deleteRecursive(namespace);
  }

  _setupTool = new ClusterSetup(ZK_ADDR);
  _setupTool.addCluster(CLUSTER_NAME, true);
  setupParticipants();
  setupDBs();

  registerParticipants(_participants, _numNodes, _startPort, 0, -3000000L);

  // start controller
  String controllerName = CONTROLLER_PREFIX + "_0";
  _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
  _controller.syncStart();

  createManagers();
  _configAccessor = new ConfigAccessor(_gZkClient);
}
 
开发者ID:apache,项目名称:helix,代码行数:28,代码来源:TestStateTransitionCancellation.java

示例11: beforeClass

import org.apache.helix.ConfigAccessor; //导入依赖的package包/类
@Override
@BeforeClass
public void beforeClass() throws Exception {
  System.out.println("START " + CLASS_NAME + " at " + new Date(System.currentTimeMillis()));

  String namespace = "/" + CLUSTER_NAME;
  if (_gZkClient.exists(namespace)) {
    _gZkClient.deleteRecursive(namespace);
  }
  _setupTool = new ClusterSetup(ZK_ADDR);

  // setup storage cluster
  _setupTool.addCluster(CLUSTER_NAME, true);

  for (int i = 0; i < NODE_NR; i++) {
    String storageNodeName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
    _setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
  }

  _manager = HelixManagerFactory
      .getZKHelixManager(CLUSTER_NAME, "Admin", InstanceType.ADMINISTRATOR, ZK_ADDR);
  _manager.connect();
  _configAccessor = new ConfigAccessor(_gZkClient);

  String controllerName = CONTROLLER_PREFIX + "_0";
  _controller =
      new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
  _controller.syncStart();

  boolean result =
      ClusterStateVerifier
          .verifyByZkCallback(new MasterNbInExtViewVerifier(ZK_ADDR, CLUSTER_NAME));
  Assert.assertTrue(result);
}
 
开发者ID:apache,项目名称:helix,代码行数:35,代码来源:TestStateTransitionTimeoutWithResource.java

示例12: enablePersistBestPossibleAssignment

import org.apache.helix.ConfigAccessor; //导入依赖的package包/类
protected void enablePersistBestPossibleAssignment(ZkClient zkClient, String clusterName,
    Boolean enabled) {
  ConfigAccessor configAccessor = new ConfigAccessor(zkClient);
  ClusterConfig clusterConfig = configAccessor.getClusterConfig(clusterName);
  clusterConfig.setPersistBestPossibleAssignment(enabled);
  configAccessor.setClusterConfig(clusterName, clusterConfig);
}
 
开发者ID:apache,项目名称:helix,代码行数:8,代码来源:ZkIntegrationTestBase.java

示例13: enablePersistIntermediateAssignment

import org.apache.helix.ConfigAccessor; //导入依赖的package包/类
protected void enablePersistIntermediateAssignment(ZkClient zkClient, String clusterName,
    Boolean enabled) {
  ConfigAccessor configAccessor = new ConfigAccessor(zkClient);
  ClusterConfig clusterConfig = configAccessor.getClusterConfig(clusterName);
  clusterConfig.setPersistIntermediateAssignment(enabled);
  configAccessor.setClusterConfig(clusterName, clusterConfig);
}
 
开发者ID:apache,项目名称:helix,代码行数:8,代码来源:ZkIntegrationTestBase.java

示例14: enableTopologyAwareRebalance

import org.apache.helix.ConfigAccessor; //导入依赖的package包/类
protected void enableTopologyAwareRebalance(ZkClient zkClient, String clusterName,
    Boolean enabled) {
  ConfigAccessor configAccessor = new ConfigAccessor(zkClient);
  ClusterConfig clusterConfig = configAccessor.getClusterConfig(clusterName);
  clusterConfig.setTopologyAwareEnabled(enabled);
  configAccessor.setClusterConfig(clusterName, clusterConfig);
}
 
开发者ID:apache,项目名称:helix,代码行数:8,代码来源:ZkIntegrationTestBase.java

示例15: enableDelayRebalanceInCluster

import org.apache.helix.ConfigAccessor; //导入依赖的package包/类
protected void enableDelayRebalanceInCluster(ZkClient zkClient, String clusterName,
    boolean enabled) {
  ConfigAccessor configAccessor = new ConfigAccessor(zkClient);
  ClusterConfig clusterConfig = configAccessor.getClusterConfig(clusterName);
  clusterConfig.setDelayRebalaceEnabled(enabled);
  configAccessor.setClusterConfig(clusterName, clusterConfig);
}
 
开发者ID:apache,项目名称:helix,代码行数:8,代码来源:ZkIntegrationTestBase.java


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