• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MessagePayload类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.googlecode.jsendnsca.MessagePayload的典型用法代码示例。如果您正苦于以下问题:Java MessagePayload类的具体用法?Java MessagePayload怎么用?Java MessagePayload使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MessagePayload类属于com.googlecode.jsendnsca包,在下文中一共展示了MessagePayload类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: shouldConstructTwoNewMessagePayload

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
@Test
public void shouldConstructTwoNewMessagePayload() throws Exception {
    final MessagePayload messagePayload = new MessagePayloadBuilder()
        .withHostname("localhost")
        .withLevel(Level.OK)
        .withServiceName("test service")
        .withMessage("test message")
        .create();

    final MessagePayload messagePayload2 = new MessagePayloadBuilder()
        .withHostname("somehost")
        .withLevel(Level.WARNING)
        .withServiceName("foo service")
        .withMessage("foo message")
        .create();

    assertEquals("localhost", messagePayload.getHostname());
    assertEquals(Level.OK, messagePayload.getLevel());
    assertEquals("test service", messagePayload.getServiceName());
    assertEquals("test message", messagePayload.getMessage());

    assertEquals("somehost", messagePayload2.getHostname());
    assertEquals(Level.WARNING, messagePayload2.getLevel());
    assertEquals("foo service", messagePayload2.getServiceName());
    assertEquals("foo message", messagePayload2.getMessage());
}
 
开发者ID:jsendnsca,项目名称:jsendnsca,代码行数:27,代码来源:MessagePayloadBuilderTest.java


示例2: shouldConstructPayloadWithoutUsingLocalHostname

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
@Test
public void shouldConstructPayloadWithoutUsingLocalHostname() {
    MessagePayload messagePayload = new MessagePayloadBuilder() {
        @Override
        MessagePayload createMessagePayload() {
            return new MessagePayload(false) {
                @Override
                public void useLocalHostname() {
                    throw new UnknownHostRuntimeException(new UnknownHostException());
                }
            };
        }
    }.create();

    assertEquals("UNKNOWN", messagePayload.getHostname());
    assertEquals(Level.UNKNOWN, messagePayload.getLevel());
    assertEquals("UNDEFINED", messagePayload.getServiceName());
    assertEquals(StringUtils.EMPTY, messagePayload.getMessage());
}
 
开发者ID:jsendnsca,项目名称:jsendnsca,代码行数:20,代码来源:MessagePayloadBuilderTest.java


