Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ptp-dev] programatically creating RM Config

Hi,

Thank you Rossi and Watson. I am trying them. Thank you.

Cheers,
Hari

On Mon, Jun 6, 2011 at 2:45 PM, Greg Watson <g.watson@xxxxxxxxxxxx> wrote:
No, you also have to create a service configuration, then add the provider to it:

       IService launchService = ServiceModelManager.getInstance().getService(IServiceConstants.LAUNCH_SERVICE);
       IServiceConfiguration config = ServiceModelManager.getInstance().newServiceConfiguration("my configuration");
       config.setServiceProvider(launchService, serviceProvider);
       ServiceModelManager.getInstance().addConfiguration(config);

At this point it should show up in the view.

Greg

On Jun 6, 2011, at 3:22 PM, Albert L. Rossi wrote:

> Greg,
>
> by that, you mean what I showed to be as step 1?
>
> Al
> ----- Greg Watson <g.watson@xxxxxxxxxxxx> wrote:
>> Al,
>>
>> If you add the serviceProvider to a service configuration, the RM should show up in the view.
>>
>> Greg
>>
>> On Jun 6, 2011, at 2:54 PM, Albert L. Rossi wrote:
>>
>>> Hari,
>>>
>>> If you intend to go through the rest of the PTP RM management framework, then you need to construct the RM, and then add it to the ModelManager.
>>>
>>> Here are the steps.
>>>
>>> 1.  Construct the service provider
>>>
>>>               IServiceProvider serviceProvider = new ResourceManagerServiceProvider();
>>>
>>> 2.  I assume you don't mind binding to the lml/jaxb classes.  If you don't want to do this, then you will have to create your own factory.  Otherwise, do what the Model Manager essentially does:
>>>
>>>               // control component
>>>               IResourceManagerControlFactory controlFactory = new JAXBResourceManagerFactory();
>>>               IResourceManagerComponentConfiguration controlConfig = controlFactory.createControlConfiguration(provider);
>>>             IResourceManagerControl control = controlFactory.createControl(controlConfig);
>>>
>>>               // monitor component
>>>             IResourceManagerMonitorFactory monitorFactory = new LMLResourceManagerFactory();
>>>             IResourceManagerComponentConfiguration monitorConfig = monitorFactory.createMonitorConfiguration(provider);
>>>             IResourceManagerMonitor monitor = monitorFactory.createMonitor(monitorConfig);
>>>
>>>               // full manager
>>>               IResourceManagerFactory factory = new LMLJAXBResourceManagerFactory();
>>>             IResourceManagerConfiguration rmConfig = factory.createConfiguration(provider);
>>>               IResourceManager manager = factory.create(rmConfig, control, monitor);
>>>
>>> 3.  You will now need to configure two things.
>>>
>>> a.  The XML configuration URL
>>> b.  The RM connections.
>>>
>>> a)  Is easy.  On the basis of your passed-in URL, just do:
>>>   rmConfig.setRMConfigurationURL(machineXMLurl);
>>>
>>> b)  The connections on both control and monitor should be set.  This can be done in any number of ways, but the easiest perhaps is to make use of the <site-data> subtree in the XML.  The code for doing this is contained in the configuration wizards for the JAXB control and LML monitor.  Here is a slightly modified method:
>>>
>>>     private void setControlConnection(IJAXBResourceManagerConfiguration rmConfig, boolean monitor) {
>>>             try {
>>>                     ResourceManagerData data = ""> >>>                     if (data != null) {
>>>                             SiteType site = data.getSiteData();
>>>                             String connection = null;
>>>                             if (site != null) {
>>>                                     if (monitor) {
>>>                                             connection = site.getMonitorConnection();
>>>                                     } else {
>>>                                             connection = site.getControlConnection();
>>>                                     }
>>>                             }
>>>                             if (connection != null) {
>>>                                     URI uri = new URI(site.getControlConnection());
>>>                                     IRemoteServices services = PTPRemoteUIPlugin.getDefault().getRemoteServices(uri, null);
>>>                                     if (services != null) {
>>>                                             rmConfig.setRemoteServicesId(services.getId());
>>>                                             String auth = uri.getAuthority();
>>>                                             String host = uri.getHost();
>>>                                             String user = uri.getUserInfo();
>>>                                             int port = uri.getPort();
>>>                                             if (auth != null && host != null) {
>>>                                                     IRemoteConnection conn = services.getConnectionManager().getConnection(host);
>>>                                                     if (conn == null && services.canCreateConnections()) {
>>>                                                             conn = services.getConnectionManager().newConnection(host);
>>>                                                             conn.setAddress(host);
>>>
>>>                                                             if (!auth.equals(host)) {
>>>                                                                     if (user != null) {
>>>                                                                             conn.setUsername(user);
>>>                                                                     }
>>>                                                                     if (port != -1) {
>>>                                                                             conn.setPort(port);
>>>                                                                     }
>>>                                                             }
>>>                                                             rmConfig.setConnectionName(conn.getName());
>>>                                                     }
>>>                                             }
>>>                                     }
>>>                             }
>>>                     }
>>>             } catch (Throwable t) {
>>>                     t.printStackTrace();
>>>             }
>>>     }
>>>
>>> 4.  Finally, you need to add this Resource Manager to the org.eclipse.ptp.core.ModelManager
>>>
>>>   ModelManager.getInstance().addResourceManager(manager).
>>>
>>>
>>>
>>> I have not tried to play with the ModelManager framework outside of the normal way of constructing a resource manager through the wizards before, so there might be a step missing here.  However, since this RM will not appear in the resource manager view, you will have to provide for starting and stopping it through your own custom actions somewhere.
>>>
>>> If you need this to appear in the view, then I would suggest that you look at the resource manager configuration wizards and perhaps contribute one that is based not on the list of xml or the types, but on the list of remote hosts.  That would be a contribution to PTP that might be very useful.
>>>
>>> Best,
>>>
>>> Al
>>> _______________________________________________
>>> ptp-dev mailing list
>>> ptp-dev@xxxxxxxxxxx
>>> https://dev.eclipse.org/mailman/listinfo/ptp-dev
>>
>> _______________________________________________
>> ptp-dev mailing list
>> ptp-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/ptp-dev
>>
>
> _______________________________________________
> ptp-dev mailing list
> ptp-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/ptp-dev

_______________________________________________
ptp-dev mailing list
ptp-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ptp-dev



--
Regards
Hari Krishnan
.
Department of Computer Science.
Louisiana State University.


Back to the top