Author: pmouawad Date: Sat Mar 2 23:45:21 2013 New Revision: 1451961 URL: http://svn.apache.org/r1451961 Log: Bug 54584 - MongoDB plugin Bugzilla Id: 54584 Added: jmeter/trunk/res/maven/ApacheJMeter_mongodb.pom jmeter/trunk/src/protocol/mongodb/ jmeter/trunk/src/protocol/mongodb/org/ jmeter/trunk/src/protocol/mongodb/org/apache/ jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/ jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/ jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/ jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/ jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElement.java (with props) jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElementBeanInfo.java (with props) jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElementResources.properties (with props) jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElementResources_fr.properties (with props) jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/ jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/EvalResultHandler.java (with props) jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/MongoDB.java (with props) jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/MongoUtils.java (with props) jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/ jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptRunner.java (with props) jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSampler.java (with props) jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSamplerBeanInfo.java (with props) jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSamplerResources.properties (with props) jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSamplerResources_fr.properties (with props) Modified: jmeter/trunk/build.properties jmeter/trunk/build.xml jmeter/trunk/res/maven/ApacheJMeter_parent.pom jmeter/trunk/xdocs/changes.xml jmeter/trunk/xdocs/usermanual/component_reference.xml Modified: jmeter/trunk/build.properties URL: http://svn.apache.org/viewvc/jmeter/trunk/build.properties?rev=1451961&r1=1451960&r2=1451961&view=diff ============================================================================== --- jmeter/trunk/build.properties (original) +++ jmeter/trunk/build.properties Sat Mar 2 23:45:21 2013 @@ -213,6 +213,11 @@ logkit.jar = logkit-${l logkit.loc = ${maven2.repo}/logkit/logkit/${logkit.version} logkit.md5 = 8D82A3E91AAE216D0A2A40B837A232FF +mongo-java-driver.version = 2.10.1 +mongo-java-driver.jar = mongo-java-driver-${mongo-java-driver.version}.jar +mongo-java-driver.loc = ${maven2.repo}/org/mongodb/mongo-java-driver/${mongo-java-driver.version} +mongo-java-driver.md5 = e12feedcdd249b3973e24d03f6cb5131 + slf4j-api.version = 1.7.2 slf4j-api.jar = slf4j-api-${slf4j-api.version}.jar slf4j-api.loc = ${maven2.repo}/org/slf4j/slf4j-api/${slf4j-api.version} Modified: jmeter/trunk/build.xml URL: http://svn.apache.org/viewvc/jmeter/trunk/build.xml?rev=1451961&r1=1451960&r2=1451961&view=diff ============================================================================== --- jmeter/trunk/build.xml (original) +++ jmeter/trunk/build.xml Sat Mar 2 23:45:21 2013 @@ -141,6 +141,7 @@ + @@ -148,6 +149,7 @@ + @@ -211,6 +213,7 @@ + @@ -260,6 +263,7 @@ + @@ -448,6 +452,7 @@ + @@ -839,9 +844,23 @@ + + + + + + + + + + + + @@ -1117,6 +1136,18 @@ run JMeter unless all the JMeter jars ar + + + + + + + + + + @@ -2728,6 +2759,7 @@ run JMeter unless all the JMeter jars ar + Added: jmeter/trunk/res/maven/ApacheJMeter_mongodb.pom URL: http://svn.apache.org/viewvc/jmeter/trunk/res/maven/ApacheJMeter_mongodb.pom?rev=1451961&view=auto ============================================================================== --- jmeter/trunk/res/maven/ApacheJMeter_mongodb.pom (added) +++ jmeter/trunk/res/maven/ApacheJMeter_mongodb.pom Sat Mar 2 23:45:21 2013 @@ -0,0 +1,49 @@ + + + + 4.0.0 + + org.apache.jmeter + ApacheJMeter_parent + @MAVEN.DEPLOY.VERSION@ + . + + ApacheJMeter_mongodb + Apache JMeter MongoDB + + + + org.apache.jmeter + jorphan + @MAVEN.DEPLOY.VERSION@ + + + org.apache.jmeter + ApacheJMeter_core + @MAVEN.DEPLOY.VERSION@ + + + org.apache.jmeter + ApacheJMeter_components + @MAVEN.DEPLOY.VERSION@ + + + + \ No newline at end of file Modified: jmeter/trunk/res/maven/ApacheJMeter_parent.pom URL: http://svn.apache.org/viewvc/jmeter/trunk/res/maven/ApacheJMeter_parent.pom?rev=1451961&r1=1451960&r2=1451961&view=diff ============================================================================== --- jmeter/trunk/res/maven/ApacheJMeter_parent.pom (original) +++ jmeter/trunk/res/maven/ApacheJMeter_parent.pom Sat Mar 2 23:45:21 2013 @@ -82,6 +82,7 @@ under the License. 1.7R4 4.10 2.0 + 2.10.1 1.7.2 2.3.1 r938 @@ -345,6 +346,11 @@ under the License. ${jodd.version} + org.mongodb + mongo-java-driver + ${mongo-java-driver.version} + + org.slf4j slf4j-api ${slf4j.version} Added: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElement.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElement.java?rev=1451961&view=auto ============================================================================== --- jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElement.java (added) +++ jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElement.java Sat Mar 2 23:45:21 2013 @@ -0,0 +1,264 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.jmeter.protocol.mongodb.config; + +import org.apache.jmeter.config.ConfigElement; +import org.apache.jmeter.protocol.mongodb.mongo.MongoDB; +import org.apache.jmeter.protocol.mongodb.mongo.MongoUtils; +import org.apache.jmeter.testbeans.TestBean; +import org.apache.jmeter.testelement.AbstractTestElement; +import org.apache.jmeter.testelement.TestStateListener; +import org.apache.jmeter.threads.JMeterContextService; +import org.apache.jorphan.logging.LoggingManager; +import org.apache.log.Logger; + +import com.mongodb.MongoOptions; + +/** + */ +public class MongoSourceElement + extends AbstractTestElement + implements ConfigElement, TestStateListener, TestBean { + + private static final Logger log = LoggingManager.getLoggerForClass(); + + public final static String CONNECTION = "MongoSourceElement.connection"; //$NON-NLS-1$ + public final static String SOURCE = "MongoSourceElement.source"; //$NON-NLS-1$ + + public final static String AUTO_CONNECT_RETRY = "MongoSourceElement.autoConnectRetry"; //$NON-NLS-1$ + public final static String CONNECTIONS_PER_HOST = "MongoSourceElement.connectionsPerHost"; //$NON-NLS-1$ + public final static String CONNECT_TIMEOUT = "MongoSourceElement.connectTimeout"; //$NON-NLS-1$ + public final static String MAX_AUTO_CONNECT_RETRY_TIME = "MongoSourceElement.maxAutoConnectRetryTime"; //$NON-NLS-1$ + public final static String MAX_WAIT_TIME = "MongoSourceElement.maxWaitTime"; //$NON-NLS-1$ + public final static String SOCKET_TIMEOUT = "MongoSourceElement.socketTimeout"; //$NON-NLS-1$ + public final static String SOCKET_KEEP_ALIVE = "MongoSourceElement.socketKeepAlive"; //$NON-NLS-1$ + public final static String THREADS_ALLOWED_TO_BLOCK_MULTIPLIER = "MongoSourceElement.threadsAllowedToBlockForConnectionMultiplier"; //$NON-NLS-1$ + + public final static String FSYNC = "MongoSourceElement.fsync"; //$NON-NLS-1$ + public final static String SAFE = "MongoSourceElement.safe"; //$NON-NLS-1$ + public final static String WAIT_FOR_JOURNALING = "MongoSourceElement.waitForJournaling"; //$NON-NLS-1$ + public final static String WRITE_OPERATION_NUMBER_OF_SERVERS = "MongoSourceElement.writeOperationNumberOfServers"; //$NON-NLS-1$ + public final static String WRITE_OPERATION_TIMEOUT = "MongoSourceElement.writeOperationTimeout"; //$NON-NLS-1$ + + public String getTitle() { + return this.getName(); + } + + public String getConnection() { + return getPropertyAsString(CONNECTION); + } + + public void setConnection(String connection) { + setProperty(CONNECTION, connection); + } + + public String getSource() { + return getPropertyAsString(SOURCE); + } + + public void setSource(String source) { + setProperty(SOURCE, source); + } + + public String getAutoConnectRetry() { + return getPropertyAsString(AUTO_CONNECT_RETRY); + } + + public void setAutoConnectRetry(String autoConnectRetry) { + setProperty(AUTO_CONNECT_RETRY, autoConnectRetry); + } + + public String getConnectionsPerHost() { + return getPropertyAsString(CONNECTIONS_PER_HOST); + } + + public void setConnectionsPerHost(String connectionsPerHost) { + setProperty(CONNECTIONS_PER_HOST, connectionsPerHost); + } + + public String getConnectTimeout() { + return getPropertyAsString(CONNECT_TIMEOUT); + } + + public void setConnectTimeout(String connectTimeout) { + setProperty(CONNECT_TIMEOUT, connectTimeout); + } + + public String getMaxAutoConnectRetryTime() { + return getPropertyAsString(MAX_AUTO_CONNECT_RETRY_TIME); + } + + public void setMaxAutoConnectRetryTime(String maxAutoConnectRetryTime) { + setProperty(MAX_AUTO_CONNECT_RETRY_TIME, maxAutoConnectRetryTime); + } + + public String getMaxWaitTime() { + return getPropertyAsString(MAX_WAIT_TIME); + } + + public void setMaxWaitTime(String maxWaitTime) { + setProperty(MAX_WAIT_TIME, maxWaitTime); + } + + public String getSocketTimeout() { + return getPropertyAsString(SOCKET_TIMEOUT); + } + + public void setSocketTimeout(String socketTimeout) { + setProperty(SOCKET_TIMEOUT, socketTimeout); + } + + public String getSocketKeepAlive() { + return getPropertyAsString(SOCKET_KEEP_ALIVE); + } + + public void setSocketKeepAlive(String socketKeepAlive) { + setProperty(SOCKET_KEEP_ALIVE, socketKeepAlive); + } + + public String getThreadsAllowedToBlockForConnectionMultiplier() { + return getPropertyAsString(THREADS_ALLOWED_TO_BLOCK_MULTIPLIER); + } + + public void setThreadsAllowedToBlockForConnectionMultiplier(String threadsAllowed) { + setProperty(THREADS_ALLOWED_TO_BLOCK_MULTIPLIER, threadsAllowed); + } + + public String getFsync() { + return getPropertyAsString(FSYNC); + } + + public void setFsync(String fsync) { + setProperty(FSYNC, fsync); + } + + public String getSafe() { + return getPropertyAsString(SAFE); + } + + public void setSafe(String safe) { + setProperty(SAFE, safe); + } + + public String getWaitForJournaling() { + return getPropertyAsString(WAIT_FOR_JOURNALING); + } + + public void setWaitForJournaling(String waitForJournaling) { + setProperty(WAIT_FOR_JOURNALING, waitForJournaling); + } + + public String getWriteOperationNumberOfServers() { + return getPropertyAsString(WRITE_OPERATION_NUMBER_OF_SERVERS); + } + + public void setWriteOperationNumberOfServers(String writeOperationNumberOfServers) { + setProperty(WRITE_OPERATION_NUMBER_OF_SERVERS, writeOperationNumberOfServers); + } + + public String getWriteOperationTimeout() { + return getPropertyAsString(WRITE_OPERATION_TIMEOUT); + } + + public void setWriteOperationTimeout(String writeOperationTimeout) { + setProperty(WRITE_OPERATION_TIMEOUT, writeOperationTimeout); + } + + public static MongoDB getMongoDB(String source) { + + Object mongoSource = JMeterContextService.getContext().getVariables().getObject(source); + + if(mongoSource == null) { + throw new IllegalStateException("mongoSource is null"); + } + else { + if(mongoSource instanceof MongoDB) { + return (MongoDB)mongoSource; + } + else { + throw new IllegalStateException("Variable:"+ source +" is not a MongoDB instance, class:"+(mongoSource != null ? mongoSource.getClass():"null")); + } + } + } + + @Override + public void addConfigElement(ConfigElement configElement) { + } + + @Override + public boolean expectsModification() { + return false; + } + + @Override + public void testStarted() { + if(log.isDebugEnabled()) { + log.debug(getTitle() + " testStarted"); + } + + MongoOptions mongoOptions = new MongoOptions(); + mongoOptions.autoConnectRetry = Boolean.parseBoolean(getAutoConnectRetry()); + mongoOptions.connectTimeout = Integer.parseInt(getConnectTimeout()); + mongoOptions.connectionsPerHost = Integer.parseInt(getConnectionsPerHost()); + mongoOptions.fsync = Boolean.parseBoolean(getFsync()); + mongoOptions.j = Boolean.parseBoolean(getWaitForJournaling()); + mongoOptions.maxAutoConnectRetryTime = Integer.parseInt(getMaxAutoConnectRetryTime()); + mongoOptions.maxWaitTime = Integer.parseInt(getMaxWaitTime()); + mongoOptions.safe = Boolean.parseBoolean(getSafe()); + mongoOptions.socketKeepAlive = Boolean.parseBoolean(getSocketKeepAlive()); + mongoOptions.socketTimeout = Integer.parseInt(getSocketTimeout()); + mongoOptions.threadsAllowedToBlockForConnectionMultiplier = Integer.parseInt(getThreadsAllowedToBlockForConnectionMultiplier()); + mongoOptions.w = Integer.parseInt(getWriteOperationNumberOfServers()); + mongoOptions.wtimeout = Integer.parseInt(getWriteOperationTimeout()); + + if(log.isDebugEnabled()) { + log.debug("options : " + mongoOptions.toString()); + } + + if(getThreadContext().getVariables().getObject(getSource()) != null) { + if(log.isWarnEnabled()) { + log.warn(getSource() + " has already been defined."); + } + } + else { + if(log.isDebugEnabled()) { + log.debug(getSource() + " is being defined."); + } + getThreadContext().getVariables().putObject(getSource(), new MongoDB(MongoUtils.toServerAddresses(getConnection()), mongoOptions)); + } + } + + @Override + public void testStarted(String s) { + testStarted(); + } + + @Override + public void testEnded() { + if(log.isDebugEnabled()) { + log.debug(getTitle() + " testEnded"); + } + ((MongoDB)getThreadContext().getVariables().getObject(getSource())).clear(); + } + + @Override + public void testEnded(String s) { + testEnded(); + } +} \ No newline at end of file Propchange: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElement.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElementBeanInfo.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElementBeanInfo.java?rev=1451961&view=auto ============================================================================== --- jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElementBeanInfo.java (added) +++ jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElementBeanInfo.java Sat Mar 2 23:45:21 2013 @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.jmeter.protocol.mongodb.config; + +import java.beans.PropertyDescriptor; + +import org.apache.jmeter.testbeans.BeanInfoSupport; +import org.apache.jorphan.logging.LoggingManager; +import org.apache.log.Logger; + +/** + */ +public class MongoSourceElementBeanInfo + extends BeanInfoSupport { + + private static final Logger log = LoggingManager.getLoggerForClass(); + + public MongoSourceElementBeanInfo() { + super(MongoSourceElement.class); + + //http://api.mongodb.org/java/2.7.2/com/mongodb/Mongo.html + createPropertyGroup("mongodb", new String[] { + "connection", + "source"}); + + //http://api.mongodb.org/java/2.7.2/com/mongodb/MongoOptions.html/ + createPropertyGroup("options", new String[]{ + "autoConnectRetry", + "connectionsPerHost", + "connectTimeout", + "maxAutoConnectRetryTime", + "maxWaitTime", + "socketTimeout", + "socketKeepAlive", + "threadsAllowedToBlockForConnectionMultiplier"}); + + //http://api.mongodb.org/java/2.7.2/com/mongodb/MongoOptions.html/ + createPropertyGroup("writeConcern", new String[] { + "fsync", + "safe", + "waitForJournaling", + "writeOperationNumberOfServers", + "writeOperationTimeout" }); + + PropertyDescriptor p = property("connection"); + p.setValue(NOT_UNDEFINED, Boolean.TRUE); + p.setValue(DEFAULT, ""); + p = property("source"); + p.setValue(NOT_UNDEFINED, Boolean.TRUE); + p.setValue(DEFAULT, ""); + + p = property("autoConnectRetry"); + p.setValue(NOT_UNDEFINED, Boolean.TRUE); + p.setValue(DEFAULT, Boolean.FALSE); + p = property("connectionsPerHost"); + p.setValue(NOT_UNDEFINED, Boolean.TRUE); + p.setValue(DEFAULT, "10"); + p = property("connectTimeout"); + p.setValue(NOT_UNDEFINED, Boolean.TRUE); + p.setValue(DEFAULT, "0"); + p = property("threadsAllowedToBlockForConnectionMultiplier"); + p.setValue(NOT_UNDEFINED, Boolean.TRUE); + p.setValue(DEFAULT, "5"); + p = property("maxAutoConnectRetryTime"); + p.setValue(NOT_UNDEFINED, Boolean.TRUE); + p.setValue(DEFAULT, "0"); + p = property("maxWaitTime"); + p.setValue(NOT_UNDEFINED, Boolean.TRUE); + p.setValue(DEFAULT, "120000"); + p = property("socketTimeout"); + p.setValue(NOT_UNDEFINED, Boolean.TRUE); + p.setValue(DEFAULT, "0"); + p = property("socketKeepAlive"); + p.setValue(NOT_UNDEFINED, Boolean.TRUE); + p.setValue(DEFAULT, Boolean.FALSE); + + p = property("fsync"); + p.setValue(NOT_UNDEFINED, Boolean.TRUE); + p.setValue(DEFAULT, Boolean.FALSE); + p = property("safe"); + p.setValue(NOT_UNDEFINED, Boolean.TRUE); + p.setValue(DEFAULT, Boolean.FALSE); + p = property("waitForJournaling"); + p.setValue(NOT_UNDEFINED, Boolean.TRUE); + p.setValue(DEFAULT, Boolean.FALSE); + p = property("writeOperationNumberOfServers"); + p.setValue(NOT_UNDEFINED, Boolean.TRUE); + p.setValue(DEFAULT, "0"); + p = property("writeOperationTimeout"); + p.setValue(NOT_UNDEFINED, Boolean.TRUE); + p.setValue(DEFAULT, "0"); + + if(log.isDebugEnabled()) { + for (PropertyDescriptor pd : getPropertyDescriptors()) { + log.debug(pd.getName()); + log.debug(pd.getDisplayName()); + } + } + } +} \ No newline at end of file Propchange: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElementBeanInfo.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElementResources.properties URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElementResources.properties?rev=1451961&view=auto ============================================================================== --- jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElementResources.properties (added) +++ jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElementResources.properties Sat Mar 2 23:45:21 2013 @@ -0,0 +1,46 @@ +displayName=MongoDB Source Config + +mongodb.displayName=MongoDB Connection +mongodb.shortDescription=Configure the connection + +connection.displayName=Server Address List +connection.shortDescription=Server Address List + +source.displayName=MongoDB Source +source.shortDescription=Configure the Source + +options.displayName=MongoDB Options +options.shortDescription=Various settings for the driver + +autoConnectRetry.displayName=Keep trying +connectionsPerHost.displayName=Maximum connections Per Host +connectTimeout.displayName=Connection timeout +maxAutoConnectRetryTime.displayName=Maximum retry time +maxWaitTime.displayName=Maximum wait time +socketKeepAlive.displayName=Socket keep alive +socketTimeout.displayName=Socket timeout +threadsAllowedToBlockForConnectionMultiplier.displayName=Block Multiplier + +autoConnectRetry.shortDescription=If true, the driver will keep trying to connect to the same server in case that the socket cannot be established.

