[teiid-commits] teiid SVN: r901 - in trunk/server/src: main/java/com/metamatrix/platform/config/service and 2 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Sat May 9 19:22:50 EDT 2009


Author: vhalbert at redhat.com
Date: 2009-05-09 19:22:50 -0400 (Sat, 09 May 2009)
New Revision: 901

Modified:
   trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java
   trunk/server/src/main/java/com/metamatrix/admin/server/ServerAdminImpl.java
   trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java
   trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java
   trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java
   trunk/server/src/test/java/com/metamatrix/admin/server/FakeConfiguration.java
   trunk/server/src/test/java/com/metamatrix/admin/server/TestServerConfigAdminImpl.java
   trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java
   trunk/server/src/test/resources/config/config.xml
Log:
Teiid 570 (new service method) - new methods to support configuring and monitoring services via adminAPI
 Teiid 571 (new connector bindinng method) - new methods to support configuring bindings (existing method is used for monitoring and exposes them in the context of a host / process) via adminAPI

Modified: trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java	2009-05-09 23:10:49 UTC (rev 900)
+++ trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java	2009-05-09 23:22:50 UTC (rev 901)
@@ -360,16 +360,16 @@
         return results;
     }
     
-    protected String getConnectorBindingNameFromUUID(String uuid) throws ConfigurationException {
-        Configuration config;
-        config = getConfigurationServiceProxy().getCurrentConfiguration();
-        ConnectorBinding cb = config.getConnectorBindingByRoutingID(uuid);
-        if (cb != null) {
-            return cb.getName();
-        } 
-        
-        return null;
-    }
+//    protected String getConnectorBindingNameFromUUID(String uuid) throws ConfigurationException {
+//        Configuration config;
+//        config = getConfigurationServiceProxy().getCurrentConfiguration();
+//        ConnectorBinding cb = config.getConnectorBindingByRoutingID(uuid);
+//        if (cb != null) {
+//            return cb.getName();
+//        } 
+//        
+//        return null;
+//    }
     
     protected List getConnectorBindingNamesFromUUIDs(List uuids, ConfigurationModelContainer configModel) {
         List results = new ArrayList(uuids.size());
@@ -386,11 +386,11 @@
     }    
     
     
-    protected List getConnectorBindingNamesFromUUIDs(List uuids) throws ConfigurationException, ServiceException {
-        ConfigurationModelContainer cmc = getConfigurationModel();
-        
-        return getConnectorBindingNamesFromUUIDs(uuids, cmc);
-    }
+//    protected List getConnectorBindingNamesFromUUIDs(List uuids) throws ConfigurationException, ServiceException {
+//        ConfigurationModelContainer cmc = getConfigurationModel();
+//        
+//        return getConnectorBindingNamesFromUUIDs(uuids, cmc);
+//    }
     
     protected Map getConnectorBindingNamesMapFromUUIDs(Collection uuids) throws ConfigurationException {
         Configuration config;

Modified: trunk/server/src/main/java/com/metamatrix/admin/server/ServerAdminImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/admin/server/ServerAdminImpl.java	2009-05-09 23:10:49 UTC (rev 900)
+++ trunk/server/src/main/java/com/metamatrix/admin/server/ServerAdminImpl.java	2009-05-09 23:22:50 UTC (rev 901)
@@ -989,5 +989,27 @@
 	public void terminateTransaction(Xid transactionId) throws AdminException {
 		getRuntimeAdmin().terminateTransaction(transactionId);
 	}
+
+	@Override
+	public Collection getConnectorBindingsToConfigure(String resourceIdentfier)
+			throws AdminException {
+		// TODO Auto-generated method stub
+		return getConfigurationAdmin().getConnectorBindingsToConfigure(resourceIdentfier);
+	}
+
+	@Override
+	public Collection getServicesToConfigure(String resourceIdentfier)
+			throws AdminException {
+		// TODO Auto-generated method stub
+		return getConfigurationAdmin().getServicesToConfigure(resourceIdentfier);
+	}
+
+	@Override
+	public Collection getServices(String identifier) throws AdminException {
+		// TODO Auto-generated method stub
+		return getMonitoringAdmin().getServices(identifier);
+	}
 	
+	
+	
 }
