當前位置: 首頁>>代碼示例>>Java>>正文


Java HierarchicalConfiguration.configurationAt方法代碼示例

本文整理匯總了Java中org.apache.commons.configuration.HierarchicalConfiguration.configurationAt方法的典型用法代碼示例。如果您正苦於以下問題:Java HierarchicalConfiguration.configurationAt方法的具體用法?Java HierarchicalConfiguration.configurationAt怎麽用?Java HierarchicalConfiguration.configurationAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.configuration.HierarchicalConfiguration的用法示例。


在下文中一共展示了HierarchicalConfiguration.configurationAt方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configure

import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
void configure(HierarchicalConfiguration conf) throws Exception {

    this.stormConfig = new Config();
    this.builder = new TopologyBuilder();

    SubnodeConfiguration topologyConf = conf.configurationAt(TOPOLOGY);
    this.topologyName = getTopologyName(topologyConf);

    SubnodeConfiguration stormConf = topologyConf.configurationAt(STORM_CONF);
    configureStorm(stormConf, stormConfig);

    SubnodeConfiguration spoutConf = conf.configurationAt(SPOUT);
    String spout = configureSpout(builder, spoutConf);

    SubnodeConfiguration boltConfs = conf.configurationAt(BOLTS);
    configureBolts(builder, boltConfs, spout);
  }
 
開發者ID:boozallen,項目名稱:cognition,代碼行數:18,代碼來源:ConfigurableIngestTopology.java

示例2: parseT100OchPort

import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
private static PortDescription parseT100OchPort(HierarchicalConfiguration cfg, long count) {
    PortNumber portNumber = PortNumber.portNumber(count);
    HierarchicalConfiguration otuConfig = cfg.configurationAt("otu");
    boolean enabled = otuConfig.getString("administrative-state").equals("up");
    OduSignalType signalType = otuConfig.getString("rate").equals("OTU4") ? OduSignalType.ODU4 : null;
    //Unsure how to retreive, outside knowledge it is tunable.
    boolean isTunable = true;
    OchSignal lambda = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4);
    DefaultAnnotations annotations = DefaultAnnotations.builder().
            set(AnnotationKeys.PORT_NAME, cfg.getString("name")).
            build();
    return ochPortDescription(portNumber, enabled, signalType, isTunable, lambda, annotations);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:14,代碼來源:PortGetterFujitsuImpl.java

示例3: parseT100OduPort