There is maximum amount of time to keep retrying, which is 15s by default.

This can be useful to avoid some exceptions being thrown when a server is down temporarily by blocking the operations.

It also can be useful to smooth the transition to a new master (so that a new master is elected within the retry time).

Note that when using this flag:
- for a replica set, the driver will trying to connect to the old master for that time, instead of failing over to the new one right away -
this does not prevent exception from being thrown in read/write operations on the socket, which must be handled by application.

Even if this flag is false, the driver already has mechanisms to automatically recreate broken connections and retry the read operations.

Default is false. +connectionsPerHost.shortDescription=The maximum number of connections allowed per host for this Mongo instance.

Those connections will be kept in a pool when idle.

Once the pool is exhausted, any operation requiring a connection will block waiting for an available connection.

Default is 10. +connectTimeout.shortDescription=The connection timeout in milliseconds.

It is used solely when establishing a new connection Socket.connect(java.net.SocketAddress, int)

Default is 0 and means no timeout. +maxAutoConnectRetryTime.shortDescription=The maximum amount of time in MS to spend retrying to open connection to the same server.

Default is 0, which means to use the default 15s if autoConnectRetry is on. +maxWaitTime.shortDescription=The maximum wait time in ms that a thread may wait for a connection to become available.

Default is 120,000. +socketKeepAlive.shortDescription=This flag controls the socket keep alive feature that keeps a connection alive through firewalls Socket.setKeepAlive(boolean)

