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


Java YmlReader.readFromFileAsMap方法代码示例

本文整理汇总了Java中com.appdynamics.extensions.yml.YmlReader.readFromFileAsMap方法的典型用法代码示例。如果您正苦于以下问题:Java YmlReader.readFromFileAsMap方法的具体用法?Java YmlReader.readFromFileAsMap怎么用?Java YmlReader.readFromFileAsMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.appdynamics.extensions.yml.YmlReader的用法示例。


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

示例1: testMasterAndRegionServers

import com.appdynamics.extensions.yml.YmlReader; //导入方法依赖的package包/类
@Test
public void testMasterAndRegionServers() throws Exception {

    config = YmlReader.readFromFileAsMap(new File("src/test/resources/conf/config.yaml"));

    List<Map<String, String>> instances = (List<Map<String, String>>) config.get("instances");
    server = instances.get(0);
    configMBeans = (Map<String, List<Map>>) config.get(ConfigConstants.MBEANS);

    PowerMockito.whenNew(Phaser.class)
            .withNoArguments().thenReturn(phaser);

    Mockito.when(serviceProvider.getMonitorConfiguration()).thenReturn(monitorConfiguration);
    Mockito.when(serviceProvider.getMetricWriteHelper()).thenReturn(metricWriter);
    Mockito.when(monitorConfiguration.getConfigYml()).thenReturn(config);
    Mockito.when(monitorConfiguration.getExecutorService()).thenReturn(executorService);

    HBaseMonitorTask hBaseMonitorTask = new HBaseMonitorTask(serviceProvider, server);

    hBaseMonitorTask.run();

    verify(executorService, times(3)).submit(anyString(), any(JMXMetricCollector.class));
}
 
开发者ID:Appdynamics,项目名称:hbase-monitoring-extension,代码行数:24,代码来源:HBaseMonitorTaskTest.java

示例2: testMasterOnly

import com.appdynamics.extensions.yml.YmlReader; //导入方法依赖的package包/类
@Test
public void testMasterOnly() throws Exception {

    config = YmlReader.readFromFileAsMap(new File("src/test/resources/conf/configMasterOnly.yaml"));

    List<Map<String, String>> instances = (List<Map<String, String>>) config.get("instances");
    server = instances.get(0);
    configMBeans = (Map<String, List<Map>>) config.get(ConfigConstants.MBEANS);

    PowerMockito.whenNew(Phaser.class)
            .withNoArguments().thenReturn(phaser);

    Mockito.when(serviceProvider.getMonitorConfiguration()).thenReturn(monitorConfiguration);
    Mockito.when(serviceProvider.getMetricWriteHelper()).thenReturn(metricWriter);
    Mockito.when(monitorConfiguration.getConfigYml()).thenReturn(config);
    Mockito.when(monitorConfiguration.getExecutorService()).thenReturn(executorService);

    HBaseMonitorTask hBaseMonitorTask = new HBaseMonitorTask(serviceProvider, server);

    hBaseMonitorTask.run();

    verify(executorService, times(3)).submit(anyString(), any(JMXMetricCollector.class));
}
 
开发者ID:Appdynamics,项目名称:hbase-monitoring-extension,代码行数:24,代码来源:HBaseMonitorTaskTest.java

示例3: testRegionServerOnly

import com.appdynamics.extensions.yml.YmlReader; //导入方法依赖的package包/类
@Test
public void testRegionServerOnly() throws Exception {

    config = YmlReader.readFromFileAsMap(new File("src/test/resources/conf/configRSOnly.yaml"));

    List<Map<String, String>> instances = (List<Map<String, String>>) config.get("instances");
    server = instances.get(0);
    configMBeans = (Map<String, List<Map>>) config.get(ConfigConstants.MBEANS);

    PowerMockito.whenNew(Phaser.class)
            .withNoArguments().thenReturn(phaser);

    Mockito.when(serviceProvider.getMonitorConfiguration()).thenReturn(monitorConfiguration);
    Mockito.when(serviceProvider.getMetricWriteHelper()).thenReturn(metricWriter);
    Mockito.when(monitorConfiguration.getConfigYml()).thenReturn(config);
    Mockito.when(monitorConfiguration.getExecutorService()).thenReturn(executorService);

    HBaseMonitorTask hBaseMonitorTask = new HBaseMonitorTask(serviceProvider, server);

    hBaseMonitorTask.run();

    verify(executorService, times(3)).submit(anyString(), any(JMXMetricCollector.class));
}
 
