@Override public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) { super.prepare(stormConf, context, collector); this.collector = collector; this.parser = new JSONParser(); this.router = new DefaultMessageRouter(getStellarContext()); }
/** * Route a telemetry message. Finds all routes for a given telemetry message. * * @param message The telemetry message that needs routed. * @param config The configuration for the Profiler. * @param context The Stellar execution context. * @return A list of all the routes for the message. */ @Override public List<MessageRoute> route(JSONObject message, ProfilerConfig config, Context context) { List<MessageRoute> routes = new ArrayList<>(); // attempt to route the message to each of the profiles for (ProfileConfig profile: config.getProfiles()) { Clock clock = clockFactory.createClock(config); Optional<MessageRoute> route = routeToProfile(message, profile, clock); route.ifPresent(routes::add); } return routes; }
/** * Create a new Profiler. * * @param config The Profiler configuration. * @param periodDurationMillis The period duration in milliseconds. * @param profileTimeToLiveMillis The time-to-live of a profile in milliseconds. * @param maxNumberOfRoutes The max number of unique routes to maintain. After this is exceeded, lesser * used routes will be evicted from the internal cache. * @param context The Stellar execution context. */ public StandAloneProfiler(ProfilerConfig config, long periodDurationMillis, long profileTimeToLiveMillis, long maxNumberOfRoutes, Context context) { this.context = context; this.config = config; this.router = new DefaultMessageRouter(context); this.distributor = new DefaultMessageDistributor(periodDurationMillis, profileTimeToLiveMillis, maxNumberOfRoutes); this.clockFactory = new DefaultClockFactory(); this.messageCount = 0; this.routeCount = 0; }
JSONParser parser = new JSONParser(); Context context = TaskUtils.getContext(globals); MessageRouter router = new DefaultMessageRouter(context);