Default is false. +socketTimeout.shortDescription=The socket timeout in milliseconds It is used for I/O socket read and write operations Socket.setSoTimeout(int)

Default is 0 and means no timeout. +threadsAllowedToBlockForConnectionMultiplier.shortDescription=This multiplier, multiplied with the connectionsPerHost setting, gives the maximum number of threads that may be waiting for a connection to become available from the pool.

All further threads will get an exception right away.

For example if connectionsPerHost is 10 and threadsAllowedToBlockForConnectionMultiplier is 5, then up to 50 threads can wait for a connection.

Default is 5. + +writeConcern.displayName=Write Concern Options +writeConcern.shortDescription=Various settings for the driver + +fsync.displayName=Fsync +safe.displayName=Safe +waitForJournaling.displayName=Wait for Journal +writeOperationNumberOfServers.displayName=Wait for Servers +writeOperationTimeout.displayName=Wait Timeout + +fsync.shortDescription=The fsync value of the global WriteConcern.

Default is false. +safe.shortDescription=If true the driver will use a WriteConcern of WriteConcern.SAFE for all operations.

If w, wtimeout, fsync or j are specified, this setting is ignored.

Default is false. +waitForJournaling.shortDescription=The j value of the global WriteConcern.

Default is false. +writeOperationNumberOfServers.shortDescription=The w value of the global WriteConcern.

