Package org.apache.helix.model

Examples of org.apache.helix.model.ResourceConfiguration


    if (resourceConfig == null || resourceConfig.getRebalancerConfig() == null) {
      LOG.error("Resource not fully defined with a rebalancer context");
      return false;
    }
    ResourceId resourceId = resourceConfig.getId();
    ResourceConfiguration config = new ResourceConfiguration(resourceId);
    config.addNamespacedConfig(resourceConfig.getUserConfig());
    config.addNamespacedConfig(resourceConfig.getRebalancerConfig().toNamespacedConfig());
    config.setBucketSize(resourceConfig.getBucketSize());
    config.setBatchMessageMode(resourceConfig.getBatchMessageMode());
    setConfiguration(resourceId, config);
    return true;
  }
View Full Code Here


    // add key1 through user config, key2 through resource config, key3 through ideal state,
    // resource type through resource config, rebalance mode through ideal state
    ResourceId resourceId = ResourceId.from("resourceId");
    UserConfig userConfig = new UserConfig(Scope.resource(resourceId));
    userConfig.setSimpleField(KEY1, VALUE1);
    ResourceConfiguration resourceConfig = new ResourceConfiguration(resourceId);
    resourceConfig.setType(ResourceType.DATA);
    resourceConfig.addNamespacedConfig(userConfig);
    resourceConfig.getRecord().setSimpleField(KEY2, VALUE2);
    IdealState idealState = new IdealState(resourceId);
    idealState.setRebalanceMode(RebalanceMode.USER_DEFINED);
    idealState.getRecord().setSimpleField(KEY3, VALUE3);

    // should have key1, key2, and key3, not type or rebalance mode
    UserConfig result = resourceConfig.getUserConfig();
    idealState.updateUserConfig(result);
    Assert.assertEquals(result.getSimpleField(KEY1), VALUE1);
    Assert.assertEquals(result.getSimpleField(KEY2), VALUE2);
    Assert.assertEquals(result.getSimpleField(KEY3), VALUE3);
    Assert.assertNull(result.getSimpleField(ResourceConfiguration.Fields.TYPE.toString()));
View Full Code Here

    Assert.assertEquals(deserialized.getReplicaCount(), context.getReplicaCount());
    Assert.assertEquals(deserialized.getStateModelDefId(), context.getStateModelDefId());
    Assert.assertEquals(deserialized.getResourceId(), context.getResourceId());

    // wrap in a physical config and then unwrap it
    ResourceConfiguration physicalConfig = new ResourceConfiguration(resourceId);
    physicalConfig.addNamespacedConfig(config.toNamespacedConfig());
    RebalancerConfig extractedConfig = new RebalancerConfig(physicalConfig);
    CustomRebalancerContext extractedContext =
        extractedConfig.getRebalancerContext(CustomRebalancerContext.class);

    // make sure the unwrapped data hasn't changed
View Full Code Here

      return false;
    }

    // Add resource user config
    if (resource.getUserConfig() != null) {
      ResourceConfiguration configuration = new ResourceConfiguration(resourceId);
      configuration.setType(resource.getType());
      configuration.addNamespacedConfig(resource.getUserConfig());
      configuration.addNamespacedConfig(resource.getRebalancerConfig().toNamespacedConfig());
      configuration.setBucketSize(resource.getBucketSize());
      configuration.setBatchMessageMode(resource.getBatchMessageMode());
      _accessor.setProperty(_keyBuilder.resourceConfig(resourceId.stringify()), configuration);
    }

    // Create an IdealState from a RebalancerConfig (if the resource is partitioned)
    RebalancerConfig rebalancerConfig = resource.getRebalancerConfig();
View Full Code Here

TOP

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

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.