开发者ID:Appdynamics,项目名称:hbase-monitoring-extension,代码行数:24,代码来源:HBaseMonitorTaskTest.java

示例4: getNodeMetrics_NonCompositeObject

import com.appdynamics.extensions.yml.YmlReader; //导入方法依赖的package包/类
@Test
public void getNodeMetrics_NonCompositeObject () throws MalformedObjectNameException, IntrospectionException, ReflectionException,
        InstanceNotFoundException, IOException {
    Map config = YmlReader.readFromFileAsMap(new File(this.getClass().getResource("/conf/config_without_composite_object.yml").getFile()));
    List<Map> mBeans = (List) config.get("mbeans");
    Set<ObjectInstance> objectInstances = Sets.newHashSet();
    objectInstances.add(new ObjectInstance("org.apache.cassandra.metrics:type=ClientRequest,scope=Read,name=Latency", "test"));

    Set<Attribute> attributes = Sets.newHashSet();
    attributes.add(new Attribute("Min", new BigDecimal(100)));
    attributes.add(new Attribute("Max", new BigDecimal(200)));

    List<String> metricNames = Lists.newArrayList();
    metricNames.add("metric1");
    metricNames.add("metric2");

    when(jmxConnectionAdapter.queryMBeans(eq(jmxConnector), Mockito.any(ObjectName.class))).thenReturn
            (objectInstances);
    when(jmxConnectionAdapter.getReadableAttributeNames(eq(jmxConnector), Mockito.any(ObjectInstance.class)))
            .thenReturn(metricNames);
    when(jmxConnectionAdapter.getAttributes(eq(jmxConnector), Mockito.any(ObjectName.class), Mockito.any(String[]
            .class))).thenReturn(attributes);

    MetricPropertiesBuilder metricPropertiesBuilder = new MetricPropertiesBuilder();

    NodeMetricsProcessor nodeMetricsProcessor = new NodeMetricsProcessor(jmxConnectionAdapter, jmxConnector);

    Map<String, MetricProperties> metricPropertiesMap = metricPropertiesBuilder.build(mBeans.get(0));

    List<Metric> metrics = nodeMetricsProcessor.getNodeMetrics(mBeans.get(0), metricPropertiesMap, "");
    Assert.assertTrue(metrics.get(0).getMetricKey().equals("ClientRequest|Read|Latency|Max Latency"));
    Assert.assertTrue(metrics.get(0).getInstanceKey().equals("ClientRequest|Read|Latency|"));
    Assert.assertTrue(metrics.get(0).getMetricValue().equals(new BigDecimal(200)));
    Assert.assertTrue(metrics.get(0).getProperties().equals(metricPropertiesMap.get("Max")));

    Assert.assertTrue(metrics.get(1).getMetricKey().equals("ClientRequest|Read|Latency|Min Latency"));
    Assert.assertTrue(metrics.get(1).getInstanceKey().equals("ClientRequest|Read|Latency|"));
    Assert.assertTrue(metrics.get(1).getMetricValue().equals(new BigDecimal(100)));
    Assert.assertTrue(metrics.get(1).getProperties().equals(metricPropertiesMap.get("Min")));
}
 
开发者ID:Appdynamics,项目名称:cassandra-monitoring-extension,代码行数:41,代码来源:NodeMetricsProcessorTest.java

示例5: getNodeMetrics_CompositeObject

