Build the liblttng-ust-java library using the new M4 macros
[lttng-ust.git] / liblttng-ust-jul / org / lttng / ust / jul / LTTngTCPSessiondClient.java
index a2d12fc3008d869a9027b03b0e22244f9a92be98..cf3074b0728f21d7d66ef4d046827a913e86feac 100644 (file)
@@ -31,18 +31,7 @@ import java.io.FileReader;
 import java.io.FileNotFoundException;
 import java.net.*;
 import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Enumeration;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
 import java.util.logging.Logger;
-import java.util.Collections;
 
 class USTRegisterMsg {
        public static int pid;
@@ -64,25 +53,13 @@ public class LTTngTCPSessiondClient {
 
        private Semaphore registerSem;
 
-       private Timer eventTimer;
-
+       private static final String rootPortFile = "/var/run/lttng/agent.port";
+       private static final String userPortFile = "/.lttng/agent.port";
        /*
-        * Indexed by event name but can contains duplicates since multiple
-        * sessions can enable the same event with or without different loglevels.
+        * This is taken from the lttng/domain.h file which is mapped to
+        * LTTNG_DOMAIN_JUL value for this agent.
         */
-       private Map<String, ArrayList<LTTngEvent>> eventMap =
-               Collections.synchronizedMap(
-                               new HashMap<String, ArrayList<LTTngEvent>>());
-
-       private Set<LTTngEvent> wildCardSet =
-               Collections.synchronizedSet(new HashSet<LTTngEvent>());
-
-       /* Timer delay at each 5 seconds. */
-       private final static long timerDelay = 5 * 1000;
-       private static boolean timerInitialized;
-
-       private static final String rootPortFile = "/var/run/lttng/jul.port";
-       private static final String userPortFile = "/.lttng/jul.port";
+       private static final int agent_domain = 3;
 
        /* Indicate if we've already release the semaphore. */
        private boolean sem_posted = false;
@@ -90,83 +67,6 @@ public class LTTngTCPSessiondClient {
        public LTTngTCPSessiondClient(String host, Semaphore sem) {
                this.sessiondHost = host;
                this.registerSem = sem;
-               this.eventTimer = new Timer();
-               this.timerInitialized = false;
-       }
-
-       private void setupEventTimer() {
-               if (this.timerInitialized) {
-                       return;
-               }
-
-               this.eventTimer.scheduleAtFixedRate(new TimerTask() {
-                       @Override
-                       public void run() {
-                               LTTngSessiondCmd2_4.sessiond_enable_handler enableCmd = new
-                                       LTTngSessiondCmd2_4.sessiond_enable_handler();
-
-                               synchronized (eventMap) {
-                                       String loggerName;
-                                       Enumeration loggers = handler.logManager.getLoggerNames();
-
-                                       /*
-                                        * Create an event for each logger found and attach it to the
-                                        * handler.
-                                        */
-                                       while (loggers.hasMoreElements()) {
-                                               ArrayList<LTTngEvent> bucket;
-
-                                               loggerName = loggers.nextElement().toString();
-
-                                               /* Logger is already enabled or end of list, skip it. */
-                                               if (handler.exists(loggerName) == true ||
-                                                               loggerName.equals("")) {
-                                                       continue;
-                                               }
-
-                                               bucket = eventMap.get(loggerName);
-                                               if (bucket == null) {
-                                                       /* No event(s) exist for this logger. */
-                                                       continue;
-                                               }
-
-                                               for (LTTngEvent event : bucket) {
-                                                       enableCmd.name = event.name;
-                                                       enableCmd.lttngLogLevel = event.logLevel.level;
-                                                       enableCmd.lttngLogLevelType = event.logLevel.type;
-
-                                                       /* Event exist so pass null here. */
-                                                       enableCmd.execute(handler, null, wildCardSet);
-                                               }
-                                       }
-                               }
-
-                               /* Handle wild cards. */
-                               synchronized (wildCardSet) {
-                                       Map<String, ArrayList<LTTngEvent>> modifiedEvents =
-                                               new HashMap<String, ArrayList<LTTngEvent>>();
-                                       Set<LTTngEvent> tmpSet = new HashSet<LTTngEvent>();
-                                       Iterator<LTTngEvent> it = wildCardSet.iterator();
-
-                                       while (it.hasNext()) {
-                                               LTTngEvent event = it.next();
-
-                                               /* Only support * for now. */
-                                               if (event.name.equals("*")) {
-                                                       enableCmd.name = event.name;
-                                                       enableCmd.lttngLogLevel = event.logLevel.level;
-                                                       enableCmd.lttngLogLevelType = event.logLevel.type;
-
-                                                       /* That might create a new event so pass the map. */
-                                                       enableCmd.execute(handler, modifiedEvents, tmpSet);
-                                               }
-                                       }
-                                       eventMap.putAll(modifiedEvents);
-                               }
-                       }
-               }, this.timerDelay, this.timerDelay);
-
-               this.timerInitialized = true;
        }
 
        /*
@@ -185,8 +85,6 @@ public class LTTngTCPSessiondClient {
         * Cleanup Agent state.
         */
        private void cleanupState() {
-               eventMap.clear();
-               wildCardSet.clear();
                if (this.handler != null) {
                        this.handler.clear();
                }
@@ -216,8 +114,6 @@ public class LTTngTCPSessiondClient {
                                 */
                                registerToSessiond();
 
-                               setupEventTimer();
-
                                /*
                                 * Block on socket receive and wait for command from the
                                 * session daemon. This will return if and only if there is a
@@ -239,7 +135,6 @@ public class LTTngTCPSessiondClient {
 
        public void destroy() {
                this.quit = true;
-               this.eventTimer.cancel();
 
                try {
                        if (this.sessiondSock != null) {
@@ -331,7 +226,7 @@ public class LTTngTCPSessiondClient {
                                                break;
                                        }
                                        enableCmd.populate(data);
-                                       enableCmd.execute(this.handler, this.eventMap, this.wildCardSet);
+                                       enableCmd.execute(this.handler);
                                        data = enableCmd.getBytes();
                                        break;
                                }
@@ -344,7 +239,7 @@ public class LTTngTCPSessiondClient {
                                                break;
                                        }
                                        disableCmd.populate(data);
-                                       disableCmd.execute(this.handler, this.eventMap, this.wildCardSet);
+                                       disableCmd.execute(this.handler);
                                        data = disableCmd.getBytes();
                                        break;
                                }
@@ -421,10 +316,11 @@ public class LTTngTCPSessiondClient {
        }
 
        private void registerToSessiond() throws Exception {
-               byte data[] = new byte[4];
+               byte data[] = new byte[8];
                ByteBuffer buf = ByteBuffer.wrap(data);
                String pid = ManagementFactory.getRuntimeMXBean().getName().split("@")[0];
 
+               buf.putInt(this.agent_domain);
                buf.putInt(Integer.parseInt(pid));
                this.outToSessiond.write(data, 0, data.length);
                this.outToSessiond.flush();
This page took 0.025985 seconds and 4 git commands to generate.