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


Java MessageInput类代码示例

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


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

示例1: launchCreatesAndStartsAppenderAndProcessesMessages

import org.graylog2.plugin.inputs.MessageInput; //导入依赖的package包/类
@Test
public void launchCreatesAndStartsAppenderAndProcessesMessages() throws Exception {
    final MessageInput messageInput = mock(MessageInput.class);
    transport.launch(messageInput);

    final DirectConsumingAppender appender = transport.getAppender();
    assertThat(appender.getName()).isEqualTo("graylog-plugin-internal-logs");
    assertThat(appender.getLayout()).isInstanceOf(SerializedLayout.class);
    assertThat(appender.isStarted()).isTrue();

    final MutableLogEvent logEvent = new MutableLogEvent();
    logEvent.setMessage(new SimpleMessage("Processed"));
    logEvent.setLevel(Level.ERROR);
    appender.append(logEvent);
    verify(messageInput, times(1)).processRawMessage(any(RawMessage.class));

    final MutableLogEvent ignoredLogEvent = new MutableLogEvent();
    ignoredLogEvent.setMessage(new SimpleMessage("Ignored"));
    ignoredLogEvent.setLevel(Level.TRACE);
    appender.append(ignoredLogEvent);
    verifyNoMoreInteractions(messageInput);
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-internal-logs,代码行数:23,代码来源:SerializedLogEventTransportTest.java

示例2: doLaunch

import org.graylog2.plugin.inputs.MessageInput; //导入依赖的package包/类
@Override
public void doLaunch(MessageInput input) throws MisfireException {
    serverStatus.awaitRunning(() -> lifecycleStateChange(Lifecycle.RUNNING));

    LOG.info("Starting s3 subscriber");

    final String legacyRegionName = input.getConfiguration().getString(CK_LEGACY_AWS_REGION, DEFAULT_REGION.getName());
    final String sqsRegionName = input.getConfiguration().getString(CK_AWS_SQS_REGION, legacyRegionName);
    final String s3RegionName = input.getConfiguration().getString(CK_AWS_S3_REGION, legacyRegionName);

    subscriber = new S3Subscriber(
            Region.getRegion(Regions.fromName(sqsRegionName)),
            Region.getRegion(Regions.fromName(s3RegionName)),
            input.getConfiguration().getString(CK_SQS_NAME),
            input,
            input.getConfiguration().getString(CK_ACCESS_KEY),
            input.getConfiguration().getString(CK_SECRET_KEY),
            input.getConfiguration().getInt(CK_THREAD_COUNT)
    );

    subscriber.start();
}
 
开发者ID:sherzberg,项目名称:graylog-plugin-s3,代码行数:23,代码来源:S3Transport.java

示例3: doLaunch

import org.graylog2.plugin.inputs.MessageInput; //导入依赖的package包/类
@Override
protected void doLaunch(final MessageInput input) throws MisfireException {
    consumer = new NsqClientBuilder(configuration).buildLookupd(new NSQMessageCallback() {
        @Override
        public void message(NSQMessage nsqMessage) {
            final RawMessage rawMessage = new RawMessage(nsqMessage.getMessage());
            nsqMessage.finished();
            input.processRawMessage(rawMessage);

            // do throttle the code
            if (isThrottled()) {
                blockUntilUnthrottled();
            }

        }
    });

    consumer.start();
}
 
开发者ID:condevtec,项目名称:graylog-plugin-nsq,代码行数:20,代码来源:NsqTransport.java

示例4: setupInput

import org.graylog2.plugin.inputs.MessageInput; //导入依赖的package包/类
private String setupInput(String name, Class<? extends MessageInput> inputType, int port) {
    Map<String, Object> properties = new HashMap<>();
    properties.put("use_null_delimiter", true);
    properties.put("bind_address", "0.0.0.0");
    properties.put("port", port);

    InputCreateRequest request = InputCreateRequest.create(
            name,
            inputType.getName(),
            true,
            properties,
            null);

    String inputId = graylogRestInterface.createInput(request);
    LOGGER.info(String.format("%s input created.", name));
    return inputId;
}
 
开发者ID:mike-plummer,项目名称:graylog-springboot,代码行数:18,代码来源:GraylogInstance.java

示例5: readDataFromNOAA

import org.graylog2.plugin.inputs.MessageInput; //导入依赖的package包/类
private Runnable readDataFromNOAA(final MessageInput messageInput) {
    return new Runnable() {
        @Override
        public void run() {
            StringBuilder response = new StringBuilder();
            try {
                BufferedReader in = new BufferedReader(new InputStreamReader(urlACESWEPAM.openStream()));
                String line;
                while ((line = in.readLine()) != null) {
                    response.append(line).append("\n");
                }
                in.close();
            } catch (Exception e) {
                LOG.error("Could not read space weather information from NOAA.", e);
                return;
            }

            messageInput.processRawMessage(new RawMessage(response.toString().getBytes()));
        }
    };
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-spaceweather,代码行数:22,代码来源:SpaceweatherTransport.java

示例6: S3Subscriber

import org.graylog2.plugin.inputs.MessageInput; //导入依赖的package包/类
public S3Subscriber(Region sqsRegion, Region s3Region, String queueName, MessageInput sourceInput, String accessKey, String secretKey, int threadCount) {
    this.sourceInput = sourceInput;

    this.subscriber = new S3SQSClient(
            sqsRegion,
            queueName,
            accessKey,
            secretKey
    );

    this.s3Reader = new S3Reader(s3Region, accessKey, secretKey);
    this.threadCount = threadCount;
    this.executor = new ScheduledThreadPoolExecutor(threadCount, Executors.defaultThreadFactory());
}
 
开发者ID:sherzberg,项目名称:graylog-plugin-s3,代码行数:15,代码来源:S3Subscriber.java

示例7: subscribeChannel

import org.graylog2.plugin.inputs.MessageInput; //导入依赖的package包/类
@Test
public void subscribeChannel() throws Exception {
    final Configuration configuration = new Configuration(
            ImmutableMap.of(
                    "redis_uri", "redis://" + REDIS_HOST + ":" + REDIS_PORT,
                    "channels", "graylog"
            )
    );

    final RedisTransport redisTransport = new RedisTransport(configuration, eventBus, localMetricRegistry);
    final RedisURI redisURI = RedisURI.create(REDIS_HOST, REDIS_PORT);
    final RedisClient client = RedisClient.create(redisURI);

    final StatefulRedisPubSubConnection<String, String> pubSub = client.connectPubSub();

    final MessageInput messageInput = mock(MessageInput.class);
    redisTransport.launch(messageInput);

    final RedisPubSubCommands<String, String> commands = pubSub.sync();
    final int numMessages = 100;
    for (int i = 0; i < numMessages; i++) {
        commands.publish("graylog", "TEST-" + i);
    }

    Thread.sleep(100L);

    verify(messageInput, times(numMessages)).processRawMessage(any(RawMessage.class));

    redisTransport.stop();
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-redis,代码行数:31,代码来源:RedisTransportIT.java

示例8: subscribePattern

import org.graylog2.plugin.inputs.MessageInput; //导入依赖的package包/类
@Test
public void subscribePattern() throws Exception {
    final Configuration configuration = new Configuration(
            ImmutableMap.of(
                    "redis_uri", "redis://" + REDIS_HOST + ":" + REDIS_PORT,
                    "patterns", "g*log"
            )
    );

    final RedisTransport redisTransport = new RedisTransport(configuration, eventBus, localMetricRegistry);
    final RedisURI redisURI = RedisURI.create(REDIS_HOST, REDIS_PORT);
    final RedisClient client = RedisClient.create(redisURI);

    final StatefulRedisPubSubConnection<String, String> pubSub = client.connectPubSub();

    final MessageInput messageInput = mock(MessageInput.class);
    redisTransport.launch(messageInput);

    final RedisPubSubCommands<String, String> commands = pubSub.sync();
    final int numMessages = 100;
    for (int i = 0; i < numMessages; i++) {
        commands.publish("graylog", "TEST-" + i);
    }
    Thread.sleep(100L);

    verify(messageInput, times(numMessages)).processRawMessage(any(RawMessage.class));

    redisTransport.stop();
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-redis,代码行数:30,代码来源:RedisTransportIT.java

示例9: getFinalChannelHandlers

import org.graylog2.plugin.inputs.MessageInput; //导入依赖的package包/类
@Override
protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getFinalChannelHandlers(MessageInput input) {
    final LinkedHashMap<String, Callable<? extends ChannelHandler>> finalChannelHandlers = super.getFinalChannelHandlers(input);
    final LinkedHashMap<String, Callable<? extends ChannelHandler>> handlers = new LinkedHashMap<>();
    handlers.put("beats", BeatsFrameDecoder::new);
    handlers.putAll(finalChannelHandlers);

    return handlers;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-beats,代码行数:10,代码来源:BeatsTransport.java

示例10: getFinalChannelHandlers

import org.graylog2.plugin.inputs.MessageInput; //导入依赖的package包/类
@Test
public void getFinalChannelHandlers() throws Exception {
    final BeatsTransport transport = new BeatsTransport(
            new Configuration(null),
            new ThroughputCounter(new HashedWheelTimer()),
            new LocalMetricRegistry(),
            Executors.newSingleThreadExecutor(),
            new ConnectionCounter()
    );

    final MessageInput input = mock(MessageInput.class);
    final LinkedHashMap<String, Callable<? extends ChannelHandler>> channelHandlers = transport.getFinalChannelHandlers(input);
    assertThat(channelHandlers).containsKey("beats");
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-beats,代码行数:15,代码来源:BeatsTransportTest.java

示例11: evaluate

import org.graylog2.plugin.inputs.MessageInput; //导入依赖的package包/类
@Override
public Boolean evaluate(FunctionArgs args, EvaluationContext context) {
    String id = idParam.optional(args, context).orElse("");

    MessageInput input = null;
    if ("".equals(id)) {
        final String name = nameParam.optional(args, context).orElse("");
        for (IOState<MessageInput> messageInputIOState : inputRegistry.getInputStates()) {
            final MessageInput messageInput = messageInputIOState.getStoppable();
            if (messageInput.getTitle().equalsIgnoreCase(name)) {
                input = messageInput;
                break;
            }
        }
        if ("".equals(name)) {
            return null;
        }
    } else {
        final IOState<MessageInput> inputState = inputRegistry.getInputState(id);
        if (inputState != null) {
            input = inputState.getStoppable();
        }

    }
    return input != null
            && input.getId().equals(context.currentMessage().getSourceInputId());
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-pipeline-processor,代码行数:28,代码来源:FromInput.java

示例12: launch

import org.graylog2.plugin.inputs.MessageInput; //导入依赖的package包/类
@Override
public void launch(MessageInput input) throws MisfireException {
    appender = new DirectConsumingAppender(
            "graylog-plugin-internal-logs",
            logEvent -> input.processRawMessage(new RawMessage(logEvent)),
            threshold);
    addAppender(appender);
}
 
开发者ID:graylog-labs,项目名称:graylog-plugin-internal-logs,代码行数:9,代码来源:SerializedLogEventTransport.java

示例13: startMonitoring

import org.graylog2.plugin.inputs.MessageInput; //导入依赖的package包/类
private void startMonitoring(MessageInput messageInput) {
    executorService = Executors.newScheduledThreadPool(servers.size());
    futures = new ArrayList<>(servers.size());
    long initalDelayMillis = TimeUnit.MILLISECONDS.convert(Math.round(Math.random() * 60), TimeUnit.SECONDS);
    long executionIntervalMillis = TimeUnit.MILLISECONDS.convert(executionInterval, getExecutionIntervalTimeUnit);
    for (Server server : servers) {
        ScheduledFuture future = executorService.scheduleAtFixedRate(new PollTask(messageInput, server, queryConfig, label),
                initalDelayMillis, executionIntervalMillis, TimeUnit.MILLISECONDS);
        futures.add(future);
    }

    LOGGER.info("JMX Input Plugin started ...");
}
 
开发者ID:sivasamyk,项目名称:graylog-plugin-input-jmx,代码行数:14,代码来源:JMXTransport.java

示例14: PollTask

import org.graylog2.plugin.inputs.MessageInput; //导入依赖的package包/类
public PollTask(MessageInput messageInput, Server server, GLQueryConfig queryConfig, String label) {
    this.messageInput = messageInput;
    this.server = server;
    this.queryConfig = queryConfig;
    this.label = label;
    queryProcessor = new JmxQueryProcessor();
    mapper = new ObjectMapper();
    connections = new Hashtable<>();
    populateConfiguredAttributes();

}
 
开发者ID:sivasamyk,项目名称:graylog-plugin-input-jmx,代码行数:12,代码来源:JMXTransport.java

示例15: getChannelHandlers

import org.graylog2.plugin.inputs.MessageInput; //导入依赖的package包/类
@Override
protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getChannelHandlers(MessageInput input) {
    final LinkedHashMap<String, Callable<? extends ChannelHandler>> handlers = new LinkedHashMap<>(super.getChannelHandlers(input));

    // Replace the default "codec-aggregator" handler with one that passes the remote address
    final RemoteAddressCodecAggregator aggregator = (RemoteAddressCodecAggregator) getAggregator();
    handlers.replace("codec-aggregator", () -> new NetflowMessageAggregationHandler(aggregator, localRegistry));
    handlers.remove("udp-datagram");

    return handlers;
}
 
开发者ID:Graylog2,项目名称:graylog-plugin-netflow,代码行数:12,代码来源:NetFlowUdpTransport.java


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