Package org.apache.helix.model

Examples of org.apache.helix.model.HelixConfigScope


      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();
View Full Code Here


    submitDag(dag);
  }

  public void submitDag(Dag dag) throws Exception {
    ConfigAccessor clusterConfig = new ConfigAccessor(_zkclient);
    HelixConfigScope clusterScope = new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER)
                                      .forCluster(_clusterName)
                                      .build();
    for (String id : dag.getNodeIds()) {
      Dag.Node node = dag.getNode(id);
      clusterConfig.set(clusterScope, node.getId(), node.toJson());
View Full Code Here

   
    _setupTool.getClusterManagementTool().addAlert(CLUSTER_NAME, _alertStr1);
    _setupTool.getClusterManagementTool().addAlert(CLUSTER_NAME, _alertStr2);
   
    // ConfigScope scope = new ConfigScopeBuilder().forCluster(CLUSTER_NAME).build();
    HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER)
                                        .forCluster(CLUSTER_NAME)
                                        .build();
    Map<String, String> properties = new HashMap<String, String>();
    properties.put("healthChange.enabled", "false");
    _setupTool.getClusterManagementTool().setConfig(scope, properties);
View Full Code Here

  @Test
  public void testAlertActionDisableNode() throws InterruptedException
  {
    // ConfigScope scope = new ConfigScopeBuilder().forCluster(CLUSTER_NAME).build();
    HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(CLUSTER_NAME).build();
    Map<String, String> properties = new HashMap<String, String>();
    properties.put("healthChange.enabled", "true");
    _setupTool.getClusterManagementTool().setConfig(scope, properties);

    String alertStr1 = "EXP(decay(1.0)(localhost_*.TestStat@DB=db1.TestMetric1))CMP(GREATER)CON(20)ACTION(DISABLE_INSTANCE)";
 
View Full Code Here

    _partitionName = partitionName;
    return this;
  }
 
  public HelixConfigScope build() {
    HelixConfigScope scope = null;
    switch(_type) {
    case CLUSTER:
      scope = new HelixConfigScope(_type, Arrays.asList(_clusterName, _clusterName), null);
      break;
    case PARTICIPANT:
      if (_participantName == null) {
        scope = new HelixConfigScope(_type, Arrays.asList(_clusterName), null);
      } else {
        scope = new HelixConfigScope(_type, Arrays.asList(_clusterName, _participantName), null);
      }
      break;
    case RESOURCE:
      if (_resourceName == null) {
        scope = new HelixConfigScope(_type, Arrays.asList(_clusterName), null);
      } else {
        scope = new HelixConfigScope(_type, Arrays.asList(_clusterName, _resourceName), null);
      }
      break;
    case PARTITION:
      if (_partitionName == null) {
        scope = new HelixConfigScope(_type, Arrays.asList(_clusterName, _resourceName), null);
      } else {
        scope = new HelixConfigScope(_type, Arrays.asList(_clusterName, _resourceName), _partitionName);
      }
      break;
    default:
      break;
    }
View Full Code Here

    AssertJUnit.assertNull(resourceExternalView);

    // test config support
//    ConfigScope scope = new ConfigScopeBuilder().forCluster(clusterName)
//        .forResource("testResource").forPartition("testPartition").build();
    HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.PARTITION)
                                  .forCluster(clusterName)
                                  .forResource("testResource")
                                  .forPartition("testPartition")
                                  .build();
 
View Full Code Here

    AssertJUnit.assertTrue(admin.isConnected());

    HelixAdmin adminTool = admin.getClusterManagmentTool();
//    ConfigScope scope = new ConfigScopeBuilder().forCluster(clusterName)
//        .forResource("testResource").forPartition("testPartition").build();
    HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.PARTITION)
                                      .forCluster(clusterName)
                                      .forResource("testResource")
                                      .forPartition("testPartition")
                                      .build();
View Full Code Here

                            3,
                            "MasterSlave",
                            true);

    ConfigAccessor configAccessor = new ConfigAccessor(_gZkClient);
    HelixConfigScope clusterScope = new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER)
                                            .forCluster(clusterName)
                                            .build();

    // cluster scope config
    String clusterConfigValue = configAccessor.get(clusterScope, "clusterConfigKey");
    Assert.assertNull(clusterConfigValue);

    configAccessor.set(clusterScope, "clusterConfigKey", "clusterConfigValue");
    clusterConfigValue = configAccessor.get(clusterScope, "clusterConfigKey");
    Assert.assertEquals(clusterConfigValue, "clusterConfigValue");

    // resource scope config
    HelixConfigScope resourceScope = new HelixConfigScopeBuilder(ConfigScopeProperty.RESOURCE)
                                      .forCluster(clusterName)
                                      .forResource("testResource")
                                      .build();
    configAccessor.set(resourceScope, "resourceConfigKey", "resourceConfigValue");
    String resourceConfigValue = configAccessor.get(resourceScope, "resourceConfigKey");
    Assert.assertEquals(resourceConfigValue, "resourceConfigValue");

    // partition scope config
    HelixConfigScope partitionScope = new HelixConfigScopeBuilder(ConfigScopeProperty.PARTITION)
                                        .forCluster(clusterName)
                                        .forResource("testResource")
                                        .forPartition("testPartition")
                                        .build();
    configAccessor.set(partitionScope, "partitionConfigKey", "partitionConfigValue");
    String partitionConfigValue = configAccessor.get(partitionScope, "partitionConfigKey");
    Assert.assertEquals(partitionConfigValue, "partitionConfigValue");

    // participant scope config
    HelixConfigScope participantScope = new HelixConfigScopeBuilder(ConfigScopeProperty.PARTICIPANT)
                                          .forCluster(clusterName)
                                          .forParticipant("localhost_12918")
                                          .build();
    configAccessor.set(participantScope, "participantConfigKey", "participantConfigValue");
    String participantConfigValue = configAccessor.get(participantScope, "participantConfigKey");
View Full Code Here

              + new Date(System.currentTimeMillis()));

      ZKHelixAdmin admin = new ZKHelixAdmin(_gZkClient);
      admin.addCluster(clusterName, true);
      ConfigAccessor configAccessor = new ConfigAccessor(_gZkClient);
      HelixConfigScope participantScope = new HelixConfigScopeBuilder(ConfigScopeProperty.PARTICIPANT)
                                              .forCluster(clusterName)
                                              .forParticipant("localhost_12918")
                                              .build();

      try {
View Full Code Here

   */
  public void setConfig(ConfigScopeProperty type, String scopeArgsCsv, String keyValuePairs)
  {
//    ConfigScope scope = new ConfigScopeBuilder().build(scopesKeyValuePairs);
    String[] scopeArgs = scopeArgsCsv.split("[\\s,]");
    HelixConfigScope scope = new HelixConfigScopeBuilder(type, scopeArgs).build();

    Map<String, String> keyValueMap = HelixUtil.parseCsvFormatedKeyValuePairs(keyValuePairs);
    _admin.setConfig(scope, keyValueMap);
  }
View Full Code Here

TOP

Related Classes of org.apache.helix.model.HelixConfigScope

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.