Receive the event filter string in the Java agent
[lttng-ust.git] / liblttng-ust-java-agent / java / lttng-ust-agent-common / org / lttng / ust / agent / AbstractLttngAgent.java
index c3fc339bc628b09234e1ed41962f2197fb221b8f..8531eaec7c3b8ddab23f0b7aa1e668ffc3376124 100644 (file)
@@ -30,6 +30,8 @@ import java.util.concurrent.atomic.AtomicInteger;
 
 import org.lttng.ust.agent.client.ILttngTcpClientListener;
 import org.lttng.ust.agent.client.LttngTcpSessiondClient;
+import org.lttng.ust.agent.filter.FilterChangeNotifier;
+import org.lttng.ust.agent.session.EventRule;
 
 /**
  * Base implementation of a {@link ILttngAgent}.
@@ -55,7 +57,7 @@ public abstract class AbstractLttngAgent<T extends ILttngHandler>
         * falls to 0, this means we can avoid sending log events through JNI
         * because nobody wants them.
         *
-        * It uses a concurrent hash set", so that the {@link #isEventEnabled} and
+        * It uses a concurrent hash map, so that the {@link #isEventEnabled} and
         * read methods do not need to take a synchronization lock.
         */
        private final Map<String, Integer> enabledEvents = new ConcurrentHashMap<String, Integer>();
@@ -189,12 +191,16 @@ public abstract class AbstractLttngAgent<T extends ILttngHandler>
        }
 
        @Override
-       public boolean eventEnabled(String eventName) {
+       public boolean eventEnabled(EventRule eventRule) {
+               /* Notify the filter change manager of the command */
+               FilterChangeNotifier.getInstance().addEventRule(eventRule);
+
+               String eventName = eventRule.getEventName();
+
                if (eventName.equals(WILDCARD)) {
                        enabledWildcards.incrementAndGet();
                        return true;
                }
-
                if (eventName.endsWith(WILDCARD)) {
                        /* Strip the "*" from the name. */
                        String prefix = eventName.substring(0, eventName.length() - 1);
@@ -206,6 +212,9 @@ public abstract class AbstractLttngAgent<T extends ILttngHandler>
 
        @Override
        public boolean eventDisabled(String eventName) {
+               /* Notify the filter change manager of the command */
+               FilterChangeNotifier.getInstance().removeEventRules(eventName);
+
                if (eventName.equals(WILDCARD)) {
                        int newCount = enabledWildcards.decrementAndGet();
                        if (newCount < 0) {
This page took 0.025179 seconds and 4 git commands to generate.