Search in sources :

Example 1 with MessageRoute

use of org.apache.metron.profiler.MessageRoute in project metron by apache.

the class ProfileSplitterBolt method routeMessage.

/**
 * Route a message based on the Profiler configuration.
 * @param input The input tuple on which to anchor.
 * @param message The telemetry message.
 * @param config The Profiler configuration.
 * @param timestamp The timestamp of the telemetry message.
 */
private void routeMessage(Tuple input, JSONObject message, ProfilerConfig config, Long timestamp) {
    // emit a tuple for each 'route'
    List<MessageRoute> routes = router.route(message, config, getStellarContext());
    for (MessageRoute route : routes) {
        Values values = createValues(message, timestamp, route);
        collector.emit(input, values);
    }
    LOG.debug("Found {} route(s) for message with timestamp={}", routes.size(), timestamp);
}
Also used : MessageRoute(org.apache.metron.profiler.MessageRoute) Values(org.apache.storm.tuple.Values)

Example 2 with MessageRoute

use of org.apache.metron.profiler.MessageRoute in project metron by apache.

the class ProfileBuilderBolt method handleMessage.

/**
 * Handles the processing of a single tuple.
 *
 * @param input The tuple containing a telemetry message.
 */
private void handleMessage(Tuple input) {
    // crack open the tuple
    JSONObject message = getField(MESSAGE_TUPLE_FIELD, input, JSONObject.class);
    ProfileConfig definition = getField(PROFILE_TUPLE_FIELD, input, ProfileConfig.class);
    String entity = getField(ENTITY_TUPLE_FIELD, input, String.class);
    Long timestamp = getField(TIMESTAMP_TUPLE_FIELD, input, Long.class);
    // keep track of time
    flushSignal.update(timestamp);
    // distribute the message
    MessageRoute route = new MessageRoute(definition, entity);
    messageDistributor.distribute(message, timestamp, route, getStellarContext());
    LOG.debug("Message distributed: profile={}, entity={}, timestamp={}", definition.getProfile(), entity, timestamp);
}
Also used : JSONObject(org.json.simple.JSONObject) MessageRoute(org.apache.metron.profiler.MessageRoute) ProfileConfig(org.apache.metron.common.configuration.profiler.ProfileConfig)

Aggregations

MessageRoute (org.apache.metron.profiler.MessageRoute)2 ProfileConfig (org.apache.metron.common.configuration.profiler.ProfileConfig)1 Values (org.apache.storm.tuple.Values)1 JSONObject (org.json.simple.JSONObject)1