\ No newline at end of file

Modified: trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java	2009-05-09 23:10:49 UTC (rev 900)
+++ trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java	2009-05-09 23:22:50 UTC (rev 901)
@@ -59,6 +59,7 @@
 import com.metamatrix.admin.objects.MMConnectorBinding;
 import com.metamatrix.admin.objects.MMLogConfiguration;
 import com.metamatrix.admin.objects.MMScriptsContainer;
+import com.metamatrix.admin.objects.MMService;
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.MetaMatrixProcessingException;
 import com.metamatrix.api.exception.security.AuthorizationException;
@@ -2014,7 +2015,105 @@
 			throw new AdminComponentException(e);
 		}
     }
+    
+    
+    @Override
+	public Collection getConnectorBindingsToConfigure(String resourceIdentfier)
+			throws AdminException {
+        if (resourceIdentfier == null) {
+            throwProcessingException("AdminImpl.requiredparameter", new Object[] {}); //$NON-NLS-1$
+        }
+        
+        HashSet results = new HashSet();
+        try {
+            ConfigurationModelContainer config = getConfigurationServiceProxy().getConfigurationModel(Configuration.NEXT_STARTUP);
 
+            Collection<ConnectorBinding> components = config.getConfiguration().getConnectorBindings();
+
+            for (Iterator<ConnectorBinding> iter = components.iterator(); iter.hasNext();) {
+                ConnectorBinding cb = iter.next();
+
+                String bindingName = cb.getName();
+
+                String[] identifierParts = new String[] {
+                     bindingName
+                };
+
+                if (identifierMatches(resourceIdentfier, identifierParts)) {
+			        MMConnectorBinding binding = new MMConnectorBinding(identifierParts);
+			        binding.setConnectorTypeName(cb.getComponentTypeID().getFullName());
+			        binding.setRoutingUUID(cb.getRoutingUUID());
+			        binding.setEnabled(cb.isEnabled());
+			        binding.setDeployed(false);
+			        binding.setRegistered(false);
+			        binding.setState(MMConnectorBinding.STATE_NOT_REGISTERED);
+			        binding.setProperties(cb.getProperties());
+			        
+			        binding.setCreated(cb.getCreatedDate());
+			        binding.setCreatedBy(cb.getCreatedBy());
+			        binding.setLastUpdated(cb.getLastChangedDate());
+			        binding.setLastUpdatedBy(cb.getLastChangedBy());
+			        results.add(binding);
+                }
+            }
+         } catch(ConfigurationException e) {
+        	throw new AdminComponentException(e); 
+        } catch (ServiceException e) {
+        	throw new AdminComponentException(e);
+        } 
+
+        return results;
+	}
+
+	@Override
+	public Collection getServicesToConfigure(String resourceIdentfier)
+			throws AdminException {
+	       if (resourceIdentfier == null) {
+	            throwProcessingException("AdminImpl.requiredparameter", new Object[] {}); //$NON-NLS-1$
+	        }
+	        
+	        HashSet results = new HashSet();
+	        try {
+	            ConfigurationModelContainer config = getConfigurationServiceProxy().getConfigurationModel(Configuration.NEXT_STARTUP);
+
+	            Collection<ServiceComponentDefn> components = config.getConfiguration().getServiceComponentDefns();
+
+	            for (Iterator<ServiceComponentDefn> iter = components.iterator(); iter.hasNext();) {
+	            	ServiceComponentDefn svc = iter.next();
+
+	                String svcName = svc.getName();
+
+	                String[] identifierParts = new String[] {
+	                     svcName
+	                };
+
+	                if (identifierMatches(resourceIdentfier, identifierParts)) {
+				        MMService service = new MMService(identifierParts);
+				        service.setComponentTypeName(svc.getComponentTypeID().getFullName());
+				        service.setEnabled(svc.isEnabled());
+				        service.setDeployed(false);
+				        service.setRegistered(false);
+				        service.setState(MMConnectorBinding.STATE_NOT_REGISTERED);
+				        service.setProperties(svc.getProperties());
+				        
+				        service.setCreated(svc.getCreatedDate());
+				        service.setCreatedBy(svc.getCreatedBy());
+				        service.setLastUpdated(svc.getLastChangedDate());
+				        service.setLastUpdatedBy(svc.getLastChangedBy());
+				        results.add(svc);
+	                }
+	            }
+	         } catch(ConfigurationException e) {
+	        	throw new AdminComponentException(e); 
+	        } catch (ServiceException e) {
+	        	throw new AdminComponentException(e);
+	        } 
+
+	        return results;
+
+	}
+
+
     protected ServiceComponentDefn getServiceByName(String serviceName) throws ConfigurationException,
                                                                        InvalidSessionException,
                                                                        AuthorizationException,

