[GitHub] incubator-geode pull request #299: [ GEODE-2141 ] #comment Fix Issue #2141
Github user upthewaterspout commented on a diff in the pull request: https://github.com/apache/incubator-geode/pull/299#discussion_r90077733 --- Diff: geode-core/src/main/java/org/apache/geode/internal/statistics/StatMonitorHandler.java --- @@ -50,36 +50,26 @@ public StatMonitorHandler() { /** Adds a monitor which will be notified of samples */ public boolean addMonitor(StatisticsMonitor monitor) { -synchronized (this) { - boolean added = false; - List oldMonitors = this.monitors; - if (!oldMonitors.contains(monitor)) { -List newMonitors = new ArrayList(oldMonitors); -added = newMonitors.add(monitor); -this.monitors = Collections.unmodifiableList(newMonitors); - } - if (!this.monitors.isEmpty()) { -startNotifier_IfEnabledAndNotRunning(); - } - return added; +boolean added = false; --- End diff -- I don't think it's safe to remove the synchronization here. You're calling contains followed by add followed by isEmpty. Also, startNotifier_... is dependent on the state of this.monitors. this.monitors could be getting changed by other threads at any point in here. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] incubator-geode pull request #299: [ GEODE-2141 ] #comment Fix Issue #2141
Github user metatype commented on a diff in the pull request: https://github.com/apache/incubator-geode/pull/299#discussion_r90025623 --- Diff: geode-core/src/main/java/org/apache/geode/internal/statistics/StatisticsMonitor.java --- @@ -114,14 +100,14 @@ protected void monitor(long millisTimeStamp, List resourceInst private final void monitorStatisticIds(long millisTimeStamp, List resourceInstances) { -List statisticIdsToMonitor = statisticIds; +ConcurrentHashSet statisticIdsToMonitor = statisticIds; if (!statisticIdsToMonitor.isEmpty()) { // TODO: } } protected final void notifyListeners(StatisticsNotification notification) { -List listenersToNotify = this.listeners; +ConcurrentHashSet listenersToNotify = this.listeners; --- End diff -- I don't think this copy is needed since `listeners` is never updated after initialization. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] incubator-geode pull request #299: [ GEODE-2141 ] #comment Fix Issue #2141
Github user metatype commented on a diff in the pull request: https://github.com/apache/incubator-geode/pull/299#discussion_r90025760 --- Diff: geode-core/src/main/java/org/apache/geode/internal/statistics/StatMonitorHandler.java --- @@ -110,7 +100,7 @@ public void sampled(long nanosTimeStamp, List resourceInstance } private void monitor(final long sampleTimeMillis, final List resourceInstance) { -List currentMonitors = StatMonitorHandler.this.monitors; +ConcurrentHashSet currentMonitors = StatMonitorHandler.this.monitors; --- End diff -- I don't think this copy is needed since `monitors` is never updated after initialization. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] incubator-geode pull request #299: [ GEODE-2141 ] #comment Fix Issue #2141
Github user metatype commented on a diff in the pull request: https://github.com/apache/incubator-geode/pull/299#discussion_r90025277 --- Diff: geode-core/src/main/java/org/apache/geode/internal/statistics/StatMonitorHandler.java --- @@ -38,7 +37,8 @@ private final boolean enableMonitorThread; /** The registered monitors */ - private volatile List monitors = Collections.emptyList(); + private volatile ConcurrentHashSet monitors = --- End diff -- Instead of `volatile` I think this should be final. I don't see a write to this var after initialization. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---