本文整理汇总了Java中org.apache.hadoop.metrics2.MetricsSystem.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Java MetricsSystem.shutdown方法的具体用法?Java MetricsSystem.shutdown怎么用?Java MetricsSystem.shutdown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.metrics2.MetricsSystem
的用法示例。
在下文中一共展示了MetricsSystem.shutdown方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFailedWrite
import org.apache.hadoop.metrics2.MetricsSystem; //导入方法依赖的package包/类
/**
* Test that writing fails when the directory isn't writable.
*/
@Test
public void testFailedWrite() {
String path = methodDir.getAbsolutePath();
MetricsSystem ms = initMetricsSystem(path, false, false);
new MyMetrics1().registerWith(ms);
methodDir.setWritable(false);
MockSink.errored = false;
try {
// publish the metrics
ms.publishMetricsNow();
assertTrue("No exception was generated while writing metrics "
+ "even though the target directory was not writable",
MockSink.errored);
ms.stop();
ms.shutdown();
} finally {
// Make sure the dir is writable again so we can delete it at the end
methodDir.setWritable(true);
}
}
示例2: doWriteTest
import org.apache.hadoop.metrics2.MetricsSystem; //导入方法依赖的package包/类
/**
* Helper method that writes metrics files to a target path, reads those
* files, and returns the contents of all files as a single string. This
* method will assert that the correct number of files is found.
*
* @param ms an initialized MetricsSystem to use
* @param path the target path from which to read the logs
* @param count the number of log files to expect
* @return the contents of the log files
* @throws IOException when the log file can't be read
* @throws URISyntaxException when the target path is an invalid URL
*/
protected String doWriteTest(MetricsSystem ms, String path, int count)
throws IOException, URISyntaxException {
final String then = DATE_FORMAT.format(new Date());
MyMetrics1 mm1 = new MyMetrics1().registerWith(ms);
new MyMetrics2().registerWith(ms);
mm1.testMetric1.incr();
mm1.testMetric2.incr(2);
ms.publishMetricsNow(); // publish the metrics
ms.stop();
ms.shutdown();
return readLogFile(path, then, count);
}
示例3: testUnregisterSource
import org.apache.hadoop.metrics2.MetricsSystem; //导入方法依赖的package包/类
@Test public void testUnregisterSource() {
MetricsSystem ms = new MetricsSystemImpl();
TestSource ts1 = new TestSource("ts1");
TestSource ts2 = new TestSource("ts2");
ms.register("ts1", "", ts1);
ms.register("ts2", "", ts2);
MetricsSource s1 = ms.getSource("ts1");
assertNotNull(s1);
// should work when metrics system is not started
ms.unregisterSource("ts1");
s1 = ms.getSource("ts1");
assertNull(s1);
MetricsSource s2 = ms.getSource("ts2");
assertNotNull(s2);
ms.shutdown();
}
示例4: testRegisterSourceWithoutName
import org.apache.hadoop.metrics2.MetricsSystem; //导入方法依赖的package包/类
@Test public void testRegisterSourceWithoutName() {
MetricsSystem ms = new MetricsSystemImpl();
TestSource ts = new TestSource("ts");
TestSource2 ts2 = new TestSource2("ts2");
ms.register(ts);
ms.register(ts2);
ms.init("TestMetricsSystem");
// if metrics source is registered without name,
// the class name will be used as the name
MetricsSourceAdapter sa = ((MetricsSystemImpl) ms)
.getSourceAdapter("TestSource");
assertNotNull(sa);
MetricsSourceAdapter sa2 = ((MetricsSystemImpl) ms)
.getSourceAdapter("TestSource2");
assertNotNull(sa2);
ms.shutdown();
}
示例5: testSilentFailedWrite
import org.apache.hadoop.metrics2.MetricsSystem; //导入方法依赖的package包/类
/**
* Test that writing fails silently when the directory is not writable.
*/
@Test
public void testSilentFailedWrite() {
String path = methodDir.getAbsolutePath();
MetricsSystem ms = initMetricsSystem(path, true, false);
new MyMetrics1().registerWith(ms);
methodDir.setWritable(false);
MockSink.errored = false;
try {
// publish the metrics
ms.publishMetricsNow();
assertFalse("An exception was generated while writing metrics "
+ "when the target directory was not writable, even though the "
+ "sink is set to ignore errors",
MockSink.errored);
ms.stop();
ms.shutdown();
} finally {
// Make sure the dir is writable again so we can delete it at the end
methodDir.setWritable(true);
}
}
示例6: testRegisterDups
import org.apache.hadoop.metrics2.MetricsSystem; //导入方法依赖的package包/类
@Test public void testRegisterDups() {
MetricsSystem ms = new MetricsSystemImpl();
TestSource ts1 = new TestSource("ts1");
TestSource ts2 = new TestSource("ts2");
ms.register("ts1", "", ts1);
MetricsSource s1 = ms.getSource("ts1");
assertNotNull(s1);
// should work when metrics system is not started
ms.register("ts1", "", ts2);
MetricsSource s2 = ms.getSource("ts1");
assertNotNull(s2);
assertNotSame(s1, s2);
ms.shutdown();
}
示例7: testRegisterSourceJmxCacheTTL
import org.apache.hadoop.metrics2.MetricsSystem; //导入方法依赖的package包/类
@Test
public void testRegisterSourceJmxCacheTTL() {
MetricsSystem ms = new MetricsSystemImpl();
ms.init("TestMetricsSystem");
TestSource ts = new TestSource("ts");
ms.register(ts);
MetricsSourceAdapter sa = ((MetricsSystemImpl) ms)
.getSourceAdapter("TestSource");
assertEquals(MetricsConfig.PERIOD_DEFAULT * 1000 + 1,
sa.getJmxCacheTTL());
ms.shutdown();
}
示例8: testMetricsCache
import org.apache.hadoop.metrics2.MetricsSystem; //导入方法依赖的package包/类
@Test
public void testMetricsCache() {
MetricsSystem ms = new MetricsSystemImpl("cache");
ms.start();
try {
String p1 = "root1";
String leafQueueName = "root1.leaf";
QueueMetrics p1Metrics =
QueueMetrics.forQueue(ms, p1, null, true, conf);
Queue parentQueue1 = make(stub(Queue.class).returning(p1Metrics).
from.getMetrics());
QueueMetrics metrics =
QueueMetrics.forQueue(ms, leafQueueName, parentQueue1, true, conf);
Assert.assertNotNull("QueueMetrics for A shoudn't be null", metrics);
// Re-register to check for cache hit, shouldn't blow up metrics-system...
// also, verify parent-metrics
QueueMetrics alterMetrics =
QueueMetrics.forQueue(ms, leafQueueName, parentQueue1, true, conf);
Assert.assertNotNull("QueueMetrics for alterMetrics shoudn't be null",
alterMetrics);
} finally {
ms.shutdown();
}
}
示例9: testMetricsCache
import org.apache.hadoop.metrics2.MetricsSystem; //导入方法依赖的package包/类
@Test
public void testMetricsCache() {
MetricsSystem ms = new MetricsSystemImpl("cache");
ms.start();
try {
String p1 = "root1";
String leafQueueName = "root1.leaf";
QueueMetrics p1Metrics =
QueueMetrics.forQueue(ms, p1, null, true, conf);
Queue parentQueue1 = make(stub(Queue.class).returning(p1Metrics).
from.getMetrics());
QueueMetrics metrics =
QueueMetrics.forQueue(ms, leafQueueName, parentQueue1, true, conf);
Assert.assertNotNull("QueueMetrics for A shoudn't be null", metrics);
// Re-register to check for cache hit, shouldn't blow up metrics-system...
// also, verify parent-metrics
QueueMetrics alterMetrics =
QueueMetrics.forQueue(ms, leafQueueName, parentQueue1, true, conf);
Assert.assertNotNull("QueueMetrics for alterMetrics shoudn't be null",
alterMetrics);
} finally {
ms.shutdown();
}
}