Default is 0. +writeOperationTimeout.shortDescription=The wtimeout value of the global WriteConcern.

Default is 0. \ No newline at end of file Propchange: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElementResources.properties ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElementResources_fr.properties URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElementResources_fr.properties?rev=1451961&view=auto ============================================================================== --- jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElementResources_fr.properties (added) +++ jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElementResources_fr.properties Sat Mar 2 23:45:21 2013 @@ -0,0 +1,46 @@ +displayName=MongoDB Source Config + +mongodb.displayName=MongoDB Connection +mongodb.shortDescription=Configure the connection + +connection.displayName=Server Address List +connection.shortDescription=Server Address List + +source.displayName=MongoDB Source +source.shortDescription=Configure the Source + +options.displayName=MongoDB Options +options.shortDescription=Various settings for the driver + +autoConnectRetry.displayName=Keep trying +connectionsPerHost.displayName=Maximum connections Per Host +connectTimeout.displayName=Connection timeout +maxAutoConnectRetryTime.displayName=Maximum retry time +maxWaitTime.displayName=Maximum wait time +socketKeepAlive.displayName=Socket keep alive +socketTimeout.displayName=Socket timeout +threadsAllowedToBlockForConnectionMultiplier.displayName=Block Multiplier + +autoConnectRetry.shortDescription=If true, the driver will keep trying to connect to the same server in case that the socket cannot be established.

