teiid SVN: r1861 - branches/JCA/console/src/main/java/org/teiid/rhq/comm/impl.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2010-02-19 16:56:15 -0500 (Fri, 19 Feb 2010)
New Revision: 1861
Removed:
branches/JCA/console/src/main/java/org/teiid/rhq/comm/impl/NetUtils.java
branches/JCA/console/src/main/java/org/teiid/rhq/comm/impl/TeiidConnectionConstants.java
Log:
Remove legacy code
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/comm/impl/NetUtils.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/comm/impl/NetUtils.java 2010-02-19 21:47:42 UTC (rev 1860)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/comm/impl/NetUtils.java 2010-02-19 21:56:15 UTC (rev 1861)
@@ -1,172 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.rhq.comm.impl;
-
-import java.io.IOException;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.Socket;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
-
-public class NetUtils {
- private InetAddress inetAddress;
-
- private static NetUtils INSTANCE = new NetUtils();
-
- public static NetUtils getInstance() {
- return INSTANCE;
- }
-
- public InetAddress getInetAddress() throws UnknownHostException {
- resolveHostName();
- return this.inetAddress;
- }
-
-
- /**
- * Resolves the given host name into InetAddress; if host name can not be resolved then it will
- * throw {@link UnknownHostException}
- * @param hostName
- * @return
- * @throws UnknownHostException
- */
- public static InetAddress resolveHostByName(String hostName) throws UnknownHostException {
- if( hostName.equalsIgnoreCase("localhost")) { //$NON-NLS-1$
- try {
- return getInstance().getInetAddress();
- } catch (UnknownHostException e) {
- }
- }
- return InetAddress.getByName(hostName);
- }
-
- /*
- * Dynamically resolving the host name should only be done when setupmm is being run
- * or when the vm initially starts up and the configuration Host has to be found based on that resolution.
- * After that, the {@link VMNaming} class should be used to obtain the logical and physical host addresses.
- */
- private synchronized void resolveHostName() throws UnknownHostException {
- UnknownHostException une = null;
-
- boolean preferIPv6=Boolean.getBoolean("java.net.preferIPv6Addresses");//$NON-NLS-1$
-
- // majority of the times we will find the address with this below call
- if (this.inetAddress == null) {
- try {
- InetAddress addr = InetAddress.getLocalHost();
- if(!addr.isLoopbackAddress()) {
- this.inetAddress = addr;
- }
- } catch(UnknownHostException e) {
- une=e;
- }
- }
-
- // see if you can find a non-loopback address, based on the preference
- if (this.inetAddress == null) {
- this.inetAddress = findAddress(preferIPv6, false);
- }
-
- // if no-addresses found so far then resort to IPv4 loopback address
- if (this.inetAddress == null) {
- this.inetAddress = findAddress(false, true);
- }
-
- if (this.inetAddress == null) {
- if (une != null) throw une;
- throw new UnknownHostException("failed to resolve the address for localhost"); //$NON-NLS-1$
- }
- }
-
-
-
- /**
- * Finds a InetAddress of the current host where the JVM is running, by querying NetworkInterfaces installed
- * and filters them by given preferences. It will return the first Address which UP and meets the criteria
- * @param preferIPv6
- * @param perferLoopback
- * @return null is returned if requested criteria is not met.
- * @throws UnknownHostException
- * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4665037 (Linux issue with resolving to loopback in the DHCP situations)
- */
- private InetAddress findAddress(boolean preferIPv6, boolean perferLoopback) throws UnknownHostException {
- try {
- Enumeration<NetworkInterface> ne = NetworkInterface.getNetworkInterfaces();
- while (ne.hasMoreElements()) {
- NetworkInterface ni = ne.nextElement();
- //## JDBC4.0-begin ##
- if (ni.isUp()) {
- //## JDBC4.0-end ##
- Enumeration<InetAddress> addrs = ni.getInetAddresses();
- while (addrs.hasMoreElements()) {
- InetAddress addr = addrs.nextElement();
-
- boolean isIPv6 = (addr instanceof Inet6Address);
- if (preferIPv6 == isIPv6 && perferLoopback == addr.isLoopbackAddress() ) {
- return addr;
- }
- }
- //## JDBC4.0-begin ##
- }
- //## JDBC4.0-end ##
- }
- } catch (SocketException e) {
- // treat this as address not found and return null;
- }
- return null;
- }
-
- /**
- * Call to determine if a port is available to be opened.
- * This is used to determine if a port is already opened
- * by some other process. If the port is available, then
- * it's not in use.
- * @param host
- * @param port
- * @return true if the port is not opened.
- * @since 4.3
- */
- public boolean isPortAvailable(String host, int port) throws UnknownHostException {
-
- try {
- //using Socket to try to connect to an existing opened socket
- Socket ss = new Socket(host, port);
-
- try {
- ss.close();
- } catch (Exception ce) {
- // it was open and considered available, then dont worry about the close error
- }
- return false;
- } catch (UnknownHostException ce) {
- throw ce;
- } catch (IOException e) {
- //ignore
- }
- return true;
- }
-}
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/comm/impl/TeiidConnectionConstants.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/comm/impl/TeiidConnectionConstants.java 2010-02-19 21:47:42 UTC (rev 1860)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/comm/impl/TeiidConnectionConstants.java 2010-02-19 21:56:15 UTC (rev 1861)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.comm.impl;
-
-import org.teiid.adminapi.AdminObject;
-
-
-/**
- * @since 4.3
- */
-public interface TeiidConnectionConstants {
-
- public static final String MMPORT = "mmport"; //$NON-NLS-1$
- public static final String PORT_DELIM = ","; //$NON-NLS-1$
-
-
- public static String ID_DELIMITER = AdminObject.DELIMITER;
- public static String MMPROCESS = AdminObject.DELIMITER + "MMProcess"; //$NON-NLS-1$
- public static String WILDCARD = "*"; //$NON-NLS-1$
- public static final String LONGRUNNINGQUERYTIME = "longRunningQueryTime"; //$NON-NLS-1$
- public static final double MS_TO_MIN = 1.66666666666667E-05;
- public static final String PROTOCOL = "mm://"; //$NON-NLS-1$
-
- public static final String SSL_PROTOCOL = "mms://"; //$NON-NLS-1$
-
- public static String defaultPort = "31000"; //$NON-NLS-1$
-
- public static String SYSTEM_NAME_PROPERTY = "metamatrix.cluster.name"; //$NON-NLS-1$
-
-}
14 years, 10 months
teiid SVN: r1860 - in branches/JCA/console/src: main/java/org/teiid/rhq/plugin and 3 other directories.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2010-02-19 16:47:42 -0500 (Fri, 19 Feb 2010)
New Revision: 1860
Added:
branches/JCA/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
Removed:
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/SecurityComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/configuration.properties
branches/JCA/console/src/test/java/org/teiid/rhq/comm/impl/
branches/JCA/console/src/test/java/org/teiid/rhq/enterprise/pool/
Modified:
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/Facet.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
Log:
Fixed VDB prop logic
Added: branches/JCA/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java (rev 0)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-02-19 21:47:42 UTC (rev 1860)
@@ -0,0 +1,365 @@
+package org.teiid.rhq.admin;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.naming.NamingException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.values.CollectionValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.teiid.adminapi.impl.RequestMetadata;
+import org.teiid.adminapi.impl.RequestMetadataMapper;
+import org.teiid.adminapi.impl.SessionMetadata;
+import org.teiid.adminapi.impl.SessionMetadataMapper;
+import org.teiid.rhq.comm.ExecutedResult;
+import org.teiid.rhq.plugin.util.PluginConstants;
+import org.teiid.rhq.plugin.util.ProfileServiceUtil;
+import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform;
+import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform.Metrics;
+import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform.Operations;
+
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+public class DQPManagementView implements PluginConstants{
+
+ private static ManagedComponent mc = null;
+ private static final Log LOG = LogFactory.getLog(DQPManagementView.class);
+
+ public DQPManagementView() {
+
+ }
+
+ /*
+ * Metric methods
+ */
+ public Object getMetric(String componentType, String identifier,
+ String metric, Map<String, Object> valueMap) {
+ Object resultObject = new Object();
+
+ if (componentType.equals(PluginConstants.ComponentType.Platform.NAME)) {
+ resultObject = getPlatformMetric(componentType, metric, valueMap);
+ } else if (componentType.equals(PluginConstants.ComponentType.VDB.NAME)) {
+ resultObject = getVdbMetric(componentType, identifier, metric,
+ valueMap);
+ }
+
+ return resultObject;
+ }
+
+ private Object getPlatformMetric(String componentType, String metric,
+ Map valueMap) {
+
+ Object resultObject = new Object();
+
+ if (metric
+ .equals(PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
+ resultObject = new Double(getQueryCount().doubleValue());
+ } else {
+ if (metric
+ .equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
+ resultObject = new Double(getSessionCount().doubleValue());
+ } else {
+ if (metric
+ .equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
+ Integer longRunningQueryLimit = (Integer) valueMap
+ .get(PluginConstants.Operation.Value.LONG_RUNNING_QUERY_LIMIT);
+ Collection<RequestMetadata> longRunningQueries = getLongRunningQueries(
+ longRunningQueryLimit);
+ resultObject = new Double(longRunningQueries.size());
+ }
+ }
+ }
+
+ return resultObject;
+ }
+
+ private Object getVdbMetric(String componentType, String identifier,
+ String metric, Map valueMap) {
+
+ Object resultObject = new Object();
+
+ // if (metric.equals(ComponentType.Metric.HIGH_WATER_MARK)) {
+ // resultObject = new Double(getHighWatermark(identifier));
+ // }
+
+ return resultObject;
+ }
+
+ /*
+ * Operation methods
+ */
+
+ public void executeOperation(ExecutedResult operationResult,
+ final Map valueMap) {
+
+ if (operationResult.getComponentType().equals(
+ PluginConstants.ComponentType.Platform.NAME)) {
+ executePlatformOperation(operationResult, operationResult
+ .getOperationName(), valueMap);
+ }
+
+ // else if
+ // (operationResult.getComponentType().equals(ConnectionConstants.ComponentType.Runtime.System.TYPE))
+ // {
+ // executeSystemOperation(operationResult,
+ // operationResult.getOperationName(), valueMap);
+ // } else if (operationResult.getComponentType().equals(
+ // Runtime.Process.TYPE)) {
+ // executeProcessOperation(operationResult,
+ // operationResult.getOperationName(), valueMap);
+ // } else if
+ // (operationResult.getComponentType().equals(com.metamatrix.rhq.comm.ConnectionConstants.ComponentType.Runtime.Host.TYPE))
+ // {
+ // executeHostOperation(operationResult,
+ // operationResult.getOperationName(), valueMap);
+ // } else if
+ // (operationResult.getComponentType().equals(com.metamatrix.rhq.comm.ConnectionConstants.ComponentType.Runtime.Session.TYPE))
+ // {
+ // executeSessionOperation(operationResult,
+ // operationResult.getOperationName(), valueMap);
+ // } else if
+ // (operationResult.getComponentType().equals(com.metamatrix.rhq.comm.ConnectionConstants.ComponentType.Runtime.Queries.TYPE))
+ // {
+ // executeQueriesOperation(operationResult,
+ // operationResult.getOperationName(), valueMap);
+ // }
+ }
+
+ private void executePlatformOperation(ExecutedResult operationResult,
+ final String operationName, final Map<String, Object> valueMap) {
+ Collection<RequestMetadata> resultObject = new ArrayList<RequestMetadata>();
+
+ if (operationName.equals(Platform.Operations.GET_LONGRUNNINGQUERIES)) {
+ Integer longRunningValue = (Integer) valueMap
+ .get(Operation.Value.LONG_RUNNING_QUERY_LIMIT);
+ List<String> fieldNameList = operationResult.getFieldNameList();
+ resultObject = getLongRunningQueries(longRunningValue);
+ operationResult.setContent(createReportResultList(fieldNameList, resultObject.iterator()));
+ }
+
+// else if (operationName.equals(ComponentType.Operation.KILL_REQUEST)) {
+// String requestID = (String) valueMap
+// .get(ConnectionConstants.ComponentType.Operation.Value.REQUEST_ID);
+// cancelRequest(requestID);
+// } else if (operationName.equals(ComponentType.Operation.GET_VDBS)) {
+// List fieldNameList = operationResult.getFieldNameList();
+// resultObject = getVDBs(fieldNameList);
+// operationResult.setContent((List) resultObject);
+// } else if (operationName.equals(ComponentType.Operation.GET_PROPERTIES)) {
+// String identifier = (String) valueMap
+// .get(ConnectionConstants.IDENTIFIER);
+// Properties props = getProperties(
+// ConnectionConstants.ComponentType.Runtime.System.TYPE,
+// identifier);
+// resultObject = createReportResultList(props);
+// operationResult.setContent((List) resultObject);
+// }
+
+ }
+
+ /*
+ * Helper methods
+ */
+
+ protected MetaValue getRequests(List<String> fieldNameList) {
+
+ MetaValue requestsCollection = null;
+ MetaValue args = null;
+
+ requestsCollection = executeManagedOperation(mc,
+ PluginConstants.Operation.GET_REQUESTS, args);
+
+ return requestsCollection;
+
+ // if (fieldNameList != null) {
+ // Collection reportResultCollection = createReportResultList(
+ // fieldNameList, requestsCollection.iterator());
+ // return reportResultCollection;
+ // } else {
+ // return requestsCollection;
+ // }
+ }
+
+ public MetaValue getSessions(List<String> fieldNameList) {
+
+ MetaValue sessionCollection = null;
+ MetaValue args = null;
+
+ sessionCollection = executeManagedOperation(mc,
+ PluginConstants.Operation.GET_SESSIONS, args);
+ return sessionCollection;
+
+ // if (fieldNameList != null) {
+ // Collection reportResultCollection = createReportResultList(
+ // fieldNameList, requestsCollection.iterator());
+ // return reportResultCollection;
+ // } else {
+ // return requestsCollection;
+ // }
+ }
+
+ public static MetaValue executeManagedOperation(ManagedComponent mc,
+ String operation, MetaValue... args) {
+
+ try {
+ mc = ProfileServiceUtil.getDQPManagementView();
+ } catch (NamingException e) {
+ LOG.error(e);
+ } catch (Exception e1) {
+ LOG.error(e1);
+ }
+
+ for (ManagedOperation mo : mc.getOperations()) {
+ String opName = mo.getName();
+ if (opName.equals(operation)) {
+ try {
+ if (args.length == 1 && args[0] == null) {
+ return mo.invoke();
+ } else {
+ return mo.invoke(args);
+ }
+ } catch (Exception e) {
+ final String msg = "Exception getting the AdminApi in " + operation; //$NON-NLS-1$
+ LOG.error(msg, e);
+ }
+ }
+ }
+ throw new MetaMatrixRuntimeException(
+ "No operation found with given name =" + operation);
+
+ }
+
+ private Integer getQueryCount() {
+
+ Integer count = new Integer(0);
+
+ MetaValue requests = null;
+ Collection<RequestMetadata> requestsCollection = new ArrayList();
+
+ requests = getRequests(null);
+
+ getRequestCollectionValue(requests, requestsCollection);
+
+ if (requestsCollection != null && !requestsCollection.isEmpty()) {
+ count = requestsCollection.size();
+ }
+
+ return count;
+ }
+
+ private Integer getSessionCount() {
+
+ Collection<SessionMetadata> activeSessionsCollection = new ArrayList<SessionMetadata>();
+ MetaValue sessionMetaValue = getSessions(null);
+ getSessionCollectionValue(sessionMetaValue, activeSessionsCollection);
+ return activeSessionsCollection.size();
+ }
+
+ protected Collection<RequestMetadata> getLongRunningQueries(
+ int longRunningValue) {
+
+ MetaValue requestsCollection = null;
+ Collection<RequestMetadata> list = new ArrayList<RequestMetadata>();
+
+ double longRunningQueryTimeDouble = new Double(longRunningValue);
+
+ requestsCollection = getRequests(null);
+
+ getRequestCollectionValue(requestsCollection, list);
+
+ Iterator<RequestMetadata> requestsIter = list.iterator();
+ while (requestsIter.hasNext()) {
+ RequestMetadata request = requestsIter.next();
+ long startTime = request.getProcessingTime();
+ // Get msec from each, and subtract.
+ long runningTime = Calendar.getInstance().getTimeInMillis()
+ - startTime;
+
+ if (runningTime < longRunningQueryTimeDouble) {
+ requestsIter.remove();
+ }
+ }
+
+ return list;
+ }
+
+ public static <T> void getRequestCollectionValue(MetaValue pValue,
+ Collection<RequestMetadata> list) {
+ MetaType metaType = pValue.getMetaType();
+ if (metaType.isCollection()) {
+ for (MetaValue value : ((CollectionValueSupport) pValue)
+ .getElements()) {
+ if (value.getMetaType().isComposite()) {
+ RequestMetadataMapper requestMapper = new RequestMetadataMapper();
+ RequestMetadata requestMetaData = requestMapper
+ .unwrapMetaValue(value);
+ list.add(requestMetaData);
+ } else {
+ throw new IllegalStateException(pValue
+ + " is not a Composite type");
+ }
+ }
+ }
+ }
+
+ public static <T> void getSessionCollectionValue(MetaValue pValue,
+ Collection<SessionMetadata> list) {
+ MetaType metaType = pValue.getMetaType();
+ if (metaType.isCollection()) {
+ for (MetaValue value : ((CollectionValueSupport) pValue)
+ .getElements()) {
+ if (value.getMetaType().isComposite()) {
+ SessionMetadataMapper sessionMapper = new SessionMetadataMapper();
+ SessionMetadata sessionMetaData = sessionMapper
+ .unwrapMetaValue(value);
+ list.add(sessionMetaData);
+ } else {
+ throw new IllegalStateException(pValue
+ + " is not a Composite type");
+ }
+ }
+ }
+ }
+
+ private Collection createReportResultList(List fieldNameList, Iterator objectIter) {
+ Collection reportResultList = new ArrayList();
+
+ while (objectIter.hasNext()) {
+ Object object = objectIter.next();
+
+ Class cls = null;
+ try {
+ cls = object.getClass();
+ Iterator methodIter = fieldNameList.iterator();
+ Map reportValueMap = new HashMap<String, String>();
+ while (methodIter.hasNext()) {
+ String fieldName = (String) methodIter.next();
+ String methodName = fieldName;
+ Method meth = cls.getMethod(methodName, (Class[]) null);
+ Object retObj = meth.invoke(object, (Object[]) null);
+ reportValueMap.put(fieldName, retObj);
+ }
+ reportResultList.add(reportValueMap);
+ } catch (Throwable e) {
+ System.err.println(e);
+ }
+ }
+ return reportResultList;
+ }
+
+}
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/Facet.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-02-19 20:41:28 UTC (rev 1859)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-02-19 21:47:42 UTC (rev 1860)
@@ -58,6 +58,7 @@
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
+import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.comm.ExecutedResult;
import org.teiid.rhq.plugin.objects.ExecutedOperationResultImpl;
import org.teiid.rhq.plugin.util.DeploymentUtils;
@@ -180,9 +181,9 @@
}
protected void execute(final ExecutedResult result, final Map valueMap) {
-// DQPManagementView dqp = new DQPManagementView();
-//
-// dqp.executeOperation(result, valueMap);
+ DQPManagementView dqp = new DQPManagementView();
+
+ dqp.executeOperation(result, valueMap);
}
@@ -288,6 +289,7 @@
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
}
+ @Override
public void deleteResource() throws Exception {
DeploymentManager deploymentManager = ProfileServiceUtil.getDeploymentManager();
@@ -311,31 +313,36 @@
}
- //@Override
+ @Override
public DeployPackagesResponse deployPackages(
Set<ResourcePackageDetails> packages,
ContentServices contentServices) {
return null;
}
+ @Override
public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType arg0) {
return null;
}
+ @Override
public List<DeployPackageStep> generateInstallationSteps(
ResourcePackageDetails arg0) {
return null;
}
+ @Override
public RemovePackagesResponse removePackages(
Set<ResourcePackageDetails> arg0) {
return null;
}
+ @Override
public InputStream retrievePackageBits(ResourcePackageDetails packageDetails) {
return null;
}
+ @Override
public CreateResourceReport createResource(CreateResourceReport createResourceReport) {
ResourcePackageDetails details = createResourceReport
.getPackageDetails();
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-02-19 20:41:28 UTC (rev 1859)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-02-19 21:47:42 UTC (rev 1860)
@@ -21,6 +21,7 @@
*/
package org.teiid.rhq.plugin;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
@@ -35,9 +36,11 @@
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform;
@@ -108,51 +111,51 @@
public void getValues(MeasurementReport report,
Set<MeasurementScheduleRequest> requests) throws Exception {
-// DQPManagementView view = new DQPManagementView();
-//
-// Map<String, Object> valueMap = new HashMap<String, Object>();
-//
-// for (MeasurementScheduleRequest request : requests) {
-// String name = request.getName();
-// LOG.debug("Measurement name = " + name); //$NON-NLS-1$
-//
-// // Initialize any parameters to be used in the retrieval of metric
-// // values
-// if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
-// Integer value = getResourceConfiguration()
-// .getSimple(
-// PluginConstants.Operation.Value.LONG_RUNNING_QUERY_LIMIT)
-// .getIntegerValue();
-// valueMap.put(PluginConstants.Operation.Value.LONG_RUNNING_QUERY_LIMIT, value);
-// }
-//
-// Object metricReturnObject = view.getMetric(getComponentType(), this
-// .getComponentIdentifier(), name, valueMap);
-//
-// try {
-// if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
-// report.addData(new MeasurementDataNumeric(request,
-// (Double) metricReturnObject));
-// } else {
-// if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
-// report.addData(new MeasurementDataNumeric(request,
-// (Double) metricReturnObject));
-// } else {
-// if (request.getName().equals(
-// PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
-// report.addData(new MeasurementDataNumeric(request,
-// (Double) metricReturnObject));
-// }
-// }
-// }
-//
-// } catch (Exception e) {
-// LOG.error("Failed to obtain measurement [" + name //$NON-NLS-1$
-// + "]. Cause: " + e); //$NON-NLS-1$
-// // throw(e);
-// }
-// }
+ DQPManagementView view = new DQPManagementView();
+ Map<String, Object> valueMap = new HashMap<String, Object>();
+
+ for (MeasurementScheduleRequest request : requests) {
+ String name = request.getName();
+ LOG.debug("Measurement name = " + name); //$NON-NLS-1$
+
+ // Initialize any parameters to be used in the retrieval of metric
+ // values
+ if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
+ Integer value = getResourceConfiguration()
+ .getSimple(
+ PluginConstants.Operation.Value.LONG_RUNNING_QUERY_LIMIT)
+ .getIntegerValue();
+ valueMap.put(PluginConstants.Operation.Value.LONG_RUNNING_QUERY_LIMIT, value);
+ }
+
+ Object metricReturnObject = view.getMetric(getComponentType(), this
+ .getComponentIdentifier(), name, valueMap);
+
+ try {
+ if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
+ report.addData(new MeasurementDataNumeric(request,
+ (Double) metricReturnObject));
+ } else {
+ if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
+ report.addData(new MeasurementDataNumeric(request,
+ (Double) metricReturnObject));
+ } else {
+ if (request.getName().equals(
+ PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
+ report.addData(new MeasurementDataNumeric(request,
+ (Double) metricReturnObject));
+ }
+ }
+ }
+
+ } catch (Exception e) {
+ LOG.error("Failed to obtain measurement [" + name //$NON-NLS-1$
+ + "]. Cause: " + e); //$NON-NLS-1$
+ // throw(e);
+ }
+ }
+
}
@Override
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/SecurityComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/SecurityComponent.java 2010-02-19 20:41:28 UTC (rev 1859)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/SecurityComponent.java 2010-02-19 21:47:42 UTC (rev 1860)
@@ -1,127 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.plugin;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertyList;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.MeasurementReport;
-import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
-import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Session;
-import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.Session.Query;
-import org.teiid.rhq.plugin.objects.ExecutedResourceConfigurationResultImpl;
-
-
-/**
- * MetaMatrix Connector component class
- *
- */
-public class SecurityComponent extends Facet {
-
- private final Log LOG = LogFactory.getLog(SecurityComponent.class);
-
-
- private ExecutedResourceConfigurationResultImpl getSessions = null;
-
- /**
- * @see org.teiid.rhq.plugin.Facet#getComponentType()
- * @since 1.0
- */
- @Override
- String getComponentType() {
- return Session.TYPE;
- }
-
- public void start(ResourceContext context) {
- super.start(context);
- }
-
- protected void setOperationArguments(String name, Configuration configuration,
- Map argumentMap) {
-
-
- }
-
- @Override
- public AvailabilityType getAvailability() {
- return AvailabilityType.UP;
-
- }
-
- @Override
- public void getValues(MeasurementReport arg0,
- Set<MeasurementScheduleRequest> arg1) throws Exception {
- // TODO Auto-generated method stub
-
- }
-
-
- /**
- * The plugin container will call this method and it needs to obtain the
- * current configuration of the managed resource. Your plugin will obtain
- * the managed resource's configuration in your own custom way and populate
- * the returned Configuration object with the managed resource's
- * configuration property values.
- *
- * @see ConfigurationFacet#loadResourceConfiguration()
- *
- */
- @Override
- public Configuration loadResourceConfiguration() {
-
- return super.loadResourceConfiguration();
- }
-
-
-// class SessionComparable implements Comparator {
-//
-// public int compare(Object arg0, Object arg1) {
-// // TODO Auto-generated method stub
-// Component a = (Component) arg0;
-// Component b = (Component) arg1;
-//
-// if ( a == null && b == null ) {
-// return 0;
-// }
-// if ( a != null && b == null ) {
-// return 1;
-// }
-// if ( a == null && b != null ) {
-// return -1;
-// }
-// int result = a.get.compareTo(b.getDisplayName());
-// return result;
-// }
-
-
-
- // }
-
-}
\ No newline at end of file
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java 2010-02-19 20:41:28 UTC (rev 1859)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java 2010-02-19 21:47:42 UTC (rev 1860)
@@ -26,10 +26,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.managed.api.ComponentType;
import org.jboss.managed.api.ManagedComponent;
-import org.jboss.managed.api.ManagedDeployment;
import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.plugins.ManagedObjectImpl;
import org.jboss.metatype.api.values.CollectionValueSupport;
@@ -68,14 +66,11 @@
for (ManagedComponent mcVdb : vdbs) {
String vdbKey = mcVdb.getDeployment().getName();
- String vdbName = ((SimpleValueSupport) mcVdb.getProperty("name")
- .getValue()).getValue().toString();
- String vdbVersion = ((SimpleValueSupport) mcVdb.getProperty(
- "version").getValue()).getValue().toString();
- // TODO: Correct this after deploying proper VDB/Metadata
- String vdbDescription = "description"; // mcVdb.getProperty("description");
- String vdbStatus = "active"; // mcVdb.getProperty("status");
- String vdbURL = "url"; // mcVdb.getProperty("url");
+ String vdbName = ProfileServiceUtil.getSimpleValue(mcVdb, "name", String.class);
+ Integer vdbVersion = ProfileServiceUtil.getSimpleValue(mcVdb, "version", Integer.class);
+ String vdbDescription = ProfileServiceUtil.getSimpleValue(mcVdb, "description", String.class);
+ String vdbStatus = ProfileServiceUtil.getSimpleValue(mcVdb, "status", String.class);
+ String vdbURL = ProfileServiceUtil.getSimpleValue(mcVdb, "url", String.class);
/**
*
@@ -86,7 +81,7 @@
discoveryContext.getResourceType(), // ResourceType
vdbKey, // Resource Key
vdbName, // Resource Name
- vdbVersion, // Version
+ vdbVersion.toString(), // Version
PluginConstants.ComponentType.VDB.DESCRIPTION, // Description
discoveryContext.getDefaultPluginConfiguration(), // Plugin
// Config
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java 2010-02-19 20:41:28 UTC (rev 1859)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java 2010-02-19 21:47:42 UTC (rev 1860)
@@ -16,8 +16,16 @@
import org.jboss.managed.api.ComponentType;
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.EnumValue;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
import org.jboss.profileservice.spi.ProfileService;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
public class ProfileServiceUtil {
protected final Log LOG = LogFactory.getLog(ProfileServiceUtil.class);
@@ -139,5 +147,34 @@
return getManagedComponent(DQPTYPE, DQPNAME);
}
+
+ public static String stringValue(MetaValue v1) {
+ if (v1 != null) {
+ MetaType type = v1.getMetaType();
+ if (type instanceof SimpleMetaType) {
+ SimpleValue simple = (SimpleValue)v1;
+ return simple.getValue().toString();
+ }
+ throw new MetaMatrixRuntimeException("Failed to convert value to string value");
+ }
+ return null;
+ }
+
+ public static <T> T getSimpleValue(ManagedComponent mc, String prop, Class<T> expectedType) {
+ ManagedProperty mp = mc.getProperty(prop);
+ if (mp != null) {
+ MetaType metaType = mp.getMetaType();
+ if (metaType.isSimple()) {
+ SimpleValue simpleValue = (SimpleValue)mp.getValue();
+ return expectedType.cast((simpleValue != null) ? simpleValue.getValue() : null);
+ }
+ else if (metaType.isEnum()) {
+ EnumValue enumValue = (EnumValue)mp.getValue();
+ return expectedType.cast((enumValue != null) ? enumValue.getValue() : null);
+ }
+ throw new IllegalStateException(prop+ " is not a simple type");
+ }
+ return null;
+ }
}
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/configuration.properties
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/configuration.properties 2010-02-19 20:41:28 UTC (rev 1859)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/configuration.properties 2010-02-19 21:47:42 UTC (rev 1860)
@@ -1,3 +0,0 @@
-url=mm://localhost:31000
-username=Admin
-password=mm
\ No newline at end of file
14 years, 10 months
teiid SVN: r1859 - in branches/JCA/console/src/main/java/org/teiid/rhq: admin/utils and 10 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-02-19 15:41:28 -0500 (Fri, 19 Feb 2010)
New Revision: 1859
Removed:
branches/JCA/console/src/main/java/org/teiid/rhq/admin/ConnectionMgr.java
branches/JCA/console/src/main/java/org/teiid/rhq/admin/utils/SingletonConnectionManager.java
branches/JCA/console/src/main/java/org/teiid/rhq/comm/Component.java
branches/JCA/console/src/main/java/org/teiid/rhq/comm/Connection.java
branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionFactory.java
branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionPool.java
branches/JCA/console/src/main/java/org/teiid/rhq/comm/VMComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/comm/impl/ComponentImpl.java
branches/JCA/console/src/main/java/org/teiid/rhq/comm/impl/InvalidConnectionImpl.java
branches/JCA/console/src/main/java/org/teiid/rhq/embedded/EmbeddedConnectionMgr.java
branches/JCA/console/src/main/java/org/teiid/rhq/embedded/pool/ConnectionPoolImpl.java
branches/JCA/console/src/main/java/org/teiid/rhq/enterprise/EnterpriseConnectionMgr.java
branches/JCA/console/src/main/java/org/teiid/rhq/enterprise/pool/ConnectionPoolImpl.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/NodeChildrenDiscoveryComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/NodeDiscoveryComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/log/JBEDSPErrorLogEntryProcessor.java
Modified:
branches/JCA/console/src/main/java/org/teiid/rhq/comm/ExecutedResult.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/Facet.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedResourceConfigurationResultImpl.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/DeploymentUtils.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
Log:
TEIID-807: merging the trunk/console into jca/console -r 1840:1858
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/admin/ConnectionMgr.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/admin/ConnectionMgr.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/admin/ConnectionMgr.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -1,66 +0,0 @@
-package org.teiid.rhq.admin;
-
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionException;
-
-
-public interface ConnectionMgr {
-
- /**
- * Called to indicate that this manager should be initialized.
- * @param props
- * @param cl is the ClassLoader to use to instantiate any classes downstream
- */
- void initialize(Properties props, ClassLoader cl);
-
- /**
- * Called to reset the pool. A subsequent call to @see #initialize(Properties, ClassLoader)
- * would establish a new set of installations based on the properties.
- */
- void shutdown();
-
- /**
- * Returns <code>true</code> if server installations have been configured and will be returned
- * in the {@link #getServerInstallations()} call.
- * @return true if servers are defined.
- */
-
- boolean hasServersDefined();
-
-
- /**
- * Returns the unique set of keys for each installation
- * @return Set of unique keys
- */
- Set getInstallationSystemKeys();
-
-
-
- /**
- * this is called only during discovery to obtain a connection for each
- * system (or server installation) on the local machine.
- *
- * In cases where a connection cannot be obtained, an entry in the
- * <code>Map</code> will be added with a null set for the value <code>Connection</code>
- * @return Map <key=installdir value=Connection>
- * @throws Exception
- * @since 1.0
- */
- Map<String, Connection> getServerInstallations();
-
- /**
- * Called to get a {@link Connection} that will be used to
- * call the MetaMatrix Server.
- * @param key is the unique identifier for the system in
- * which to obtain the connection for.
- * @return Connection for the system to communicate with.
- * @throws Exception
- * @since 1.0
- */
- Connection getConnection(String key) throws ConnectionException;
-
-}
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/admin/utils/SingletonConnectionManager.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/admin/utils/SingletonConnectionManager.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/admin/utils/SingletonConnectionManager.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -1,145 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.admin.utils;
-
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.teiid.rhq.admin.ConnectionMgr;
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionException;
-
-
-public class SingletonConnectionManager {
-
- private static final Log log = LogFactory.getLog(SingletonConnectionManager.class);
-
- private static final String ENTERPRISE_CONNECTION_MGR="org.teiid.rhq.enterprise.EnterpriseConnectionMgr"; //$NON-NLS-1$
- private static final String EMBEDDED_CONNECTION_MGR="org.teiid.rhq.embedded.EmbeddedConnectionMgr"; //$NON-NLS-1$
-
- private static SingletonConnectionManager instance = null;
- private ConnectionMgr connmgr;
- private ClassLoader loader;
- private boolean initialized = false;
-
-
- private SingletonConnectionManager() {
-
-
- }
-
- public synchronized static SingletonConnectionManager getInstance() {
-
- if (instance == null) {
- instance = new SingletonConnectionManager();
- instance.setupConnectionMgr();
- }
-
- return instance;
- }
-
- public Set getInstallationSystemKeys() {
- return connmgr.getInstallationSystemKeys();
- }
-
- public Connection getConnection(String key) throws ConnectionException {
- return connmgr.getConnection(key);
- }
-
-
- public void initialize(Properties props) {
- if (connmgr != null && initialized) {
- // re-establish the connectionfactory and pool
- shutdown();
- setupConnectionMgr();
- }
- initializeConnectionMgr(props);
-
- }
-
- public Map getServerInstallations() {
- return connmgr.getServerInstallations();
- }
-
- public boolean hasServersDefined() {
- return connmgr.hasServersDefined();
- }
-
- public void shutdown() {
- connmgr.shutdown();
- connmgr = null;
- }
-
-
-
- private void setupConnectionMgr() {
- this.loader = this.getClass().getClassLoader();
- ConnectionMgr mgr = null;
- Class clzz = null;
- // first try enterprise version
- try {
- clzz = Class.forName(ENTERPRISE_CONNECTION_MGR, true, this.loader);
- } catch (ClassNotFoundException noent) {
-
- // no try the embedded connection pool version
- try {
- clzz = Class.forName(EMBEDDED_CONNECTION_MGR, true, this.loader);
- } catch (ClassNotFoundException noemb) {
-
- }
- }
-
- if (clzz == null) {
- throw new InvalidPluginConfigurationException("System Error: cannot load either enterprise or embedded connection mgr");
- }
-
- try {
- mgr = (ConnectionMgr) clzz.newInstance();
- } catch (Exception e) {
- throw new InvalidPluginConfigurationException(e);
- }
-
- this.connmgr = mgr;
-
- }
-
- private void initializeConnectionMgr(Properties props) {
-
- connmgr.initialize(props, this.loader);
- this.initialized = true;
-
- }
-
- public boolean isEmbedded() {
- try {
- Class.forName(EMBEDDED_CONNECTION_MGR);
- return true;
- } catch (ClassNotFoundException noent) {
- return false;
- }
- }
-
-}
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/comm/Component.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/comm/Component.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/comm/Component.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -1,85 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.comm;
-
-import java.util.Map;
-
-
-/**
- * @since 4.3
- */
-public interface Component extends Comparable<Object> {
-
- public static final String SYSTEM_KEY = "teiid.system.key"; //$NON-NLS-1$
- public static final String NAME = "teiid.name"; //$NON-NLS-1$
- public static final String IDENTIFIER = "teiid.identifier"; //$NON-NLS-1$
- public static final String DESCRIPTION = "teiid.description"; //$NON-NLS-1$
- public static final String VERSION = "teiid.version"; //$NON-NLS-1$
-
- /**
- * Return the system key that this component identifies with.
- * @return String system key
- */
- String getSystemKey();
-
- /**
- * Return the name for this component
- * @return String name
- */
- String getName();
-
- /**
- * return the unique identifier for this component
- * @return String unique identifier
- */
- String getIdentifier();
-
- /**
- * Return the description
- * @return String description
- */
- String getDescription();
-
- /**
- * Return the version
- * @return String version
- */
- String getVersion();
-
- /**
- * Return a value for the request property key
- * @param key is the identifier to look for
- * @return String value
- */
- String getProperty(String key);
-
-
- /**
- * Return the map of properties.
- * @return Map of properties
- */
- Map getProperties();
-
-
-
-
-}
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/comm/Connection.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/comm/Connection.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/comm/Connection.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -1,140 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.comm;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Properties;
-
-import org.teiid.rhq.admin.utils.SingletonConnectionManager;
-
-
-
-public interface Connection {
-
- /**
- * Called to find out if the connection represents a valid connection to the
- * JBEDSP system. This call should be used only after obtaining a connection
- * from the {@link SingletonConnectionManager#getConnection(String)}.
- * The connection can become invalid if the JBEDSP system goes down.
- */
- boolean isValid();
-
- /**
- * Called by the {@link ConnectionPool} to check if the connection is still open.
- * @return true is the connection is alive.
-
- */
- boolean isAlive();
-
- /**
- * Call to indicate the connection is no longer needed and that
- * resources can be released.
- */
- public void close() ;
-
-
- /**
- * This method is called by a component of the JBEDSP RHQ plugin. The
- * component identifier, type and metric operation are used to execute the correlating logic.
- * The valueMap is a map of values (0-n) that are required by
- * the logic to determine the metric.
- * @param componentType @see ConnectionConstants.ComponentType
- * @param identifier
- * @param metric
- * @param valueMap
- * @return Object
- * @throws ConnectionException
- */
- public Object getMetric(final String componentType, String identifier, final String metric, final Map valueMap) throws ConnectionException;
-
- /**
- * This method is called by a component of the JBEDSP RHQ plugin. The
- * component type and operation are used to execute the correlating logic.
- * The valueMap is a collection of values (0-n) that are required by
- * the operation.
- * {@link ConnectionConstants.ComponentType} for <code>componentType</code> values
- * @param result
- * @param componentType
- * @param operationName
- * @param valueMap
- * @throws ConnectionException
- */
- public void executeOperation(final ExecutedResult result, final Map valueMap) throws ConnectionException;
-
- /**
- * This method is called by a component to determine if that particular component is con. The
- * component type and identifier are used to execute the correlating logic.
- *
- * {@link ConnectionConstants.ComponentType} for <code>componentType</code> values
- *
- * The return value is true if UP else false if DOWN
- *
- * @param componentType
- * @param identifier
- * @return Boolean
- * @throws ConnectionException
- */
- public Boolean isAvailable(final String componentType, final String identifier) throws ConnectionException;
-
-
- /**
- * Return the properties for component of a specified resource type {@link ConnectionConstants.ComponentType}
- * @param componentType {@link ConnectionConstants.ComponentType}
- * @param identifier
- * @return
- * @throws ConnectionException
- * @since 4.3
- */
-
- public Properties getProperties(String componenType, String identifier) throws ConnectionException;
-
- /**
- * Returns a property for a given identifier
- *
- * @param identifier
- * @param property
- * @throws ConnectionException
- */
- public String getProperty(String identifier, String property) throws ConnectionException;
-
- /**
- * Returns the unique key that maps this connection to the system that is being connected to.
- * This key used during the enterprise monitoring to keep track of which connection belongs to
- * what's being monitored.
- *
- * @return key JBEDSP represented by this connection
- * @throws Exception
- */
- public String getKey() throws Exception;
-
- /**
- * Returns a <code>Collection</code> of {@link Component Component}s for the given identifier for the
- * given name of the {@link ConnectionConstants.ComponentType}
- * @param componentType
- * @param identifier
- * @return
- * @throws ConnectionException
- */
- public Collection<Component> discoverComponents(String componentType, String identifier) throws ConnectionException;
-
-}
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionFactory.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionFactory.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionFactory.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.comm;
-
-import java.util.Properties;
-
-
-/**
- * The primary interface to be implemented by the pool user. The ConnectionFactory
- * is called by the {@link ConnectionPool} to create and close the connection.
- *
- *
- * This
- */
-public interface ConnectionFactory {
-
- public static final String CONNECTION_FACTORY_DEFAULT="org.teiid.rhq.comm.impl.TeiidConnectionFactory"; //$NON-NLS-1$
-
-
-
- /**
- * Set the environment that this factory is being run in - typically used
- * to obtain properties when creating connections and to log messages as
- * necessary.
- * @param env The environment properties needed to create a connection by the connector manager
- * {@link ConnectionConstants}
- * @param connectionPool is passed so the factory can set the pool on the connection.
- */
- void initialize(Properties env, ConnectionPool connectionPool) throws ConnectionException;
-
- /**
- * Return the url used to connect to the server.
- * @return String url
- */
- String getURL();
-
- /**
- * Create the connection. This connection is to an existing MetaMatrix server.
- * @return The Connection form of source-specific connection
- * @throws ConnectorException If an error occurs while creating the connection
- */
- Connection createConnection() throws ConnectionException;
-
-
- /**
- * Called by the {@link ConnectionPool} when a connection is being cleaned up from the pool.
- * This will allow the creator of the connection to do any last cleanup steps necessary in order
- * to release all resources.
- *
- * In cases where the {@link Connection}, when the {@link Connection#close()} method only returns
- * the connection to the pool and does not actually close the connection, this close will be
- * responsible for actually closing the connection to the source.
- * @param connection
-
- */
- void closeConnection(Connection connection) ;
-
-}
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionPool.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionPool.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/comm/ConnectionPool.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -1,103 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.comm;
-
-import java.util.Properties;
-
-
-
-
-/**
- * The primary interface for the ConnectionPool used by the connection manager
- * responsible for handing out connections to the discovery and resource JON objects.
- *
- * After the instantiation of the ConnectionPool, the @link #initialize(String, Properties) method
- * will be called so the pool can be initialized.
- * @since 1.0
- *
- */
-public interface ConnectionPool extends ConnectionPoolConstants {
-
-
- /**
- * Set the connection factory responsible for creating a connection
- * when the pool needs a new one. @see ConnectionPoolConstants for the
- * avalable settings to configure the pool.
- * @param env are the environment variables needed to iniatilize the connection pool.
- * @since 1.0
- */
- void initialize(Properties env, ClassLoader cl) throws ConnectionException ;
-
- /**
- * Return a unique key that identifies this connection pool
- *
- * @return
- */
- String getKey();
-
-
- /**
- * Returns a {@link Connection} from the pool.
- * @return Connction
- */
- Connection getConnection() throws ConnectionException;
-
-
- /**
- * Return the connection to the pool. It's up to the
- * implementation of the pool if the connection is reused or not
- * @param connection returned to the pool
- */
- void close(Connection connection) throws ConnectionException;
-
-
- /**
- * Called to shutdown the pool.
- *
- */
- void shutdown() throws ConnectionException;
-
-
- /**
- * Return the <code>ClassLoader</code> used to instantiate the {@link ConnectionFactory} and
- * will be used on all calls in the {@link Connection}
- * @return
- */
- ClassLoader getClassLoader();
-
- /**
- * Return the number of connection that are currently in use.
- * @return int is the number of connections in use
- *
- * @since
- */
- int getConnectionsInUseCount();
-
- /**
- * Return the number of connections that are currently available in the pool.
- * @return int is the number of connections currently available in the pool.
- *
- * @since 6.2
- */
- int getAvailableConnectionCount();
-
-}
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/comm/ExecutedResult.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/comm/ExecutedResult.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/comm/ExecutedResult.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -21,6 +21,7 @@
*/
package org.teiid.rhq.comm;
+import java.util.Collection;
import java.util.List;
public interface ExecutedResult {
@@ -33,7 +34,7 @@
List<String> getFieldNameList();
- void setContent(List content);
+ void setContent(Collection content);
void setContent(String content);
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/comm/VMComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/comm/VMComponent.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/comm/VMComponent.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.comm;
-
-
-/**
- * @since 4.3
- */
-public interface VMComponent extends Component {
- public static final String PORT = "mm.port"; //$NON-NLS-1$
-
- String getPort();
-}
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/comm/impl/ComponentImpl.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/comm/impl/ComponentImpl.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/comm/impl/ComponentImpl.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -1,244 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.comm.impl;
-
-import java.util.Map;
-import java.util.Properties;
-
-import org.teiid.rhq.comm.Component;
-import org.teiid.rhq.comm.VMComponent;
-
-import com.metamatrix.core.util.HashCodeUtil;
-
-
-/**
- */
-public class ComponentImpl implements VMComponent {
- private String systemKey;
- private String description;
- private String name;
- private String identifier;
- private String version="1.0"; //$NON-NLS-1$
- private String port;
- int hashCode;
-
-
- private Properties compprops = new Properties();
-
-
- public void addProperty(String key, String value) {
- compprops.put(key, value);
- }
-
- public void setProperties(Properties props) {
- compprops.putAll(props);
- }
-
- public String getProperty(String key) {
- return (String)compprops.get(key);
- }
-
- public Map getProperties() {
- return compprops;
- }
-
- /**
- * @return Returns the systemKey.
- * @since 1.0
- */
- public String getSystemKey() {
- return this.systemKey;
- }
-
-
- /**
- * @param systemKey The systemKey to set.
- * @since 1.0
- */
- public void setSystemKey(String systemKey) {
- this.systemKey = systemKey;
- }
-
- /**
- * @see org.teiid.rhq.comm.Component#getDescription()
- * @since 1.0
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * @see org.teiid.rhq.comm.Component#getIdentifier()
- * @since 1.0
- */
- public String getIdentifier() {
- return identifier;
- }
-
- /**
- * @see org.teiid.rhq.comm.Component#getName()
- * @since 1.0
- */
- public String getName() {
- return name;
- }
-
- /**
- * @see org.teiid.rhq.comm.Component#getVersion()
- * @since 1.0
- */
- public String getVersion() {
- return version;
- }
-
-
- /**
- * @return Returns the port.
- */
- public String getPort() {
- return this.port;
- }
-
-
-
- /**
- * @param port The port to set.
- */
- public void setPort(String port) {
- this.port = port;
- }
-
-
- /**
- * @param description The description to set.
- * @since 1.0
- */
- protected void setDescription(String description) {
- this.description = description;
- }
-
-
- /**
- * @param identifier The identifier to set.
- * @since 1.0
- */
- protected void setIdentifier(String identifier) {
- this.identifier = identifier;
- this.hashCode = HashCodeUtil.hashCode(0, this.identifier);
- }
-
-
- /**
- * @param name The name to set.
- * @since 1.0
- */
- protected void setName(String name) {
- this.name = name;
- }
-
-
- /**
- * @param version The version to set.
- * @since 1.0
- */
- protected void setVersion(String version) {
- this.version = version;
- }
-
- /**
- * Returns true if the specified object is semantically equal to this instance.
- * Note: this method is consistent with <code>compareTo()</code>.
- * <p>
- * @param obj the object that this instance is to be compared to.
- * @return whether the object is equal to this object.
- */
- public boolean equals(Object obj) {
- // Check if instances are identical ...
- if (this == obj) {
- return true;
- }
-
- // Check if object can be compared to this one
- // (this includes checking for null ) ...
- if (obj instanceof Component) {
-
-
- // fail fast on different hash codes
- if (this.hashCode() != obj.hashCode()) {
- return false;
- }
-
- // slower comparison
- Component that = (Component)obj;
- return ( that.getSystemKey().equals(this.getSystemKey()) );
- }
-
- // Otherwise not comparable ...
- return false;
- }
-
- /**
- * Compares this object to another. If the specified object is an instance of
- * the same class, then this method compares the name; otherwise, it throws a
- * ClassCastException (as instances are comparable only to instances of the same
- * class). Note: this method is consistent with <code>equals()</code>.
- * <p>
- * @param obj the object that this instance is to be compared to.
- * @return a negative integer, zero, or a positive integer as this object
- * is less than, equal to, or greater than the specified object, respectively.
- * @throws ClassCastException if the specified object's type prevents it
- * from being compared to this instance.
- */
- public int compareTo(Object obj) {
- // Check if instances are identical ...
- if (this == obj) {
- return 0;
- }
- if (obj == null ) {
- throw new IllegalArgumentException("Object is null, must be of type " + this.getClass().getName());
- }
-
- // Check if object cannot be compared to this one
- // (this includes checking for null ) ...
- if (!(obj instanceof Component)) {
- throw new IllegalArgumentException(obj.getClass().getName() + " is not of type " + this.getClass().getName());
- }
-
- // Check if everything else is equal ...
- Component that = (Component)obj;
- int result = that.hashCode() - this.hashCode;
- if ( result != 0 ) return result;
- return this.getIdentifier().compareTo(that.getIdentifier());
- }
-
- /**
- * Returns a string representing this instance.
- * @return the string representation of this instance.
- */
- public String toString() {
- return this.getIdentifier();
- }
-
-
-
-
-}
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/comm/impl/InvalidConnectionImpl.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/comm/impl/InvalidConnectionImpl.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/comm/impl/InvalidConnectionImpl.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -1,200 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.comm.impl;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.teiid.rhq.comm.Component;
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionException;
-import org.teiid.rhq.comm.ConnectionPool;
-import org.teiid.rhq.comm.ExecutedResult;
-
-
-
-/**
- */
-public class InvalidConnectionImpl implements
- Connection,
- TeiidConnectionConstants {
-
-
- private static final Log LOG = LogFactory.getLog(InvalidConnectionImpl.class);
-
- private static final Object METRIC=new Double(0);
- private static final String EMPTY_STRING=""; //$NON-NLS-1$
-
-
- private String key = EMPTY_STRING;
- private Properties environmentProps = null;
- private ConnectionPool connectionPool = null;
-
- public InvalidConnectionImpl (final String key,
- final Properties envProps,
- final ConnectionPool pool) {
- this.key = key;
- this.environmentProps = envProps;
- this.connectionPool = pool;
- }
-
- public boolean isValid() {
- return false;
- }
- /**
- * @see org.teiid.rhq.comm.Connection#isAlive()
- * @since 1.0
- */
- public boolean isAlive() {
- return false;
- }
-
- /**
- * @see org.teiid.rhq.comm.Connection#close()
- * @since 1.0
- */
- public void close() {
- try {
- if (connectionPool != null) {
- connectionPool.close(this);
- }
-
- } catch (Exception e) {
- LOG.error("Error returning connection to the connection pool", e); //$NON-NLS-1$
- }
- }
-
- /**
- * @see org.teiid.rhq.comm.Connection#getMetric(java.lang.String, java.lang.String, java.util.Map)
- * @since 1.0
- */
- public Object getMetric(String componentType,
- String identifier,
- String metric,
- Map valueMap) throws ConnectionException {
- return METRIC;
- }
-
- /**
- * @see org.teiid.rhq.comm.Connection#executeOperation(java.lang.String, java.lang.String, java.util.Map)
- * @since 1.0
- */
- public void executeOperation(ExecutedResult operationResult,
- Map argumentMap) throws ConnectionException {
- }
-
- /**
- * @see org.teiid.rhq.comm.Connection#isAvailable(java.lang.String, java.lang.String)
- * @since 1.0
- */
- public Boolean isAvailable(String componentType,
- String identifier) throws ConnectionException {
- return false;
- }
-
-
-
- /**
- * @see org.teiid.rhq.comm.Connection#getProperties(java.lang.String, java.lang.String)
- * @since 1.0
- */
- public Properties getProperties(String resourceType,
- String identifier) throws ConnectionException {
- return new Properties();
- }
-
- /**
- * @see org.teiid.rhq.comm.Connection#getProperty(java.lang.String, java.lang.String)
- * @since 1.0
- */
- public String getProperty(String identifier,
- String property) throws ConnectionException {
- return EMPTY_STRING;
- }
-
- /**
- * @see org.teiid.rhq.comm.Connection#getKey()
- * @since 1.0
- */
- public String getKey() throws Exception {
- return key;
- }
-
- /**
- * @see org.teiid.rhq.comm.Connection#getConnectors(java.lang.String)
- * @since 1.0
- */
- public Collection<Component> getConnectors(String vmname) throws ConnectionException {
- return Collections.EMPTY_LIST;
- }
-
-
- public Collection<Component> getVMs(String hostname) throws ConnectionException {
- return Collections.EMPTY_LIST;
- }
-
- public Collection<Component> getVDBs(List fieldNameList) throws ConnectionException {
- return Collections.EMPTY_LIST;
- }
-
-
- public Collection getAllHosts() throws ConnectionException {
- return Collections.EMPTY_LIST;
- }
-
- public Component getHost(String identifier) throws ConnectionException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Collection<Component> getConnectorsForConfig(String vmidentifier)
- throws ConnectionException {
-// TODO Auto-generated method stub
-return Collections.EMPTY_LIST;
-}
-
-public Collection<Component> getServices(String vmIdentifier)
- throws ConnectionException {
-// TODO Auto-generated method stub
-return Collections.EMPTY_LIST;
-}
-
-public Collection<Component> getServicesForConfig(String identifier)
- throws ConnectionException {
-// TODO Auto-generated method stub
-return Collections.EMPTY_LIST;
-}
-
-public Collection<Component> discoverComponents(String componentType,
- String identifier) throws ConnectionException {
- // TODO Auto-generated method stub
- return Collections.EMPTY_LIST;
-}
-
-
-
-}
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/embedded/EmbeddedConnectionMgr.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/embedded/EmbeddedConnectionMgr.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/embedded/EmbeddedConnectionMgr.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -1,97 +0,0 @@
-package org.teiid.rhq.embedded;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.teiid.rhq.admin.ConnectionMgr;
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionException;
-import org.teiid.rhq.comm.ConnectionPool;
-import org.teiid.rhq.embedded.pool.ConnectionPoolImpl;
-import org.teiid.rhq.embedded.pool.EmbeddedConnectionConstants;
-
-
-
-public class EmbeddedConnectionMgr implements ConnectionMgr {
- private static final Log log = LogFactory.getLog(EmbeddedConnectionMgr.class);
-
- private ConnectionPool pool;
- private Properties props;
- private ClassLoader loader;
-
- private Map<String, Connection> connectionList = new HashMap(1);
-
-
- public Connection getConnection(String key) throws ConnectionException {
- return pool.getConnection();
- }
-
-
-
- public Set<String> getInstallationSystemKeys() {
- Set<String> keys = new HashSet<String>(1);
- keys.add(EmbeddedConnectionConstants.SYSTEM_KEY);
- return keys;
- }
-
-
-
- public Map getServerInstallations() {
- connectionList = new HashMap(1);
- try {
- connectionList.put(pool.getKey(), pool.getConnection());
- } catch (ConnectionException e) {
- // TODO Auto-generated catch block
- throw new InvalidPluginConfigurationException(e);
- }
- return connectionList;
- }
-
- public void shutdown() {
-
- try {
- pool.shutdown();
- } catch (ConnectionException e) {
- // TODO Auto-generated catch block
- log.error("Error shutting down connection pool", e);
-
- }
- pool = null;
-
- connectionList.clear();
-
- }
-
- public boolean hasServersDefined() {
- return (pool !=null);
- }
-
- public void initialize(Properties props, ClassLoader cl) {
- this.props = props;
- this.loader = cl;
-
- // allow override of the factory class
- // this was put in to allow testing to set the factory
- String factoryclass = System.getProperty(ConnectionPool.CONNECTION_FACTORY);
- if (factoryclass != null) {
- props.setProperty(ConnectionPool.CONNECTION_FACTORY, factoryclass);
- }
-
- try {
- Class clzz = Class.forName(ConnectionPoolImpl.class.getName(), true, this.loader);
- this.pool = (ConnectionPoolImpl) clzz.newInstance();
- //new ConnectionPoolImpl();
- this.pool.initialize(props, cl);
-
- log.info("ConnectionPool created for key " + pool.getKey()); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (Throwable t) {
- throw new InvalidPluginConfigurationException(t);
- }
- }
-}
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/embedded/pool/ConnectionPoolImpl.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/embedded/pool/ConnectionPoolImpl.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/embedded/pool/ConnectionPoolImpl.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -1,266 +0,0 @@
-package org.teiid.rhq.embedded.pool;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionException;
-import org.teiid.rhq.comm.ConnectionFactory;
-import org.teiid.rhq.comm.ConnectionPool;
-
-
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/**
- * Simple pooling built on JDBCUtil. Not compatible with DataSources, etc.
- * Added due to poor 1.6 support among common connection pool implementations.
- *
- * TODO: Should be switched to proxool or some implementation
- */
-public class ConnectionPoolImpl implements ConnectionPool
-
-{
-
- public static final String WAIT_TIME_FOR_RESOURCE= "jbedsp.pool.wait.time"; //$NON-NLS-1$
- public static final String MAXIMUM_RESOURCE_POOL_SIZE = "jbedsp.pool.maximum.size"; //$NON-NLS-1$
- public static final String RESOURCE_TEST_INTERVAL = "jbedsp.pool.test.interval"; //$NON-NLS-1$
-
- private final class ConnectionProxy implements InvocationHandler {
- private Connection c;
- private long lastTest = System.currentTimeMillis();
- private Boolean valid = Boolean.TRUE;
-
- public ConnectionProxy(Connection c) {
- this.c = c;
- }
-
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
- try {
- if (method.getName().equals("close")) { //$NON-NLS-1$
- boolean isShutdown = shutdown;
- boolean success = false;
- try {
- if (!isShutdown) {
- connections.add((Connection)proxy);
- success = true;
- }
- } finally {
- connectionLock.release();
- if (!success) {
- c.close();
- return null;
- }
- }
- if (success) {
- return null;
- }
- } else if (method.getName().equals("isValid")) { //$NON-NLS-1$
- long now = System.currentTimeMillis();
- if (lastTest + testInterval > now) {
- return c.isValid();
- }
- lastTest = now;
- try {
- valid = c.isAlive();
- } catch (AbstractMethodError e) {
- valid = c.isValid();
- }
- return valid;
- }
- return method.invoke(c, args);
- } catch (InvocationTargetException e) {
- valid = false;
- throw e.getCause();
- }
- }
- }
-
- /**
- * The default connection factory if one is not specified in the environment
- */
- static final String CONNECTION_FACTORY_DEFAULT=ConnectionFactory.CONNECTION_FACTORY_DEFAULT; //$NON-NLS-1$
-
-
- private Semaphore connectionLock;
- private ConcurrentLinkedQueue<Connection> connections = new ConcurrentLinkedQueue<Connection>();
- private Properties p;
- private int timeout;
- private int testInterval;
- private volatile boolean shutdown;
- private ConnectionFactory factory = null;
-
- private ClassLoader loader = null;
-
- public void close(Connection connection) {
-
-
- }
-
-
-
- @Override
- public int getAvailableConnectionCount() {
- // TODO Auto-generated method stub
- return 0;
- }
-
-
-
- @Override
- public int getConnectionsInUseCount() {
- // TODO Auto-generated method stub
- return 0;
- }
-
-
-
- public ClassLoader getClassLoader() {
- return this.loader;
- }
-
-
- public String getKey() {
- return EmbeddedConnectionConstants.SYSTEM_KEY;
- }
-
-
-
- public void initialize(Properties env, ClassLoader cl) throws ConnectionException {
- this.p = env;
- this.loader = cl;
- this.timeout = getIntProperty(p, WAIT_TIME_FOR_RESOURCE, 30000);
- this.testInterval = getIntProperty(p, RESOURCE_TEST_INTERVAL, 30000);
- this.connectionLock = new Semaphore(getIntProperty(p, MAXIMUM_RESOURCE_POOL_SIZE, 15));
-
-// liveAndUnusedTime = getIntProperty(LIVE_AND_UNUSED_TIME, DEFAULT_LIVE_AND_UNUSED_TIME);
-// cleaningInterval = getIntProperty(CLEANING_INTERVAL, DEFAULT_CLEANING_INTERVAL);
-
-
- createFactory();
- }
-
-
-
- public Connection getConnection() throws ConnectionException {
- if (shutdown) {
- throw new ConnectionException("pool shutdown"); //$NON-NLS-1$
- }
- try {
- if (!connectionLock.tryAcquire(timeout, TimeUnit.MILLISECONDS)) {
- throw new ConnectionException("Timeout waiting for connection"); //$NON-NLS-1$
- }
- } catch (InterruptedException e) {
- throw new ConnectionException(e);
- }
- boolean releaseLock = true;
- try {
- boolean valid = false;
- Connection c = connections.poll();
- if (c != null) {
-
- valid = c.isValid();
- if (!valid) {
- try {
- factory.closeConnection(c);
- } catch (Exception e) {
-
- }
- c = null;
- }
- }
- if (c == null) {
- if (shutdown) {
- throw new ConnectionException("pool shutdown"); //$NON-NLS-1$
- }
- c = factory.createConnection();
- c = (Connection) Proxy.newProxyInstance(this.loader, new Class[] {Connection.class}, new ConnectionProxy(c));
- connections.add(c);
- }
-
- releaseLock = false;
- return c;
- } catch (ConnectionException ce) {
- throw ce;
- } finally {
- if (releaseLock) {
- connectionLock.release();
- }
- }
- }
-
- public void shutdown() {
- this.shutdown = true;
- Connection c = connections.poll();
- while (c != null) {
- try {
- c.close();
- } catch (Exception e) {
-
- }
- c = connections.poll();
- }
-
- }
-
-
- private void createFactory() throws ConnectionException {
-
- String factoryclass = p.getProperty(ConnectionPool.CONNECTION_FACTORY, CONNECTION_FACTORY_DEFAULT);
-
- try {
- Class<?> c = Class.forName(factoryclass, true, this.loader);
- factory = (ConnectionFactory)c.newInstance();
- } catch (Exception err) {
- throw new ConnectionException(err.getMessage());
- }
-
- // Initialize connector instance...
- factory.initialize(p, this);
-
- }
-
- public static int getIntProperty(Properties props, String propName, int defaultValue) throws ConnectionException {
- int val = defaultValue;
- String stringVal = props.getProperty(propName);
- if(stringVal != null && stringVal.trim().length() > 0) {
- try {
- val = Integer.parseInt(stringVal);
- } catch (NumberFormatException nfe) {
- throw new ConnectionException(nfe.getMessage());
- }
- }
- return val;
- }
-
-
-
-}
-
-
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/enterprise/EnterpriseConnectionMgr.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/enterprise/EnterpriseConnectionMgr.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/enterprise/EnterpriseConnectionMgr.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -1,154 +0,0 @@
-package org.teiid.rhq.enterprise;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.teiid.rhq.admin.ConnectionMgr;
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionConstants;
-import org.teiid.rhq.comm.ConnectionException;
-import org.teiid.rhq.comm.ConnectionPool;
-import org.teiid.rhq.enterprise.pool.ConnectionPoolImpl;
-
-
-public class EnterpriseConnectionMgr implements ConnectionMgr {
- private static final Log log = LogFactory.getLog(EnterpriseConnectionMgr.class);
-
-
- public static final String INSTALL_SERVER_PROP="mmservers"; //$NON-NLS-1$
-
- private static Map poolMap = Collections.synchronizedMap( new HashMap(5) );
-
-
- private Properties props = null;
-
-
- public Connection getConnection(String key) throws ConnectionException {
- Connection connection = null;
-
- log.info("Get Connection for " + key); //$NON-NLS-1$
-
- ConnectionPool pool = (ConnectionPool) poolMap.get(key);
- connection = pool.getConnection();
-
- return connection;
- }
-
-
- public Set getInstallationSystemKeys() {
- // TODO Auto-generated method stub
- return poolMap.keySet();
- }
-
-
- public boolean hasServersDefined() {
-
- if (poolMap != null && poolMap.size() > 0) {
- return true;
- }
- return false;
-
- }
-
- public Map getServerInstallations() {
- Map connectionList = new HashMap();
- Iterator installationIter = poolMap.keySet().iterator();
-
- while (installationIter.hasNext()) {
- String installDir = (String) installationIter.next();
- try {
- if (poolMap.get(installDir) != null) {
- ConnectionPool pool = (ConnectionPool) poolMap.get(installDir);
-
- Connection connection = pool.getConnection();
- connectionList.put(installDir, connection);
- } else {
- // this shouldn't happen
- connectionList.put(installDir, null);
- }
- } catch (Exception e) {
- connectionList.put(installDir, null);
- }
- }
-
-
- return connectionList;
- }
-
-
- public void shutdown() {
- Iterator installationIter = poolMap.keySet().iterator();
-
- while (installationIter.hasNext()) {
- String installDir = (String) installationIter.next();
- ConnectionPool pool = (ConnectionPool) poolMap.get(installDir);
- try {
- pool.shutdown();
- } catch (ConnectionException e) {
- // TODO Auto-generated catch block
- log.error("Error shutting down connection pool " + pool.getKey(), e);
- e.printStackTrace();
- }
- }
-
- poolMap.clear();
- }
- public void initialize(Properties props, ClassLoader cl) {
- this.props = props;
-
- String servers = this.props.getProperty(INSTALL_SERVER_PROP);
-
- /**
- * split the server installation properties by the delimiter
- * to determine the number of servers installed on the local machine
- */
- Collection installationList = AdminUtil.getTokens(servers, ";"); //$NON-NLS-1$
- Iterator installationIter = installationList.iterator();
-
- while (installationIter.hasNext()) {
- String serverInfoValues = (String) installationIter.next();
- Collection serverInfoValuesList = new LinkedList();
- serverInfoValuesList = AdminUtil.getTokens(serverInfoValues, ","); //$NON-NLS-1$
- Object[] serverInfoArray = serverInfoValuesList.toArray();
- String installDir = (String) serverInfoArray[0];
- String url = (String) serverInfoArray[1];
- String username = (String) serverInfoArray[2];
- String password = (String) serverInfoArray[3];
-
- props.setProperty(ConnectionConstants.PASSWORD, password);
- props.setProperty(ConnectionConstants.USERNAME, username);
- props.setProperty(ConnectionConstants.URL, url);
-
- // allow override of the factory class
- // this was put in to allow testing to set the factory
- String factoryclass = System.getProperty(ConnectionPool.CONNECTION_FACTORY);
- if (factoryclass != null) {
- props.setProperty(ConnectionPool.CONNECTION_FACTORY, factoryclass);
- }
-
- try {
-
- Class clzz = Class.forName(ConnectionPoolImpl.class.getName(), true, cl);
- ConnectionPool pool = (ConnectionPool) clzz.newInstance();
- pool.initialize(props, cl);
-
- poolMap.put(pool.getKey(), pool);
-
- log.info("ConnectionPool created for key " + pool.getKey() + " at url " + url); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (Throwable t) {
- throw new InvalidPluginConfigurationException(t);
- }
- }
- }
-
-
-}
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/enterprise/pool/ConnectionPoolImpl.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/enterprise/pool/ConnectionPoolImpl.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/enterprise/pool/ConnectionPoolImpl.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -1,424 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.enterprise.pool;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionException;
-import org.teiid.rhq.comm.ConnectionFactory;
-import org.teiid.rhq.comm.ConnectionPool;
-
-
-
-
-/**
- * This is the connection pool used to manage connections to the MetaMatrix server.
- */
-public class ConnectionPoolImpl implements ConnectionPool {
- private final Log LOG = LogFactory.getLog(ConnectionPoolImpl.class);
-
- /**
- * The default connection factory if one is not specified in the environment
- */
- private static final String CONNECTION_FACTORY_DEFAULT=ConnectionFactory.CONNECTION_FACTORY_DEFAULT; //$NON-NLS-1$
-
- public static final String WAIT_TIME_FOR_RESOURCE= "teiid.pool.wait.time"; //$NON-NLS-1$
- public static final String MAXIMUM_RESOURCE_POOL_SIZE = "teiid.pool.maximum.size"; //$NON-NLS-1$
- public static final String RESOURCE_TEST_INTERVAL = "teiid.pool.test.interval"; //$NON-NLS-1$
-
-
- private static final int DEFAULT_LIVE_AND_UNUSED_TIME = 60;
- private static final int DEFAULT_CLEANING_INTERVAL = 60;
- private static final boolean DEFAULT_ENABLE_SHRINKING = true;
-
-
- private int liveAndUnusedTime = DEFAULT_LIVE_AND_UNUSED_TIME;
- private int cleaningInterval = DEFAULT_CLEANING_INTERVAL;
- private boolean enableShrinking = DEFAULT_ENABLE_SHRINKING;
-
- private int timeout;
- private int testInterval;
-
-
-
- private Set<ConnectionWrapper> availConnections = Collections.synchronizedSet( new HashSet(10) );
- private Set<Connection> inuseConnections = Collections.synchronizedSet( new HashSet(10) );
-
- private Semaphore connectionLock;
-
- private ConnectionFactory factory = null;
-// private String installDir = null;
- private Properties envProps = null;
-
- private volatile boolean shuttingDownPool;
-
- private CleanUpThread cleaningThread;
-
- private ClassLoader clzzloader;
-
-
- // private Object lock = new Object();
-
- public ConnectionPoolImpl() {
-
- LOG.info("Creating Connection Pool"); //$NON-NLS-1$
- }
-
-
- /**
- * @see org.teiid.rhq.comm.ConnectionPool#getClassLoader()
- *
- */
- public ClassLoader getClassLoader() {
- return clzzloader;
- }
-
-
-
-
- @Override
- public int getAvailableConnectionCount() {
- return availConnections.size();
- }
-
-
-
-
- @Override
- public int getConnectionsInUseCount() {
- return inuseConnections.size();
- }
-
-
- public String getKey() {
- // TODO Auto-generated method stub
- return factory.getURL();
- }
-
-
- /**
- * @see com.metamatrix.rhq.admin.pool.ConnectionPool#close(org.teiid.rhq.comm.Connection)
- *
- */
- public void close(Connection connection) throws ConnectionException {
- if (this.shuttingDownPool) {
- return;
- }
- try {
- if (!connectionLock.tryAcquire(timeout, TimeUnit.MILLISECONDS)) {
- throw new ConnectionException("Timeout waiting for lock"); //$NON-NLS-1$
- }
- } catch (InterruptedException e) {
- throw new ConnectionException(e);
- }
- try {
- inuseConnections.remove(connection);
- if (connection.isValid()) {
- ConnectionWrapper cw = new ConnectionWrapper(connection);
- availConnections.add(cw);
- LOG.debug("Connection checked in for system "); //$NON-NLS-1$
- } else {
- this.closeConnection(connection);
- LOG.debug("Connection returned and closed for system "); //$NON-NLS-1$
-
- }
-
-
-
- } finally {
- connectionLock.release();
- }
-
- }
-
-
- /**
- * @see com.metamatrix.rhq.admin.pool.ConnectionPool#getConnection()
- *
- */
- public Connection getConnection() throws ConnectionException {
-
- if (this.shuttingDownPool) {
- return null;
- }
-
- try {
- if (!connectionLock.tryAcquire(timeout, TimeUnit.MILLISECONDS)) {
- throw new ConnectionException("Timeout waiting for lock trying to get connection"); //$NON-NLS-1$
- }
- } catch (InterruptedException e) {
- throw new ConnectionException(e);
- }
-
- try {
- if (availConnections.isEmpty()) {
- Connection conn = createConnection();
- inuseConnections.add(conn);
- return conn;
- }
-
-
- for (Iterator it=availConnections.iterator(); it.hasNext();) {
- ConnectionWrapper conn = (ConnectionWrapper) it.next();
- it.remove();
- if (conn.originalConnection.isValid()) {
- inuseConnections.add(conn.originalConnection);
- LOG.debug("Existing connection obtained for system "); //$NON-NLS-1$
- return conn.originalConnection;
- }
- this.closeConnection(conn.originalConnection);
-
- }
-
- Connection conn = createConnection();
- inuseConnections.add(conn);
- return conn;
-
- } finally {
- connectionLock.release();
- }
-
- }
-
- /**
- * @see com.metamatrix.rhq.admin.pool.ConnectionPool#initialize(java.lang.String, java.util.Properties)
- *
- */
- public void initialize(Properties env, ClassLoader cl) throws ConnectionException {
- this.envProps = env;
- // this.installDir = env.getProperty(EnterpriseConnectionConstants.INSTALL_DIR);
-
- this.clzzloader = cl;
- this.connectionLock = new Semaphore(getIntProperty(MAXIMUM_RESOURCE_POOL_SIZE, 15));
-
- this.timeout = getIntProperty( WAIT_TIME_FOR_RESOURCE, 30000);
- this.testInterval = getIntProperty( RESOURCE_TEST_INTERVAL, 30000);
- this.connectionLock = new Semaphore(getIntProperty( MAXIMUM_RESOURCE_POOL_SIZE, 15));
-
-
- initializeProps();
- createFactory();
- }
-
- /**
- * @see com.metamatrix.rhq.admin.pool.ConnectionPool#shutdown()
- *
- */
- public void shutdown() throws ConnectionException {
- shuttingDownPool = true;
-
- try {
- if (!connectionLock.tryAcquire(timeout, TimeUnit.MILLISECONDS)) {
- throw new ConnectionException("Timeout waiting for lock trying to get connection"); //$NON-NLS-1$
- }
- } catch (InterruptedException e) {
- throw new ConnectionException(e);
- }
-
- try {
- //close cleaning thread
- if (this.cleaningThread != null) {
- this.cleaningThread.stopCleanup();
- this.cleaningThread.interrupt();
- }
-
- // cleanup, passing true, will close all available connections
- this.cleanUp(true);
-
-
- for (Iterator i = inuseConnections.iterator(); i.hasNext();) {
- Connection conn = (Connection)i.next();
- this.closeConnection(conn);
- }
- inuseConnections.clear();
-
-
-
- envProps.clear();
- factory = null;
- } finally {
- connectionLock.release();
- }
-
-
- }
-
-
- private void createFactory() throws ConnectionException {
-
- String factoryclass = envProps.getProperty(ConnectionPool.CONNECTION_FACTORY, CONNECTION_FACTORY_DEFAULT);
-
- Thread currentThread = Thread.currentThread();
- ClassLoader threadContextLoader = currentThread.getContextClassLoader();
- try {
- currentThread.setContextClassLoader(this.clzzloader);
- try {
- Class c = Class.forName(factoryclass, true, this.clzzloader);
- factory = (ConnectionFactory)c.newInstance();
- } catch (Exception err) {
- throw new ConnectionException(err.getMessage());
- }
-
- // Initialize connector instance...
- factory.initialize(this.envProps, this);
-
-
- } finally {
- currentThread.setContextClassLoader(threadContextLoader);
- }
-
- }
-
- private void initializeProps() throws ConnectionException {
- liveAndUnusedTime = getIntProperty(LIVE_AND_UNUSED_TIME, DEFAULT_LIVE_AND_UNUSED_TIME);
- cleaningInterval = getIntProperty(CLEANING_INTERVAL, DEFAULT_CLEANING_INTERVAL);
-
-
- if (!this.shuttingDownPool) {
- this.cleaningThread = new CleanUpThread(cleaningInterval * 1000);
- this.cleaningThread.setDaemon(true);
- this.cleaningThread.start();
- }
-
- String value = envProps.getProperty(ENABLE_SHRINKING);
- if ( value != null ) {
- enableShrinking = Boolean.valueOf(value).booleanValue();
- }
-
- }
-
- private int getIntProperty(String propertyName, int defaultValue) throws ConnectionException {
- String value = this.envProps.getProperty(propertyName );
- if (value == null || value.trim().length() == 0) {
- return defaultValue;
- }
- return Integer.parseInt(value);
-
- }
-
-
- private Connection createConnection() throws ConnectionException {
- Thread currentThread = Thread.currentThread();
- ClassLoader threadContextLoader = currentThread.getContextClassLoader();
- try {
- currentThread.setContextClassLoader(this.clzzloader);
-
- // Initialize connector instance...
- return factory.createConnection();
-
-
- } finally {
- currentThread.setContextClassLoader(threadContextLoader);
- }
-
-
-
- }
-
- private void closeConnection(Connection conn) {
- Thread currentThread = Thread.currentThread();
- ClassLoader threadContextLoader = currentThread.getContextClassLoader();
- try {
- currentThread.setContextClassLoader(this.clzzloader);
- // Initialize connector instance...
- factory.closeConnection(conn);
-
-
- } finally {
- currentThread.setContextClassLoader(threadContextLoader);
- }
-
- }
-
- protected void cleanUp(boolean forceClose) {
- Set values = new HashSet(this.availConnections);
-
- for (Iterator i = values.iterator(); i.hasNext();) {
- ConnectionWrapper conn = (ConnectionWrapper)i.next();
-
- if (forceClose || (enableShrinking && conn.getIdelTime() >= this.liveAndUnusedTime)
- || !conn.originalConnection.isAlive()) {
- availConnections.remove(conn);
- this.closeConnection(conn.originalConnection);
-
- }
- }
-
- }
-
- /**
- * ConnectionWrapper is used to store the connection in the availableConnections and
- * will provide the amount of idletime a connection has been unused so that
- * it can be determined if the pool can be shrunk
- *
- */
- class ConnectionWrapper {
- Connection originalConnection;
- private long timeReturnedToPool;
-
- ConnectionWrapper(Connection originalConn) {
- originalConnection = originalConn;
- timeReturnedToPool = System.currentTimeMillis();
- }
-
- int getIdelTime() {
- return (int) (System.currentTimeMillis() - timeReturnedToPool) / 1000;
- }
- }
-
- class CleanUpThread extends Thread {
- private long sleepTime;
- private boolean continueChecks = true;
-
- CleanUpThread(long sleepTime) {
- super("MMConnectionPoolCleanUpThread"); //$NON-NLS-1$
- this.sleepTime = sleepTime;
- }
-
- public void stopCleanup() {
- this.continueChecks = false;
- }
-
- public void run() {
- while ( this.continueChecks ) {
- try {
- sleep(sleepTime);
- } catch (InterruptedException e) {
- // ignore it
- }
- ConnectionPoolImpl.this.cleanUp(false);
- }
- }
- }
-
-
-
-}
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/Facet.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -21,21 +21,13 @@
*/
package org.teiid.rhq.plugin;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.deployers.spi.management.deploy.DeploymentManager;
@@ -45,8 +37,6 @@
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.content.PackageDetailsKey;
import org.rhq.core.domain.content.PackageType;
-import org.rhq.core.domain.content.transfer.ContentResponseResult;
-import org.rhq.core.domain.content.transfer.DeployIndividualPackageResponse;
import org.rhq.core.domain.content.transfer.DeployPackageStep;
import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
@@ -55,12 +45,10 @@
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.domain.resource.CreateResourceStatus;
-import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.content.ContentFacet;
import org.rhq.core.pluginapi.content.ContentServices;
-import org.rhq.core.pluginapi.content.version.PackageVersions;
import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
@@ -70,11 +58,6 @@
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
-import org.rhq.core.util.ZipUtil;
-import org.rhq.core.util.exception.ThrowableUtil;
-import org.teiid.rhq.admin.utils.SingletonConnectionManager;
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionException;
import org.teiid.rhq.comm.ExecutedResult;
import org.teiid.rhq.plugin.objects.ExecutedOperationResultImpl;
import org.teiid.rhq.plugin.util.DeploymentUtils;
@@ -88,9 +71,6 @@
OperationFacet, ConfigurationFacet, ContentFacet, DeleteResourceFacet,
CreateChildResourceFacet {
- protected static SingletonConnectionManager connMgr = SingletonConnectionManager
- .getInstance();
-
protected final Log LOG = LogFactory.getLog(Facet.class);
/**
@@ -111,45 +91,21 @@
private String identifier;
+ protected String componentType;
+
// may be null when the component is not a host or vm
private String port = null;
protected boolean isAvailable = false;
- /**
- * Name of the backing package type that will be used when discovering
- * packages. This corresponds to the name of the package type defined in the
- * plugin descriptor.
- */
- private static final String PKG_TYPE_FILE = "vdb";
-
- /**
- * Architecture string used in describing discovered packages.
- */
- private static final String ARCHITECTURE = "noarch";
-
- private static final String BACKUP_FILE_EXTENSION = ".rej";
-
private final Log log = LogFactory.getLog(this.getClass());
- private PackageVersions versions;
-
/**
* The name of the ManagedDeployment (e.g.:
- * vfszip:/C:/opt/jboss-5.0.0.GA/server/default/deploy/foo.vdb).
+ * C:/opt/jboss-5.0.0.GA/server/default/deploy/foo.vdb).
*/
protected String deploymentName;
- /**
- * The type of the ManagedDeployment.
- */
- // protected KnownDeploymentTypes deploymentType;
- /**
- * The absolute path of the deployment file (e.g.:
- * C:/opt/jboss-5.0.0.GA/server/default/deploy/foo.vdb).
- */
- protected File deploymentFile;
-
abstract String getComponentType();
/**
@@ -161,6 +117,7 @@
*/
public void start(ResourceContext context) {
resourceContext = context;
+ deploymentName=context.getResourceKey();
}
/**
@@ -214,7 +171,7 @@
}
protected void setOperationArguments(String name,
- Configuration configuration, Map argumentMap) {
+ Configuration configuration, Map<String, Object> argumentMap) {
// moved this logic up to the associated implemented class
throw new InvalidPluginConfigurationException(
"Not implemented on component type " + this.getComponentType()
@@ -223,44 +180,12 @@
}
protected void execute(final ExecutedResult result, final Map valueMap) {
- Connection conn = null;
- try {
- conn = getConnection();
-
- if (!conn.isValid()) {
- return;
- }
- conn.executeOperation(result, valueMap);
-
- } catch (Exception e) {
- final String msg = "Error invoking operation [" + name + "]. Cause: " + e; //$NON-NLS-1$ //$NON-NLS-2$
- LOG.error(msg);
- throw new RuntimeException(msg);
- } finally {
- conn.close();
- }
+// DQPManagementView dqp = new DQPManagementView();
+//
+// dqp.executeOperation(result, valueMap);
+
}
-
- /**
- * The connection will be returned when it is available. If it is not, then
- * null will be returned. Resource methods will not throw exceptions as a
- * MetaMatrix System goes up and down. That state will be indicated by it's
- * availability state.
- *
- * @return
- */
-
- public Connection getConnection() throws ConnectionException {
- Connection conn = connMgr.getConnection(getSystemKey());
- if (conn.isValid()) {
- this.isAvailable = true;
- } else {
- this.isAvailable = false;
- }
-
- return conn;
- }
-
+
/*
* (non-Javadoc) This method is called by JON to check the availability of
* the inventoried component on a time scheduled basis
@@ -281,7 +206,7 @@
* @return true if the resource is available
*/
protected boolean isAvailable() {
- return this.isAvailable;
+ return true;
}
/**
@@ -306,8 +231,7 @@
public OperationResult invokeOperation(String name,
Configuration configuration) {
Map valueMap = new HashMap();
- Connection conn = null;
-
+
Set operationDefinitionSet = this.resourceContext.getResourceType()
.getOperationDefinitions();
@@ -364,359 +288,54 @@
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
}
- @Override
public void deleteResource() throws Exception {
- // TODO Auto-generated method stub
+
+ DeploymentManager deploymentManager = ProfileServiceUtil.getDeploymentManager();
+
+ log.debug("Stopping deployment [" + this.deploymentName + "]...");
+ DeploymentProgress progress = deploymentManager.stop(this.deploymentName);
+ DeploymentStatus stopStatus = DeploymentUtils.run(progress);
+ if (stopStatus.isFailed()) {
+ log.error("Failed to stop deployment '" + this.deploymentName + "'.", stopStatus.getFailure());
+ throw new Exception("Failed to stop deployment '" + this.deploymentName + "' - cause: "
+ + stopStatus.getFailure());
+ }
+ log.debug("Removing deployment [" + this.deploymentName + "]...");
+ progress = deploymentManager.remove(this.deploymentName);
+ DeploymentStatus removeStatus = DeploymentUtils.run(progress);
+ if (removeStatus.isFailed()) {
+ log.error("Failed to remove deployment '" + this.deploymentName + "'.", removeStatus.getFailure());
+ throw new Exception("Failed to remove deployment '" + this.deploymentName + "' - cause: "
+ + removeStatus.getFailure());
+ }
}
- @Override
+ //@Override
public DeployPackagesResponse deployPackages(
Set<ResourcePackageDetails> packages,
ContentServices contentServices) {
- String resourceTypeName = this.resourceContext.getResourceType()
- .getName();
-
- // You can only update the one application file referenced by this
- // resource, so punch out if multiple are
- // specified.
- if (packages.size() != 1) {
- log.warn("Request to update " + resourceTypeName
- + " file contained multiple packages: " + packages);
- DeployPackagesResponse response = new DeployPackagesResponse(
- ContentResponseResult.FAILURE);
- response.setOverallRequestErrorMessage("Only one "
- + resourceTypeName + " can be updated at a time.");
- return response;
- }
-
- ResourcePackageDetails packageDetails = packages.iterator().next();
-
- log.debug("Updating VDB file '" + this.deploymentFile + "' using ["
- + packageDetails + "]...");
- // Find location of existing application.
- if (!this.deploymentFile.exists()) {
- return failApplicationDeployment(
- "Could not find application to update at location: "
- + this.deploymentFile, packageDetails);
- }
-
- log.debug("Writing new EAR/WAR bits to temporary file...");
- File tempFile;
- try {
- tempFile = writeNewAppBitsToTempFile(contentServices,
- packageDetails);
- } catch (Exception e) {
- return failApplicationDeployment(
- "Error writing new application bits to temporary file - cause: "
- + e, packageDetails);
- }
- log.debug("Wrote new EAR/WAR bits to temporary file '" + tempFile
- + "'.");
-
- boolean deployExploded = this.deploymentFile.isDirectory();
-
- // Backup the original app file/dir.
- File tempDir = resourceContext.getTemporaryDirectory();
- File backupDir = new File(tempDir, "deployBackup");
- File backupOfOriginalFile = new File(backupDir, this.deploymentFile
- .getName());
- log.debug("Backing up existing EAR/WAR '" + this.deploymentFile
- + "' to '" + backupOfOriginalFile + "'...");
- try {
- if (backupOfOriginalFile.exists()) {
- FileUtils.forceDelete(backupOfOriginalFile);
- }
- if (this.deploymentFile.isDirectory()) {
- FileUtils.copyDirectory(this.deploymentFile,
- backupOfOriginalFile, true);
- } else {
- FileUtils.copyFile(this.deploymentFile, backupOfOriginalFile,
- true);
- }
- } catch (Exception e) {
- throw new RuntimeException("Failed to backup existing "
- + resourceTypeName + "'" + this.deploymentFile + "' to '"
- + backupOfOriginalFile + "'.");
- }
-
- // Now stop the original app.
- try {
- DeploymentManager deploymentManager = ProfileServiceUtil
- .getDeploymentManager();
- DeploymentProgress progress = deploymentManager
- .stop(this.deploymentName);
- DeploymentUtils.run(progress);
- } catch (Exception e) {
- throw new RuntimeException("Failed to stop deployment ["
- + this.deploymentName + "].", e);
- }
-
- // And then remove it (this will delete the physical file/dir from the
- // deploy dir).
- try {
- DeploymentManager deploymentManager = ProfileServiceUtil
- .getDeploymentManager();
- DeploymentProgress progress = deploymentManager
- .remove(this.deploymentName);
- DeploymentUtils.run(progress);
- } catch (Exception e) {
- throw new RuntimeException("Failed to remove deployment ["
- + this.deploymentName + "].", e);
- }
-
- // Deploy away!
- log.debug("Deploying '" + tempFile + "'...");
- DeploymentManager deploymentManager = null;
- try {
- deploymentManager = ProfileServiceUtil.getDeploymentManager();
- DeploymentUtils.deployArchive(deploymentManager, tempFile,
- deployExploded);
- } catch (Exception e) {
- // Deploy failed - rollback to the original app file...
- log.debug("Redeploy failed - rolling back to original archive...",
- e);
- String errorMessage = ThrowableUtil.getAllMessages(e);
- try {
- // Try to delete the new app file, which failed to deploy, if it
- // still exists.
- if (this.deploymentFile.exists()) {
- try {
- FileUtils.forceDelete(this.deploymentFile);
- } catch (IOException e1) {
- log.debug("Failed to delete application file '"
- + this.deploymentFile
- + "' that failed to deploy.", e1);
- }
- }
- // Now redeploy the original file - this generally should
- // succeed.
- DeploymentUtils.deployArchive(deploymentManager,
- backupOfOriginalFile, deployExploded);
- errorMessage += " ***** ROLLED BACK TO ORIGINAL APPLICATION FILE. *****";
- } catch (Exception e1) {
- log.debug("Rollback failed!", e1);
- errorMessage += " ***** FAILED TO ROLLBACK TO ORIGINAL APPLICATION FILE. *****: "
- + ThrowableUtil.getAllMessages(e1);
- }
- log
- .info("Failed to update " + resourceTypeName + " file '"
- + this.deploymentFile + "' using ["
- + packageDetails + "].");
- return failApplicationDeployment(errorMessage, packageDetails);
- }
-
- // Deploy was successful!
- deleteBackupOfOriginalFile(backupOfOriginalFile);
- persistApplicationVersion(packageDetails, this.deploymentFile);
-
- DeployPackagesResponse response = new DeployPackagesResponse(
- ContentResponseResult.SUCCESS);
- DeployIndividualPackageResponse packageResponse = new DeployIndividualPackageResponse(
- packageDetails.getKey(), ContentResponseResult.SUCCESS);
- response.addPackageResponse(packageResponse);
-
- log.debug("Updated " + resourceTypeName + " file '"
- + this.deploymentFile + "' successfully - returning response ["
- + response + "]...");
-
- return response;
+ return null;
}
- @Override
public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType arg0) {
- if (!this.deploymentFile.exists())
- throw new IllegalStateException("Deployment file '"
- + this.deploymentFile + "' for " + "VDB Archive"
- + " does not exist.");
-
- String fileName = this.deploymentFile.getName();
- PackageVersions packageVersions = loadPackageVersions();
- String version = packageVersions.getVersion(fileName);
- if (version == null) {
- // This is either the first time we've discovered this VDB, or
- // someone purged the PC's data dir.
- version = "1.0";
- packageVersions.putVersion(fileName, version);
- packageVersions.saveToDisk();
- }
-
- // Package name is the deployment's file name (e.g. foo.ear).
- PackageDetailsKey key = new PackageDetailsKey(fileName, version,
- PKG_TYPE_FILE, ARCHITECTURE);
- ResourcePackageDetails packageDetails = new ResourcePackageDetails(key);
- packageDetails.setFileName(fileName);
- packageDetails.setLocation(this.deploymentFile.getPath());
- if (!this.deploymentFile.isDirectory())
- packageDetails.setFileSize(this.deploymentFile.length());
- packageDetails.setFileCreatedDate(null); // TODO: get created date via
- // SIGAR
- Set<ResourcePackageDetails> packages = new HashSet<ResourcePackageDetails>();
- packages.add(packageDetails);
-
- return packages;
+ return null;
}
- @Override
public List<DeployPackageStep> generateInstallationSteps(
ResourcePackageDetails arg0) {
return null;
}
public RemovePackagesResponse removePackages(
- Set<ResourcePackageDetails> packages) {
- throw new UnsupportedOperationException(
- "Cannot remove the package backing an VDB resource.");
+ Set<ResourcePackageDetails> arg0) {
+ return null;
}
- @Override
public InputStream retrievePackageBits(ResourcePackageDetails packageDetails) {
- File packageFile = new File(packageDetails.getName());
- File fileToSend;
- try {
- if (packageFile.isDirectory()) {
- fileToSend = File.createTempFile("rhq", ".zip");
- ZipUtil.zipFileOrDirectory(packageFile, fileToSend);
- } else
- fileToSend = packageFile;
- return new BufferedInputStream(new FileInputStream(fileToSend));
- } catch (IOException e) {
- throw new RuntimeException("Failed to retrieve package bits for "
- + packageDetails, e);
- }
+ return null;
}
- /**
- * Returns an instantiated and loaded versions store access point.
- *
- * @return will not be <code>null</code>
- */
- private PackageVersions loadPackageVersions() {
- if (this.versions == null) {
- ResourceType resourceType = this.resourceContext.getResourceType();
- String pluginName = resourceType.getPlugin();
- File dataDirectoryFile = this.resourceContext.getDataDirectory();
- dataDirectoryFile.mkdirs();
- String dataDirectory = dataDirectoryFile.getAbsolutePath();
- log.trace("Creating application versions store with plugin name ["
- + pluginName + "] and data directory [" + dataDirectory
- + "]");
- this.versions = new PackageVersions(pluginName, dataDirectory);
- this.versions.loadFromDisk();
- }
-
- return this.versions;
- }
-
- /**
- * Creates the necessary transfer objects to report a failed application
- * deployment (update).
- *
- * @param errorMessage
- * reason the deploy failed
- * @param packageDetails
- * describes the update being made
- *
- * @return response populated to reflect a failure
- */
- private DeployPackagesResponse failApplicationDeployment(
- String errorMessage, ResourcePackageDetails packageDetails) {
- DeployPackagesResponse response = new DeployPackagesResponse(
- ContentResponseResult.FAILURE);
-
- DeployIndividualPackageResponse packageResponse = new DeployIndividualPackageResponse(
- packageDetails.getKey(), ContentResponseResult.FAILURE);
- packageResponse.setErrorMessage(errorMessage);
-
- response.addPackageResponse(packageResponse);
-
- return response;
- }
-
- private File writeNewAppBitsToTempFile(ContentServices contentServices,
- ResourcePackageDetails packageDetails) throws Exception {
- File tempDir = resourceContext.getTemporaryDirectory();
- File tempFile = new File(tempDir, this.deploymentFile.getName());
-
- OutputStream tempOutputStream = null;
- try {
- tempOutputStream = new BufferedOutputStream(new FileOutputStream(
- tempFile));
- long bytesWritten = contentServices.downloadPackageBits(
- resourceContext.getContentContext(), packageDetails
- .getKey(), tempOutputStream, true);
- log
- .debug("Wrote " + bytesWritten + " bytes to '" + tempFile
- + "'.");
- } catch (IOException e) {
- log.error(
- "Error writing updated application bits to temporary location: "
- + tempFile, e);
- throw e;
- } finally {
- if (tempOutputStream != null) {
- try {
- tempOutputStream.close();
- } catch (IOException e) {
- log.error("Error closing temporary output stream", e);
- }
- }
- }
- if (!tempFile.exists()) {
- log.error("Temporary file for application update not written to: "
- + tempFile);
- throw new Exception();
- }
- return tempFile;
- }
-
- private void persistApplicationVersion(
- ResourcePackageDetails packageDetails, File appFile) {
- String packageName = appFile.getName();
- PackageVersions versions = loadApplicationVersions();
- versions.putVersion(packageName, packageDetails.getVersion());
- }
-
- private void deleteBackupOfOriginalFile(File backupOfOriginalFile) {
- try {
- FileUtils.forceDelete(backupOfOriginalFile);
- } catch (Exception e) {
- // not critical.
- log.warn("Failed to delete backup of original file: "
- + backupOfOriginalFile);
- }
- }
-
- /**
- * Returns an instantiated and loaded versions store access point.
- *
- * @return will not be <code>null</code>
- */
- private PackageVersions loadApplicationVersions() {
- if (versions == null) {
- ResourceType resourceType = resourceContext.getResourceType();
- String pluginName = resourceType.getPlugin();
-
- File dataDirectoryFile = resourceContext.getDataDirectory();
-
- if (!dataDirectoryFile.exists()) {
- dataDirectoryFile.mkdir();
- }
-
- String dataDirectory = dataDirectoryFile.getAbsolutePath();
-
- log.debug("Creating application versions store with plugin name ["
- + pluginName + "] and data directory [" + dataDirectory
- + "]");
-
- versions = new PackageVersions(pluginName, dataDirectory);
- versions.loadFromDisk();
- }
-
- return versions;
- }
-
- @Override
public CreateResourceReport createResource(CreateResourceReport createResourceReport) {
ResourcePackageDetails details = createResourceReport
.getPackageDetails();
@@ -736,15 +355,10 @@
return createResourceReport;
}
- Configuration deployTimeConfig = details
- .getDeploymentTimeConfiguration();
- @SuppressWarnings( { "ConstantConditions" })
- // boolean deployExploded = deployTimeConfig.getSimple(
- // "deployExploded").getBooleanValue();
-
DeploymentManager deploymentManager = ProfileServiceUtil.getDeploymentManager();
DeploymentUtils.deployArchive(deploymentManager, archiveFile, false);
+ deploymentName = archivePath;
createResourceReport.setResourceName(archivePath);
createResourceReport.setResourceKey(archivePath);
createResourceReport.setStatus(CreateResourceStatus.SUCCESS);
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/NodeChildrenDiscoveryComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/NodeChildrenDiscoveryComponent.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/NodeChildrenDiscoveryComponent.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -1,122 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.plugin;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.teiid.rhq.comm.Component;
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionException;
-
-
-/**
- * Discovery component used to discover the monitored connector bindings
- *
- */
-public abstract class NodeChildrenDiscoveryComponent extends NodeDiscoveryComponent {
-
-
- private final Log LOG = LogFactory.getLog(NodeChildrenDiscoveryComponent.class);
-
- /**
- * @see ResourceDiscoveryComponent#discoverResources(ResourceDiscoveryContext)
- */
-
- @Override
- protected void addResources(Set<DiscoveredResourceDetails> found, ResourceType resourceType, Facet parent)
- throws InvalidPluginConfigurationException {
- Connection conn = null;
- try {
- conn = getConnection();
- if (!conn.isValid()) {
- return;
- }
- Collection<Component> components = getComponents(conn, parent);
-
- if (components == null || components.size() == 0) {
- LOG.info("No components were found to be configured for parent "+ parent.getComponentIdentifier()); //$NON-NLS-1$
- return;
- }
-
- Iterator<Component> comIter = components.iterator();
-
- while (comIter.hasNext()) {
- Component comp = comIter.next();
- LOG.info("Processing component "+ comp.getName()); //$NON-NLS-1$
-
- DiscoveredResourceDetails resource = this.createResource(resourceType, comp);
-
- found.add(resource);
- }
- } catch (InvalidPluginConfigurationException ipe) {
- throw ipe;
- } catch (Throwable t) {
- throw new InvalidPluginConfigurationException(t);
-
- } finally {
- if (conn != null) {
- conn.close();
- }
- }
-
-
- }
-
- protected DiscoveredResourceDetails createResource(ResourceType resourceType, Component component)
- throws InvalidPluginConfigurationException {
-
- DiscoveredResourceDetails resource = createResource(resourceType,
- systemkey + "|" + component.getIdentifier(),
- component.getName(),
- (component.getDescription()!=null?component.getDescription():""));
-
-
- Configuration configuration = resource.getPluginConfiguration();
- configuration.put(new PropertySimple(Component.NAME, component.getName()));
- configuration.put(new PropertySimple(Component.IDENTIFIER, component.getIdentifier()));
- configuration.put(new PropertySimple(Component.SYSTEM_KEY, systemkey));
-
- addAdditionalProperties(configuration, component);
-
- return resource;
-
- }
-
- protected void addAdditionalProperties(Configuration configuration, Component component) throws InvalidPluginConfigurationException {
-
- }
-
- abstract Collection<Component> getComponents(Connection conn, Facet parent) throws ConnectionException;
-
-
-}
\ No newline at end of file
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/NodeDiscoveryComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/NodeDiscoveryComponent.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/NodeDiscoveryComponent.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -1,131 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.plugin;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.teiid.rhq.admin.utils.SingletonConnectionManager;
-import org.teiid.rhq.comm.Component;
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionConstants;
-
-
-/**
- * Discovery component used to discover the monitored services
- *
- */
-public class NodeDiscoveryComponent implements
- ResourceDiscoveryComponent {
- private static final Log LOG = LogFactory
- .getLog(NodeDiscoveryComponent.class);
-
- private static SingletonConnectionManager connMgr = SingletonConnectionManager.getInstance();
-
- protected String systemkey = null;
-
-
- public Set<DiscoveredResourceDetails> discoverResources(
- ResourceDiscoveryContext discoveryContext) throws InvalidPluginConfigurationException, Exception {
-
-
- String name = discoveryContext.getResourceType().getName();
-
- LOG.info("Discovering " + name); //$NON-NLS-1$
-
- // if no servers have been defined, do not discover resources
- if (!connMgr.hasServersDefined()) {
- LOG.info("Unable to discover " + name + ", no JBEDSP Platforms defined"); //$NON-NLS-1$
- return Collections.EMPTY_SET;
- }
-
- Facet parent = (Facet) discoveryContext.getParentResourceComponent();
-
- String parentName = parent.getComponentName();
- systemkey = parent.getSystemKey();
-
- LOG.info("Discovering JBEDSP " + name + " for " + (parentName!=null?parentName:"PARENTNAMENOTFOUND")); //$NON-NLS-1$ //$NON-NLS-2$
-
- Set<DiscoveredResourceDetails> found = new HashSet<DiscoveredResourceDetails>();
-
- addResources(found, discoveryContext.getResourceType(), parent);
-
- return found;
- }
-
- protected void addResources(Set<DiscoveredResourceDetails> found, ResourceType resourceType, Facet parent)
- throws InvalidPluginConfigurationException {
- String identifier = parent.getComponentIdentifier()+ "|" + resourceType.getName();
- DiscoveredResourceDetails resource = createResource(resourceType, identifier, resourceType.getName(), resourceType.getDescription());
-
- found.add(resource);
-
- }
-
- protected DiscoveredResourceDetails createResource(ResourceType resourceType, String identifier, String name, String description)
- throws InvalidPluginConfigurationException {
-
- DiscoveredResourceDetails resource = new DiscoveredResourceDetails(resourceType,
- identifier, name,
- ConnectionConstants.VERSION,
- (description!=null?description:""),
- null,
- null);
-
- Configuration configuration = resource.getPluginConfiguration();
- configuration.put(new PropertySimple(Component.NAME, name));
- configuration.put(new PropertySimple(Component.IDENTIFIER, identifier));
- configuration.put(new PropertySimple(Component.SYSTEM_KEY, systemkey));
-
- addAdditionalProperties(configuration);
-
- return resource;
-
- }
-
-
-
- protected void addAdditionalProperties(Configuration configuration) throws InvalidPluginConfigurationException {
-
- }
-
- protected Connection getConnection() throws InvalidPluginConfigurationException{
- try {
- return connMgr.getConnection(this.systemkey);
-
- } catch (Throwable t) {
- throw new InvalidPluginConfigurationException(t);
-
- }
- }
-
-}
\ No newline at end of file
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -21,7 +21,6 @@
*/
package org.teiid.rhq.plugin;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
@@ -31,80 +30,131 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.managed.api.ComponentType;
import org.jboss.managed.api.ManagedComponent;
import org.jboss.managed.api.RunState;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.MeasurementDataNumeric;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
-import org.teiid.rhq.admin.utils.SingletonConnectionManager;
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionConstants;
-//import org.teiid.rhq.comm.ConnectionConstants;
-//import org.teiid.rhq.comm.Connection;
-//import org.teiid.rhq.comm.ConnectionConstants;
-//import org.teiid.rhq.comm.ConnectionConstants.ComponentType.Runtime.System.Metrics;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
-import org.teiid.rhq.plugin.util.PluginConstants.Operation;
-import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Runtime.Metrics;
+import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform;
-
/**
*
*/
-public class PlatformComponent extends Facet {
+public class PlatformComponent extends Facet implements PluginConstants {
private final Log LOG = LogFactory.getLog(PlatformComponent.class);
+
/**
* @see org.teiid.rhq.plugin.Facet#getComponentType()
* @since 4.3
*/
@Override
String getComponentType() {
- return null;
+ return PluginConstants.ComponentType.Platform.NAME;
}
-
+
@Override
public AvailabilityType getAvailability() {
RunState runState = null;
ManagedComponent mc;
try {
- mc = ProfileServiceUtil.getManagedComponent(
- new ComponentType(PluginConstants.ComponentType.Runtime.TYPE,
- PluginConstants.ComponentType.Runtime.SUBTYPE),
- PluginConstants.ComponentType.Runtime.TEIID_RUNTIME_ENGINE);
+ mc = ProfileServiceUtil.getManagedComponent(new org.jboss.managed.api.ComponentType(
+ ComponentType.Platform.TYPE,
+ ComponentType.Platform.SUBTYPE),
+ ComponentType.Platform.TEIID_RUNTIME_ENGINE);
runState = mc.getRunState();
} catch (NamingException e) {
- LOG.error("Naming exception getting: " + PluginConstants.ComponentType.Runtime.TEIID_RUNTIME_ENGINE);
- return AvailabilityType.DOWN;
+ LOG
+ .error("Naming exception getting: "
+ + PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE);
+ return AvailabilityType.DOWN;
} catch (Exception e) {
- LOG.error("Exception getting: " + PluginConstants.ComponentType.Runtime.TEIID_RUNTIME_ENGINE);
+ LOG
+ .error("Exception getting: "
+ + PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE);
return AvailabilityType.DOWN;
}
-
- return (runState == RunState.RUNNING) ? AvailabilityType.UP : AvailabilityType.DOWN;
-
+
+ return (runState == RunState.RUNNING) ? AvailabilityType.UP
+ : AvailabilityType.DOWN;
+
}
-
- protected void setOperationArguments(String name, Configuration configuration,
- Map valueMap) {
-
- }
+ @Override
+ protected void setOperationArguments(String name,
+ Configuration configuration, Map<String, Object> valueMap) {
+ // Parameter logic for System Operations
+ if (name.equals(Platform.Operations.GET_QUERIES) ||
+ name.equals(Platform.Operations.GET_LONGRUNNINGQUERIES)) {
+ Integer long_running_value = getResourceConfiguration().getSimple(Operation.Value.LONG_RUNNING_QUERY_LIMIT).getIntegerValue();
+ valueMap.put(Operation.Value.LONG_RUNNING_QUERY_LIMIT, long_running_value);
+ } else if (name.equals(Platform.Operations.KILL_REQUEST)) {
+ String key = Operation.Value.REQUEST_ID;
+ valueMap.put(key, configuration.getSimple(key).getStringValue());
+ }
+// else if (name.equals(ConnectionConstants.ComponentType.Operation.GET_PROPERTIES) ) {
+// String key = ConnectionConstants.IDENTIFIER;
+// valueMap.put(key, getComponentIdentifier());
+// }
+ }
@Override
public void getValues(MeasurementReport report,
Set<MeasurementScheduleRequest> requests) throws Exception {
+
+// DQPManagementView view = new DQPManagementView();
+//
+// Map<String, Object> valueMap = new HashMap<String, Object>();
+//
+// for (MeasurementScheduleRequest request : requests) {
+// String name = request.getName();
+// LOG.debug("Measurement name = " + name); //$NON-NLS-1$
+//
+// // Initialize any parameters to be used in the retrieval of metric
+// // values
+// if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
+// Integer value = getResourceConfiguration()
+// .getSimple(
+// PluginConstants.Operation.Value.LONG_RUNNING_QUERY_LIMIT)
+// .getIntegerValue();
+// valueMap.put(PluginConstants.Operation.Value.LONG_RUNNING_QUERY_LIMIT, value);
+// }
+//
+// Object metricReturnObject = view.getMetric(getComponentType(), this
+// .getComponentIdentifier(), name, valueMap);
+//
+// try {
+// if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
+// report.addData(new MeasurementDataNumeric(request,
+// (Double) metricReturnObject));
+// } else {
+// if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
+// report.addData(new MeasurementDataNumeric(request,
+// (Double) metricReturnObject));
+// } else {
+// if (request.getName().equals(
+// PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
+// report.addData(new MeasurementDataNumeric(request,
+// (Double) metricReturnObject));
+// }
+// }
+// }
+//
+// } catch (Exception e) {
+// LOG.error("Failed to obtain measurement [" + name //$NON-NLS-1$
+// + "]. Cause: " + e); //$NON-NLS-1$
+// // throw(e);
+// }
+// }
+
}
-
-
-
+
@Override
public void stop() {
// TODO Auto-generated method stub
@@ -113,19 +163,20 @@
@Override
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
-
+
Properties props = System.getProperties();
-
- Iterator<PropertySimple> pluginPropIter = report.getConfiguration().getSimpleProperties().values().iterator();
-
- while (pluginPropIter.hasNext()){
+
+ Iterator<PropertySimple> pluginPropIter = report.getConfiguration()
+ .getSimpleProperties().values().iterator();
+
+ while (pluginPropIter.hasNext()) {
PropertySimple pluginProp = pluginPropIter.next();
props.put(pluginProp.getName(), pluginProp.getStringValue());
}
-
- SingletonConnectionManager.getInstance().initialize(props);
+
+ //SingletonConnectionManager.getInstance().initialize(props);
super.updateResourceConfiguration(report);
-
- }
+ }
+
}
\ No newline at end of file
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/PlatformDiscoveryComponent.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -58,9 +58,9 @@
Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
ManagedComponent mc = ProfileServiceUtil.getManagedComponent(
- new ComponentType(PluginConstants.ComponentType.Runtime.TYPE,
- PluginConstants.ComponentType.Runtime.SUBTYPE),
- PluginConstants.ComponentType.Runtime.TEIID_RUNTIME_ENGINE);
+ new ComponentType(PluginConstants.ComponentType.Platform.TYPE,
+ PluginConstants.ComponentType.Platform.SUBTYPE),
+ PluginConstants.ComponentType.Platform.TEIID_RUNTIME_ENGINE);
Configuration c = new Configuration();
String managerName = mc.getName();
@@ -74,9 +74,9 @@
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
discoveryContext.getResourceType(), // ResourceType
managerName, // Resource Key
- PluginConstants.ComponentType.Runtime.TEIID_ENGINE_RESOURCE_NAME, // Resource Name
+ PluginConstants.ComponentType.Platform.TEIID_ENGINE_RESOURCE_NAME, // Resource Name
null, // Version TODO can we get that from discovery ?
- PluginConstants.ComponentType.Runtime.TEIID_ENGINE_RESOURCE_DESCRIPTION, // Description
+ PluginConstants.ComponentType.Platform.TEIID_ENGINE_RESOURCE_DESCRIPTION, // Description
c, // Plugin Config
null // Process info from a process scan
);
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBComponent.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -32,6 +32,7 @@
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.teiid.rhq.comm.ConnectionConstants;
+import org.teiid.rhq.plugin.util.PluginConstants;
/**
@@ -42,6 +43,15 @@
private final Log LOG = LogFactory
.getLog(VDBComponent.class);
+
+ /* (non-Javadoc)
+ * @see org.teiid.rhq.plugin.Facet#getComponentName()
+ */
+ @Override
+ public String getComponentName() {
+ return PluginConstants.ComponentType.VDB.NAME;
+ }
+
/**
* The plugin container will call this method when your resource component
* has been scheduled to collect some measurements now. It is within this
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/VDBDiscoveryComponent.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -67,22 +67,9 @@
for (ManagedComponent mcVdb : vdbs) {
+ String vdbKey = mcVdb.getDeployment().getName();
String vdbName = ((SimpleValueSupport) mcVdb.getProperty("name")
.getValue()).getValue().toString();
-// ManagementView managementView = ProfileServiceUtil
-// .getManagementView(ProfileServiceUtil.getProfileService(),
-// false);
- //ManagedDeployment managedDeployment = managementView.getDeploymentNamesForType(arg0)(vdbName);
- //Set deploymentNames = null;
-
-// try
-// {
-// deploymentNames = managementView.getDeploymentNames();
-// }
-// catch (Exception e)
-// {
-// log.error("Unable to get deployment for type " , e);
-// }
String vdbVersion = ((SimpleValueSupport) mcVdb.getProperty(
"version").getValue()).getValue().toString();
// TODO: Correct this after deploying proper VDB/Metadata
@@ -97,7 +84,7 @@
*/
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
discoveryContext.getResourceType(), // ResourceType
- vdbName, // Resource Key
+ vdbKey, // Resource Key
vdbName, // Resource Name
vdbVersion, // Version
PluginConstants.ComponentType.VDB.DESCRIPTION, // Description
Deleted: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/log/JBEDSPErrorLogEntryProcessor.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/log/JBEDSPErrorLogEntryProcessor.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/log/JBEDSPErrorLogEntryProcessor.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -1,96 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.plugin.log;
-
-import java.io.File;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.rhq.core.domain.event.EventSeverity;
-import org.rhq.core.pluginapi.event.log.MultiLineLogEntryProcessor;
-
-
-/**
- * @since 4.3
- */
-public class JBEDSPErrorLogEntryProcessor extends MultiLineLogEntryProcessor {
-
-
- /**
- * The regex for the primary log line: '['date']' '['severityLevel']' '['clientIP']' message
- * e.g.: [Wed Oct 11 14:32:52 2008] [error] [client 127.0.0.1] client denied by server configuration
- * NOTE: The message portion may contain multiple lines.
- */
- private static final String REGEX = "(.*) (.*) (INFO|WARNING|ERROR|DEBUG) (.*)"; //$NON-NLS-1$
- private static final Pattern PATTERN = Pattern.compile(REGEX);
-
- private static final String DATE_PATTERN = "MMM dd, yyyy kk:mm:ss.SSS"; // e.g.: Aug 26, 2008 13:10:11.371 //$NON-NLS-1$
- private static final DateFormat DATE_FORMAT = new SimpleDateFormat(DATE_PATTERN);
-
- private static final Map<SeverityLevel, EventSeverity> LEVEL_TO_SEVERITY_MAP = new LinkedHashMap();
- static {
- LEVEL_TO_SEVERITY_MAP.put(SeverityLevel.DEBUG, EventSeverity.DEBUG);
- LEVEL_TO_SEVERITY_MAP.put(SeverityLevel.INFO, EventSeverity.INFO);
- LEVEL_TO_SEVERITY_MAP.put(SeverityLevel.WARNING, EventSeverity.WARN);
- LEVEL_TO_SEVERITY_MAP.put(SeverityLevel.ERROR, EventSeverity.ERROR);
- }
-
- public JBEDSPErrorLogEntryProcessor(String eventType, File logFile) {
- super(eventType, logFile);
- }
-
- protected Pattern getPattern() {
- return PATTERN;
- }
-
- protected DateFormat getDefaultDateFormat() {
- return DATE_FORMAT;
- }
-
- protected LogEntry processPrimaryLine(Matcher matcher) throws ParseException {
- String dateString = matcher.group(1);
- Date timestamp = parseDateString(dateString);
- String severityLevelString = matcher.group(3);
- SeverityLevel severityLevel;
- try {
- severityLevel = SeverityLevel.valueOf(severityLevelString.toUpperCase());
- }
- catch (IllegalArgumentException e) {
- throw new ParseException("Unknown severity level: " + severityLevelString); //$NON-NLS-1$
- }
- EventSeverity severity = LEVEL_TO_SEVERITY_MAP.get(severityLevel);
- String detail = matcher.group(4);
- return new LogEntry(timestamp, severity, detail);
- }
-
- private enum SeverityLevel {
- DEBUG,
- INFO,
- WARNING,
- ERROR
- }
-}
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedOperationResultImpl.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -21,6 +21,7 @@
*/
package org.teiid.rhq.plugin.objects;
+import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -98,7 +99,7 @@
while (resultIter.hasNext()) {
Map reportRowMap = (Map) resultIter.next();
Iterator reportRowKeySetIter = reportRowMap.keySet().iterator();
- pm = new PropertyMap("userMap"); //$NON-NLS-1$
+ pm = new PropertyMap(MAPNAME); //$NON-NLS-1$
while (reportRowKeySetIter.hasNext()) {
String key = (String) reportRowKeySetIter.next();
@@ -110,7 +111,7 @@
operationResult.getComplexResults().put(list);
}
- public void setContent(List content) {
+ public void setContent(Collection content) {
this.content = content;
setComplexResult();
}
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedResourceConfigurationResultImpl.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedResourceConfigurationResultImpl.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/objects/ExecutedResourceConfigurationResultImpl.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -21,6 +21,7 @@
*/
package org.teiid.rhq.plugin.objects;
+import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -108,7 +109,7 @@
}
- public void setContent(List content) {
+ public void setContent(Collection content) {
this.content = content;
setComplexResult();
}
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/DeploymentUtils.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/DeploymentUtils.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/DeploymentUtils.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -76,7 +76,7 @@
DeploymentStatus distributeStatus;
Exception distributeFailure = null;
try {
- progress = deploymentManager.distribute(archiveFileName, contentURL, false);
+ progress = deploymentManager.distribute(archiveFileName, contentURL, true);
distributeStatus = run(progress);
if (distributeStatus.isFailed()) {
distributeFailure = (distributeStatus.getFailure() != null) ? distributeStatus.getFailure() :
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/PluginConstants.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -57,8 +57,9 @@
*/
public interface ComponentType {
- public interface Runtime {
+ public interface Platform {
+ public final static String NAME = "Platform"; //$NON-NLS-1$
public final static String TYPE = "ConnectionFactory"; //$NON-NLS-1$
public final static String SUBTYPE = "NoTx"; //$NON-NLS-1$
public final static String TEIID_RUNTIME_ENGINE = "teiid/runtime-engine"; //$NON-NLS-1$
@@ -68,9 +69,13 @@
public static interface Operations {
- public final static String BOUNCE_SYSTEM = "bounceSystem"; //$NON-NLS-1$
+ public final static String GET_QUERIES = "listQueries"; //$NON-NLS-1$
public final static String GET_LONGRUNNINGQUERIES = "listLongRunningQueries"; //$NON-NLS-1$
-
+ public final static String KILL_REQUEST = "killRequest"; //$NON-NLS-1$
+ public final static String GET_PROPERTIES = "getProperties"; //$NON-NLS-1$
+ public final static String GET_REQUESTS = "getRequests"; //$NON-NLS-1$
+ public final static String GET_SESSIONS = "getActiveSessions"; //$NON-NLS-1$
+
}
public static interface Metrics {
@@ -154,10 +159,6 @@
}
- public interface Security {
-
- }
-
/**
* Use these metric names when calling getValues() on the connection
* interface.
@@ -178,9 +179,10 @@
public static interface Operation {
public final static String KILL_REQUEST = "killRequest"; //$NON-NLS-1$
public final static String GET_VDBS = "listVDBs"; //$NON-NLS-1$
-
public final static String GET_PROPERTIES = "getProperties"; //$NON-NLS-1$
-
+ public final static String GET_REQUESTS = "getRequests"; //$NON-NLS-1$
+ public final static String GET_SESSIONS = "getActiveSessions"; //$NON-NLS-1$
+
/**
* Use these value names when calling executeOperation() on the
* connection interface. These will correlate with parameters used in
Modified: branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java
===================================================================
--- branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java 2010-02-19 20:19:45 UTC (rev 1858)
+++ branches/JCA/console/src/main/java/org/teiid/rhq/plugin/util/ProfileServiceUtil.java 2010-02-19 20:41:28 UTC (rev 1859)
@@ -21,7 +21,10 @@
public class ProfileServiceUtil {
protected final Log LOG = LogFactory.getLog(ProfileServiceUtil.class);
+ private static ComponentType DQPTYPE = new ComponentType("teiid", "dqp");
+ private static String DQPNAME = "org.teiid.dqp.internal.process.DQPManagementView";
+
/**
* Get the passed in {@link ManagedComponent}
*
@@ -131,5 +134,10 @@
File deployDir = warFile.getParentFile();
return deployDir;
}
+
+ public static ManagedComponent getDQPManagementView() throws NamingException, Exception {
+
+ return getManagedComponent(DQPTYPE, DQPNAME);
+ }
}
14 years, 10 months
teiid SVN: r1858 - trunk/console/src/test/java/org/teiid/rhq/comm/impl.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2010-02-19 15:19:45 -0500 (Fri, 19 Feb 2010)
New Revision: 1858
Removed:
trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeConnection.java
trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeConnectionFactory.java
trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeInvalidConnectionFactory.java
Log:
More build fix
Deleted: trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeConnection.java
===================================================================
--- trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeConnection.java 2010-02-19 20:14:12 UTC (rev 1857)
+++ trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeConnection.java 2010-02-19 20:19:45 UTC (rev 1858)
@@ -1,243 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.comm.impl;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.teiid.rhq.comm.Component;
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionException;
-import org.teiid.rhq.comm.ConnectionPool;
-import org.teiid.rhq.comm.ExecutedResult;
-
-
-/**
- * @since 6.2
- */
-public class FakeConnection implements Connection{
-
- public static int NUM_CONNECTORS = 3;
- public static int NUM_VMS = 2;
- public static int NUM_HOSTS = 1;
-
- private static final String HOST_ID = "Host_id_1"; //$NON-NLS-1$
-
- private String installDir = null;
- private ConnectionPool pool;
- private Properties envProps = null;
-
- public FakeConnection(ConnectionPool pool, Properties env) {
- this.pool = pool;
- this.envProps = env;
-
- }
-
-
-
- @Override
- public Collection<Component> discoverComponents(String componentType,
- String identifier) throws ConnectionException {
- // TODO Auto-generated method stub
- return null;
- }
-
-
-
- @Override
- public void executeOperation(ExecutedResult result, Map valueMap)
- throws ConnectionException {
- // TODO Auto-generated method stub
-
- }
-
-
-
- @Override
- public String getKey() throws Exception {
- // TODO Auto-generated method stub
- return "fakekey";
- }
-
-
-
- @Override
- public Object getMetric(String componentType, String identifier,
- String metric, Map valueMap) throws ConnectionException {
- // TODO Auto-generated method stub
- return null;
- }
-
-
-
- /**
- * @see com.metamatrix.rhq.comm.Connection#isValid()
- * @since 6.2
- */
- public boolean isValid() {
- return true;
- }
-
- /**
- * @throws Exception
- * @see com.metamatrix.rhq.comm.Connection#close()
- * @since 6.2
- */
- public void close() {
- try {
- pool.close(this);
- } catch (Exception err) {
- throw new RuntimeException(err);
-
- }
- }
-
-
- /**
- * @see com.metamatrix.rhq.comm.Connection#getConnectors(java.lang.String)
- * @since 6.2
- */
- public Collection<Component> getConnectors(String vmname) throws ConnectionException {
- Collection<Component> vms = getVMs();
- Collection<Component> cs = new ArrayList(5);
- for (Iterator vmIt=vms.iterator(); vmIt.hasNext();) {
- Component vm = (Component) vmIt.next();
- for (int i = 0; i < NUM_VMS; i++) {
- ComponentImpl c = new ComponentImpl();
- c.setSystemKey(this.installDir);
- c.setIdentifier(vm.getIdentifier() + "|VM_id_" + i); //$NON-NLS-1$
- c.setName("VM_id_" + i); //$NON-NLS-1$
- cs.add(c);
- }
- }
-
- return cs;
- }
-
- /**
- * @see com.metamatrix.rhq.comm.Connection#getEnvironment()
- * @since 6.2
- */
- public Properties getEnvironment() throws Exception {
- return this.envProps;
- }
-
- /**
- * @see com.metamatrix.rhq.comm.Connection#getHost()
- * @since 6.2
- */
- public Component getHost() throws ConnectionException {
- ComponentImpl c = new ComponentImpl();
- c.setSystemKey(this.installDir);
- c.setIdentifier(HOST_ID);
- c.setName(HOST_ID );
- c.setPort("1"); //$NON-NLS-1$
- return c;
- }
-
- /**
- * @see com.metamatrix.rhq.comm.Connection#getInstallationDirectory()
- * @since 6.2
- */
- public String getInstallationDirectory() throws Exception {
- return installDir;
- }
-
- /**
- * @see com.metamatrix.rhq.comm.Connection#getMetric(java.lang.String, java.lang.String, java.util.Map)
- * @since 6.2
- */
- public Object getMetric(String componentType,
- String metric,
- Map valueMap) throws ConnectionException {
- return null;
- }
-
-
-
- /**
- * @see com.metamatrix.rhq.comm.Connection#getProperties(java.lang.String, java.lang.String)
- * @since 6.2
- */
- public Properties getProperties(String resourceType,
- String identifier) throws ConnectionException {
- return null;
- }
-
- /**
- * @see com.metamatrix.rhq.comm.Connection#getProperty(java.lang.String, java.lang.String)
- * @since 6.2
- */
- public String getProperty(String identifier,
- String property) throws ConnectionException {
- return this.envProps.getProperty(property);
- }
-
- /**
- * @see com.metamatrix.rhq.comm.Connection#getVMs()
- * @since 6.2
- */
- public Collection<Component> getVMs() throws ConnectionException {
-
-
- Component host = getHost();
- Collection cs = new ArrayList(5);
- for (int i = 0; i < NUM_VMS; i++) {
- ComponentImpl c = new ComponentImpl();
- c.setSystemKey(this.installDir);
- c.setIdentifier(host.getIdentifier() + "|VM_id_" + i); //$NON-NLS-1$
- c.setName("VM_id_" + i); //$NON-NLS-1$
- c.setPort(String.valueOf(i));
- cs.add(c);
- }
-
- return cs;
-
- }
-
- public Collection<Component> getVDBs(List fieldNameList) throws ConnectionException {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @see com.metamatrix.rhq.comm.Connection#isAlive()
- * @since 6.2
- */
- public boolean isAlive() {
- return true;
- }
-
- /**
- * @see com.metamatrix.rhq.comm.Connection#isAvailable(java.lang.String, java.lang.String)
- * @since 6.2
- */
- public Boolean isAvailable(String componentType,
- String identifier) throws ConnectionException {
- return true;
- }
-
-}
Deleted: trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeConnectionFactory.java
===================================================================
--- trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeConnectionFactory.java 2010-02-19 20:14:12 UTC (rev 1857)
+++ trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeConnectionFactory.java 2010-02-19 20:19:45 UTC (rev 1858)
@@ -1,80 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.comm.impl;
-
-
-import java.util.Properties;
-
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionException;
-import org.teiid.rhq.comm.ConnectionFactory;
-import org.teiid.rhq.comm.ConnectionPool;
-
-
-
-
-public class FakeConnectionFactory implements
- ConnectionFactory {
-
- static boolean createdfactory = false;
- private static Properties connEnv;
- private ConnectionPool pool;
-
- public Connection createConnection(){
-
- return new FakeConnection(pool, connEnv);
-
- }
-
-
-
-
- @Override
- public String getURL() {
- // TODO Auto-generated method stub
- return null;
- }
-
-
-
-
- @Override
- public void initialize(Properties env, ConnectionPool connectionPool)
- throws ConnectionException {
- connEnv = env;
- this.pool = connectionPool;
- createdfactory = true;
-
- }
-
-
- public void closeConnection(Connection connection) {
-
- }
-
-
- public String getProperty(String key) {
- return connEnv.getProperty(key);
- }
-
-
-}
Deleted: trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeInvalidConnectionFactory.java
===================================================================
--- trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeInvalidConnectionFactory.java 2010-02-19 20:14:12 UTC (rev 1857)
+++ trunk/console/src/test/java/org/teiid/rhq/comm/impl/FakeInvalidConnectionFactory.java 2010-02-19 20:19:45 UTC (rev 1858)
@@ -1,81 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.comm.impl;
-
-
-import java.util.Properties;
-
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionException;
-import org.teiid.rhq.comm.ConnectionFactory;
-import org.teiid.rhq.comm.ConnectionPool;
-
-
-
-public class FakeInvalidConnectionFactory implements
- ConnectionFactory {
-
- static boolean createdfactory = false;
- private static Properties connEnv;
- private ConnectionPool pool;
-
- public Connection createConnection(){
-
- Connection result = new InvalidConnectionImpl("INVALIDKEY", connEnv, pool);
-
-
- return result;
- }
-
-
-
-
- @Override
- public String getURL() {
- // TODO Auto-generated method stub
- return null;
- }
-
-
-
-
- @Override
- public void initialize(Properties env, ConnectionPool connectionPool)
- throws ConnectionException {
- connEnv = env;
- this.pool = connectionPool;
- createdfactory = true;
-
- }
-
-
- public void closeConnection(Connection connection) {
-
- }
-
-
- public String getProperty(String key) {
- return connEnv.getProperty(key);
- }
-
-
-}
14 years, 10 months
teiid SVN: r1857 - trunk/test-integration/db/src/main/resources/ctc_tests.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2010-02-19 15:14:12 -0500 (Fri, 19 Feb 2010)
New Revision: 1857
Modified:
trunk/test-integration/db/src/main/resources/ctc_tests/ctc.xml
Log:
Teiid-773 - Per Warrens request, the error file generated using the xml file option will use the same logic to write an error file that the text file option uses.
Modified: trunk/test-integration/db/src/main/resources/ctc_tests/ctc.xml
===================================================================
--- trunk/test-integration/db/src/main/resources/ctc_tests/ctc.xml 2010-02-19 19:18:45 UTC (rev 1856)
+++ trunk/test-integration/db/src/main/resources/ctc_tests/ctc.xml 2010-02-19 20:14:12 UTC (rev 1857)
@@ -234,6 +234,9 @@
<fileset dir="${root_output}/${queryset.dir}/output/${scenario.name}">
<include name="ERROR*"/>
</fileset>
+ <fileset dir="${root_output}/${queryset.dir}/output/${scenario.name}">
+ <include name="*.err"/>
+ </fileset>
</path>
<condition property="error.files.exist">
14 years, 10 months
teiid SVN: r1856 - trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2010-02-19 14:18:45 -0500 (Fri, 19 Feb 2010)
New Revision: 1856
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java
Log:
Teiid-773 - Per Warrens request, the error file generated using the xml file option will use the same logic to write an error file that the text file option uses.
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java 2010-02-19 18:57:27 UTC (rev 1855)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java 2010-02-19 19:18:45 UTC (rev 1856)
@@ -214,11 +214,16 @@
// printResultSet(results));
// Convert results to ResultsHolder
+ actualResults = new ResultsHolder(TagNames.Elements.QUERY_RESULTS);
+ actualResults.setQueryID(expectedResults.getQueryID());
+
if (expectedResults.getRows().size() > 0) {
- actualResults = new ResultsHolder(TagNames.Elements.QUERY_RESULTS);
- actualResults.setQueryID(expectedResults.getQueryID());
- convertResults(resultSet, batchSize, actualResults);
+ convertResults(resultSet, batchSize, actualResults);
compareResults(actualResults, expectedResults, eMsg, isOrdered);
+ } else if (actualResults.getRows() != null && actualResults.getRows().size() > 0) {
+ throw new QueryTestFailedException(eMsg + "Expected results indicated no results, but actual shows " + actualResults.getRows().size() + " rows."); //$NON-NLS-1$
+
+
}
// DEBUG:
@@ -344,7 +349,7 @@
sortRecords(expectedRows, true);
expectedResults.setRows(expectedRows);
}
-
+
compareResultSets(actualResults.getRows(),
actualResults.getTypes(),
actualResults.getIdentifiers(),
@@ -469,8 +474,8 @@
}
// DEBUG:
- // debugOut.println("================== Compariing Rows ===================");
-
+ // debugOut.println("================== Compariing Rows ===================");
+
// Loop through rows
for (int row = 0; row < actualRowCount; row++) {
@@ -491,7 +496,7 @@
final Object actualValue = actualRecord.get(col);
// Get expected value
final Object expectedValue = expectedRecord.get(col);
-
+
// DEBUG:
// debugOut.println(" Col: " +(col +1) + ": expectedValue:[" + expectedValue + "] actualValue:[" + actualValue +
// "]");
@@ -513,7 +518,8 @@
// DEBUG:
// debugOut.println(" ExpectedType: " + expectedValue.getClass() + " ActualType: " +
// actualValue.getClass());
- if (expectedValue instanceof String) {
+
+ if (expectedValue instanceof String) {
final String expectedString = (String)expectedValue;
if (actualValue instanceof Blob || actualValue instanceof Clob || actualValue instanceof SQLXML) {
// LOB types are special case - metadata says they're Object types so
@@ -536,6 +542,14 @@
// Check for String difference
assertStringsMatch(expectedString, (String)actualValue, (row + 1), (col + 1), eMsg);
}
+ } else {
+
+ throw new QueryTestFailedException(eMsg + "Value mismatch at row " + (row + 1) //$NON-NLS-1$
+ + " and column " + (col + 1) //$NON-NLS-1$
+ + ": expected = [" //$NON-NLS-1$
+ + expectedValue + "], actual = [" //$NON-NLS-1$
+ + actualValue + "]"); //$NON-NLS-1$
+
}
}
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java 2010-02-19 18:57:27 UTC (rev 1855)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java 2010-02-19 19:18:45 UTC (rev 1856)
@@ -251,7 +251,7 @@
resultSet.beforeFirst();
generateErrorResults(querySetID, queryID, sql, errorFile,
- resultSet, (results != null ? (List) results : null));
+ resultSet, (File) results);
} catch (Throwable e) {
throw new QueryTestFailedException(e.getMessage());
@@ -276,7 +276,7 @@
*/
private void generateErrorResults(String querySetID, String queryID,
String sql, File resultsFile, ResultSet actualResult,
- List<String> results)
+ File results)
throws QueryTestFailedException {
FileOutputStream actualOut = null;
@@ -379,7 +379,7 @@
// .currentTimeMillis())) + ".xml"; //$NON-NLS-1$
// return errorFileName;
- return queryID + ".txt";
+ return queryID + ".err";
}
/**
14 years, 10 months
teiid SVN: r1855 - in trunk/console/src: main/java/org/teiid/rhq/plugin and 2 other directories.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2010-02-19 13:57:27 -0500 (Fri, 19 Feb 2010)
New Revision: 1855
Removed:
trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
trunk/console/src/main/java/org/teiid/rhq/plugin/log/JBEDSPErrorLogEntryProcessor.java
trunk/console/src/test/java/org/teiid/rhq/comm/impl/TestConnectionPool.java
Modified:
trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java
trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
Log:
Fix build
Deleted: trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-02-19 17:46:45 UTC (rev 1854)
+++ trunk/console/src/main/java/org/teiid/rhq/admin/DQPManagementView.java 2010-02-19 18:57:27 UTC (rev 1855)
@@ -1,365 +0,0 @@
-package org.teiid.rhq.admin;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.naming.NamingException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.managed.api.ComponentType;
-import org.jboss.managed.api.ManagedComponent;
-import org.jboss.managed.api.ManagedOperation;
-import org.jboss.metatype.api.types.MetaType;
-import org.jboss.metatype.api.values.CollectionValueSupport;
-import org.jboss.metatype.api.values.MetaValue;
-import org.teiid.adminapi.impl.RequestMetadata;
-import org.teiid.adminapi.impl.RequestMetadataMapper;
-import org.teiid.adminapi.impl.SessionMetadata;
-import org.teiid.adminapi.impl.SessionMetadataMapper;
-import org.teiid.rhq.comm.ExecutedResult;
-import org.teiid.rhq.plugin.util.PluginConstants;
-import org.teiid.rhq.plugin.util.ProfileServiceUtil;
-import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform;
-import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform.Metrics;
-import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform.Operations;
-
-import com.metamatrix.core.MetaMatrixRuntimeException;
-
-public class DQPManagementView implements PluginConstants{
-
- private static ManagedComponent mc = null;
- private static final Log LOG = LogFactory.getLog(DQPManagementView.class);
-
- public DQPManagementView() {
-
- }
-
- /*
- * Metric methods
- */
- public Object getMetric(String componentType, String identifier,
- String metric, Map<String, Object> valueMap) {
- Object resultObject = new Object();
-
- if (componentType.equals(PluginConstants.ComponentType.Platform.NAME)) {
- resultObject = getPlatformMetric(componentType, metric, valueMap);
- } else if (componentType.equals(PluginConstants.ComponentType.VDB.NAME)) {
- resultObject = getVdbMetric(componentType, identifier, metric,
- valueMap);
- }
-
- return resultObject;
- }
-
- private Object getPlatformMetric(String componentType, String metric,
- Map valueMap) {
-
- Object resultObject = new Object();
-
- if (metric
- .equals(PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
- resultObject = new Double(getQueryCount().doubleValue());
- } else {
- if (metric
- .equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
- resultObject = new Double(getSessionCount().doubleValue());
- } else {
- if (metric
- .equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
- Integer longRunningQueryLimit = (Integer) valueMap
- .get(PluginConstants.Operation.Value.LONG_RUNNING_QUERY_LIMIT);
- Collection<RequestMetadata> longRunningQueries = getLongRunningQueries(
- longRunningQueryLimit);
- resultObject = new Double(longRunningQueries.size());
- }
- }
- }
-
- return resultObject;
- }
-
- private Object getVdbMetric(String componentType, String identifier,
- String metric, Map valueMap) {
-
- Object resultObject = new Object();
-
- // if (metric.equals(ComponentType.Metric.HIGH_WATER_MARK)) {
- // resultObject = new Double(getHighWatermark(identifier));
- // }
-
- return resultObject;
- }
-
- /*
- * Operation methods
- */
-
- public void executeOperation(ExecutedResult operationResult,
- final Map valueMap) {
-
- if (operationResult.getComponentType().equals(
- PluginConstants.ComponentType.Platform.NAME)) {
- executePlatformOperation(operationResult, operationResult
- .getOperationName(), valueMap);
- }
-
- // else if
- // (operationResult.getComponentType().equals(ConnectionConstants.ComponentType.Runtime.System.TYPE))
- // {
- // executeSystemOperation(operationResult,
- // operationResult.getOperationName(), valueMap);
- // } else if (operationResult.getComponentType().equals(
- // Runtime.Process.TYPE)) {
- // executeProcessOperation(operationResult,
- // operationResult.getOperationName(), valueMap);
- // } else if
- // (operationResult.getComponentType().equals(com.metamatrix.rhq.comm.ConnectionConstants.ComponentType.Runtime.Host.TYPE))
- // {
- // executeHostOperation(operationResult,
- // operationResult.getOperationName(), valueMap);
- // } else if
- // (operationResult.getComponentType().equals(com.metamatrix.rhq.comm.ConnectionConstants.ComponentType.Runtime.Session.TYPE))
- // {
- // executeSessionOperation(operationResult,
- // operationResult.getOperationName(), valueMap);
- // } else if
- // (operationResult.getComponentType().equals(com.metamatrix.rhq.comm.ConnectionConstants.ComponentType.Runtime.Queries.TYPE))
- // {
- // executeQueriesOperation(operationResult,
- // operationResult.getOperationName(), valueMap);
- // }
- }
-
- private void executePlatformOperation(ExecutedResult operationResult,
- final String operationName, final Map<String, Object> valueMap) {
- Collection<RequestMetadata> resultObject = new ArrayList<RequestMetadata>();
-
- if (operationName.equals(Platform.Operations.GET_LONGRUNNINGQUERIES)) {
- Integer longRunningValue = (Integer) valueMap
- .get(Operation.Value.LONG_RUNNING_QUERY_LIMIT);
- List<String> fieldNameList = operationResult.getFieldNameList();
- resultObject = getLongRunningQueries(longRunningValue);
- operationResult.setContent(createReportResultList(fieldNameList, resultObject.iterator()));
- }
-
-// else if (operationName.equals(ComponentType.Operation.KILL_REQUEST)) {
-// String requestID = (String) valueMap
-// .get(ConnectionConstants.ComponentType.Operation.Value.REQUEST_ID);
-// cancelRequest(requestID);
-// } else if (operationName.equals(ComponentType.Operation.GET_VDBS)) {
-// List fieldNameList = operationResult.getFieldNameList();
-// resultObject = getVDBs(fieldNameList);
-// operationResult.setContent((List) resultObject);
-// } else if (operationName.equals(ComponentType.Operation.GET_PROPERTIES)) {
-// String identifier = (String) valueMap
-// .get(ConnectionConstants.IDENTIFIER);
-// Properties props = getProperties(
-// ConnectionConstants.ComponentType.Runtime.System.TYPE,
-// identifier);
-// resultObject = createReportResultList(props);
-// operationResult.setContent((List) resultObject);
-// }
-
- }
-
- /*
- * Helper methods
- */
-
- protected MetaValue getRequests(List<String> fieldNameList) {
-
- MetaValue requestsCollection = null;
- MetaValue args = null;
-
- requestsCollection = executeManagedOperation(mc,
- PluginConstants.Operation.GET_REQUESTS, args);
-
- return requestsCollection;
-
- // if (fieldNameList != null) {
- // Collection reportResultCollection = createReportResultList(
- // fieldNameList, requestsCollection.iterator());
- // return reportResultCollection;
- // } else {
- // return requestsCollection;
- // }
- }
-
- public MetaValue getSessions(List<String> fieldNameList) {
-
- MetaValue sessionCollection = null;
- MetaValue args = null;
-
- sessionCollection = executeManagedOperation(mc,
- PluginConstants.Operation.GET_SESSIONS, args);
- return sessionCollection;
-
- // if (fieldNameList != null) {
- // Collection reportResultCollection = createReportResultList(
- // fieldNameList, requestsCollection.iterator());
- // return reportResultCollection;
- // } else {
- // return requestsCollection;
- // }
- }
-
- public static MetaValue executeManagedOperation(ManagedComponent mc,
- String operation, MetaValue... args) {
-
- try {
- mc = ProfileServiceUtil.getDQPManagementView();
- } catch (NamingException e) {
- LOG.error(e);
- } catch (Exception e1) {
- LOG.error(e1);
- }
-
- for (ManagedOperation mo : mc.getOperations()) {
- String opName = mo.getName();
- if (opName.equals(operation)) {
- try {
- if (args.length == 1 && args[0] == null) {
- return mo.invoke();
- } else {
- return mo.invoke(args);
- }
- } catch (Exception e) {
- final String msg = "Exception getting the AdminApi in " + operation; //$NON-NLS-1$
- LOG.error(msg, e);
- }
- }
- }
- throw new MetaMatrixRuntimeException(
- "No operation found with given name =" + operation);
-
- }
-
- private Integer getQueryCount() {
-
- Integer count = new Integer(0);
-
- MetaValue requests = null;
- Collection<RequestMetadata> requestsCollection = new ArrayList();
-
- requests = getRequests(null);
-
- getRequestCollectionValue(requests, requestsCollection);
-
- if (requestsCollection != null && !requestsCollection.isEmpty()) {
- count = requestsCollection.size();
- }
-
- return count;
- }
-
- private Integer getSessionCount() {
-
- Collection<SessionMetadata> activeSessionsCollection = new ArrayList<SessionMetadata>();
- MetaValue sessionMetaValue = getSessions(null);
- getSessionCollectionValue(sessionMetaValue, activeSessionsCollection);
- return activeSessionsCollection.size();
- }
-
- protected Collection<RequestMetadata> getLongRunningQueries(
- int longRunningValue) {
-
- MetaValue requestsCollection = null;
- Collection<RequestMetadata> list = new ArrayList<RequestMetadata>();
-
- double longRunningQueryTimeDouble = new Double(longRunningValue);
-
- requestsCollection = getRequests(null);
-
- getRequestCollectionValue(requestsCollection, list);
-
- Iterator<RequestMetadata> requestsIter = list.iterator();
- while (requestsIter.hasNext()) {
- RequestMetadata request = requestsIter.next();
- long startTime = request.getProcessingTime();
- // Get msec from each, and subtract.
- long runningTime = Calendar.getInstance().getTimeInMillis()
- - startTime;
-
- if (runningTime < longRunningQueryTimeDouble) {
- requestsIter.remove();
- }
- }
-
- return list;
- }
-
- public static <T> void getRequestCollectionValue(MetaValue pValue,
- Collection<RequestMetadata> list) {
- MetaType metaType = pValue.getMetaType();
- if (metaType.isCollection()) {
- for (MetaValue value : ((CollectionValueSupport) pValue)
- .getElements()) {
- if (value.getMetaType().isComposite()) {
- RequestMetadataMapper requestMapper = new RequestMetadataMapper();
- RequestMetadata requestMetaData = requestMapper
- .unwrapMetaValue(value);
- list.add(requestMetaData);
- } else {
- throw new IllegalStateException(pValue
- + " is not a Composite type");
- }
- }
- }
- }
-
- public static <T> void getSessionCollectionValue(MetaValue pValue,
- Collection<SessionMetadata> list) {
- MetaType metaType = pValue.getMetaType();
- if (metaType.isCollection()) {
- for (MetaValue value : ((CollectionValueSupport) pValue)
- .getElements()) {
- if (value.getMetaType().isComposite()) {
- SessionMetadataMapper sessionMapper = new SessionMetadataMapper();
- SessionMetadata sessionMetaData = sessionMapper
- .unwrapMetaValue(value);
- list.add(sessionMetaData);
- } else {
- throw new IllegalStateException(pValue
- + " is not a Composite type");
- }
- }
- }
- }
-
- private Collection createReportResultList(List fieldNameList, Iterator objectIter) {
- Collection reportResultList = new ArrayList();
-
- while (objectIter.hasNext()) {
- Object object = objectIter.next();
-
- Class cls = null;
- try {
- cls = object.getClass();
- Iterator methodIter = fieldNameList.iterator();
- Map reportValueMap = new HashMap<String, String>();
- while (methodIter.hasNext()) {
- String fieldName = (String) methodIter.next();
- String methodName = fieldName;
- Method meth = cls.getMethod(methodName, (Class[]) null);
- Object retObj = meth.invoke(object, (Object[]) null);
- reportValueMap.put(fieldName, retObj);
- }
- reportResultList.add(reportValueMap);
- } catch (Throwable e) {
- System.err.println(e);
- }
- }
- return reportResultList;
- }
-
-}
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-02-19 17:46:45 UTC (rev 1854)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/Facet.java 2010-02-19 18:57:27 UTC (rev 1855)
@@ -58,7 +58,6 @@
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
-import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.comm.ExecutedResult;
import org.teiid.rhq.plugin.objects.ExecutedOperationResultImpl;
import org.teiid.rhq.plugin.util.DeploymentUtils;
@@ -181,9 +180,9 @@
}
protected void execute(final ExecutedResult result, final Map valueMap) {
- DQPManagementView dqp = new DQPManagementView();
-
- dqp.executeOperation(result, valueMap);
+// DQPManagementView dqp = new DQPManagementView();
+//
+// dqp.executeOperation(result, valueMap);
}
@@ -289,7 +288,6 @@
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
}
- @Override
public void deleteResource() throws Exception {
DeploymentManager deploymentManager = ProfileServiceUtil.getDeploymentManager();
@@ -313,36 +311,31 @@
}
- @Override
+ //@Override
public DeployPackagesResponse deployPackages(
Set<ResourcePackageDetails> packages,
ContentServices contentServices) {
return null;
}
- @Override
public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType arg0) {
return null;
}
- @Override
public List<DeployPackageStep> generateInstallationSteps(
ResourcePackageDetails arg0) {
return null;
}
- @Override
public RemovePackagesResponse removePackages(
Set<ResourcePackageDetails> arg0) {
return null;
}
- @Override
public InputStream retrievePackageBits(ResourcePackageDetails packageDetails) {
return null;
}
- @Override
public CreateResourceReport createResource(CreateResourceReport createResourceReport) {
ResourcePackageDetails details = createResourceReport
.getPackageDetails();
Modified: trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-02-19 17:46:45 UTC (rev 1854)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/PlatformComponent.java 2010-02-19 18:57:27 UTC (rev 1855)
@@ -21,7 +21,6 @@
*/
package org.teiid.rhq.plugin;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
@@ -36,11 +35,9 @@
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.MeasurementDataNumeric;
import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
-import org.teiid.rhq.admin.DQPManagementView;
import org.teiid.rhq.plugin.util.PluginConstants;
import org.teiid.rhq.plugin.util.ProfileServiceUtil;
import org.teiid.rhq.plugin.util.PluginConstants.ComponentType.Platform;
@@ -111,51 +108,51 @@
public void getValues(MeasurementReport report,
Set<MeasurementScheduleRequest> requests) throws Exception {
- DQPManagementView view = new DQPManagementView();
+// DQPManagementView view = new DQPManagementView();
+//
+// Map<String, Object> valueMap = new HashMap<String, Object>();
+//
+// for (MeasurementScheduleRequest request : requests) {
+// String name = request.getName();
+// LOG.debug("Measurement name = " + name); //$NON-NLS-1$
+//
+// // Initialize any parameters to be used in the retrieval of metric
+// // values
+// if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
+// Integer value = getResourceConfiguration()
+// .getSimple(
+// PluginConstants.Operation.Value.LONG_RUNNING_QUERY_LIMIT)
+// .getIntegerValue();
+// valueMap.put(PluginConstants.Operation.Value.LONG_RUNNING_QUERY_LIMIT, value);
+// }
+//
+// Object metricReturnObject = view.getMetric(getComponentType(), this
+// .getComponentIdentifier(), name, valueMap);
+//
+// try {
+// if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
+// report.addData(new MeasurementDataNumeric(request,
+// (Double) metricReturnObject));
+// } else {
+// if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
+// report.addData(new MeasurementDataNumeric(request,
+// (Double) metricReturnObject));
+// } else {
+// if (request.getName().equals(
+// PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
+// report.addData(new MeasurementDataNumeric(request,
+// (Double) metricReturnObject));
+// }
+// }
+// }
+//
+// } catch (Exception e) {
+// LOG.error("Failed to obtain measurement [" + name //$NON-NLS-1$
+// + "]. Cause: " + e); //$NON-NLS-1$
+// // throw(e);
+// }
+// }
- Map<String, Object> valueMap = new HashMap<String, Object>();
-
- for (MeasurementScheduleRequest request : requests) {
- String name = request.getName();
- LOG.debug("Measurement name = " + name); //$NON-NLS-1$
-
- // Initialize any parameters to be used in the retrieval of metric
- // values
- if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
- Integer value = getResourceConfiguration()
- .getSimple(
- PluginConstants.Operation.Value.LONG_RUNNING_QUERY_LIMIT)
- .getIntegerValue();
- valueMap.put(PluginConstants.Operation.Value.LONG_RUNNING_QUERY_LIMIT, value);
- }
-
- Object metricReturnObject = view.getMetric(getComponentType(), this
- .getComponentIdentifier(), name, valueMap);
-
- try {
- if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.QUERY_COUNT)) {
- report.addData(new MeasurementDataNumeric(request,
- (Double) metricReturnObject));
- } else {
- if (request.getName().equals(PluginConstants.ComponentType.Platform.Metrics.SESSION_COUNT)) {
- report.addData(new MeasurementDataNumeric(request,
- (Double) metricReturnObject));
- } else {
- if (request.getName().equals(
- PluginConstants.ComponentType.Platform.Metrics.LONG_RUNNING_QUERIES)) {
- report.addData(new MeasurementDataNumeric(request,
- (Double) metricReturnObject));
- }
- }
- }
-
- } catch (Exception e) {
- LOG.error("Failed to obtain measurement [" + name //$NON-NLS-1$
- + "]. Cause: " + e); //$NON-NLS-1$
- // throw(e);
- }
- }
-
}
@Override
Deleted: trunk/console/src/main/java/org/teiid/rhq/plugin/log/JBEDSPErrorLogEntryProcessor.java
===================================================================
--- trunk/console/src/main/java/org/teiid/rhq/plugin/log/JBEDSPErrorLogEntryProcessor.java 2010-02-19 17:46:45 UTC (rev 1854)
+++ trunk/console/src/main/java/org/teiid/rhq/plugin/log/JBEDSPErrorLogEntryProcessor.java 2010-02-19 18:57:27 UTC (rev 1855)
@@ -1,96 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.plugin.log;
-
-import java.io.File;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.rhq.core.domain.event.EventSeverity;
-import org.rhq.core.pluginapi.event.log.MultiLineLogEntryProcessor;
-
-
-/**
- * @since 4.3
- */
-public class JBEDSPErrorLogEntryProcessor extends MultiLineLogEntryProcessor {
-
-
- /**
- * The regex for the primary log line: '['date']' '['severityLevel']' '['clientIP']' message
- * e.g.: [Wed Oct 11 14:32:52 2008] [error] [client 127.0.0.1] client denied by server configuration
- * NOTE: The message portion may contain multiple lines.
- */
- private static final String REGEX = "(.*) (.*) (INFO|WARNING|ERROR|DEBUG) (.*)"; //$NON-NLS-1$
- private static final Pattern PATTERN = Pattern.compile(REGEX);
-
- private static final String DATE_PATTERN = "MMM dd, yyyy kk:mm:ss.SSS"; // e.g.: Aug 26, 2008 13:10:11.371 //$NON-NLS-1$
- private static final DateFormat DATE_FORMAT = new SimpleDateFormat(DATE_PATTERN);
-
- private static final Map<SeverityLevel, EventSeverity> LEVEL_TO_SEVERITY_MAP = new LinkedHashMap();
- static {
- LEVEL_TO_SEVERITY_MAP.put(SeverityLevel.DEBUG, EventSeverity.DEBUG);
- LEVEL_TO_SEVERITY_MAP.put(SeverityLevel.INFO, EventSeverity.INFO);
- LEVEL_TO_SEVERITY_MAP.put(SeverityLevel.WARNING, EventSeverity.WARN);
- LEVEL_TO_SEVERITY_MAP.put(SeverityLevel.ERROR, EventSeverity.ERROR);
- }
-
- public JBEDSPErrorLogEntryProcessor(String eventType, File logFile) {
- super(eventType, logFile);
- }
-
- protected Pattern getPattern() {
- return PATTERN;
- }
-
- protected DateFormat getDefaultDateFormat() {
- return DATE_FORMAT;
- }
-
- protected LogEntry processPrimaryLine(Matcher matcher) throws ParseException {
- String dateString = matcher.group(1);
- Date timestamp = parseDateString(dateString);
- String severityLevelString = matcher.group(3);
- SeverityLevel severityLevel;
- try {
- severityLevel = SeverityLevel.valueOf(severityLevelString.toUpperCase());
- }
- catch (IllegalArgumentException e) {
- throw new ParseException("Unknown severity level: " + severityLevelString); //$NON-NLS-1$
- }
- EventSeverity severity = LEVEL_TO_SEVERITY_MAP.get(severityLevel);
- String detail = matcher.group(4);
- return new LogEntry(timestamp, severity, detail);
- }
-
- private enum SeverityLevel {
- DEBUG,
- INFO,
- WARNING,
- ERROR
- }
-}
Deleted: trunk/console/src/test/java/org/teiid/rhq/comm/impl/TestConnectionPool.java
===================================================================
--- trunk/console/src/test/java/org/teiid/rhq/comm/impl/TestConnectionPool.java 2010-02-19 17:46:45 UTC (rev 1854)
+++ trunk/console/src/test/java/org/teiid/rhq/comm/impl/TestConnectionPool.java 2010-02-19 18:57:27 UTC (rev 1855)
@@ -1,376 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.rhq.comm.impl;
-
-import java.util.Properties;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.teiid.rhq.comm.Connection;
-import org.teiid.rhq.comm.ConnectionConstants;
-import org.teiid.rhq.comm.ConnectionPool;
-//import org.teiid.rhq.embedded.pool.ConnectionPoolImpl;
-
-import org.teiid.rhq.enterprise.pool.ConnectionPoolImpl;
-
-
-
-
-/**
- * @since 4.3
- */
-public class TestConnectionPool extends TestCase {
- static {
- // System.setProperty(SingletonConnectionManager.INSTALL_SERVER_PROP,StartingEnvironmentConstants.SINGLE_SYSTEM_PARM);
-
- // reset the conn mager for the next test case class
-
- }
-
- private boolean failure = false;
- int count;
-
- /**
- * This suite of all tests could be defined in another class but it seems easier to
- * maintain it here.
- */
- public static Test suite() {
-
- TestSuite suite = new TestSuite("TestConnectionPool"); //$NON-NLS-1$
- suite.addTestSuite(TestConnectionPool.class);
- return suite;
- }
-
-
- // ################################## MAIN ################################
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- /**
- * @since 1.0
- */
-// public static void main(final String[] arguments) {
-// try {
-//
-// TestConnectionPool test = new TestConnectionPool();
-// test.runTest();
-//
-//
-// }catch (Exception e) {
-// e.printStackTrace();
-// }
-// }
-
-// public void runTest() throws Exception {
-// testSimple();
-// testSecond();
-// testThreading();
-// }
-
- public void testSimple() throws Exception {
- log("Start simpleTest...");
- failure = false;
-
- Properties props = new Properties();
- props.setProperty(ConnectionPool.CONNECTION_FACTORY, "org.teiid.rhq.comm.impl.FakeConnectionFactory");
-
- ConnectionPool pool = new ConnectionPoolImpl();
- pool.initialize(props, this.getClass().getClassLoader());
-
- if (!FakeConnectionFactory.createdfactory) {
- logError("Didn't use the fake factory");
- }
-
- Connection conn = pool.getConnection();
-
- int cnt = pool.getAvailableConnectionCount();
- if (cnt != 0) {
- logError("Available count should have been 0, but was " + cnt);
- }
-
-
- cnt = pool.getConnectionsInUseCount();
- if (cnt != 1) {
- logError("Connections in use should have been 1, but was " + cnt);
- }
-
- pool.close(conn);
-
- cnt = pool.getConnectionsInUseCount();
- if (cnt != 0) {
- logError("Connections in use should have been 0 after checkin, but was " + cnt);
- }
-
- cnt = pool.getAvailableConnectionCount();
- if (cnt != 1) {
- logError("Available count should have been 1 after checking, but was " + cnt);
- }
-
- pool.shutdown();
- log("Was simpleTest a success " + !failure );
- }
-
- public void testSecond() throws Exception {
- log("Start secondTest...");
- failure = false;
- Properties props = new Properties();
- props.setProperty(ConnectionPool.CONNECTION_FACTORY, "org.teiid.rhq.comm.impl.FakeConnectionFactory");
-
- ConnectionPool pool = new ConnectionPoolImpl();
- pool.initialize( props, this.getClass().getClassLoader());
-
- if (!FakeConnectionFactory.createdfactory) {
- logError("Didn't use the fake factory");
- }
-
- Connection conn = pool.getConnection();
- Connection conn2 = pool.getConnection();
- Connection conn3 = pool.getConnection();
-
- validateAvailCnt(pool, 0);
-
- validateInUseCnt(pool, 3);
-
-
- pool.close(conn);
-
- validateAvailCnt(pool, 1);
-
- validateInUseCnt(pool, 2);
-
-
- Connection conn4 = pool.getConnection();
- Connection conn5 = pool.getConnection();
-
- validateAvailCnt(pool, 0);
-
- validateInUseCnt(pool, 4);
-
- pool.close(conn5);
- pool.close(conn3);
- pool.close(conn2);
- pool.close(conn4);
-
- validateAvailCnt(pool, 4);
-
- validateInUseCnt(pool, 0);
-
- pool.shutdown();
- log("Was secondTest a success " + !failure );
- }
-
- private void validateInUseCnt(ConnectionPool pool, int cnt) {
-
-// int incnt = pool.getConnectionsInUseCount();
-// if (incnt != cnt) {
-// logError("Connections in use should have been " + cnt + " , but was " + incnt);
-// }
- }
-
- private void validateAvailCnt(ConnectionPool pool, int cnt) {
-
-// int incnt = pool.getAvailableConnectionCount();
-// if (incnt != cnt) {
-// logError("Available count should have been " + cnt + " , but was " + incnt);
-// }
- }
-
- public void testThreading() throws Exception {
- failure = false;
- log("Start threadingTest...");
-
- Properties props = new Properties();
- props.setProperty(ConnectionPool.CONNECTION_FACTORY, "org.teiid.rhq.comm.impl.FakeConnectionFactory");
- props.setProperty(ConnectionConstants.PASSWORD, "PW");
- props.setProperty(ConnectionConstants.USERNAME, "USERNAME");
-
- ConnectionPool pool = new ConnectionPoolImpl();
- pool.initialize( props, this.getClass().getClassLoader());
-
-
- int threadCnt = 10;
-// int max_size = 1;
- // int expectedNumErrors = threadCnt - max_size;
-
- TimeOutThread[] ts = new TimeOutThread[threadCnt];
-
- for (count = 0; count < threadCnt; count++) {
- ts[count] = new TimeOutThread(pool, 10, count);
- }
-
- for(int k = 0; k < threadCnt; k++){
- ts[k].start();
- }
-
- try {
- for(int k = 0; k < threadCnt; k++){
- ts[k].join();
- }
- } catch (InterruptedException e) {
- }
-
- for(int k = 0; k < threadCnt; k++){
- if (ts[k].hasException()) {
- Exception e = ts[k].getException();
-
- logError("Exception " + e.getMessage());
-
-
- }
- // which thread
- int pc = ts[k].getProcessCnt();
-
- // number of connections suppose to process per thread
- int ptc = ts[k].getPerThreadCnt();
-
- // the number of connection actually processed
- int mx = ts[k].getMaxProcessedCnt();
-
- // the end count of the connection left after close is suppose to be called
- int ct = ts[k].getConnectionCount();
- if (ct != 0) {
- logError("Thread " + pc + " did have the connections go back down to zero");
- }
- if (ptc != mx) {
- logError("PerThreadCnt " + ptc + ", but only successfully processed " + mx);
- } else {
- log("Process " + pc + " for thread # " + k);
- }
-
-
- }
-
- log("Was threadingTest a success " + !failure );
-
-
- }
-
-
-
- private void logError(String msg) {
- failure = true;
- System.out.println(msg);
- }
-
- private void log(String msg) {
- System.out.println(msg);
- }
-
- protected class TimeOutThread extends BaseThread{
- private ConnectionPool pool;
- private int connCnt = 0;
- private int processCnt = 0;
- private int maxCnt = 0;
-
-
- public TimeOutThread(ConnectionPool connpool, int connections, int processcnt) {
- super(connections);
- this.pool = connpool;
- this.processCnt = processcnt;
-
-
- }
- public int getProcessCnt() {
- return processCnt;
- }
-
- public int getMaxProcessedCnt() {
- return maxCnt;
- }
- public int getConnectionCount() {
- return this.connCnt;
- }
-
- public void run(){
- // DO NOT call resource.close(), all the resources should remain
- // checkedout to cause the next resource request to timeout.
-
-
- for (int i=0; i < perThreadCnt; i++ ) {
- Connection conn = null;
- try {
- conn = pool.getConnection();
- ++connCnt;
- ++maxCnt;
-
- yield();
-// Properties psrops =conn.
-// if (psrops == null || psrops.isEmpty()) {
-// setException(new Exception("Null Environment"));
-// }
-// if (conn.getProperty(ConnectionConstants.USERNAME) == null) {
-// setException(new Exception("No UserName"));
-// }
-// if (psrops.size() < 3) {
-// setException(new Exception("NOt Enough Properties"));
-// System.out.println(psrops);
-// }
-
- } catch (Exception toe) {
- setException(toe);
-
- }
-
- // yield to the other thread to checkout instance, which should timeout
- try {
- pool.close(conn);
- --connCnt;
- } catch (Exception err) {
- setException(err);
- }
- }
- }
- }
-
- protected class BaseThread extends Thread{
- protected String objName = "Thread " + count; //$NON-NLS-1$
- protected int perThreadCnt = 1;
- private Exception t = null;
-
-
- public BaseThread(int iterationCnt) {
- perThreadCnt = iterationCnt;
- }
-
- public int getPerThreadCnt() {
- return perThreadCnt;
- }
-
- public Exception getException() {
- return t;
- }
-
- public void setException(Exception te) {
- t = te;
- }
-
- public boolean hasException() {
- return (t==null ? false : true);
- }
-
- }
-
-}
14 years, 10 months
teiid SVN: r1854 - trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2010-02-19 12:46:45 -0500 (Fri, 19 Feb 2010)
New Revision: 1854
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java
Log:
Teiid-773 - Per Warrens request, the error file generated using the xml file option will use the same logic to write an error file that the text file option uses.
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java 2010-02-19 16:49:44 UTC (rev 1853)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java 2010-02-19 17:46:45 UTC (rev 1854)
@@ -27,10 +27,12 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.io.PrintStream;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.List;
import java.util.Properties;
import org.jdom.Attribute;
@@ -43,6 +45,7 @@
import org.teiid.test.client.ResultsGenerator;
import org.teiid.test.client.TestProperties;
import org.teiid.test.framework.exception.QueryTestFailedException;
+import org.teiid.test.util.TestResultSetUtil;
import com.metamatrix.core.util.FileUtils;
import com.metamatrix.core.util.StringUtil;
@@ -51,8 +54,11 @@
public class XMLGenerateResults implements ResultsGenerator {
private static final SimpleDateFormat FILE_NAME_DATE_FORMATER = new SimpleDateFormat(
"yyyyMMdd_HHmmss"); //$NON-NLS-1$
+ private static final int MAX_COL_WIDTH = 65;
+
private String outputDir = "";
private String generateDir = "";
+
public XMLGenerateResults( String testname, Properties props) {
@@ -193,9 +199,122 @@
}
}
}
-
+
+// Begin New from Impl
+
+
public String generateErrorFile(final String querySetID,
final String queryID, final String sql, final ResultSet resultSet,
+ final Throwable queryError, final Object results)
+ throws QueryTestFailedException {
+
+ String errorFileName = null;
+ try {
+ // write actual results to error file
+ errorFileName = generateErrorFileName(queryID, querySetID);
+ // configID, queryID, Integer.toString(clientID));
+ // CombinedTestClient.log("\t" + this.clientID + ": Writing error file with actual results: " + errorFileName); //$NON-NLS-1$ //$NON-NLS-2$
+ File errorFile = new File(getOutputDir(), errorFileName);
+
+ // the resultset will be passed in as null when
+ // the error was due to a thrown exception, and not based comparison issues
+ if (resultSet == null) {
+ FileOutputStream actualOut = null;
+ try {
+ actualOut = new FileOutputStream(errorFile);
+ PrintStream filePrintStream = new PrintStream(actualOut);
+
+
+ TestResultSetUtil.printThrowable(queryError, sql, filePrintStream);
+
+ filePrintStream.flush();
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new QueryTestFailedException(e);
+ } finally {
+ if (actualOut != null) {
+ try {
+ actualOut.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ return errorFileName;
+
+ }
+
+ // rewind resultset
+
+ resultSet.beforeFirst();
+
+ generateErrorResults(querySetID, queryID, sql, errorFile,
+ resultSet, (results != null ? (List) results : null));
+
+ } catch (Throwable e) {
+ throw new QueryTestFailedException(e.getMessage());
+ // CombinedTestClient.logError("Error writing error file \"" + outputDir + "\"/" + errorFileName + ": " + e); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ return errorFileName;
+ }
+
+
+ /**
+ * Generate an error file for a query that failed comparison. File should
+ * have the SQL, the actual results returned from the server and the results
+ * that were expected.
+ *
+ * @param queryID
+ * @param sql
+ * @param resultsFile
+ * @param actualResult
+ * @param expectedResultFile
+ * @param ex
+ * @throws QueryTestFailedException
+ */
+ private void generateErrorResults(String querySetID, String queryID,
+ String sql, File resultsFile, ResultSet actualResult,
+ List<String> results)
+ throws QueryTestFailedException {
+
+ FileOutputStream actualOut = null;
+ try {
+ actualOut = new FileOutputStream(resultsFile);
+ PrintStream filePrintStream = new PrintStream(actualOut);
+
+ TestResultSetUtil.printResultSet(actualResult, sql, MAX_COL_WIDTH, true, filePrintStream);
+
+// if (results != null) {
+// for (Iterator<String> it=results.iterator(); it.hasNext();) {
+// String line = it.next();
+// filePrintStream.print(line);
+// }
+// } else {
+//
+// ResultSetUtil.printResultSet(actualResult, MAX_COL_WIDTH, true, filePrintStream);
+// }
+
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new QueryTestFailedException(e);
+ } finally {
+ if (actualOut != null) {
+ try {
+ actualOut.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+// End of copy from impl
+
+ public String generateErrorFilex(final String querySetID,
+ final String queryID, final String sql, final ResultSet resultSet,
final Throwable queryError, final Object expectedResultsFile)
throws QueryTestFailedException {
@@ -260,7 +379,7 @@
// .currentTimeMillis())) + ".xml"; //$NON-NLS-1$
// return errorFileName;
- return queryID + ".xml";
+ return queryID + ".txt";
}
/**
14 years, 10 months