/**
* The default network URL when creating a live session.
*/
- public static final String DEFAULT_LIVE_NETWORK_URK = "net://127.0.0.1"; //$NON-NLS-1$
+ public static final String DEFAULT_LIVE_NETWORK_URL = "net://127.0.0.1"; //$NON-NLS-1$
+
+ /**
+ * The default live port for a live session.
+ */
+ public static final int DEFAULT_LIVE_PORT = 5344;
// ------------------------------------------------------------------------
// Attributes
import java.io.UnsupportedEncodingException;
import java.net.Socket;
import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
*/
public final class LttngRelaydConsumer {
+ private static final Pattern PROTOCOL_HOST_PATTERN = Pattern.compile("(\\S+://)*(\\d+\\.\\d+\\.\\d+\\.\\d+)"); //$NON-NLS-1$
private static final int SIGNAL_THROTTLE_NANOSEC = 10_000_000;
private static final String ENCODING_UTF_8 = "UTF-8"; //$NON-NLS-1$
}
try {
- fConnection = new Socket(fConnectionInfo.getHost(), fConnectionInfo.getPort());
+ Matcher matcher = PROTOCOL_HOST_PATTERN.matcher(fConnectionInfo.getHost());
+ String host = null;
+ if (matcher.matches()) {
+ host = matcher.group(2);
+ }
+
+ if (host == null || host.isEmpty()) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.LttngRelaydConsumer_ErrorConnecting));
+ }
+
+ fConnection = new Socket(host, fConnectionInfo.getPort());
fRelayd = LttngRelaydConnectorFactory.getNewConnector(fConnection);
List<SessionResponse> sessions = fRelayd.getSessions();
SessionResponse selectedSession = null;
*/
private static final String DEFAULT_TEXT = "<" + Messages.EnableChannelDialog_DefaultMessage + ">"; //$NON-NLS-1$ //$NON-NLS-2$
- /**
- * The default port for the connection to Relayd. This actual value is
- * needed because this is not an optional argument to a command; this is
- * what is used to connect directly to Relayd from Java through a socket.
- * There is also currently no way to know the default value by issuing a
- * command.
- */
- private static final int DEFAULT_LIVE_PORT = 5344;
-
- /**
- * The default address for the connection to Relayd. Only local is supported
- * for now. See above comment for why it's needed.
- */
- private static final String DEFAULT_LIVE_URL = "127.0.0.1"; //$NON-NLS-1$
-
/**
* Supported network protocols for streaming
*/
label.setLayoutData(layoutData);
fLiveHostAddressText = new Text(fLiveGroup, SWT.NONE);
- fLiveHostAddressText.setText(DEFAULT_LIVE_URL);
+ fLiveHostAddressText.setText(SessionInfo.DEFAULT_LIVE_NETWORK_URL);
fLiveHostAddressText.setEnabled(false);
fLiveHostAddressText.setToolTipText(Messages.TraceControl_CreateSessionLiveConnectionUrlTooltip);
layoutData = new GridData(GridData.FILL_HORIZONTAL);
fLiveHostAddressText.setLayoutData(layoutData);
fLivePortText = new Text(fLiveGroup, SWT.NONE);
- fLivePortText.setText(Integer.toString(DEFAULT_LIVE_PORT));
+ fLivePortText.setText(Integer.toString(SessionInfo.DEFAULT_LIVE_PORT));
fLivePortText.setToolTipText(Messages.TraceControl_CreateSessionLiveConnectionPortTooltip);
layoutData = new GridData(GridData.FILL_HORIZONTAL);
fLivePortText.setLayoutData(layoutData);
if (fParent.isLiveSupported() && fLiveButton != null) {
fIsLive = fLiveButton.getSelection();
fLiveDelay = LTTngControlServiceConstants.UNUSED_VALUE;
- fLiveUrl = DEFAULT_LIVE_URL;
- fLivePort = DEFAULT_LIVE_PORT;
+ fLiveUrl = SessionInfo.DEFAULT_LIVE_NETWORK_URL;
+ fLivePort = SessionInfo.DEFAULT_LIVE_PORT;
}
if (!"".equals(fSessionPath)) { //$NON-NLS-1$
}
if (fIsLive && fNetworkUrl == null && fControlUrl == null && fDataUrl == null) {
- fNetworkUrl = SessionInfo.DEFAULT_LIVE_NETWORK_URK;
+ fNetworkUrl = SessionInfo.DEFAULT_LIVE_NETWORK_URL;
}
// Check for invalid names
try {
lttngRelaydConsumer.connect();
} catch (CoreException e) {
- new Status(IStatus.ERROR, Activator.PLUGIN_ID, org.eclipse.tracecompass.internal.lttng2.control.ui.relayd.Messages.LttngRelaydConnectionManager_ConnectionError, e);
+ return new Status(IStatus.ERROR, Activator.PLUGIN_ID, org.eclipse.tracecompass.internal.lttng2.control.ui.relayd.Messages.LttngRelaydConnectionManager_ConnectionError, e);
}
initializeTraceResource(connectionInfo, lttngRelaydConsumer.getTracePath(), project);
return Status.OK_STATUS;
private void copyLiveInfo(ISessionInfo sessionInfo) {
// Since we can't retrieve this information from the node, we copy it over
- fSessionInfo.setLive(sessionInfo.isLive());
- fSessionInfo.setLiveDelay(sessionInfo.getLiveDelay());
- fSessionInfo.setLivePort(sessionInfo.getLivePort());
- fSessionInfo.setLiveUrl(sessionInfo.getLiveUrl());
+ if (sessionInfo.getLivePort() != null) {
+ fSessionInfo.setLivePort(sessionInfo.getLivePort());
+ }
+ if (sessionInfo.getLiveUrl() != null) {
+ fSessionInfo.setLiveUrl(sessionInfo.getLiveUrl());
+ }
}
// ------------------------------------------------------------------------
}
continue;
}
+ matcher = LTTngControlServiceConstants.LIST_LIVE_TIMER_INTERVAL_PATTERN.matcher(line);
+ if (matcher.matches()) {
+ int liveDelay = Integer.parseInt(matcher.group(1));
+ if (liveDelay > 0) {
+ sessionInfo.setLive(true);
+ sessionInfo.setLiveUrl(SessionInfo.DEFAULT_LIVE_NETWORK_URL);
+ sessionInfo.setLivePort(SessionInfo.DEFAULT_LIVE_PORT);
+ sessionInfo.setLiveDelay(liveDelay);
+ }
+ index++;
+ continue;
+ }
+
index++;
}
* Pattern to match for list snapshot information (lttng snapshot list-output)
*/
static final Pattern LIST_SNAPSHOT_OUTPUT_PATTERN = Pattern.compile("\\s+\\[(\\d+)\\]\\s+(\\S*)\\:\\s+(\\S*)(.*)"); //$NON-NLS-1$
+ /**
+ * Pattern to match the live timer interval line of session list.
+ */
+ static final Pattern LIST_LIVE_TIMER_INTERVAL_PATTERN = Pattern.compile("\\s*Live\\stimer\\sinterval\\s\\(usec\\):\\s(\\d+)"); //$NON-NLS-1$
/**
* Pattern to match snapshot path for network tracing (lttng list <session>)
* Note: file for protocol is not considered as network trace since local consumer will be used.