Community
Participate
Working Groups
this feature will allow stdout from executing process to be displayed on console window - on a per job basis, as you would normally expect when printf() is called. This is a 2.0 TODO item as I understand. It is complementary to what we have now (click on each process to view its output) in the sense that it combines and displays console output on the fly as processes run. My initial implementation will be provided later once the format requirement is clear.
Created attachment 79416 [details] new console class
Created attachment 79417 [details] attach console to each new job
Feiyi, I've taken a look at this and there are a few things that need to be fixed up before it can be committed. 1. Each source file has to have the default Eclipse copyright and license notice. This is something like: /******************************************************************************* * Copyright (c) 2007 <your company> 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 * * Contributors: * <your company> - Initial API and implementation *******************************************************************************/ 2. Contributions of UI functionality should be in org.eclipse.ptp.ui rather than org.eclipse.ptp.core. There should be no UI dependencies in org.eclipse.ptp.core. I suggest putting PConsole in org.eclipse.ptp.ui.consoles. 3. Comment (2) also applies to the patch to AbstractResourceManager. This should all be done in the UI plugin. Also, you'll need to remove consoles when jobs a removed. I think the way to do this is to add the new console to the console view using the console manager. You do this using ConsolePlugin.getConsoleManager().addConsoles() when the job starts and removeConsoles() when the job terminates (I've never done this so you'll need to check it works) See org.eclipse.ui.console for more information. 4. You can register for new/remove job events by adding a child listener to all queues. Note that you'll also need to listen for new/removed queues so you can update the child listeners. This should be done in the PTPUIPlugin.start() method. See the way JobManager and MachineManager do it. I'd suggest creating a ConsoleManager. 5. You'll now need to listen for element events on each process of job to get the attributes. You can set this up when you get a new job event. 6. I'd also suggest naming the PConsole class something like JobConsole. I'm trying to get away from this P stuff. Thanks!
(In reply to comment #3) > 3. Comment (2) also applies to the patch to AbstractResourceManager. This > should all be done in the UI plugin. Also, you'll need to remove consoles when > jobs a removed. I think the way to do this is to add the new console to the > console view using the console manager. You do this using > ConsolePlugin.getConsoleManager().addConsoles() when the job starts and > removeConsoles() when the job terminates (I've never done this so you'll need > to check it works) See org.eclipse.ui.console for more information. Now I think about it, you should probably remove the console when the job is removed, not when it terminates. Greg
Greg - Comment 1, 2,3,5,6 are clear. I will make changes correspondingly. Regarding #4, to create a ConsoleManager when plugin starts. I have one question though: suppose I have ConsoleManager to implements the QueueChildListener interface, what would be appropriate place to register self and to who. There is a protected modelPresentation variable in AbstractUIMananger, but I am not sure if and how to get to model element such as Queue to add to their listener list. Thanks Feiyi (In reply to comment #3) > Feiyi, > > I've taken a look at this and there are a few things that need to be fixed up > before it can be committed. > > 1. Each source file has to have the default Eclipse copyright and license > notice. This is something like: > > /******************************************************************************* > * Copyright (c) 2007 <your company> 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 > * > * Contributors: > * <your company> - Initial API and implementation > > *******************************************************************************/ > > 2. Contributions of UI functionality should be in org.eclipse.ptp.ui rather > than org.eclipse.ptp.core. There should be no UI dependencies in > org.eclipse.ptp.core. I suggest putting PConsole in > org.eclipse.ptp.ui.consoles. > > 3. Comment (2) also applies to the patch to AbstractResourceManager. This > should all be done in the UI plugin. Also, you'll need to remove consoles when > jobs a removed. I think the way to do this is to add the new console to the > console view using the console manager. You do this using > ConsolePlugin.getConsoleManager().addConsoles() when the job starts and > removeConsoles() when the job terminates (I've never done this so you'll need > to check it works) See org.eclipse.ui.console for more information. > > 4. You can register for new/remove job events by adding a child listener to all > queues. Note that you'll also need to listen for new/removed queues so you can > update the child listeners. This should be done in the PTPUIPlugin.start() > method. See the way JobManager and MachineManager do it. I'd suggest creating a > ConsoleManager. > > 5. You'll now need to listen for element events on each process of job to get > the attributes. You can set this up when you get a new job event. > > 6. I'd also suggest naming the PConsole class something like JobConsole. I'm > trying to get away from this P stuff. > > Thanks! >
Looking at JobManager, etc., I'd suggest not extending AbstractUIManager. It does a whole lot of stuff you're not interested in. I'd start with a brand new ConsoleManager class that does something like the following. Create an instance of the class in the PTPUIPlugin.start() method. 1. Get the model manager using PTPCorePlugin.getDefault().getModelManager(). 2. Register an IModelManagerChildListener, for each resource manager register an IResourceManagerChildListener, and for each queue register an IQueueChildListener. 3. In the handlers for INewResourceManagerEvent and IRemoveResourceManagerEvent, you should add and remove IResourceManagerChildListeners respectively. 4. In the handlers for INewQueueEvent and IRemoveQueueEvent, you should add and remove IQueueChildListeners respectively. 5. When you receive an INewJobEvent, you should create a new IOConsole and IOConsoleOutputStream and register it with ConsolePlugin.getConsoleManager().addConsoles(). You'll also need to keep the IOConsoleOutputStream associated with the job in some data structure. You'll also need to add an IJobChildListener. 6. When you receive an IRemoveJobEvent, you should remove the console using ConsolePlugin.getConsoleManager().removeConsoles(), and remove the IJobChildListener. 7. In the handlers for INewProcessEvent and IRemoveProcessEvent, you should add and remove IProcessLiseners for each process. 8. In the handler for IProcessChangeEvent you can obtain the standard out attribute, look up the IOConsoleOutputStream associated with this processes job, send the output to the console using IOConsoleOutputStream.write(). Greg
> > 3. In the handlers for INewResourceManagerEvent and > IRemoveResourceManagerEvent, you should add and remove > IResourceManagerChildListeners respectively. hmm ... I don't see IResourceManagerChildListener define handlers for IRemoveResoruceManagerEvent or INewResourceManagerEvent. IResourceManagerListener has handler for IResourceManagerChangeEvent, but it is suppose for attributes changes. Supposely, there could be IUniversityChildListener, but it is not defined. Did I misunderstand something here? Feiyi
Handlers for IRemoveResoruceManagerEvent and INewResourceManagerEvent are defined in IModelManagerChildListener. The INew* and IRemove* handlers are always in the child listener of the parent element (model manager is the parent of resource manager).
Yes, I misread the statement ... I have it implemented and tested, seems working. Before I upload, one question, MessageConsole is created with a name (String type). For now, I use job.getId() as it is unique, but it is different from the name displayed in UI (job.getName() gives you a Job02). Is there better way of naming the console? Thanks Feiyi (In reply to comment #8) > Handlers for IRemoveResoruceManagerEvent and INewResourceManagerEvent are > defined in IModelManagerChildListener. The INew* and IRemove* handlers are > always in the child listener of the parent element (model manager is the parent > of resource manager). >
If you want a unique name, you should concatenate the name of the resource manager, the queue and the job. e.g. String name = rm.getName() + ":" + queue.getName() + ":" + job.getName() You could just use job.getName(), but there's a chance that jobs from different queues might have the same name.
Created attachment 80365 [details] console manager
Created attachment 80366 [details] console class that handle process output
Created attachment 80368 [details] patch to initialize ConsoleManger at the startup.
I have committed this with the following changes: ConsoleManager: - The console manager maintains a mapping between jobs and JobConsoles - Removed handlers and JobConsole when a job is removed ("remove terminated jobs" action) - Added a shutdown() method that removes all handlers and JobConsoles - Added flag to enable/disable job consoles (default disable) JobConsole: - Added flag to prefix output by process index (default enable) - Moved getUniqueName() from ConsoleManager to JobConsole - Only call getNewStream() once, when the console is first created There are few things that still need to be done: 1. Add preference setting to enable/disable job consoles 2. Add preference setting to enable/disable output prefixing 3. Ensure all methods have javadoc comments 4. Remove and/or fix the jout() method which still calls newMessageStream() 5. getUniqueName() can contain symbols (e.g. @) which don't seem to be displayed properly on the console tab. Need to work out what is happening here. Some general pointers on coding: - All new code needs to have javadoc and non-javadoc comments on every method. - Please keep methods sorted (Source>Sort Members...) and formatted (Source>Format) Thanks!
Added check box to enable console when job is launched. Output prefixing is always enabled. This is enough for 2.0 release.