[teiid-commits] teiid SVN: r1045 - trunk/server/src/main/java/com/metamatrix/admin/server.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Thu Jun 11 18:17:54 EDT 2009
Author: tejones
Date: 2009-06-11 18:17:54 -0400 (Thu, 11 Jun 2009)
New Revision: 1045
Modified:
trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java
trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java
trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java
Log:
TEIID-597: Added support for deployed services and connectors. Removed HOST update logic since this is no longer possible.
Modified: trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java 2009-06-11 21:23:16 UTC (rev 1044)
+++ trunk/server/src/main/java/com/metamatrix/admin/server/AbstractAdminImpl.java 2009-06-11 22:17:54 UTC (rev 1045)
@@ -60,7 +60,9 @@
import com.metamatrix.common.config.api.Configuration;
import com.metamatrix.common.config.api.ConfigurationModelContainer;
import com.metamatrix.common.config.api.ConnectorBinding;
+import com.metamatrix.common.config.api.DeployedComponent;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
+import com.metamatrix.common.config.model.BasicDeployedComponent;
import com.metamatrix.common.extensionmodule.ExtensionModuleManager;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.object.PropertyDefinition;
@@ -474,6 +476,21 @@
return results;
}
+ protected DeployedComponent getDeployedComponent(String identifier) throws ConfigurationException {
+ Configuration config = getConfigurationServiceProxy().getCurrentConfiguration();
+ Collection components = config.getDeployedComponents();
+ for (Iterator iter = components.iterator(); iter.hasNext(); ) {
+ BasicDeployedComponent bdc = (BasicDeployedComponent)iter.next();
+ String[] identifierParts = new String[] {
+ bdc.getHostID().getName(), bdc.getVMComponentDefnID().getName(), bdc.getName()
+ };
+ if (identifierMatches(identifier, identifierParts)) {
+ return bdc;
+ }
+
+ }
+ return null;
+ }
/**
* Get admin objects of the specified className that match the specified identifier.
Modified: trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java 2009-06-11 21:23:16 UTC (rev 1044)
+++ trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java 2009-06-11 22:17:54 UTC (rev 1045)
@@ -67,6 +67,7 @@
import com.metamatrix.common.actions.ModificationException;
import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.api.AuthenticationProvider;
+import com.metamatrix.common.config.api.ComponentDefnID;
import com.metamatrix.common.config.api.ComponentType;
import com.metamatrix.common.config.api.ComponentTypeID;
import com.metamatrix.common.config.api.Configuration;
@@ -75,6 +76,7 @@
import com.metamatrix.common.config.api.ConnectorArchive;
import com.metamatrix.common.config.api.ConnectorBinding;
import com.metamatrix.common.config.api.ConnectorBindingType;
+import com.metamatrix.common.config.api.DeployedComponent;
import com.metamatrix.common.config.api.ExtensionModule;
import com.metamatrix.common.config.api.Host;
import com.metamatrix.common.config.api.HostID;
@@ -88,9 +90,9 @@
import com.metamatrix.common.config.api.exceptions.InvalidConfigurationException;
import com.metamatrix.common.config.model.BasicConfigurationObjectEditor;
import com.metamatrix.common.config.model.BasicConnectorArchive;
-import com.metamatrix.common.config.model.BasicDeployedComponent;
import com.metamatrix.common.config.model.BasicExtensionModule;
import com.metamatrix.common.config.model.ConfigurationModelContainerAdapter;
+import com.metamatrix.common.config.model.ConfigurationModelContainerImpl;
import com.metamatrix.common.config.util.ConfigObjectsNotResolvableException;
import com.metamatrix.common.config.util.ConfigurationPropertyNames;
import com.metamatrix.common.config.util.InvalidConfigurationElementException;
@@ -118,6 +120,7 @@
import com.metamatrix.metadata.runtime.exception.VirtualDatabaseException;
import com.metamatrix.metadata.runtime.vdb.defn.VDBCreation;
import com.metamatrix.metadata.runtime.vdb.defn.VDBDefnFactory;
+import com.metamatrix.platform.config.spi.xml.XMLConfigurationMgr;
import com.metamatrix.platform.registry.ClusteredRegistryState;
import com.metamatrix.platform.service.api.exception.ServiceException;
import com.metamatrix.server.admin.apiimpl.MaterializationLoadScriptsImpl;
@@ -1490,7 +1493,7 @@
/**
- * Supported classes are {@link com.metamatrix.admin.api.objects.Host}, {@link com.metamatrix.admin.api.objects.ConnectorBinding},
+ * Supported classes are {@link com.metamatrix.admin.api.objects.ConnectorBinding}, {@link com.metamatrix.admin.api.objects.Service},
* {@link SystemObject}, {@link ProcessObject}
* @see com.metamatrix.admin.api.core.CoreConfigAdmin#updateProperties(java.lang.String, java.lang.String, java.util.Properties)
* @since 4.3
@@ -1499,17 +1502,12 @@
String className,
Properties properties) throws AdminException {
- Collection adminObjects = getAdminObjects(identifier, className);
- if (adminObjects == null || adminObjects.size() == 0) {
- throwProcessingException("ServerConfigAdminImpl.No_Objects_Found", new Object[] {identifier, className}); //$NON-NLS-1$
- }
- if (adminObjects.size() > 1) {
- throwProcessingException("ServerConfigAdminImpl.Multiple_Objects_Found", new Object[] {identifier, className}); //$NON-NLS-1$
- }
- AdminObject adminObject = (AdminObject) adminObjects.iterator().next();
+ int nodeCount = getNodeCount(identifier);
+ int type = MMAdminObject.getObjectType(className);
+
+ AdminObject adminObject = null;
+ String hostName;
- String hostName;
- int type = MMAdminObject.getObjectType(className);
switch (type) {
@@ -1517,25 +1515,8 @@
this.updateSystemProperties(properties);
break;
- case MMAdminObject.OBJECT_TYPE_HOST:
- hostName = adminObject.getName();
- Host host = getHostByName(hostName);
- Properties hostProperties = host.getProperties();
- hostProperties.putAll(properties);
-
- try {
- Host updatedHost = (Host)getConfigurationServiceProxy().modify(host, hostProperties, getUserName());
- if (updatedHost == null) {
- throwProcessingException("ServerConfigAdminImpl.Host_was_null_when_updating_properties", new Object[] {hostName}); //$NON-NLS-1$
- }
- } catch (ConfigurationException e) {
- throw new AdminComponentException(e);
- } catch (ServiceException e) {
- throw new AdminComponentException(e);
- }
- break;
-
case MMAdminObject.OBJECT_TYPE_PROCESS_OBJECT:
+ adminObject = getAdminObject(identifier, className);
ProcessObject process = (ProcessObject)adminObject;
String processName = adminObject.getName();
hostName = process.getHostIdentifier();
@@ -1561,19 +1542,38 @@
break;
case MMAdminObject.OBJECT_TYPE_CONNECTOR_BINDING:
- String connectorBindingName = adminObject.getName();
- try {
+ String connectorBindingName;
+ if (nodeCount > 1) {
+ adminObject = getAdminObject(identifier, className);
+ connectorBindingName = adminObject.getName();
+ }else{
+ connectorBindingName = identifier;
+ }
+
+ try {
ConnectorBinding connectorBinding = this.getConnectorBindingByName(connectorBindingName);
- Properties bindingProperties = connectorBinding.getProperties();
- bindingProperties.putAll(properties);
+
+ //If the node count in the identifier is greater than 1, then this connector binding is deployed.
+ if (nodeCount>1){
+ DeployedComponent updatedConnectorBinding = updateDeployedComponentProperties(
+ properties, identifier);
+
+ if (updatedConnectorBinding == null) {
+ throwProcessingException("ServerConfigAdminImpl.Connector_Binding_was_null_when_updating_properties", new Object[] {connectorBindingName}); //$NON-NLS-1$
+ }
+ }else{
- ConnectorBinding updatedConnectorBinding =
- (ConnectorBinding)getConfigurationServiceProxy().modify(connectorBinding,
- bindingProperties,
- getUserName());
-
- if (updatedConnectorBinding == null) {
- throwProcessingException("ServerConfigAdminImpl.Connector_Binding_was_null_when_updating_properties", new Object[] {connectorBindingName}); //$NON-NLS-1$
+ Properties bindingProperties = connectorBinding.getProperties();
+ bindingProperties.putAll(properties);
+
+ ConnectorBinding updatedConnectorBinding =
+ (ConnectorBinding)getConfigurationServiceProxy().modify(connectorBinding,
+ bindingProperties,
+ getUserName());
+
+ if (updatedConnectorBinding == null) {
+ throwProcessingException("ServerConfigAdminImpl.Connector_Binding_was_null_when_updating_properties", new Object[] {connectorBindingName}); //$NON-NLS-1$
+ }
}
} catch (ConfigurationException e) {
throw new AdminComponentException(e);
@@ -1583,20 +1583,40 @@
break;
case MMAdminObject.OBJECT_TYPE_SERVICE:
- String serviceName = adminObject.getName();
+ String serviceName;
+ if (nodeCount > 1) {
+ adminObject = getAdminObject(identifier, className);
+ serviceName = adminObject.getName();
+ }else{
+ serviceName = identifier;
+ }
+
try {
ServiceComponentDefn serviceDefn = this.getServiceByName(serviceName);
+
+ ComponentDefnID componentDefnID = (ComponentDefnID)serviceDefn.getID();
- Properties svcProperties = serviceDefn.getProperties();
- svcProperties.putAll(properties);
+ //If the node count in the identifier is greater than 1, then this service is deployed.
+ if (nodeCount>1){
+ DeployedComponent updatedServiceDefn = updateDeployedComponentProperties(
+ properties, identifier);
+
+ if (updatedServiceDefn == null) {
+ throwProcessingException("ServerConfigAdminImpl.Service_was_null_when_updating_properties", new Object[] {serviceName}); //$NON-NLS-1$
+ }
+ }else{
- ServiceComponentDefn updatedServiceDefn =
- (ServiceComponentDefn)getConfigurationServiceProxy().modify(serviceDefn,
- svcProperties,
- getUserName());
-
- if (updatedServiceDefn == null) {
- throwProcessingException("ServerConfigAdminImpl.Service_was_null_when_updating_properties", new Object[] {serviceName}); //$NON-NLS-1$
+ Properties svcProperties = serviceDefn.getProperties();
+ svcProperties.putAll(properties);
+
+ ServiceComponentDefn updatedServiceDefn =
+ (ServiceComponentDefn)getConfigurationServiceProxy().modify(serviceDefn,
+ svcProperties,
+ getUserName());
+
+ if (updatedServiceDefn == null) {
+ throwProcessingException("ServerConfigAdminImpl.Service_was_null_when_updating_properties", new Object[] {serviceName}); //$NON-NLS-1$
+ }
}
} catch (ConfigurationException e) {
throw new AdminComponentException(e);
@@ -1621,6 +1641,40 @@
}
+ /**
+ * @param properties
+ * @param componentDefnID
+ * @return
+ * @throws ConfigurationException
+ */
+ private DeployedComponent updateDeployedComponentProperties(
+ Properties properties, String identifier)
+ throws ConfigurationException {
+ DeployedComponent dc = getDeployedComponent(identifier);
+
+ Properties bindingProperties = dc.getProperties();
+ bindingProperties.putAll(properties);
+
+ DeployedComponent updatedConnectorBinding =
+ (DeployedComponent)getConfigurationServiceProxy().modify(dc,
+ bindingProperties,
+ getUserName());
+ return updatedConnectorBinding;
+ }
+
+ private AdminObject getAdminObject(String identifier, String className)
+ throws AdminException {
+ Collection adminObjects = getAdminObjects(identifier, className);
+ if (adminObjects == null || adminObjects.size() == 0) {
+ throwProcessingException("ServerConfigAdminImpl.No_Objects_Found", new Object[] {identifier, className}); //$NON-NLS-1$
+ }
+ if (adminObjects.size() > 1) {
+ throwProcessingException("ServerConfigAdminImpl.Multiple_Objects_Found", new Object[] {identifier, className}); //$NON-NLS-1$
+ }
+ AdminObject adminObject = (AdminObject) adminObjects.iterator().next();
+ return adminObject;
+ }
+
private ConnectorBinding getConnectorBindingByName(String name) throws ConfigurationException, ServiceException, AdminProcessingException {
Configuration nextStartupConfig = getConfigurationServiceProxy().getNextStartupConfiguration();
ConnectorBinding cb = nextStartupConfig.getConnectorBinding(name);
@@ -2160,9 +2214,10 @@
ConfigurationException,
MetaMatrixComponentException {
- return (ServiceComponentDefn)getConfigurationServiceProxy().getComponentDefn(Configuration.NEXT_STARTUP_ID,serviceID);
+ return (ServiceComponentDefn)getConfigurationServiceProxy().getComponentDefn(Configuration.NEXT_STARTUP_ID,serviceID);
}
-
+
+
/**
* @param properties
* @param connectorBindingName
@@ -2353,6 +2408,20 @@
return buffer.toString();
}
+
+ /**
+ * Will return the number of nodes in an identifier based on the
+ * delimiter {@link AdminObject.DELIMITER}
+ * @param identifier
+ * @return the number of nodes
+ */
+ protected int getNodeCount(String identifier) {
+ int count = 0;
+
+ count = identifier.split("\\"+AdminObject.DELIMITER).length;
+
+ return count;
+ }
/**
* @see com.metamatrix.admin.api.core.CoreConfigAdmin#addUDF(byte[], java.lang.String)
Modified: trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java 2009-06-11 21:23:16 UTC (rev 1044)
+++ trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java 2009-06-11 22:17:54 UTC (rev 1045)
@@ -1258,7 +1258,7 @@
config = getConfigurationServiceProxy().getCurrentConfiguration();
ServiceComponentDefn svc = config.getServiceComponentDefn(MMAdminObject.getNameFromIdentifier(objectIdentifier));
- component = this.getDeployedComponent(objectIdentifier);
+ component = getDeployedComponent(objectIdentifier);
return convertPropertyDefinitions(component, svc.getProperties());
@@ -1383,23 +1383,9 @@
}
- private ComponentObject getDeployedComponent(String identifier) throws ConfigurationException {
- Configuration config = getConfigurationServiceProxy().getCurrentConfiguration();
- Collection components = config.getDeployedComponents();
- for (Iterator iter = components.iterator(); iter.hasNext(); ) {
- BasicDeployedComponent bdc = (BasicDeployedComponent)iter.next();
- String[] identifierParts = new String[] {
- bdc.getHostID().getName(), bdc.getVMComponentDefnID().getName(), bdc.getName()
- };
- if (identifierMatches(identifier, identifierParts)) {
- return bdc;
- }
-
- }
- return null;
- }
+
private ComponentType getConnectorTypeComponentType(String identifier) throws ConfigurationException {
Collection types = getConfigurationServiceProxy().getAllComponentTypes(false);
for (Iterator iter = types.iterator(); iter.hasNext();) {
More information about the teiid-commits
mailing list