There is maximum amount of time to keep retrying, which is 15s by default.

This can be useful to avoid some exceptions being thrown when a server is down temporarily by blocking the operations.

It also can be useful to smooth the transition to a new master (so that a new master is elected within the retry time).

Note that when using this flag:
- for a replica set, the driver will trying to connect to the old master for that time, instead of failing over to the new one right away -
this does not prevent exception from being thrown in read/write operations on the socket, which must be handled by application.

Even if this flag is false, the driver already has mechanisms to automatically recreate broken connections and retry the read operations.

Default is false. +connectionsPerHost.shortDescription=The maximum number of connections allowed per host for this Mongo instance.

Those connections will be kept in a pool when idle.

Once the pool is exhausted, any operation requiring a connection will block waiting for an available connection.

Default is 10. +connectTimeout.shortDescription=The connection timeout in milliseconds.

It is used solely when establishing a new connection Socket.connect(java.net.SocketAddress, int)

Default is 0 and means no timeout. +maxAutoConnectRetryTime.shortDescription=The maximum amount of time in MS to spend retrying to open connection to the same server.

Default is 0, which means to use the default 15s if autoConnectRetry is on. +maxWaitTime.shortDescription=The maximum wait time in ms that a thread may wait for a connection to become available.

Default is 120,000. +socketKeepAlive.shortDescription=This flag controls the socket keep alive feature that keeps a connection alive through firewalls Socket.setKeepAlive(boolean)