Modified: trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java	2009-05-09 23:10:49 UTC (rev 900)
+++ trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java	2009-05-09 23:22:50 UTC (rev 901)
@@ -47,6 +47,7 @@
 import com.metamatrix.admin.api.objects.AdminObject;
 import com.metamatrix.admin.api.objects.Model;
 import com.metamatrix.admin.api.objects.Resource;
+import com.metamatrix.admin.api.objects.Service;
 import com.metamatrix.admin.api.objects.Session;
 import com.metamatrix.admin.api.objects.SystemObject;
 import com.metamatrix.admin.api.objects.Transaction;
@@ -62,6 +63,7 @@
 import com.metamatrix.admin.objects.MMQueueWorkerPool;
 import com.metamatrix.admin.objects.MMRequest;
 import com.metamatrix.admin.objects.MMResource;
+import com.metamatrix.admin.objects.MMService;
 import com.metamatrix.admin.objects.MMSession;
 import com.metamatrix.admin.objects.MMSystem;
 import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -164,11 +166,12 @@
 			        MMConnectorBinding binding = new MMConnectorBinding(identifierParts);
 			        binding.setConnectorTypeName(configBinding.getComponentTypeID().getFullName());
 			        binding.setRoutingUUID(configBinding.getRoutingUUID());
-			        binding.setEnabled(configBinding.isEnabled());
+			        binding.setEnabled(component.isEnabled()); // use the deployed component setting for being enabled.
 			        binding.setDeployed(true);
 			        binding.setRegistered(false);
 			        binding.setState(MMConnectorBinding.STATE_NOT_REGISTERED);
 			        binding.setProperties(configBinding.getProperties());
+			        binding.setDescription(component.getDescription());
 			        
 			        binding.setCreated(configBinding.getCreatedDate());
 			        binding.setCreatedBy(configBinding.getCreatedBy());
@@ -196,8 +199,6 @@
 			        if (runtimeMap.containsKey(deployedComponent.getFullName())) {
 			            //reuse MMConnectorBinding from config
 			            binding = (MMConnectorBinding) runtimeMap.get(deployedComponent.getFullName());
-			            binding.setConnectorTypeName(deployedComponent.getComponentTypeID().getFullName());
-			            binding.setDescription(deployedComponent.getDescription());
 			            binding.setState(serviceBinding.getCurrentState());
 			            binding.setStateChangedTime(serviceBinding.getStateChangeTime());
 			            binding.setRegistered(true);
@@ -707,7 +708,124 @@
 		}
        return results;
     }
