Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2014-08-12 02:55:57 -0400
committerUwe Stieber2014-08-12 02:57:23 -0400
commit8e2bc4affcde4d71b9edf191fe329532da9c58b7 (patch)
tree8e538ec8c9cafb4f397d484ddf4df316ec982c13
parent66e7fc4b4af42462d5ce91feaa3fb7829af305b8 (diff)
downloadorg.eclipse.tcf-8e2bc4affcde4d71b9edf191fe329532da9c58b7.tar.gz
org.eclipse.tcf-8e2bc4affcde4d71b9edf191fe329532da9c58b7.tar.xz
org.eclipse.tcf-8e2bc4affcde4d71b9edf191fe329532da9c58b7.zip
Target Explorer: Improve logging to also log the remote services available on a fully opened channel
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/events/ChannelEvent.java1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/InitializeLoggingStep.java61
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListenerManager.java43
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/EventListener.java3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.java1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.properties3
6 files changed, 92 insertions, 20 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/events/ChannelEvent.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/events/ChannelEvent.java
index f71b723c9..f8e8377db 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/events/ChannelEvent.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/events/ChannelEvent.java
@@ -28,6 +28,7 @@ public final class ChannelEvent extends EventObject {
public static final String TYPE_CLOSE = "close"; //$NON-NLS-1$
public static final String TYPE_MARK = "mark"; //$NON-NLS-1$
public static final String TYPE_CLOSE_WRITER = "closeWriter"; //$NON-NLS-1$
+ public static final String TYPE_SERVICS = "services"; //$NON-NLS-1$
// Property constants
public static final String PROP_MESSAGE = "message"; //$NON-NLS-1$
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/InitializeLoggingStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/InitializeLoggingStep.java
index 467dd4c6b..bd631e07a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/InitializeLoggingStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.core/src/org/eclipse/tcf/te/tcf/core/internal/channelmanager/steps/InitializeLoggingStep.java
@@ -9,12 +9,17 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.core.internal.channelmanager.steps;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.tcf.protocol.IChannel;
+import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.events.EventManager;
import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
@@ -53,7 +58,7 @@ public class InitializeLoggingStep extends AbstractPeerStep {
* @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
*/
@Override
- public void execute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, ICallback callback) {
+ public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) {
Assert.isNotNull(context);
Assert.isNotNull(data);
Assert.isNotNull(fullQualifiedId);
@@ -65,24 +70,50 @@ public class InitializeLoggingStep extends AbstractPeerStep {
final String logname = StepperAttributeUtil.getStringProperty(ITcfStepAttributes.ATTR_LOG_NAME, fullQualifiedId, data);
if (channel.getState() == IChannel.STATE_OPEN) {
- boolean forceNew = StepperAttributeUtil.getBooleanProperty(IChannelManager.FLAG_FORCE_NEW, fullQualifiedId, data);
- boolean noValueAdd = StepperAttributeUtil.getBooleanProperty(IChannelManager.FLAG_NO_VALUE_ADD, fullQualifiedId, data);
- boolean noPathMap = StepperAttributeUtil.getBooleanProperty(IChannelManager.FLAG_NO_PATH_MAP, fullQualifiedId, data);
+ // Query the remote services from the channel before sending the "open" event
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ // Get the remote services from the channel
+ List<String> remoteServices = new ArrayList<String>(channel.getRemoteServices());
+ Collections.sort(remoteServices);
- // Log successfully opened channels
- String message = forceNew ? "Private" : "Shared"; //$NON-NLS-1$ //$NON-NLS-2$
- if (noValueAdd) message += ", No Value Add"; //$NON-NLS-1$
- if (noPathMap) message += ", Not Applying Path Map"; //$NON-NLS-1$
+ String buffer = remoteServices.toString();
+ buffer = buffer.replaceAll("\\[", "").replaceAll("\\]", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- IPropertiesContainer eventData = new PropertiesContainer();
- eventData.setProperty(ChannelEvent.PROP_MESSAGE, message);
- eventData.setProperty(ChannelEvent.PROP_LOG_NAME, logname);
+ IPropertiesContainer eventData = new PropertiesContainer();
+ eventData.setProperty(ChannelEvent.PROP_MESSAGE, buffer.toString());
+ eventData.setProperty(ChannelEvent.PROP_LOG_NAME, logname);
- ChannelEvent event = new ChannelEvent(InitializeLoggingStep.this, channel, ChannelEvent.TYPE_OPEN, eventData);
- EventManager.getInstance().fireEvent(event);
- }
+ ChannelEvent event = new ChannelEvent(InitializeLoggingStep.this, channel, ChannelEvent.TYPE_SERVICS, eventData);
+ EventManager.getInstance().fireEvent(event);
+
+ // Get the data to send the "open" event
+ boolean forceNew = StepperAttributeUtil.getBooleanProperty(IChannelManager.FLAG_FORCE_NEW, fullQualifiedId, data);
+ boolean noValueAdd = StepperAttributeUtil.getBooleanProperty(IChannelManager.FLAG_NO_VALUE_ADD, fullQualifiedId, data);
+ boolean noPathMap = StepperAttributeUtil.getBooleanProperty(IChannelManager.FLAG_NO_PATH_MAP, fullQualifiedId, data);
+
+ // Log successfully opened channels
+ String message = forceNew ? "Private" : "Shared"; //$NON-NLS-1$ //$NON-NLS-2$
+ if (noValueAdd) message += ", No Value Add"; //$NON-NLS-1$
+ if (noPathMap) message += ", Not Applying Path Map"; //$NON-NLS-1$
- callback(data, fullQualifiedId, callback, Status.OK_STATUS, null);
+ eventData = new PropertiesContainer();
+ eventData.setProperty(ChannelEvent.PROP_MESSAGE, message);
+ eventData.setProperty(ChannelEvent.PROP_LOG_NAME, logname);
+
+ event = new ChannelEvent(InitializeLoggingStep.this, channel, ChannelEvent.TYPE_OPEN, eventData);
+ EventManager.getInstance().fireEvent(event);
+
+ callback(data, fullQualifiedId, callback, Status.OK_STATUS, null);
+ }
+ };
+
+ if (Protocol.isDispatchThread()) runnable.run();
+ else Protocol.invokeLater(runnable);
+ } else {
+ callback(data, fullQualifiedId, callback, Status.OK_STATUS, null);
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListenerManager.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListenerManager.java
index 363645576..2d8d48a8d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListenerManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/ChannelTraceListenerManager.java
@@ -153,8 +153,6 @@ public class ChannelTraceListenerManager {
Assert.isNotNull(channel);
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- // The trace listener interface does not have a onChannelOpenend method, but
- // for consistency, log the channel opening similar to the others.
if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_CHANNEL_TRACE_LISTENER)) {
CoreBundleActivator.getTraceHandler().trace("TraceListener.onChannelOpening ( " + channel + ", \"" + message + "\" )", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ITracing.ID_TRACE_CHANNEL_TRACE_LISTENER, this);
@@ -194,8 +192,6 @@ public class ChannelTraceListenerManager {
Assert.isNotNull(channel);
Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
- // The trace listener interface does not have a onChannelOpenend method, but
- // for consistency, log the channel opening similar to the others.
if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_CHANNEL_TRACE_LISTENER)) {
CoreBundleActivator.getTraceHandler().trace("TraceListener.onChannelRedirected ( " + channel + ", \"" + message + "\" )", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ITracing.ID_TRACE_CHANNEL_TRACE_LISTENER, this);
@@ -225,6 +221,45 @@ public class ChannelTraceListenerManager {
}
/**
+ * Channel remote services got queried.
+ *
+ * @param logname The log name or <code>null</code>.
+ * @param channel The channel. Must not be <code>null</code>.
+ * @param message A message or <code>null</code>.
+ */
+ public void onChannelServices(String logname, IChannel channel, String message) {
+ Assert.isNotNull(channel);
+ Assert.isTrue(Protocol.isDispatchThread(), "Illegal Thread Access"); //$NON-NLS-1$
+
+ if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITracing.ID_TRACE_CHANNEL_TRACE_LISTENER)) {
+ CoreBundleActivator.getTraceHandler().trace("TraceListener.onChannelServices ( " + channel + ", \"" + message + "\" )", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ ITracing.ID_TRACE_CHANNEL_TRACE_LISTENER, this);
+ }
+
+ // Get the preference key if or if not logging is enabled
+ boolean loggingEnabled = CoreBundleActivator.getScopedPreferences().getBoolean(IPreferenceKeys.PREF_LOGGING_ENABLED);
+ // If false, we are done here and wont create any console or trace listener.
+ if (!loggingEnabled) return;
+
+ // Log the channel opening
+ String date = DATE_FORMAT.format(new Date(System.currentTimeMillis()));
+
+ String fullMessage = NLS.bind(Messages.ChannelTraceListener_channelServices_message,
+ new Object[] {
+ date,
+ Integer.toHexString(channel.hashCode()),
+ message != null ? "(" + message.trim() + ")" : "" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ });
+
+ List<String> queue = queued.get(channel);
+ if (queue == null) {
+ queue = new ArrayList<String>();
+ queued.put(channel, queue);
+ }
+ queue.add(fullMessage);
+ }
+
+ /**
* Mark an event in the channel log.
*
* @param logname The log name or <code>null</code>.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/EventListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/EventListener.java
index 58e57edf8..585f4e990 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/EventListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/listener/EventListener.java
@@ -70,6 +70,9 @@ public final class EventListener extends PlatformObject implements IEventListene
else if (ChannelEvent.TYPE_CLOSE_WRITER.equals(type)) {
LogManager.getInstance().closeWriter(logname, channel, message);
}
+ else if (ChannelEvent.TYPE_SERVICS.equals(type)) {
+ ChannelTraceListenerManager.getInstance().onChannelServices(logname, channel, message);
+ }
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.java
index 89301d65c..9523ef383 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.java
@@ -34,6 +34,7 @@ public class Messages extends NLS {
public static String ChannelTraceListener_channelOpened_message;
public static String ChannelTraceListener_channelClosed_message;
public static String ChannelTraceListener_channelMark_message;
+ public static String ChannelTraceListener_channelServices_message;
public static String LogManager_error_renameFailed;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.properties
index 8a6a57836..abeeb08ec 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.log.core/src/org/eclipse/tcf/te/tcf/log/core/internal/nls/Messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+# Copyright (c) 2012, 2014 Wind River Systems, Inc. and others. All rights reserved.
# This program and the accompanying materials are made available under the terms
# of the Eclipse Public License v1.0 which accompanies this distribution, and is
# available at http://www.eclipse.org/legal/epl-v10.html
@@ -13,5 +13,6 @@ ChannelTraceListener_channelRedirected_message=# {0}: Redirected channel {1} {2}
ChannelTraceListener_channelOpened_message=# {0}: Opened channel {1} {2}
ChannelTraceListener_channelClosed_message=# {0}: Closed channel {1} (error={2})
ChannelTraceListener_channelMark_message=# {0}: Channel {1}: {2}
+ChannelTraceListener_channelServices_message=# {0}: Remote services available for channel {1} {2}
LogManager_error_renameFailed=Failed to rename file while cycling the log files.\n\nFrom: {0}\nTo: {1}

Back to the top