Default is false. +socketTimeout.shortDescription=The socket timeout in milliseconds It is used for I/O socket read and write operations Socket.setSoTimeout(int)

Default is 0 and means no timeout. +threadsAllowedToBlockForConnectionMultiplier.shortDescription=This multiplier, multiplied with the connectionsPerHost setting, gives the maximum number of threads that may be waiting for a connection to become available from the pool.

All further threads will get an exception right away.

For example if connectionsPerHost is 10 and threadsAllowedToBlockForConnectionMultiplier is 5, then up to 50 threads can wait for a connection.

Default is 5. + +writeConcern.displayName=Write Concern Options +writeConcern.shortDescription=Various settings for the driver + +fsync.displayName=Fsync +safe.displayName=Safe +waitForJournaling.displayName=Wait for Journal +writeOperationNumberOfServers.displayName=Wait for Servers +writeOperationTimeout.displayName=Wait Timeout + +fsync.shortDescription=The fsync value of the global WriteConcern.

Default is false. +safe.shortDescription=If true the driver will use a WriteConcern of WriteConcern.SAFE for all operations.

If w, wtimeout, fsync or j are specified, this setting is ignored.

Default is false. +waitForJournaling.shortDescription=The j value of the global WriteConcern.

Default is false. +writeOperationNumberOfServers.shortDescription=The w value of the global WriteConcern.

Default is 0. +writeOperationTimeout.shortDescription=The wtimeout value of the global WriteConcern.

