import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import org.lttng.ust.agent.AbstractLttngAgent;
-
/**
* Client for agents to connect to a local session daemon, using a TCP socket.
*
private static final String ROOT_PORT_FILE = "/var/run/lttng/agent.port";
private static final String USER_PORT_FILE = "/.lttng/agent.port";
- private static int protocolMajorVersion = 1;
- private static int protocolMinorVersion = 0;
+ private static final int PROTOCOL_MAJOR_VERSION = 2;
+ private static final int PROTOCOL_MINOR_VERSION = 0;
/** Command header from the session deamon. */
private final CountDownLatch registrationLatch = new CountDownLatch(1);
private DataInputStream inFromSessiond;
private DataOutputStream outToSessiond;
- private final AbstractLttngAgent<?> logAgent;
+ private final ILttngTcpClientListener logAgent;
+ private final int domainValue;
private final boolean isRoot;
-
/**
* Constructor
*
* @param logAgent
- * The logging agent this client will operate on.
+ * The listener this client will operate on, typically an LTTng
+ * agent.
+ * @param domainValue
+ * The integer to send to the session daemon representing the
+ * tracing domain to handle.
* @param isRoot
* True if this client should connect to the root session daemon,
* false if it should connect to the user one.
*/
- public LttngTcpSessiondClient(AbstractLttngAgent<?> logAgent, boolean isRoot) {
+ public LttngTcpSessiondClient(ILttngTcpClientListener logAgent, int domainValue, boolean isRoot) {
this.logAgent = logAgent;
+ this.domainValue = domainValue;
this.isRoot = isRoot;
}
ByteBuffer buf = ByteBuffer.wrap(data);
String pid = ManagementFactory.getRuntimeMXBean().getName().split("@")[0];
- buf.putInt(logAgent.getDomain().value());
+ buf.putInt(domainValue);
buf.putInt(Integer.parseInt(pid));
- buf.putInt(protocolMajorVersion);
- buf.putInt(protocolMinorVersion);
+ buf.putInt(PROTOCOL_MAJOR_VERSION);
+ buf.putInt(PROTOCOL_MINOR_VERSION);
this.outToSessiond.write(data, 0, data.length);
this.outToSessiond.flush();
}
case CMD_LIST:
{
ISessiondCommand listLoggerCmd = new SessiondListLoggersCommand();
- ILttngAgentResponse response = listLoggerCmd.execute(logAgent);
+ LttngAgentResponse response = listLoggerCmd.execute(logAgent);
responseData = response.getBytes();
break;
}
{
if (inputData == null) {
/* Invalid command */
- responseData = ILttngAgentResponse.FAILURE_RESPONSE.getBytes();
+ responseData = LttngAgentResponse.FAILURE_RESPONSE.getBytes();
break;
}
ISessiondCommand enableCmd = new SessiondEnableEventCommand(inputData);
- ILttngAgentResponse response = enableCmd.execute(logAgent);
+ LttngAgentResponse response = enableCmd.execute(logAgent);
responseData = response.getBytes();
break;
}
{
if (inputData == null) {
/* Invalid command */
- responseData = ILttngAgentResponse.FAILURE_RESPONSE.getBytes();
+ responseData = LttngAgentResponse.FAILURE_RESPONSE.getBytes();
break;
}
ISessiondCommand disableCmd = new SessiondDisableEventCommand(inputData);
- ILttngAgentResponse response = disableCmd.execute(logAgent);
+ LttngAgentResponse response = disableCmd.execute(logAgent);
responseData = response.getBytes();
break;
}