Java Code Examples for org.apache.helix.ConfigAccessor#getInstanceConfig()

The following examples show how to use org.apache.helix.ConfigAccessor#getInstanceConfig() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestCrushAutoRebalanceNonRack.java    From helix with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public void beforeClass() throws Exception {
  System.out.println("START " + CLASS_NAME + " at " + new Date(System.currentTimeMillis()));

  _gSetupTool.addCluster(CLUSTER_NAME, true);

  ConfigAccessor configAccessor = new ConfigAccessor(_gZkClient);
  ClusterConfig clusterConfig = configAccessor.getClusterConfig(CLUSTER_NAME);
  clusterConfig.setTopology("/instance");
  clusterConfig.setFaultZoneType("instance");
  configAccessor.setClusterConfig(CLUSTER_NAME, clusterConfig);

  for (int i = 0; i < NUM_NODE; i++) {
    String storageNodeName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
    _gSetupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
    _nodes.add(storageNodeName);
    String tag = "tag-" + i % 2;
    _gSetupTool.getClusterManagementTool().addInstanceTag(CLUSTER_NAME, storageNodeName, tag);
    _nodeToTagMap.put(storageNodeName, tag);
    InstanceConfig instanceConfig =
        configAccessor.getInstanceConfig(CLUSTER_NAME, storageNodeName);
    instanceConfig.setDomain("instance=" + storageNodeName);
    configAccessor.setInstanceConfig(CLUSTER_NAME, storageNodeName, instanceConfig);
  }

  // start dummy participants
  for (String node : _nodes) {
    MockParticipantManager participant = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, node);
    participant.syncStart();
    _participants.add(participant);
  }

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

  enablePersistBestPossibleAssignment(_gZkClient, CLUSTER_NAME, true);
}
 
Example 2
Source File: ZkTestBase.java    From helix with Apache License 2.0 5 votes vote down vote up
protected void enableDelayRebalanceInInstance(HelixZkClient zkClient, String clusterName,
    String instanceName, boolean enabled) {
  ConfigAccessor configAccessor = new ConfigAccessor(zkClient);
  InstanceConfig instanceConfig = configAccessor.getInstanceConfig(clusterName, instanceName);
  instanceConfig.setDelayRebalanceEnabled(enabled);
  configAccessor.setInstanceConfig(clusterName, instanceName, instanceConfig);
}
 
Example 3
Source File: TestAlertingRebalancerFailure.java    From helix with Apache License 2.0 4 votes vote down vote up
private void setDomainId(String instanceName, ConfigAccessor configAccessor) {
  String domain = String.format("Rack=%s, Instance=%s", instanceName, instanceName);
  InstanceConfig instanceConfig = configAccessor.getInstanceConfig(CLUSTER_NAME, instanceName);
  instanceConfig.setDomain(domain);
  configAccessor.setInstanceConfig(CLUSTER_NAME, instanceName, instanceConfig);
}
 
Example 4
Source File: TestAlertingRebalancerFailure.java    From helix with Apache License 2.0 4 votes vote down vote up
private void setInstanceEnable(String instanceName, boolean enabled,
    ConfigAccessor configAccessor) {
  InstanceConfig instanceConfig = configAccessor.getInstanceConfig(CLUSTER_NAME, instanceName);
  instanceConfig.setInstanceEnabled(enabled);
  configAccessor.setInstanceConfig(CLUSTER_NAME, instanceName, instanceConfig);
}
 
Example 5
Source File: TestNodeSwap.java    From helix with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public void beforeClass() throws Exception {
  System.out.println("START " + CLASS_NAME + " at " + new Date(System.currentTimeMillis()));

  _gSetupTool.addCluster(CLUSTER_NAME, true);

  ConfigAccessor configAccessor = new ConfigAccessor(_gZkClient);
  ClusterConfig clusterConfig = configAccessor.getClusterConfig(CLUSTER_NAME);
  clusterConfig.setTopology("/zone/instance");
  clusterConfig.setFaultZoneType("zone");
  configAccessor.setClusterConfig(CLUSTER_NAME, clusterConfig);

  Set<String> nodes = new HashSet<>();
  for (int i = 0; i < NUM_NODE; i++) {
    String storageNodeName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
    _gSetupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
    String zone = "zone-" + i % 3;
    String domain = String.format("zone=%s,instance=%s", zone, storageNodeName);

    InstanceConfig instanceConfig =
        configAccessor.getInstanceConfig(CLUSTER_NAME, storageNodeName);
    instanceConfig.setDomain(domain);
    _gSetupTool.getClusterManagementTool().setInstanceConfig(CLUSTER_NAME, storageNodeName,
        instanceConfig);
    nodes.add(storageNodeName);
  }

  // start dummy participants
  for (String node : nodes) {
    MockParticipantManager participant = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, node);
    participant.syncStart();
    _participants.add(participant);
  }

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

  enablePersistBestPossibleAssignment(_gZkClient, CLUSTER_NAME, true);
  enableTopologyAwareRebalance(_gZkClient, CLUSTER_NAME, true);
}