Default is 0. \ No newline at end of file Propchange: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/config/MongoSourceElementResources_fr.properties ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/EvalResultHandler.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/EvalResultHandler.java?rev=1451961&view=auto ============================================================================== --- jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/EvalResultHandler.java (added) +++ jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/EvalResultHandler.java Sat Mar 2 23:45:21 2013 @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.jmeter.protocol.mongodb.mongo; + +import com.mongodb.DBObject; +import com.mongodb.util.JSON; + +/** + */ +public class EvalResultHandler { + + //This can lead to code smell, meh! Do we care + public String handle(Object o) { + if(o == null) { + return "ok"; + } + + if(o instanceof Double) { + return this.handle((Double)o); + } + else if(o instanceof Integer) { + return this.handle((Integer)o); + } + else if(o instanceof String) { + return this.handle((String)o); + } + else if(o instanceof DBObject) { + return this.handle((DBObject)o); + } + else { + return "return type not handled"; + } + } + + public String handle(Integer o) { + return o.toString(); + } + + public String handle(String o) { + return o; + } + + public String handle(Double o) { + return o.toString(); + } + + + public String handle(DBObject o) { + return JSON.serialize(o); + } +} Propchange: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/EvalResultHandler.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/MongoDB.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/MongoDB.java?rev=1451961&view=auto ============================================================================== --- jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/MongoDB.java (added) +++ jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/MongoDB.java Sat Mar 2 23:45:21 2013 @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.jmeter.protocol.mongodb.mongo; + +import java.util.List; + +import org.apache.jorphan.logging.LoggingManager; +import org.apache.log.Logger; + +import com.mongodb.DB; +import com.mongodb.Mongo; +import com.mongodb.MongoOptions; +import com.mongodb.ServerAddress; + +/** + */ +public class MongoDB { + + private static final Logger log = LoggingManager.getLoggerForClass(); + + // Mongo is Thread Safe + private Mongo mongo = null; + + public MongoDB( + List serverAddresses, + MongoOptions mongoOptions) { + mongo = new Mongo(serverAddresses, mongoOptions); + } + + public DB getDB(String database, String username, String password) { + + if(log.isDebugEnabled()) { + log.debug("username: " + username+", password: " + password+", database: " + database); + } + DB db = mongo.getDB(database); + boolean authenticated = db.isAuthenticated(); + + if(!authenticated) { + if(username != null && password != null && username.length() > 0 && password.length() > 0) { + authenticated = db.authenticate(username, password.toCharArray()); + } + } + if(log.isDebugEnabled()) { + log.debug("authenticated: " + authenticated); + } + return db; + } + + public void clear() { + if(log.isDebugEnabled()) { + log.debug("clearing"); + } + + mongo.close(); + //there is no harm in trying to clear up + mongo = null; + } +} \ No newline at end of file Propchange: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/MongoDB.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/MongoUtils.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/MongoUtils.java?rev=1451961&view=auto ============================================================================== --- jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/MongoUtils.java (added) +++ jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/MongoUtils.java Sat Mar 2 23:45:21 2013 @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.jmeter.protocol.mongodb.mongo; + +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.Arrays; + +import org.apache.jorphan.logging.LoggingManager; +import org.apache.log.Logger; + +import com.mongodb.ServerAddress; + +/** + */ +public class MongoUtils { + + private static final Logger log = LoggingManager.getLoggerForClass(); + + public static ArrayList toServerAddresses(String connections) { + + ArrayList addresses = new ArrayList(); + try { + for(String connection : Arrays.asList(connections.split(","))) { + int port = 27017; + String[] hostPort = connection.split(":"); + if(hostPort.length > 1 && hostPort[1] != null) { + port = Integer.parseInt(hostPort[1].trim()); + } + addresses.add(new ServerAddress(hostPort[0], port)); + } + } + catch(UnknownHostException uhe) { + if(log.isWarnEnabled()) { + log.warn("", uhe); + } + } + return addresses; + } +} Propchange: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/mongo/MongoUtils.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptRunner.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptRunner.java?rev=1451961&view=auto ============================================================================== --- jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptRunner.java (added) +++ jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptRunner.java Sat Mar 2 23:45:21 2013 @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.jmeter.protocol.mongodb.sampler; + +import org.apache.jorphan.logging.LoggingManager; +import org.apache.log.Logger; + +import com.mongodb.DB; + +/** + */ +public class MongoScriptRunner { + + private static final Logger log = LoggingManager.getLoggerForClass(); + + public MongoScriptRunner() { + super(); + } + + /** + * + * @param db + * @param script + * @return + * @throws Exception + */ + public Object evaluate(DB db, String script) + throws Exception { + + if(log.isDebugEnabled()) { + log.debug("database: " + db.getName()+", script: " + script); + } + + db.requestStart(); + try { + db.requestEnsureConnection(); + + Object result = db.eval(script); + + if(log.isDebugEnabled()) { + log.debug("Result : " + result); + } + return result; + } finally { + db.requestDone(); + } + } +} \ No newline at end of file Propchange: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptRunner.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSampler.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSampler.java?rev=1451961&view=auto ============================================================================== --- jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSampler.java (added) +++ jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSampler.java Sat Mar 2 23:45:21 2013 @@ -0,0 +1,150 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.jmeter.protocol.mongodb.sampler; + +import org.apache.jmeter.protocol.mongodb.config.MongoSourceElement; +import org.apache.jmeter.protocol.mongodb.mongo.EvalResultHandler; +import org.apache.jmeter.protocol.mongodb.mongo.MongoDB; +import org.apache.jmeter.samplers.AbstractSampler; +import org.apache.jmeter.samplers.Entry; +import org.apache.jmeter.samplers.SampleResult; +import org.apache.jmeter.testbeans.TestBean; +import org.apache.jorphan.logging.LoggingManager; +import org.apache.log.Logger; + +import com.mongodb.DB; + +/** + */ +public class MongoScriptSampler + extends AbstractSampler + implements TestBean { + + private static final Logger log = LoggingManager.getLoggerForClass(); + + public final static String SOURCE = "MongoScriptSampler.source"; //$NON-NLS-1$ + + public final static String DATABASE = "MongoScriptSampler.database"; //$NON-NLS-1$ + public final static String USERNAME = "MongoScriptSampler.username"; //$NON-NLS-1$ + public final static String PASSWORD = "MongoScriptSampler.password"; //$NON-NLS-1$ + + public final static String SCRIPT = "MongoScriptSampler.script"; //$NON-NLS-1$ + + private static final long serialVersionUID = -7789012234636439896L; + + public MongoScriptSampler() { + trace("MongoScriptSampler()"); + } + + @Override + public SampleResult sample(Entry e) { + trace("sample()"); + + SampleResult res = new SampleResult(); + String data = getScript(); + + res.setSampleLabel(getTitle()); + res.setResponseCodeOK(); + res.setResponseCode("200"); + res.setSuccessful(true); + res.setResponseMessageOK(); + res.setSamplerData(data); + res.setDataType(SampleResult.TEXT); + res.setContentType("text/plain"); // $NON-NLS-1$ + res.sampleStart(); + + try { + MongoDB mongoDB = MongoSourceElement.getMongoDB(getSource()); + MongoScriptRunner runner = new MongoScriptRunner(); + DB db = mongoDB.getDB(getDatabase(), getUsername(), getPassword()); + res.latencyEnd(); + Object result = runner.evaluate(db, data); + res.sampleEnd(); + EvalResultHandler handler = new EvalResultHandler(); + String resultAsString = handler.handle(result); + res.setResponseData(resultAsString.getBytes()); + } + catch (Exception ex) { + res.sampleEnd(); + log.warn("", ex); + res.setResponseCode("500");// $NON-NLS-1$ + res.setSuccessful(false); + res.setResponseMessage(ex.toString()); + res.setResponseData(ex.getMessage().getBytes()); + } + finally { + res.sampleEnd(); + } + + return res; + } + + public String getTitle() { + return this.getName(); + } + + public String getScript() { + return getPropertyAsString(SCRIPT); + } + + public void setScript(String script) { + setProperty(SCRIPT, script); + } + + public String getDatabase() { + return getPropertyAsString(DATABASE); + } + + public void setDatabase(String database) { + setProperty(DATABASE, database); + } + + public String getUsername() { + return getPropertyAsString(USERNAME); + } + + public void setUsername(String username) { + setProperty(USERNAME, username); + } + + public String getPassword() { + return getPropertyAsString(PASSWORD); + } + + public void setPassword(String password) { + setProperty(PASSWORD, password); + } + + public String getSource() { + return getPropertyAsString(SOURCE); + } + + public void setSource(String source) { + setProperty(SOURCE, source); + } + + /* + * Helper + */ + private void trace(String s) { + if(log.isDebugEnabled()) { + log.debug(Thread.currentThread().getName() + " (" + getTitle() + " " + s + " " + this.toString()); + } + } +} \ No newline at end of file Propchange: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSampler.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSamplerBeanInfo.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSamplerBeanInfo.java?rev=1451961&view=auto ============================================================================== --- jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSamplerBeanInfo.java (added) +++ jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSamplerBeanInfo.java Sat Mar 2 23:45:21 2013 @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.jmeter.protocol.mongodb.sampler; + +import java.beans.PropertyDescriptor; + +import org.apache.jmeter.testbeans.BeanInfoSupport; +import org.apache.jmeter.testbeans.gui.TextAreaEditor; +import org.apache.jmeter.testbeans.gui.TypeEditor; +import org.apache.jorphan.logging.LoggingManager; +import org.apache.log.Logger; + +/** + */ +public class MongoScriptSamplerBeanInfo + extends BeanInfoSupport { + + private static final Logger log = LoggingManager.getLoggerForClass(); + + public MongoScriptSamplerBeanInfo() { + super(MongoScriptSampler.class); + + //http://api.mongodb.org/java/2.7.2/com/mongodb/Mongo.html + createPropertyGroup("mongodb", new String[] { + "source", + "database", + "username", + "password" }); + + createPropertyGroup("sampler", new String[]{ + "script"}); + + PropertyDescriptor p = property("database"); + p.setValue(NOT_UNDEFINED, Boolean.TRUE); + p.setValue(DEFAULT, ""); + p = property("username"); + p.setValue(NOT_UNDEFINED, Boolean.TRUE); + p.setValue(DEFAULT, ""); + p = property("password", TypeEditor.PasswordEditor); + p.setValue(NOT_UNDEFINED, Boolean.TRUE); + p.setValue(DEFAULT, ""); + p = property("source"); + p.setValue(NOT_UNDEFINED, Boolean.TRUE); + p.setValue(DEFAULT, ""); + + p = property("script"); + p.setValue(NOT_UNDEFINED, Boolean.FALSE); + p.setValue(DEFAULT, ""); + p.setValue(NOT_EXPRESSION, Boolean.TRUE); + p.setPropertyEditorClass(TextAreaEditor.class); + + if(log.isDebugEnabled()) { + for (PropertyDescriptor pd : getPropertyDescriptors()) { + log.debug(pd.getName()); + log.debug(pd.getDisplayName()); + } + } + } +} \ No newline at end of file Propchange: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSamplerBeanInfo.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSamplerResources.properties URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSamplerResources.properties?rev=1451961&view=auto ============================================================================== --- jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSamplerResources.properties (added) +++ jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSamplerResources.properties Sat Mar 2 23:45:21 2013 @@ -0,0 +1,14 @@ +displayName=MongoDB Script +mongodb.displayName=MongoDB Connection +mongodb.shortDescription=Configure the connection + +source.displayName=MongoDB Source +source.shortDescription=Configure the Source + +database.displayName=Database Name +username.displayName=Username +password.displayName=Password + +sampler.displayName=Script +script.displayName=The script to run +script.shortDescription=Add your mongo shell script as you would via the mongo shell. Propchange: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSamplerResources.properties ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSamplerResources_fr.properties URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSamplerResources_fr.properties?rev=1451961&view=auto ============================================================================== --- jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSamplerResources_fr.properties (added) +++ jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSamplerResources_fr.properties Sat Mar 2 23:45:21 2013 @@ -0,0 +1,14 @@ +displayName=MongoDB Script +mongodb.displayName=MongoDB Connection +mongodb.shortDescription=Configure the connection + +source.displayName=MongoDB Source +source.shortDescription=Configure the Source + +database.displayName=Database Name +username.displayName=Username +password.displayName=Password + +sampler.displayName=Script +script.displayName=The script to run +script.shortDescription=Add your mongo shell script as you would via the mongo shell. Propchange: jmeter/trunk/src/protocol/mongodb/org/apache/jmeter/protocol/mongodb/sampler/MongoScriptSamplerResources_fr.properties ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: jmeter/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1451961&r1=1451960&r2=1451961&view=diff ============================================================================== --- jmeter/trunk/xdocs/changes.xml (original) +++ jmeter/trunk/xdocs/changes.xml Sat Mar 2 23:45:21 2013 @@ -167,6 +167,7 @@ This does not affect JMeter operation.

General

    +
  • 54584 - MongoDB plugin

Non-functional changes

Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1451961&r1=1451960&r2=1451961&view=diff ============================================================================== --- jmeter/trunk/xdocs/usermanual/component_reference.xml (original) +++ jmeter/trunk/xdocs/usermanual/component_reference.xml Sat Mar 2 23:45:21 2013 @@ -1862,6 +1862,17 @@ If omitted, output is captured and retur Expected return code for System Call, required if "Check Return Code" is checked. + + +TODO + + + + + + + + ^ @@ -3921,6 +3932,16 @@ GUI that they can use while developing n + + +TODO + + + + + + + ^