| 1 | /* |
| 2 | * Copyright (C) 2015 - EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com> |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of the GNU Lesser General Public License, version 2.1 only, |
| 6 | * as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This library is distributed in the hope that it will be useful, but WITHOUT |
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License |
| 11 | * for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU Lesser General Public License |
| 14 | * along with this library; if not, write to the Free Software Foundation, |
| 15 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 16 | */ |
| 17 | |
| 18 | package org.lttng.ust.agent; |
| 19 | |
| 20 | /** |
| 21 | * Interface to define LTTng Java agents. |
| 22 | * |
| 23 | * An "agent" is a representative of an LTTng session daemon in the Java world. |
| 24 | * It tracks the settings of a tracing session as they defined in the session |
| 25 | * daemon. |
| 26 | * |
| 27 | * It also track the current logging handlers that are sending events to UST. |
| 28 | * |
| 29 | * @author Alexandre Montplaisir |
| 30 | * |
| 31 | * @param <T> |
| 32 | * The type of logging handler that should register to this agent |
| 33 | */ |
| 34 | public interface ILttngAgent<T extends ILttngHandler> { |
| 35 | |
| 36 | // ------------------------------------------------------------------------ |
| 37 | // Agent configuration elements |
| 38 | // ------------------------------------------------------------------------ |
| 39 | |
| 40 | /** |
| 41 | * Tracing domains. Corresponds to domains defined by LTTng Tools. |
| 42 | */ |
| 43 | enum Domain { |
| 44 | JUL(3), LOG4J(4); |
| 45 | private int value; |
| 46 | |
| 47 | private Domain(int value) { |
| 48 | this.value = value; |
| 49 | } |
| 50 | |
| 51 | public int value() { |
| 52 | return value; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * The tracing domain of this agent. |
| 58 | * |
| 59 | * @return The tracing domain. |
| 60 | */ |
| 61 | Domain getDomain(); |
| 62 | |
| 63 | // ------------------------------------------------------------------------ |
| 64 | // Log handler registering |
| 65 | // ------------------------------------------------------------------------ |
| 66 | |
| 67 | /** |
| 68 | * Register a handler to this agent. |
| 69 | * |
| 70 | * @param handler |
| 71 | * The handler to register |
| 72 | */ |
| 73 | void registerHandler(T handler); |
| 74 | |
| 75 | /** |
| 76 | * Deregister a handler from this agent. |
| 77 | * |
| 78 | * @param handler |
| 79 | * The handler to deregister. |
| 80 | */ |
| 81 | void unregisterHandler(T handler); |
| 82 | |
| 83 | // ------------------------------------------------------------------------ |
| 84 | // Tracing session parameters |
| 85 | // ------------------------------------------------------------------------ |
| 86 | |
| 87 | /** |
| 88 | * Query if a given event is currently enabled in a current tracing session, |
| 89 | * meaning it should be sent to UST. |
| 90 | * |
| 91 | * @param eventName |
| 92 | * The name of the event to check. |
| 93 | * @return True if the event is currently enabled, false if it is not. |
| 94 | */ |
| 95 | boolean isEventEnabled(String eventName); |
| 96 | } |