[teiid-commits] teiid SVN: r1855 - in trunk/console/src: main/java/org/teiid/rhq/plugin and 2 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Fri Feb 19 13:57:27 EST 2010
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);
- }
-
- }
-
-}
More information about the teiid-commits
mailing list