X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=liblttng-ust-jul%2Forg%2Flttng%2Fust%2Fjul%2FLTTngTCPSessiondClient.java;h=cf3074b0728f21d7d66ef4d046827a913e86feac;hb=8d17995998aa11ffeecbe2cf7701106283544253;hp=a2d12fc3008d869a9027b03b0e22244f9a92be98;hpb=96caa5edeee13a015a63c6a38d075bddcb91c6c2;p=lttng-ust.git diff --git a/liblttng-ust-jul/org/lttng/ust/jul/LTTngTCPSessiondClient.java b/liblttng-ust-jul/org/lttng/ust/jul/LTTngTCPSessiondClient.java index a2d12fc3..cf3074b0 100644 --- a/liblttng-ust-jul/org/lttng/ust/jul/LTTngTCPSessiondClient.java +++ b/liblttng-ust-jul/org/lttng/ust/jul/LTTngTCPSessiondClient.java @@ -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> eventMap = - Collections.synchronizedMap( - new HashMap>()); - - private Set wildCardSet = - Collections.synchronizedSet(new HashSet()); - - /* 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 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> modifiedEvents = - new HashMap>(); - Set tmpSet = new HashSet(); - Iterator 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();