+   
+   /**
+    * Get monitoring information about services.
+    * @see com.metamatrix.admin.api.server.ServerMonitoringAdmin#getServicess(java.lang.String)
+    * @param identifier Fully-qualified identifier of a host, process, or service
+    * to get information for.  For example, "hostname", or "hostname.processname", or "
+    * "hostname.processname.servicename". 
+    * <p>If identifier is "*", this method returns information about all services in the system.
+    * @return a <code>Collection</code> of <code>com.metamatrix.admin.api.Service</code>
+    * @since 4.3
+    */
+   public Collection getServices(String identifier) throws AdminException  {
+       
+       if (identifier == null) {
+           throwProcessingException("AdminImpl.requiredparameter", new Object[] {}); //$NON-NLS-1$
+       }
+       
+       HashSet results = new HashSet();
+       try {
+			//get config data from ConfigurationService
+			Configuration config = getConfigurationServiceProxy().getCurrentConfiguration();
+			Collection components = config.getDeployedComponents();
+			
+			//convert config data to MMService objects, put in a hashmap by identifier
+			Map runtimeMap = new HashMap();
+			for (Iterator iter = components.iterator(); iter.hasNext();) {
+			    BasicDeployedComponent component = (BasicDeployedComponent)iter.next();
+			    if (component.isDeployedConnector()) {
+			    	continue;
+			    }
+			    String serviceName = component.getName();
 
+			    String[] identifierParts = new String[] {
+			        component.getHostID().getName(), component.getVMComponentDefnID().getName(), serviceName
+			    };
+
+			    ServiceComponentDefn service = config.getServiceComponentDefn(serviceName);
+			    if (service != null && identifierMatches(identifier, identifierParts)) {
+
+			    	MMService mmservice = new MMService(identifierParts);
+			        mmservice.setComponentTypeName(service.getComponentTypeID().getFullName());
+			        mmservice.setEnabled(component.isEnabled());
+			        mmservice.setDeployed(true);
+			        mmservice.setRegistered(false);
+			        mmservice.setState(Service.STATE_NOT_REGISTERED);
+			        mmservice.setProperties(service.getProperties());
+			        mmservice.setDescription(component.getDescription());
+			        
+			        mmservice.setCreated(service.getCreatedDate());
+			        mmservice.setCreatedBy(service.getCreatedBy());
+			        mmservice.setLastUpdated(service.getLastChangedDate());
+			        mmservice.setLastUpdatedBy(service.getLastChangedBy());
+
+			        runtimeMap.put(component.getFullName(), mmservice);
+			        results.add(mmservice);
+			    }
+
+			}
+			
+			// get runtime data from RuntimeStateAdminAPIHelper
+			Collection serviceBindings = this.registry.getServiceBindings(null, null);
+			
+			//convert runtime data into MMConnectorBinding objects
+			for (Iterator iter = serviceBindings.iterator(); iter.hasNext();) {
+			    ServiceRegistryBinding serviceBinding = (ServiceRegistryBinding) iter.next();
+			    DeployedComponent deployedComponent = serviceBinding.getDeployedComponent();
+
+			    if (deployedComponent!= null && ! deployedComponent.isDeployedConnector()) {
+			        String name = serviceBinding.getDeployedName();
+			        
+			        MMService mmservice;
+			        if (runtimeMap.containsKey(deployedComponent.getFullName())) {
+			            //reuse MMService from config
+			            mmservice = (MMService) runtimeMap.get(deployedComponent.getFullName());			            
+			            mmservice.setState(serviceBinding.getCurrentState());
+			            mmservice.setStateChangedTime(serviceBinding.getStateChangeTime());
+			            mmservice.setRegistered(true);
+			            mmservice.setServiceID(serviceBinding.getServiceID().getID());
+
+			        } else {
+			        	
+					    String[] identifierParts = new String[] {
+						        deployedComponent.getHostID().getName(), 
+						        deployedComponent.getVMComponentDefnID().getName(), 
+						        deployedComponent.getName()
+						    };
+				            
+				        if (identifierMatches(identifier, identifierParts)) {
+				        	
+				            //not in config - create new MMConnectorBinding
+				            mmservice = new MMService(identifierParts);
+				            mmservice.setDeployed(false);
+				            mmservice.setState(MMConnectorBinding.STATE_NOT_DEPLOYED);
+
+	
+				            mmservice.setComponentTypeName(deployedComponent.getComponentTypeID().getFullName());
+				            mmservice.setDescription(deployedComponent.getDescription());
+				            mmservice.setState(serviceBinding.getCurrentState());
+				            mmservice.setStateChangedTime(serviceBinding.getStateChangeTime());
+				            mmservice.setRegistered(true);
+				            mmservice.setServiceID(serviceBinding.getServiceID().getID());
+				            
+				            results.add(mmservice);
+			        	
+				        }
+			        	
+			        }
+			    }
+			}
+		} catch (ServiceException e) {
+			throw new AdminComponentException(e);
+		} catch (ConfigurationException e) {
+			throw new AdminComponentException(e);
+		}
+       return results;
+   }
+   
+
    /**
     * Get monitoring information about worker queues for DQPs or connector bindings.
     * @see com.metamatrix.admin.api.server.ServerMonitoringAdmin#getQueueWorkerPools(java.lang.String)

Modified: trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java	2009-05-09 23:10:49 UTC (rev 900)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java	2009-05-09 23:22:50 UTC (rev 901)
@@ -816,6 +816,9 @@
         }
     }
     
+    /**
+     * the name is nullable, if not specified, then the name in the inputStream (connector type file) will be used
+     */
     public ComponentType importConnectorType(InputStream inputStream, String name, String principalName) throws ConfigurationException {
         ComponentType newType = null;
         ConfigurationObjectEditor editor = createEditor();

Modified: trunk/server/src/test/java/com/metamatrix/admin/server/FakeConfiguration.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/admin/server/FakeConfiguration.java	2009-05-09 23:10:49 UTC (rev 900)
+++ trunk/server/src/test/java/com/metamatrix/admin/server/FakeConfiguration.java	2009-05-09 23:22:50 UTC (rev 901)
@@ -53,6 +53,7 @@
 import com.metamatrix.common.config.model.BasicConfigurationObjectEditor;
 import com.metamatrix.common.config.model.BasicConnectorBinding;
 import com.metamatrix.common.config.model.BasicDeployedComponent;
+import com.metamatrix.common.config.model.BasicServiceComponentDefn;
 import com.metamatrix.common.config.model.BasicVMComponentDefn;
 import com.metamatrix.common.config.model.ConfigurationVisitor;
 import com.metamatrix.common.log.LogConfiguration;
@@ -67,7 +68,10 @@
     
     
     /**List<DeployedComponent**/
-    public List deployedComponents;
+    public List deployedComponents;
+    public List services;
+    public Map serviceMap;
+    public List connectorbindings;
     protected Map hosts ;
     
 
@@ -124,7 +128,10 @@
      */
     public void initDeployedComponents() {
         deployedComponents = new ArrayList();
-        hosts = new HashMap();
+        hosts = new HashMap();
+        serviceMap = new HashMap();
+        this.connectorbindings = new ArrayList();
+        this.services = new ArrayList();
         
         //Connector Bindings
         ConfigurationObjectEditor editor = new BasicConfigurationObjectEditor(false);
@@ -140,7 +147,10 @@
         DeployedComponentID deployedComponentID1 = new DeployedComponentID("connectorBinding1", Configuration.NEXT_STARTUP_ID, (HostID) h.getID(),  //$NON-NLS-1$
                                                                            processID1); 
         ConnectorBindingID connectorBindingID1 = new ConnectorBindingID(Configuration.NEXT_STARTUP_ID, "connectorBinding1"); //$NON-NLS-1$
-         BasicDeployedComponent deployedComponent1 = new BasicDeployedComponent(deployedComponentID1, Configuration.NEXT_STARTUP_ID, 
+        BasicConnectorBinding cb = new BasicConnectorBinding(Configuration.NEXT_STARTUP_ID, connectorBindingID1, ConnectorBindingType.CONNECTOR_TYPE_ID);
+        
+        this.connectorbindings.add(cb);
+        BasicDeployedComponent deployedComponent1 = new BasicDeployedComponent(deployedComponentID1, Configuration.NEXT_STARTUP_ID, 
                                                                                (HostID) h.getID(), processID1, 
                                                                           connectorBindingID1, 
                                                                           ConnectorBindingType.CONNECTOR_TYPE_ID);
@@ -159,6 +169,11 @@
         DeployedComponentID deployedComponentID2 = new DeployedComponentID("connectorBinding2", Configuration.NEXT_STARTUP_ID, (HostID) h2.getID(),  //$NON-NLS-1$
                                                                            processID2); 
         ConnectorBindingID connectorBindingID2 = new ConnectorBindingID(Configuration.NEXT_STARTUP_ID, "connectorBinding2"); //$NON-NLS-1$
+        BasicConnectorBinding cb2 = new BasicConnectorBinding(Configuration.NEXT_STARTUP_ID, connectorBindingID2, ConnectorBindingType.CONNECTOR_TYPE_ID);
+        
+        this.connectorbindings.add(cb2);
+
+        
         BasicDeployedComponent deployedComponent2 = new BasicDeployedComponent(deployedComponentID2, Configuration.NEXT_STARTUP_ID, 
                                                                                (HostID) h2.getID(), processID2, 
                                                                           connectorBindingID2, 
@@ -179,6 +194,11 @@
         DeployedComponentID deployedComponentID3 = new DeployedComponentID("connectorBinding3", Configuration.NEXT_STARTUP_ID, (HostID) h3.getID(),  //$NON-NLS-1$
                                                                            processID3); 
         ConnectorBindingID connectorBindingID3 = new ConnectorBindingID(Configuration.NEXT_STARTUP_ID, "connectorBinding3"); //$NON-NLS-1$
+        BasicConnectorBinding cb3 = new BasicConnectorBinding(Configuration.NEXT_STARTUP_ID, connectorBindingID3, ConnectorBindingType.CONNECTOR_TYPE_ID);
+        
+        this.connectorbindings.add(cb3);
+
+        
         BasicDeployedComponent  deployedComponent3 = new BasicDeployedComponent(deployedComponentID3, Configuration.NEXT_STARTUP_ID, 
                                                                                 (HostID) h3.getID(), processID3, 
                                                                           connectorBindingID3, 
@@ -192,6 +212,12 @@
         DeployedComponentID deployedComponentID1A = new DeployedComponentID("dqp1", Configuration.NEXT_STARTUP_ID, (HostID) h.getID(),  //$NON-NLS-1$
                                                                            processID1); 
         ServiceComponentDefnID defnID1A = new ServiceComponentDefnID(Configuration.NEXT_STARTUP_ID, "dqp1"); //$NON-NLS-1$
+        BasicServiceComponentDefn sdfn = new BasicServiceComponentDefn(Configuration.NEXT_STARTUP_ID, defnID1A, new ComponentTypeID("QueryService"));
+                
+                this.services.add(sdfn);
+                serviceMap.put(defnID1A.getFullName(), sdfn);
+       		
+        
         BasicDeployedComponent deployedComponent1A = new BasicDeployedComponent(deployedComponentID1A, Configuration.NEXT_STARTUP_ID, 
                                                                                 (HostID) h.getID(), processID1, 
                                                                           defnID1A, 
@@ -203,6 +229,12 @@
         DeployedComponentID deployedComponentID2A = new DeployedComponentID("dqp2", Configuration.NEXT_STARTUP_ID, (HostID) h2.getID(),  //$NON-NLS-1$
                                                                            processID2); 
         ServiceComponentDefnID defnID2A = new ServiceComponentDefnID(Configuration.NEXT_STARTUP_ID, "dqp2"); //$NON-NLS-1$
+        BasicServiceComponentDefn sdfn2 = new BasicServiceComponentDefn(Configuration.NEXT_STARTUP_ID, defnID2A, new ComponentTypeID("QueryService"));
+        
+        this.services.add(sdfn2);
+        serviceMap.put(defnID2A.getFullName(), sdfn2);
+
+        
         BasicDeployedComponent deployedComponent2A = new BasicDeployedComponent(deployedComponentID2A, Configuration.NEXT_STARTUP_ID, 
                                                                                 (HostID) h2.getID(), processID2, 
                                                                           defnID2A, 
@@ -214,6 +246,11 @@
         DeployedComponentID deployedComponentID3A = new DeployedComponentID("dqp3", Configuration.NEXT_STARTUP_ID, (HostID) h3.getID(),  //$NON-NLS-1$
                                                                            processID3); 
         ServiceComponentDefnID defnID3A = new ServiceComponentDefnID(Configuration.NEXT_STARTUP_ID, "dqp3"); //$NON-NLS-1$
+       BasicServiceComponentDefn sdfn3 = new BasicServiceComponentDefn(Configuration.NEXT_STARTUP_ID, defnID3A, new ComponentTypeID("QueryService"));
+        
+        this.services.add(sdfn3);
+        serviceMap.put(defnID3A.getFullName(), sdfn3);    
+        
         BasicDeployedComponent  deployedComponent3A = new BasicDeployedComponent(deployedComponentID3A, Configuration.NEXT_STARTUP_ID, 
                                                                                  (HostID) h3.getID(), processID3, 
                                                                           defnID3A, 
@@ -324,7 +361,10 @@
     }
 
     public Collection getConnectorBindings() {
-        return null;
+       List results = new ArrayList();
+        
+       results.addAll(this.connectorbindings);
+       return results;
     }
 
     /**
@@ -398,15 +438,19 @@
     }
 
     public ServiceComponentDefn getServiceComponentDefn(ComponentDefnID defnID) {
-        return null;
+        return (ServiceComponentDefn) serviceMap.get(defnID.getFullName());
     }
 
     public ServiceComponentDefn getServiceComponentDefn(String name) {
-        return null;
+    	 return (ServiceComponentDefn) serviceMap.get(name);
     }
 
     public Collection getServiceComponentDefns() {
-        return null;
+        List results = new ArrayList();
+        
+        results.addAll(this.services);
+        return results;
+
     }
 
     public VMComponentDefn getVMComponentDefn(ComponentDefnID componentID) {

Modified: trunk/server/src/test/java/com/metamatrix/admin/server/TestServerConfigAdminImpl.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/admin/server/TestServerConfigAdminImpl.java	2009-05-09 23:10:49 UTC (rev 900)
+++ trunk/server/src/test/java/com/metamatrix/admin/server/TestServerConfigAdminImpl.java	2009-05-09 23:22:50 UTC (rev 901)
@@ -345,7 +345,35 @@
         if(admin.getConfigurationModel().getConfiguration().getAuthenticationProvider(name) == null) {
             fail("AuthenticationProvider ["+name+"] was not found to be added"); //$NON-NLS-1$ //$NON-NLS-2$
         }
-    }    
+    } 
+    
+    public void testGetConnectorBindings() throws Exception {
+    	Collection<ConnectorBinding> bindings = admin.getConnectorBindingsToConfigure("*");
+        assertEquals(2, bindings.size());
+        
+       	bindings = admin.getConnectorBindingsToConfigure("My Connector");
+        assertEquals(1, bindings.size());
+        
+       	bindings = admin.getConnectorBindingsToConfigure("My*");
+        assertEquals(1, bindings.size());
+
+
+
+    }
+    
+    public void testGetServices() throws Exception {
+    	Collection<ConnectorBinding> bindings = admin.getServicesToConfigure("*");
+        assertEquals(7, bindings.size());
+        
+       	bindings = admin.getServicesToConfigure("QueryService");
+        assertEquals(1, bindings.size());
+        
+       	bindings = admin.getServicesToConfigure("Query*");
+        assertEquals(1, bindings.size());
+
+
+
+    }
     
 }
     

Modified: trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java	2009-05-09 23:10:49 UTC (rev 900)
+++ trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java	2009-05-09 23:22:50 UTC (rev 901)
@@ -44,8 +44,10 @@
 import com.metamatrix.admin.objects.MMQueueWorkerPool;
 import com.metamatrix.admin.objects.MMRequest;
 import com.metamatrix.admin.objects.MMResource;
+import com.metamatrix.admin.objects.MMService;
 import com.metamatrix.admin.objects.MMSession;
 import com.metamatrix.admin.objects.MMSystem;
+import com.metamatrix.common.config.api.ServiceComponentDefn;
 import com.metamatrix.common.config.api.SharedResource;
 import com.metamatrix.platform.registry.ClusteredRegistryState;
 import com.metamatrix.platform.registry.FakeRegistryUtil;
@@ -146,9 +148,52 @@
         
         results = admin.getConnectorBindings(HOST_2_2_2_2_WILDCARD);  
         assertEquals(1, results.size());
+        
+    }
+    
+    /**
+     * Tests <code>ServerMonitoringImpl.getServices()</code>.
+     * 
+     * Fake data is set up in FakeConfiguration.getDeployedComponents(), FakeConfiguration.getServices(),
+     * FakeRuntimeStateAdminAPIHelper.getService(), 
+     * Expects service1 to be deployed, but not running. 
+     * Expects service2 to be deployed and running. 
+     * Expects service3 to be running, but not deployed. 
+     * @since 6.1
+     */
+    public void testGetServices() throws AdminException {
+    	
+        try {
+			ServiceRegistryBinding binding = admin.registry.getServiceBinding("3.3.3.3","3", new ServiceID(3, "3.3.3.3", "3")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+			binding.updateState(ConnectorBinding.STATE_CLOSED);
+		} catch (ResourceNotBoundException e1) {
+		}
 
+		
+        Collection<MMService> results = admin.getServices(AdminObject.WILDCARD);  
+        assertEquals(3, results.size());
         
+        for (Iterator iter = results.iterator(); iter.hasNext(); ) {
+            
+        	MMService svc = (MMService) iter.next();
+
+            if (HOST_2_2_2_2_PROCESS2_DQP2.equals(svc.getIdentifier())){ 
+            
+                assertEquals(true, svc.isRegistered());
+             } else if (_3_3_3_3_PROCESS3_DQP3.equals(svc.getIdentifier())) { 
+                
+                  assertEquals(true, svc.isRegistered());
+            }
+        }            
+        
+        results = admin.getServices(HOST_2_2_2_2_PROCESS2_DQP2);  
+        assertEquals(1, results.size());
+        
+        results = admin.getServices(_3_3_3_3_PROCESS3_DQP3);  
+        assertEquals(1, results.size());
+        
     }
+
     
     
     

Modified: trunk/server/src/test/resources/config/config.xml
===================================================================
--- trunk/server/src/test/resources/config/config.xml	2009-05-09 23:10:49 UTC (rev 900)
+++ trunk/server/src/test/resources/config/config.xml	2009-05-09 23:22:50 UTC (rev 901)
@@ -81,7 +81,9 @@
                     <DeployedService Name="ConfigurationService" ComponentType="ConfigurationService" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup" />
                      <DeployedService Name="QueryService" ComponentType="QueryService" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup" />
                     <DeployedService Name="RuntimeMetadataService" ComponentType="RuntimeMetadataService" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup" />
-             </Process>
+                    <DeployedService Name="My Connector" ComponentType="JDBC Connector" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup" />
+                   <DeployedService Name="Test Connector" ComponentType="JDBC Connector" LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup" />
+            </Process>
         </Host>
     </Configuration>
     <Services>
@@ -164,6 +166,16 @@
 				<Property Name="IsXA">true</Property>
             </Properties>
         </Connector>
+        <Connector Name="My Connector" ComponentType="JDBC Connector" LastChangedBy="ImportConfiguration" LastChangedDate="2005-03-09T06:28:34.422-06:00" CreatedBy="ImportConfiguration" CreationDate="2005-03-09T06:28:34.422-06:00" QueuedService="false">
+            <Properties>
+                <Property Name="Password">abc</Property>
+                <Property Name="User">theuser</Property>
+                <Property Name="URL">jdbc:mmx://server:port</Property>
+                <Property Name="Driver">driver.class</Property>
+				<Property Name="IsXA">true</Property>
+            </Properties>
+        </Connector>
+
     </ConnectorBindings>
       <AuthenticationProviders>
         <Provider Name="testFileDomainProvider" ComponentType="File Membership Domain Provider" LastChangedBy="metamatrixadmin" LastChangedDate="2007-05-24T12:52:48.088-06:00" CreatedBy="metamatrixadmin" CreationDate="2007-05-24T12:52:48.088-06:00">




More information about the teiid-commits mailing list