import com.appdynamics.extensions.yml.YmlReader; //导入方法依赖的package包/类
@Test
public void getNodeMetrics_CompositeObject () throws MalformedObjectNameException, IntrospectionException,
        ReflectionException, InstanceNotFoundException, IOException, OpenDataException {
    Map config = YmlReader.readFromFileAsMap(new File(this.getClass().getResource
            ("/conf/config_with_composite_object.yml").getFile()));
    List<Map> mBeans = (List) config.get("mbeans");
    Set<ObjectInstance> objectInstances = Sets.newHashSet();
    objectInstances.add(new ObjectInstance("java.lang:type=Memory", "test"));

    Set<Attribute> attributes = Sets.newHashSet();
    attributes.add(new Attribute("HeapMemoryUsage", createCompositeDataSupportObject()));

    List<String> metricNames = Lists.newArrayList();
    metricNames.add("metric1");
    metricNames.add("metric2");
    when(jmxConnectionAdapter.queryMBeans(eq(jmxConnector), Mockito.any(ObjectName.class))).thenReturn
            (objectInstances);
    when(jmxConnectionAdapter.getReadableAttributeNames(eq(jmxConnector), Mockito.any(ObjectInstance.class)))
            .thenReturn(metricNames);
    when(jmxConnectionAdapter.getAttributes(eq(jmxConnector), Mockito.any(ObjectName.class), Mockito.any(String[]
            .class))).thenReturn(attributes);

    MetricPropertiesBuilder metricPropertiesBuilder = new MetricPropertiesBuilder();
    NodeMetricsProcessor nodeMetricsProcessor = new NodeMetricsProcessor(jmxConnectionAdapter, jmxConnector);
    Map<String, MetricProperties> metricPropertiesMap = metricPropertiesBuilder.build(mBeans.get(0));
    List<Metric> metrics = nodeMetricsProcessor.getNodeMetrics(mBeans.get(0), metricPropertiesMap, "");

    Assert.assertTrue(metrics.get(0).getMetricKey().equals("Memory|Heap Memory Usage|Max Heap Memory"));
    Assert.assertTrue(metrics.get(0).getInstanceKey().equals("Memory|"));
    Assert.assertTrue(metrics.get(0).getMetricValue().equals(new BigDecimal(100)));
    Assert.assertTrue(metrics.get(0).getProperties().equals(metricPropertiesMap.get("HeapMemoryUsage.max")));

    Assert.assertTrue(metrics.get(1).getMetricKey().equals("Memory|Heap Memory Usage|Used Heap Memory"));
    Assert.assertTrue(metrics.get(1).getInstanceKey().equals("Memory|"));
    Assert.assertTrue(metrics.get(1).getMetricValue().equals(new BigDecimal(50)));
    Assert.assertTrue(metrics.get(1).getProperties().equals(metricPropertiesMap.get("HeapMemoryUsage.used")));
}
 
开发者ID:Appdynamics,项目名称:cassandra-monitoring-extension,代码行数:38,代码来源:NodeMetricsProcessorTest.java

示例6: getNodeMetrics_compositeAndNonCompositeObjects

import com.appdynamics.extensions.yml.YmlReader; //导入方法依赖的package包/类
@Test
public void getNodeMetrics_compositeAndNonCompositeObjects() throws MalformedObjectNameException, IntrospectionException,
        ReflectionException, InstanceNotFoundException, IOException, OpenDataException  {
    Map config = YmlReader.readFromFileAsMap(new File(this.getClass().getResource("/conf/config_with_composite_and_noncomposite_objects.yml").getFile()));
    List<Map> mBeans = (List) config.get("mbeans");
    Set<ObjectInstance> objectInstances = Sets.newHashSet();
    objectInstances.add(new ObjectInstance("java.lang:type=Memory", "test"));

    Set<Attribute> attributes = Sets.newHashSet();
    attributes.add(new Attribute("ObjectPendingFinalizationCount", 0));
    attributes.add(new Attribute("HeapMemoryUsage", createCompositeDataSupportObject()));

    List<String> metricNames = Lists.newArrayList();
    metricNames.add("metric1");
    metricNames.add("metric2");

    when(jmxConnectionAdapter.queryMBeans(eq(jmxConnector), Mockito.any(ObjectName.class))).thenReturn
            (objectInstances);
    when(jmxConnectionAdapter.getReadableAttributeNames(eq(jmxConnector), Mockito.any(ObjectInstance.class)))
            .thenReturn(metricNames);
    when(jmxConnectionAdapter.getAttributes(eq(jmxConnector), Mockito.any(ObjectName.class), Mockito.any(String[]
            .class))).thenReturn(attributes);

    MetricPropertiesBuilder metricPropertiesBuilder = new MetricPropertiesBuilder();

    NodeMetricsProcessor nodeMetricsProcessor = new NodeMetricsProcessor(jmxConnectionAdapter, jmxConnector);

    Map<String, MetricProperties> metricPropertiesMap = metricPropertiesBuilder.build(mBeans.get(0));

    List<Metric> metrics = nodeMetricsProcessor.getNodeMetrics(mBeans.get(0), metricPropertiesMap, "");
    Assert.assertTrue(metrics.get(0).getMetricKey().equals("Memory|ObjectPendingFinalizationCount"));
    Assert.assertTrue(metrics.get(0).getInstanceKey().equals("Memory|"));
    Assert.assertTrue(metrics.get(0).getMetricValue().equals(new BigDecimal(0)));
    Assert.assertTrue(metrics.get(0).getProperties().equals(metricPropertiesMap.get("ObjectPendingFinalizationCount")));

    Assert.assertTrue(metrics.get(1).getMetricKey().equals("Memory|Heap Memory Usage|Heap Memory Used"));
    Assert.assertTrue(metrics.get(1).getInstanceKey().equals("Memory|"));
    Assert.assertTrue(metrics.get(1).getMetricValue().equals(new BigDecimal(50)));
    Assert.assertTrue(metrics.get(1).getProperties().equals(metricPropertiesMap.get("HeapMemoryUsage.used")));
}
 