import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
private static PortDescription parseT100OduPort(HierarchicalConfiguration cfg, long count) {
    PortNumber portNumber = PortNumber.portNumber(count);
    HierarchicalConfiguration ethernetConfig = cfg.configurationAt("ethernet");
    boolean enabled = ethernetConfig.getString("administrative-state").equals("up");
    //Rate is in kbps
    CltSignalType signalType = ethernetConfig.getString("rate").equals("100000000") ?
            CltSignalType.CLT_100GBE : null;
    DefaultAnnotations annotations = DefaultAnnotations.builder().
            set(AnnotationKeys.PORT_NAME, cfg.getString("name")).
            build();
    return oduCltPortDescription(portNumber, enabled, signalType, annotations);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:13,代碼來源:PortGetterFujitsuImpl.java

示例4: parseSwitchId

import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
protected static String parseSwitchId(HierarchicalConfiguration cfg) {
    HierarchicalConfiguration field =
            cfg.configurationAt("data.capable-switch." +
                                        "logical-switches." +
                                        "switch");
    return field.getProperty("id").toString();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:8,代碼來源:XmlConfigParser.java

示例5: parseBalancer

import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private <E extends VMwareBalancer<?>> E parseBalancer(
        HierarchicalConfiguration parent, Class<E> targetClass,
        Class<? extends E> defaultBalancer,
        VMwareDatacenterInventory inventory) throws Exception {

    String balancerClass = parent.getString("balancer[@class]");
    Class<?> loadedClass = null;
    if (balancerClass != null) {
        loadedClass = this.getClass().getClassLoader()
                .loadClass(balancerClass);
        if (!targetClass.isAssignableFrom(loadedClass)) {
            loadedClass = null;
            logger.warn("The configured balancer '" + balancerClass
                    + "' is not of type " + targetClass.getSimpleName());
        }
    }
    if (loadedClass == null) {
        balancerClass = defaultBalancer.getName();
        parent.addProperty("balancer[@class]", balancerClass);
        loadedClass = defaultBalancer;
    }
    HierarchicalConfiguration balancerConfig = parent
            .configurationAt(ELEMENT_BALANCER);
    E balancer = (E) loadedClass.newInstance();
    balancer.setConfiguration(balancerConfig);
    balancer.setInventory(inventory);
    return balancer;
}
 
開發者ID:servicecatalog,項目名稱:development,代碼行數:30,代碼來源:LoadBalancerConfiguration.java

示例6: configureBolts

import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
/**
 * Gets a topology builder and set of storm bolt configurations. Initializes the bolts and sets them with the
 * topology builder.
 *
 * @param builder   storm topology builder
 * @param boltsConf component configurations
 * @param spout     type of storm component being added (spout/bolt)
 * @throws ConfigurationException
 */
void configureBolts(TopologyBuilder builder, SubnodeConfiguration boltsConf, String spout)
    throws ConfigurationException {

  String prevComponent = spout;
  // bolts subscribe to other bolts by number
  HashMap<Integer, String> boltNumberToId = new HashMap<>();

  List<HierarchicalConfiguration> bolts = boltsConf.configurationsAt(BOLT);
  for (HierarchicalConfiguration bolt : bolts) {
    String boltType = bolt.getString(TYPE);
    Configuration boltConf = bolt.configurationAt(CONF);
    int boltNum = bolt.getInt(NUMBER_ATTRIBUTE);

    String boltId = String.format("%02d_%s", boltNum, boltType);
    boltNumberToId.put(boltNum, boltId);
    String subscribingToComponent = getSubscribingToComponent(prevComponent, boltNumberToId, boltConf);
    logger.info("{} subscribing to {}", boltId, subscribingToComponent);

    IComponent baseComponent = buildComponent(boltType, boltConf);

    StormParallelismConfig stormParallelismConfig = getStormParallelismConfig(boltConf);
    BoltDeclarer declarer = buildBoltDeclarer(builder, stormParallelismConfig, boltId, baseComponent);

    configureTickFrequency(boltConf, declarer);

    configureStreamGrouping(subscribingToComponent, boltConf, declarer);

    prevComponent = boltId;

    boltNum++;
  }
}
 
開發者ID:boozallen,項目名稱:cognition,代碼行數:42,代碼來源:ConfigurableIngestTopology.java

示例7: testConfigure

import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
@Test
public void testConfigure(
    @Injectable HierarchicalConfiguration conf,
    @Injectable SubnodeConfiguration topologyConf,
    @Injectable SubnodeConfiguration stormConf,
    @Injectable SubnodeConfiguration spoutConf,
    @Injectable SubnodeConfiguration boltConfs,
    @Injectable String topologyName,
    @Injectable String spout) throws Exception {

  new Expectations(topology) {{
    conf.configurationAt(TOPOLOGY);
    result = topologyConf;
    topology.getTopologyName(topologyConf);
    result = topologyName;

    topologyConf.configurationAt(STORM_CONF);
    result = stormConf;
    topology.configureStorm(stormConf, (Config) any);

    conf.configurationAt(SPOUT);
    result = spoutConf;
    topology.configureSpout((TopologyBuilder) any, spoutConf);
    result = spout;

    conf.configurationAt(BOLTS);
    result = boltConfs;
    topology.configureBolts((TopologyBuilder) any, boltConfs, spout);
  }};
  topology.configure(conf);
}
 
開發者ID:boozallen,項目名稱:cognition,代碼行數:32,代碼來源:ConfigurableIngestTopologyTest.java

示例8: parseCapableSwitchId

import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
public static String parseCapableSwitchId(HierarchicalConfiguration cfg) {
    HierarchicalConfiguration field =
            cfg.configurationAt("data.capable-switch");
    return field.getProperty("id").toString();
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:6,代碼來源:XmlConfigParser.java

示例9: VmManagerConfig

import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
/**
 * 
 * @param config
 */
@SuppressWarnings("unchecked")
public VmManagerConfig(@Nonnull HierarchicalConfiguration config) {
    this.config = config;
    if (this.config != null) {
        List<HierarchicalConfiguration> creds = config.configurationsAt("credentials");
        if (creds != null) {
            for (HierarchicalConfiguration credentialsConfig : creds) {
                CloudCredentials cloudCredentials = new CloudCredentials(credentialsConfig);
                credentialsMap.put(cloudCredentials.getType(), cloudCredentials);
            }
        }
        
        List<HierarchicalConfiguration> tags = config.configurationsAt("tags/tag");
        if (tags != null) {
            for (HierarchicalConfiguration tagsConfig : tags) {
                InstanceTag tag = new InstanceTag(tagsConfig.getString("@name"), tagsConfig.getString(""));
                if (tag.isValid()) {
                    tagList.add(tag);
                }
            }
        }

        HierarchicalConfiguration defaultInstance = config.configurationAt("default-instance-description");
        List<HierarchicalConfiguration> regionConfigs = config.configurationsAt("instance-descriptions");
        if (regionConfigs != null) {
            for (HierarchicalConfiguration regionConfig : regionConfigs) {
                VMRegion region = VMRegion.valueOf(regionConfig.getString("@region"));
                Map<VMImageType, InstanceDescription> instanceMap = new HashMap<VMImageType, InstanceDescription>();
                regionMap.put(region, instanceMap);
                List<HierarchicalConfiguration> instanceConfigs = regionConfig
                        .configurationsAt("instance-descripion");
                for (HierarchicalConfiguration instanceConfig : instanceConfigs) {
                    InstanceDescription description = new InstanceDescription(instanceConfig, defaultInstance);
                    instanceMap.put(description.getType(), description);
                }

            }
        }

        // get reserved elastic ips
        List<HierarchicalConfiguration> eipConfig = config.configurationsAt("reserved-elastic-ips/eip");
        if (eipConfig != null) {
            for (HierarchicalConfiguration eip : eipConfig) {
                reservedElasticIps.add(eip.getString(""));
            }
        }
        // get instance type definitions
        List<HierarchicalConfiguration> instanceTypesConfig = config.configurationsAt("instance-types/type");
        instanceTypes = new ArrayList<VmInstanceType>();
        if (instanceTypesConfig != null) {
            for (HierarchicalConfiguration instanceTypeConfig : instanceTypesConfig) {
                // example: <type name="c3.large" cost=".105" users="500" cpus="2" ecus="7" mem="3.75" />
                VmInstanceType type = VmInstanceType.builder()
                        .withName(instanceTypeConfig.getString("@name"))
                        .withCost(instanceTypeConfig.getDouble("@cost", 0D))
                        .withMemory(instanceTypeConfig.getDouble("@mem", 0D))
                        .withJvmArgs(instanceTypeConfig.getString("@jvmArgs"))
                        .withEcus(instanceTypeConfig.getInt("@ecus", 0))
                        .withCpus(instanceTypeConfig.getInt("@cpus", 0))
                        .withDefault(instanceTypeConfig.getBoolean("@default", false))
                        .withUsers(instanceTypeConfig.getInt("@users", 0)).build();
                instanceTypes.add(type);

            }
        }
    }
}
 
開發者ID:intuit,項目名稱:Tank,代碼行數:72,代碼來源:VmManagerConfig.java

示例10: testConfigureBolts

import org.apache.commons.configuration.HierarchicalConfiguration; //導入方法依賴的package包/類
@Test
public void testConfigureBolts(
    @Injectable TopologyBuilder builder,
    @Injectable SubnodeConfiguration boltsConf,
    @Injectable HierarchicalConfiguration bolt,
    @Injectable SubnodeConfiguration boltConf,
    @Injectable IComponent baseComponent,
    @Injectable StormParallelismConfig stormParallelismConfig,
    @Injectable BoltDeclarer declarer) throws Exception {

  List<HierarchicalConfiguration> bolts = Arrays.asList(bolt);
  String spout = "spout_id";

  new Expectations(topology) {{
    boltsConf.configurationsAt(BOLT);
    result = bolts;

    bolt.getString(TYPE);
    result = "bolt_type";
    bolt.configurationAt(CONF);
    result = boltConf;
    bolt.getInt(NUMBER_ATTRIBUTE);
    result = 0;
    topology.getSubscribingToComponent(spout, (HashMap<Integer, String>) any, boltConf);
    result = spout;

    topology.buildComponent("bolt_type", boltConf);
    result = baseComponent;

    topology.getStormParallelismConfig(boltConf);
    result = stormParallelismConfig;
    topology.buildBoltDeclarer(builder, stormParallelismConfig, "00_bolt_type", baseComponent);
    result = declarer;

    topology.configureTickFrequency(boltConf, declarer);

    topology.configureStreamGrouping(spout, boltConf, declarer);

  }};

  topology.configureBolts(builder, boltsConf, spout);
}
 
開發者ID:boozallen,項目名稱:cognition,代碼行數:43,代碼來源:ConfigurableIngestTopologyTest.java


注:本文中的org.apache.commons.configuration.HierarchicalConfiguration.configurationAt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。