private void runHelper() throws Exception { log.debug("PlayUIServer.StatsEventRouterRunnable started"); //Idea: collect all event stats, and route them to the appropriate modules while (!shutdown.get()) { List<StatsStorageEvent> events = new ArrayList<>(); StatsStorageEvent sse = eventQueue.take(); //Blocking operation events.add(sse); eventQueue.drainTo(events); //Non-blocking for (UIModule m : uiModules) { List<String> callbackTypes = m.getCallbackTypeIDs(); List<StatsStorageEvent> out = new ArrayList<>(); for (StatsStorageEvent e : events) { if (callbackTypes.contains(e.getTypeID())) { out.add(e); } } m.reportStorageEvents(out); } try { Thread.sleep(uiProcessingDelay); } catch (InterruptedException e) { if (!shutdown.get()) { throw new RuntimeException("Unexpected interrupted exception", e); } } } } }
@Override public synchronized void attach(StatsStorage statsStorage) { if (statsStorage == null) throw new IllegalArgumentException("StatsStorage cannot be null"); if (statsStorageInstances.contains(statsStorage)) return; StatsStorageListener listener = new QueueStatsStorageListener(eventQueue); listeners.add(new Pair<>(statsStorage, listener)); statsStorage.registerStatsStorageListener(listener); statsStorageInstances.add(statsStorage); for (UIModule uiModule : uiModules) { uiModule.onAttach(statsStorage); } log.info("StatsStorage instance attached to UI: {}", statsStorage); }
@Override public synchronized void detach(StatsStorage statsStorage) { if (statsStorage == null) throw new IllegalArgumentException("StatsStorage cannot be null"); if (!statsStorageInstances.contains(statsStorage)) return; //No op boolean found = false; for (Iterator<Pair<StatsStorage, StatsStorageListener>> iterator = listeners.iterator(); iterator.hasNext();) { Pair<StatsStorage, StatsStorageListener> p = iterator.next(); if (p.getFirst() == statsStorage) { //Same object, not equality statsStorage.deregisterStatsStorageListener(p.getSecond()); iterator.remove(); found = true; } } for (UIModule uiModule : uiModules) { uiModule.onDetach(statsStorage); } if (found) { log.info("StatsStorage instance detached from UI: {}", statsStorage); } }
List<Route> routes = m.getRoutes(); for (Route r : routes) { RoutingDsl.PathPatternMatcher ppm = routingDsl.match(r.getHttpMethod().name(), r.getRoute()); List<String> typeIDs = m.getCallbackTypeIDs(); for (String typeID : typeIDs) { List<UIModule> list = typeIDModuleMap.get(typeID);
List<Route> routes = m.getRoutes(); for (Route r : routes) { RoutingDsl.PathPatternMatcher ppm = routingDsl.match(r.getHttpMethod().name(), r.getRoute()); List<String> typeIDs = m.getCallbackTypeIDs(); for (String typeID : typeIDs) { List<UIModule> list = typeIDModuleMap.get(typeID);
private void runHelper() throws Exception { log.debug("PlayUIServer.StatsEventRouterRunnable started"); //Idea: collect all event stats, and route them to the appropriate modules while (!shutdown.get()) { List<StatsStorageEvent> events = new ArrayList<>(); StatsStorageEvent sse = eventQueue.take(); //Blocking operation events.add(sse); eventQueue.drainTo(events); //Non-blocking for (UIModule m : uiModules) { List<String> callbackTypes = m.getCallbackTypeIDs(); List<StatsStorageEvent> out = new ArrayList<>(); for (StatsStorageEvent e : events) { if (callbackTypes.contains(e.getTypeID())) { out.add(e); } } m.reportStorageEvents(out); } try { Thread.sleep(uiProcessingDelay); } catch (InterruptedException e) { if (!shutdown.get()) { throw new RuntimeException("Unexpected interrupted exception", e); } } } } }
List<Route> routes = m.getRoutes(); for (Route r : routes) { RoutingDsl.PathPatternMatcher ppm = routingDsl.match(r.getHttpMethod().name(), r.getRoute()); List<String> typeIDs = m.getCallbackTypeIDs(); for (String typeID : typeIDs) { List<UIModule> list = typeIDModuleMap.get(typeID);
@Override public synchronized void attach(StatsStorage statsStorage) { if (statsStorage == null) throw new IllegalArgumentException("StatsStorage cannot be null"); if (statsStorageInstances.contains(statsStorage)) return; StatsStorageListener listener = new QueueStatsStorageListener(eventQueue); listeners.add(new Pair<>(statsStorage, listener)); statsStorage.registerStatsStorageListener(listener); statsStorageInstances.add(statsStorage); for (UIModule uiModule : uiModules) { uiModule.onAttach(statsStorage); } log.info("StatsStorage instance attached to UI: {}", statsStorage); }
@Override public synchronized void detach(StatsStorage statsStorage) { if (statsStorage == null) throw new IllegalArgumentException("StatsStorage cannot be null"); if (!statsStorageInstances.contains(statsStorage)) return; //No op boolean found = false; for (Iterator<Pair<StatsStorage, StatsStorageListener>> iterator = listeners.iterator(); iterator.hasNext();) { Pair<StatsStorage, StatsStorageListener> p = iterator.next(); if (p.getFirst() == statsStorage) { //Same object, not equality statsStorage.deregisterStatsStorageListener(p.getSecond()); iterator.remove(); found = true; } } for (UIModule uiModule : uiModules) { uiModule.onDetach(statsStorage); } if (found) { log.info("StatsStorage instance detached from UI: {}", statsStorage); } }
private void runHelper() throws Exception { log.debug("PlayUIServer.StatsEventRouterRunnable started"); //Idea: collect all event stats, and route them to the appropriate modules while (!shutdown.get()) { List<StatsStorageEvent> events = new ArrayList<>(); StatsStorageEvent sse = eventQueue.take(); //Blocking operation events.add(sse); eventQueue.drainTo(events); //Non-blocking for (UIModule m : uiModules) { List<String> callbackTypes = m.getCallbackTypeIDs(); List<StatsStorageEvent> out = new ArrayList<>(); for (StatsStorageEvent e : events) { if (callbackTypes.contains(e.getTypeID())) { out.add(e); } } m.reportStorageEvents(out); } try { Thread.sleep(uiProcessingDelay); } catch (InterruptedException e) { if (!shutdown.get()) { throw new RuntimeException("Unexpected interrupted exception", e); } } } } }
@Override public synchronized void attach(StatsStorage statsStorage) { if (statsStorage == null) throw new IllegalArgumentException("StatsStorage cannot be null"); if (statsStorageInstances.contains(statsStorage)) return; StatsStorageListener listener = new QueueStatsStorageListener(eventQueue); listeners.add(new Pair<>(statsStorage, listener)); statsStorage.registerStatsStorageListener(listener); statsStorageInstances.add(statsStorage); for (UIModule uiModule : uiModules) { uiModule.onAttach(statsStorage); } log.info("StatsStorage instance attached to UI: {}", statsStorage); }
@Override public synchronized void detach(StatsStorage statsStorage) { if (statsStorage == null) throw new IllegalArgumentException("StatsStorage cannot be null"); if (!statsStorageInstances.contains(statsStorage)) return; //No op boolean found = false; for (Iterator<Pair<StatsStorage, StatsStorageListener>> iterator = listeners.iterator(); iterator.hasNext();) { Pair<StatsStorage, StatsStorageListener> p = iterator.next(); if (p.getFirst() == statsStorage) { //Same object, not equality statsStorage.deregisterStatsStorageListener(p.getSecond()); iterator.remove(); found = true; } } for (UIModule uiModule : uiModules) { uiModule.onDetach(statsStorage); } if (found) { log.info("StatsStorage instance detached from UI: {}", statsStorage); } }