开发者ID:Appdynamics,项目名称:cassandra-monitoring-extension,代码行数:41,代码来源:NodeMetricsProcessorTest.java

示例7: getNodeMetrics_NonCompositeObject

import com.appdynamics.extensions.yml.YmlReader; //导入方法依赖的package包/类
@Test
public void getNodeMetrics_NonCompositeObject () throws MalformedObjectNameException, IntrospectionException, ReflectionException,
        InstanceNotFoundException, IOException {
    Map config = YmlReader.readFromFileAsMap(new File(this.getClass().getResource("/conf/config_without_composite_object.yml").getFile()));
    List<Map> mBeans = (List) config.get("mbeans");
    Set<ObjectInstance> objectInstances = Sets.newHashSet();
    objectInstances.add(new ObjectInstance("org.apache.activemq.metrics:type=ClientRequest,scope=Read,name=Latency", "test"));

    Set<Attribute> attributes = Sets.newHashSet();
    attributes.add(new Attribute("Min", new BigDecimal(100)));
    attributes.add(new Attribute("Max", new BigDecimal(200)));

    List<String> metricNames = Lists.newArrayList();
    metricNames.add("metric1");
    metricNames.add("metric2");

    when(jmxConnectionAdapter.queryMBeans(eq(jmxConnector), Mockito.any(ObjectName.class))).thenReturn
            (objectInstances);
    when(jmxConnectionAdapter.getReadableAttributeNames(eq(jmxConnector), Mockito.any(ObjectInstance.class)))
            .thenReturn(metricNames);
    when(jmxConnectionAdapter.getAttributes(eq(jmxConnector), Mockito.any(ObjectName.class), Mockito.any(String[]
            .class))).thenReturn(attributes);

    MetricPropertiesBuilder metricPropertiesBuilder = new MetricPropertiesBuilder();

    NodeMetricsProcessor nodeMetricsProcessor = new NodeMetricsProcessor(jmxConnectionAdapter, jmxConnector);

    Map<String, MetricProperties> metricPropertiesMap = metricPropertiesBuilder.build(mBeans.get(0));

    List<Metric> metrics = nodeMetricsProcessor.getNodeMetrics(mBeans.get(0), metricPropertiesMap, "");
    Assert.assertTrue(metrics.get(0).getMetricKey().equals("ClientRequest|Read|Latency|Max Latency"));
    Assert.assertTrue(metrics.get(0).getInstanceKey().equals("ClientRequest|Read|Latency|"));
    Assert.assertTrue(metrics.get(0).getMetricValue().equals(new BigDecimal(200)));
    Assert.assertTrue(metrics.get(0).getProperties().equals(metricPropertiesMap.get("Max")));

    Assert.assertTrue(metrics.get(1).getMetricKey().equals("ClientRequest|Read|Latency|Min Latency"));
    Assert.assertTrue(metrics.get(1).getInstanceKey().equals("ClientRequest|Read|Latency|"));
    Assert.assertTrue(metrics.get(1).getMetricValue().equals(new BigDecimal(100)));
    Assert.assertTrue(metrics.get(1).getProperties().equals(metricPropertiesMap.get("Min")));
}
 
开发者ID:Appdynamics,项目名称:activemq-monitoring-extension,代码行数:41,代码来源:NodeMetricsProcessorTest.java


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