|
Packit |
c04fcb |
/*
|
|
Packit |
c04fcb |
* Copyright (C) 2016 - EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
|
|
Packit |
c04fcb |
*
|
|
Packit |
c04fcb |
* This library is free software; you can redistribute it and/or modify it
|
|
Packit |
c04fcb |
* under the terms of the GNU Lesser General Public License, version 2.1 only,
|
|
Packit |
c04fcb |
* as published by the Free Software Foundation.
|
|
Packit |
c04fcb |
*
|
|
Packit |
c04fcb |
* This library is distributed in the hope that it will be useful, but WITHOUT
|
|
Packit |
c04fcb |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
Packit |
c04fcb |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
Packit |
c04fcb |
* for more details.
|
|
Packit |
c04fcb |
*
|
|
Packit |
c04fcb |
* You should have received a copy of the GNU Lesser General Public License
|
|
Packit |
c04fcb |
* along with this library; if not, write to the Free Software Foundation,
|
|
Packit |
c04fcb |
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
package org.lttng.ust.agent.client;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
import java.nio.ByteBuffer;
|
|
Packit |
c04fcb |
import java.nio.ByteOrder;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/**
|
|
Packit |
c04fcb |
* Session daemon command indicating to the Java agent that an
|
|
Packit |
c04fcb |
* application-specific context was disabled in the tracing session.
|
|
Packit |
c04fcb |
*
|
|
Packit |
c04fcb |
* @author Alexandre Montplaisir
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
class SessiondDisableAppContextCommand extends SessiondCommand {
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
private final String retrieverName;
|
|
Packit |
c04fcb |
private final String contextName;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
private final boolean commandIsValid;
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
public SessiondDisableAppContextCommand(byte[] data) {
|
|
Packit |
c04fcb |
if (data == null) {
|
|
Packit |
c04fcb |
throw new IllegalArgumentException();
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
ByteBuffer buf = ByteBuffer.wrap(data);
|
|
Packit |
c04fcb |
buf.order(ByteOrder.BIG_ENDIAN);
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/*
|
|
Packit |
c04fcb |
* The buffer contains the retriever name first, followed by the
|
|
Packit |
c04fcb |
* context's name.
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
retrieverName = readNextString(buf);
|
|
Packit |
c04fcb |
contextName = readNextString(buf);
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/* If any of these strings were null then the command was invalid */
|
|
Packit |
c04fcb |
commandIsValid = ((retrieverName != null) && (contextName != null));
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
@Override
|
|
Packit |
c04fcb |
public LttngAgentResponse execute(ILttngTcpClientListener agent) {
|
|
Packit |
c04fcb |
if (!commandIsValid) {
|
|
Packit |
c04fcb |
return LttngAgentResponse.FAILURE_RESPONSE;
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
boolean success = agent.appContextDisabled(retrieverName, contextName);
|
|
Packit |
c04fcb |
return (success ? LttngAgentResponse.SUCESS_RESPONSE : DISABLE_APP_CONTEXT_FAILURE_RESPONSE);
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
|
|
Packit |
c04fcb |
/**
|
|
Packit |
c04fcb |
* Response sent when the disable-context command asks to disable an
|
|
Packit |
c04fcb |
* unknown context name.
|
|
Packit |
c04fcb |
*/
|
|
Packit |
c04fcb |
private static final LttngAgentResponse DISABLE_APP_CONTEXT_FAILURE_RESPONSE = new LttngAgentResponse() {
|
|
Packit |
c04fcb |
@Override
|
|
Packit |
c04fcb |
public ReturnCode getReturnCode() {
|
|
Packit |
c04fcb |
/* Same return code used for unknown event/logger names */
|
|
Packit |
c04fcb |
return ReturnCode.CODE_UNKNOWN_LOGGER_NAME;
|
|
Packit |
c04fcb |
}
|
|
Packit |
c04fcb |
};
|
|
Packit |
c04fcb |
}
|