示例3: testSendToNagios

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
@Test
public void testSendToNagios() throws Exception {

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(createRouteBuilder());

    MessagePayload expectedPayload = new MessagePayload("localhost", Level.OK, camelctx.getName(),  "Hello Nagios");

    MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class);
    mock.expectedMessageCount(1);
    mock.allMessages().body().isInstanceOf(String.class);
    mock.expectedBodiesReceived("Hello Nagios");

    camelctx.start();
    try {
        ProducerTemplate template = camelctx.createProducerTemplate();
        template.sendBody("direct:start", "Hello Nagios");

        mock.assertIsSatisfied();

        Mockito.verify(nagiosPassiveCheckSender, Mockito.times(1)).send(expectedPayload);
    } finally {
        camelctx.stop();
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:26,代码来源:NagiosIntegrationTest.java


示例4: testSendToNagiosWarn

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
@Test
public void testSendToNagiosWarn() throws Exception {

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(createRouteBuilder());

    MessagePayload expectedPayload1 = new MessagePayload("localhost", Level.WARNING, camelctx.getName(),  "Hello Nagios");

    MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class);
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived("Hello Nagios");

    camelctx.start();
    try {
        ProducerTemplate template = camelctx.createProducerTemplate();
        template.sendBodyAndHeader("direct:start", "Hello Nagios", NagiosConstants.LEVEL, Level.WARNING);

        mock.assertIsSatisfied();
        Mockito.verify(nagiosPassiveCheckSender).send(expectedPayload1);
    } finally {
        camelctx.stop();
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:24,代码来源:NagiosIntegrationTest.java


示例5: testSendToNagiosWarnAsText

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
@Test
public void testSendToNagiosWarnAsText() throws Exception {

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(createRouteBuilder());

    MessagePayload expectedPayload1 = new MessagePayload("localhost", Level.WARNING, camelctx.getName(),  "Hello Nagios");

    MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class);
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived("Hello Nagios");

    camelctx.start();
    try {
        ProducerTemplate template = camelctx.createProducerTemplate();
        template.sendBodyAndHeader("direct:start", "Hello Nagios", NagiosConstants.LEVEL, "WARNING");

        mock.assertIsSatisfied();

        Mockito.verify(nagiosPassiveCheckSender).send(expectedPayload1);
    } finally {
        camelctx.stop();
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:25,代码来源:NagiosIntegrationTest.java


示例6: shouldConstructNewMessagePayload

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
@Test
public void shouldConstructNewMessagePayload() throws Exception {
    final MessagePayload messagePayload = new MessagePayloadBuilder()
        .withHostname("localhost")
        .withLevel(Level.CRITICAL)
        .withServiceName("test service")
        .withMessage("test message")
        .create();

    assertEquals("localhost", messagePayload.getHostname());
    assertEquals(Level.CRITICAL, messagePayload.getLevel());
    assertEquals("test service", messagePayload.getServiceName());
    assertEquals("test message", messagePayload.getMessage());
}
 
开发者ID:jsendnsca,项目名称:jsendnsca,代码行数:15,代码来源:MessagePayloadBuilderTest.java


示例7: testSendTwoToNagios

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
@Test
public void testSendTwoToNagios() throws Exception {

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(createRouteBuilder());

    MessagePayload expectedPayload1 = new MessagePayload("localhost", Level.OK, camelctx.getName(),  "Hello Nagios");
    MessagePayload expectedPayload2 = new MessagePayload("localhost", Level.OK, camelctx.getName(),  "Bye Nagios");

    MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class);
    mock.expectedMessageCount(2);
    mock.allMessages().body().isInstanceOf(String.class);
    mock.expectedBodiesReceived("Hello Nagios", "Bye Nagios");

    camelctx.start();
    try {
        ProducerTemplate template = camelctx.createProducerTemplate();
        template.sendBody("direct:start", "Hello Nagios");
        template.sendBody("direct:start", "Bye Nagios");

        mock.assertIsSatisfied();

        Mockito.verify(nagiosPassiveCheckSender).send(expectedPayload1);
        Mockito.verify(nagiosPassiveCheckSender).send(expectedPayload2);
    } finally {
        camelctx.stop();
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:29,代码来源:NagiosIntegrationTest.java


示例8: testSendToNagiosMultiHeaders

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
@Test
public void testSendToNagiosMultiHeaders() throws Exception {

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(createRouteBuilder());

    MessagePayload expectedPayload1 = new MessagePayload("myHost", Level.CRITICAL, "myService",  "Hello Nagios");

    MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class);
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived("Hello Nagios");

    Map<String, Object> headers = new HashMap<String, Object>();
    headers.put(NagiosConstants.LEVEL, "CRITICAL");
    headers.put(NagiosConstants.HOST_NAME, "myHost");
    headers.put(NagiosConstants.SERVICE_NAME, "myService");

    camelctx.start();
    try {
        ProducerTemplate template = camelctx.createProducerTemplate();
        template.sendBodyAndHeaders("direct:start", "Hello Nagios", headers);

        mock.assertIsSatisfied();
        Mockito.verify(nagiosPassiveCheckSender).send(expectedPayload1);
    } finally {
        camelctx.stop();
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:29,代码来源:NagiosIntegrationTest.java


示例9: NscaCollector

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
public NscaCollector(PropertiesConfiguration properties) {
	super(properties, ActivecheckCollectorType.REPORTING);
	messageQueue = new LinkedList<MessagePayload>();

	// initialize what has not been initialized
	collectorInit();
}
 
开发者ID:frederikhappel,项目名称:activecheck,代码行数:8,代码来源:NscaCollector.java


示例10: sendImpl

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
@Override
public synchronized void sendImpl(NagiosServiceReport report) {
	String message = report.getMessageWithPerformancedata().replace("\n",
			"\\n");
	MessagePayload payload = new MessagePayloadBuilder().withHostname(report.getServiceHost()).withLevel(status2level.get(report.getStatus())).withMessage(message).create();
	String serviceName = report.getServiceName();
	if (serviceName != null) {
		payload.setServiceName(report.getServiceName());
	}
	messageQueue.add(payload);
	logger.trace(message);
}
 
开发者ID:frederikhappel,项目名称:activecheck,代码行数:13,代码来源:NscaCollector.java


示例11: send

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
public void send(Level level, String serviceName, String message)
		throws NagiosException, IOException {
	message = message.replace("\n", "\\n");
	MessagePayload payload = new MessagePayloadBuilder()
			.withHostname(senderHostName).withLevel(level)
			.withServiceName(serviceName).withMessage(message).create();

	sender.send(payload);
}
 
开发者ID:frederikhappel,项目名称:graylog2-plugin-alarmcallback-nsca,代码行数:10,代码来源:NscaHost.java


示例12: createMessagePayload

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
MessagePayload createMessagePayload() {
    return new MessagePayload(false);
}
 
开发者ID:jsendnsca,项目名称:jsendnsca,代码行数:4,代码来源:MessagePayloadBuilder.java


示例13: create

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
/**
 * Return the built {@link MessagePayload}
 *
 * @return the built {@link MessagePayload}
 */
public MessagePayload create() {
    return payload;
}
 
开发者ID:jsendnsca,项目名称:jsendnsca,代码行数:9,代码来源:MessagePayloadBuilder.java


示例14: getMessagePayloadList

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
public List<MessagePayload> getMessagePayloadList() {
        return messagePayloads;
    } 
开发者ID:jsendnsca,项目名称:jsendnsca,代码行数:4,代码来源:NagiosNscaStub.java


示例15: parsePayload

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
private MessagePayload parsePayload(InputStream inputStream, byte[] initVector) throws IOException {
            DataInputStream stream = new DataInputStream(inputStream);

            byte[] bytes = new byte[16 + 64 + 128 + maxMessageSizeInChars];
            stream.readFully(bytes);

            decrypt(bytes, initVector);

            stream = new DataInputStream(new ByteArrayInputStream(bytes));

            int amountToSkip = 12;
            skipBytes(stream, amountToSkip);

            short level = stream.readShort();
            byte[] hostNameBytes = new byte[64];
            stream.readFully(hostNameBytes);
            String hostName = new String(hostNameBytes).trim();
            byte[] serviceNameBytes = new byte[128];
            stream.readFully(serviceNameBytes);
            String serviceName = new String(serviceNameBytes).trim();

            byte[] messageBytes = new byte[maxMessageSizeInChars];
            stream.readFully(messageBytes);
            String message = new String(messageBytes).trim();
            return new MessagePayloadBuilder().withHostname(hostName).withLevel(level).withServiceName(serviceName).withMessage(message).create();
        } 
开发者ID:jsendnsca,项目名称:jsendnsca,代码行数:27,代码来源:NagiosNscaStub.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Transaction类代码示例发布时间:2022-05-23
下一篇:
Java DRefPattern类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap