Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js Tue Jan 27 15:00:13 2015 @@ -44,6 +44,7 @@ define(["dojo/_base/xhr", "dijit/form/Form", "dijit/form/CheckBox", "dijit/form/RadioButton", + "dojox/form/Uploader", "dojox/validate/us", "dojox/validate/web", "dojo/domReady!"], @@ -61,6 +62,9 @@ define(["dojo/_base/xhr", var virtualHostNodeName = registry.byId("addVirtualHostNode.nodeName"); virtualHostNodeName.set("regExpGen", util.nameOrContextVarRegexp); + // Readers are HTML5 + this.reader = window.FileReader ? new FileReader() : undefined; + this.dialog = registry.byId("addVirtualHostNodeAndVirtualHost"); this.addButton = registry.byId("addVirtualHostNodeAndVirtualHost.addButton"); this.cancelButton = registry.byId("addVirtualHostNodeAndVirtualHost.cancelButton"); @@ -68,34 +72,51 @@ define(["dojo/_base/xhr", this.addButton.on("click", function(e){that._add(e);}); this.virtualHostNodeTypeFieldsContainer = dom.byId("addVirtualHostNode.typeFields"); + this.virtualHostNodeSelectedFileContainer = dom.byId("addVirtualHostNode.selectedFile"); + this.virtualHostNodeSelectedFileStatusContainer = dom.byId("addVirtualHostNode.selectedFileStatus"); + this.virtualHostNodeUploadFields = dom.byId("addVirtualHostNode.uploadFields"); + this.virtualHostNodeFileFields = dom.byId("addVirtualHostNode.fileFields"); + this.virtualHostNodeForm = registry.byId("addVirtualHostNode.form"); this.virtualHostNodeType = registry.byId("addVirtualHostNode.type"); + this.virtualHostNodeFileCheck = registry.byId("addVirtualHostNode.upload"); + this.virtualHostNodeFile = registry.byId("addVirtualHostNode.file"); + this.virtualHostNodeType.set("disabled", true); this.virtualHostTypeFieldsContainer = dom.byId("addVirtualHost.typeFields"); this.virtualHostForm = registry.byId("addVirtualHost.form"); this.virtualHostType = registry.byId("addVirtualHost.type"); + this.virtualHostType.set("disabled", true); - this.supportedVirtualHostNodeTypes = metadata.getTypesForCategory("VirtualHostNode"); - this.supportedVirtualHostNodeTypes.sort(); - this.supportedVirtualHostTypes = metadata.getTypesForCategory("VirtualHost"); - this.supportedVirtualHostTypes.sort(); - - //VH Type BDB_HA_REPLICA is not user creatable. This is only needed until we have model meta data available. - this.supportedVirtualHostTypes = array.filter(this.supportedVirtualHostTypes, function(item){ - return item != "BDB_HA_REPLICA" && item != "BDB_HA"; - }); + var supportedVirtualHostNodeTypes = metadata.getTypesForCategory("VirtualHostNode"); + supportedVirtualHostNodeTypes.sort(); - var virtualHostNodeTypeStore = util.makeTypeStore(this.supportedVirtualHostNodeTypes); + var virtualHostNodeTypeStore = util.makeTypeStore(supportedVirtualHostNodeTypes); this.virtualHostNodeType.set("store", virtualHostNodeTypeStore); this.virtualHostNodeType.set("disabled", false); this.virtualHostNodeType.on("change", function(type){that._vhnTypeChanged(type, that.virtualHostNodeTypeFieldsContainer, "qpid/management/virtualhostnode/");}); - this.virtualHostTypeStore = util.makeTypeStore(this.supportedVirtualHostTypes); - this.virtualHostType.set("store", this.virtualHostTypeStore); - this.virtualHostType.set("disabled", false); + this.virtualHostType.set("disabled", true); this.virtualHostType.on("change", function(type){that._vhTypeChanged(type, that.virtualHostTypeFieldsContainer, "qpid/management/virtualhost/");}); + + if (this.reader) + { + this.reader.onload = function(evt) {that._vhnUploadFileComplete(evt);}; + this.reader.onerror = function(ex) {console.error("Failed to load JSON file", ex);}; + this.virtualHostNodeFile.on("change", function(selected){that._vhnFileChanged(selected)}); + this.virtualHostNodeFileCheck.on("change", function(selected){that._vhnFileFlagChanged(selected)}); + } + else + { + // Fall back for IE8/9 which do not support FileReader + this.virtualHostNodeFileCheck.set("disabled", "disabled"); + this.virtualHostNodeFileCheck.set("title", "Requires a more recent browser with HTML5 support"); + this.virtualHostNodeFileFields.style.display = "none"; + } + + this.virtualHostNodeUploadFields.style.display = "none"; }, show: function() { @@ -161,8 +182,29 @@ define(["dojo/_base/xhr", }, _vhnTypeChanged: function (type, typeFieldsContainer, urlStem) { - this._processDropDownsForBdbHa(type); - this._processDropDownsForJson(type); + var validChildTypes = metadata.validChildTypes("VirtualHostNode", type, "VirtualHost"); + validChildTypes.sort(); + + var virtualHostTypeStore = util.makeTypeStore( validChildTypes ); + + this.virtualHostType.set("store", virtualHostTypeStore); + this.virtualHostType.set("disabled", validChildTypes.length <= 1); + if (validChildTypes.length == 1) + { + this.virtualHostType.set("value", validChildTypes[0]); + } + else + { + this.virtualHostType.reset(); + } + + var vhnTypeSelected = !(type == ''); + this.virtualHostNodeUploadFields.style.display = vhnTypeSelected ? "block" : "none"; + + if (!vhnTypeSelected) + { + this._vhnFileFlagChanged(false); + } this._typeChanged(type, typeFieldsContainer, urlStem, "VirtualHostNode"); }, @@ -203,52 +245,43 @@ define(["dojo/_base/xhr", ); } }, - _processDropDownsForBdbHa: function (type) + _vhnFileFlagChanged: function (selected) { - if (type == "BDB_HA") - { - this.virtualHostType.set("disabled", true); - if (!this.virtualHostTypeStore.get("BDB_HA")) - { - this.virtualHostTypeStore.add({id: "BDB_HA", name: "BDB_HA"}); - } - this.virtualHostType.set("value", "BDB_HA"); - } - else - { - if (this.virtualHostTypeStore.get("BDB_HA")) - { - this.virtualHostTypeStore.remove("BDB_HA"); - } - this.virtualHostType.set("value", ""); - - this.virtualHostType.set("disabled", false); - } + this.virtualHostForm.domNode.style.display = selected ? "none" : "block"; + this.virtualHostNodeFileFields.style.display = selected ? "block" : "none"; + this.virtualHostType.set("required", !selected); + this.virtualHostNodeFile.reset(); + this.virtualHostInitialConfiguration = undefined; + this.virtualHostNodeSelectedFileContainer.innerHTML = ""; + this.virtualHostNodeSelectedFileStatusContainer.className = ""; + }, + _vhnFileChanged: function (evt) + { + // We only ever expect a single file + var file = this.virtualHostNodeFile.domNode.children[0].files[0]; + + this.addButton.set("disabled", true); + this.virtualHostNodeSelectedFileContainer.innerHTML = file.name; + this.virtualHostNodeSelectedFileStatusContainer.className = "loadingIcon"; + + console.log("Beginning to read file " + file.name); + this.reader.readAsDataURL(file); + }, + _vhnUploadFileComplete: function(evt) + { + var reader = evt.target; + var result = reader.result; + console.log("File read complete, contents " + result); + this.virtualHostInitialConfiguration = result; + this.addButton.set("disabled", false); + this.virtualHostNodeSelectedFileStatusContainer.className = "loadedIcon"; }, - _processDropDownsForJson: function (type) + _cancel: function(e) { - if (type == "JSON") - { - if (this.virtualHostType.value == "ProvidedStore") + if (this.reader) { - this.virtualHostType.set("value", ""); + this.reader.abort(); } - - if (this.virtualHostTypeStore.get("ProvidedStore")) - { - this.virtualHostTypeStore.remove("ProvidedStore"); - } - } - else - { - if (!this.virtualHostTypeStore.get("ProvidedStore")) - { - this.virtualHostTypeStore.add({id: "ProvidedStore", name: "ProvidedStore"}); - } - } - }, - _cancel: function(e) - { this.dialog.hide(); }, _add: function(e) @@ -258,16 +291,32 @@ define(["dojo/_base/xhr", }, _submit: function() { - if(this.virtualHostNodeForm.validate() && this.virtualHostForm.validate()) + + var uploadVHConfig = this.virtualHostNodeFileCheck.get("checked"); + var virtualHostNodeData = undefined; + + if (uploadVHConfig && this.virtualHostNodeFile.getFileList().length > 0 && this.virtualHostNodeForm.validate()) { - var success = false,failureReason=null; + // VH config is being uploaded + virtualHostNodeData = this._getValues(this.virtualHostNodeForm); + var virtualHostNodeContext = this.virtualHostNodeContext.get("value"); + if (virtualHostNodeContext) + { + virtualHostNodeData["context"] = virtualHostNodeContext; + } - var virtualHostNodeData = this._getValues(this.virtualHostNodeForm); + // Add the loaded virtualhost configuration + virtualHostNodeData["virtualHostInitialConfiguration"] = this.virtualHostInitialConfiguration; + } + else if (!uploadVHConfig && this.virtualHostNodeForm.validate() && this.virtualHostForm.validate()) + { + virtualHostNodeData = this._getValues(this.virtualHostNodeForm); var virtualHostNodeContext = this.virtualHostNodeContext.get("value"); if (virtualHostNodeContext) { virtualHostNodeData["context"] = virtualHostNodeContext; } + var virtualHostData = this._getValues(this.virtualHostForm); var virtualHostContext = this.virtualHostContext.get("value"); if (virtualHostContext) @@ -278,48 +327,35 @@ define(["dojo/_base/xhr", //Default the VH name to be the same as the VHN name. virtualHostData["name"] = virtualHostNodeData["name"]; - var encodedVirtualHostNodeName = encodeURIComponent(virtualHostNodeData.name); - xhr.put({ - url: "api/latest/virtualhostnode/" + encodedVirtualHostNodeName, - sync: true, - handleAs: "json", - headers: { "Content-Type": "application/json"}, - putData: json.stringify(virtualHostNodeData), - load: function(x) {success = true; }, - error: function(error) {success = false; failureReason = error;} - }); + virtualHostNodeData["virtualHostInitialConfiguration"] = json.stringify(virtualHostData) - if(success === true && virtualHostNodeData["type"] != "BDB_HA") - { - var encodedVirtualHostName = encodeURIComponent(virtualHostData.name); - xhr.put({ - url: "api/latest/virtualhost/" + encodedVirtualHostNodeName + "/" + encodedVirtualHostName, - sync: true, - handleAs: "json", - headers: { "Content-Type": "application/json"}, - putData: json.stringify(virtualHostData), - load: function (x) { - success = true; - }, - error: function (error) { - success = false; - failureReason = error; - } - }); - } + } + else + { + alert('Form contains invalid data. Please correct first'); + return; + } - if (success == true) - { - this.dialog.hide(); - } - else - { - util.xhrErrorHandler(failureReason); - } + var success = false,failureReason=null; + + var encodedVirtualHostNodeName = encodeURIComponent(virtualHostNodeData.name); + xhr.put({ + url: "api/latest/virtualhostnode/" + encodedVirtualHostNodeName, + sync: true, + handleAs: "json", + headers: { "Content-Type": "application/json"}, + putData: json.stringify(virtualHostNodeData), + load: function(x) {success = true; }, + error: function(error) {success = false; failureReason = error;} + }); + + if (success == true) + { + this.dialog.hide(); } else { - alert('Form contains invalid data. Please correct first'); + util.xhrErrorHandler(failureReason); } }, _getValues: function (form)
Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/management-http/src/main/java/resources/showVirtualHost.html URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/management-http/src/main/java/resources/showVirtualHost.html?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/management-http/src/main/java/resources/showVirtualHost.html (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/management-http/src/main/java/resources/showVirtualHost.html Tue Jan 27 15:00:13 2015 @@ -114,6 +114,7 @@ <button data-dojo-type="dijit.form.Button" class="startButton" type="button" data-dojo-props="disabled: true">Start</button> <button data-dojo-type="dijit.form.Button" class="stopButton" type="button" data-dojo-props="disabled: true">Stop</button> <button data-dojo-type="dijit.form.Button" class="editButton" type="button" data-dojo-props="disabled: true">Edit</button> + <button data-dojo-type="dijit.form.Button" class="downloadButton" type="button" data-dojo-props="disabled: true">Download</button> <button data-dojo-type="dijit.form.Button" class="deleteButton" data-dojo-props="iconClass: 'dijitIconDelete'">Delete</button> </div> Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/store/MemorySystemConfigImpl.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/store/MemorySystemConfigImpl.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/store/MemorySystemConfigImpl.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/store/MemorySystemConfigImpl.java Tue Jan 27 15:00:13 2015 @@ -20,7 +20,8 @@ */ package org.apache.qpid.server.store; -import org.apache.qpid.server.BrokerOptions; +import java.util.Map; + import org.apache.qpid.server.configuration.updater.TaskExecutor; import org.apache.qpid.server.logging.EventLogger; import org.apache.qpid.server.logging.LogRecorder; @@ -40,10 +41,10 @@ public class MemorySystemConfigImpl exte public MemorySystemConfigImpl(final TaskExecutor taskExecutor, final EventLogger eventLogger, final LogRecorder logRecorder, - final BrokerOptions brokerOptions, + final Map<String,Object> attributes, final BrokerShutdownProvider brokerShutdownProvider) { - super(taskExecutor, eventLogger, logRecorder, brokerOptions, brokerShutdownProvider); + super(taskExecutor, eventLogger, logRecorder, attributes, brokerShutdownProvider); } @Override Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhostnode/memory/MemoryVirtualHostNode.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhostnode/memory/MemoryVirtualHostNode.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhostnode/memory/MemoryVirtualHostNode.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhostnode/memory/MemoryVirtualHostNode.java Tue Jan 27 15:00:13 2015 @@ -20,6 +20,8 @@ */ package org.apache.qpid.server.virtualhostnode.memory; +import java.util.Collection; +import java.util.Collections; import java.util.Map; import org.apache.qpid.server.model.Broker; @@ -30,7 +32,7 @@ import org.apache.qpid.server.store.Dura import org.apache.qpid.server.store.MemoryConfigurationStore; import org.apache.qpid.server.virtualhostnode.AbstractStandardVirtualHostNode; -@ManagedObject(type=MemoryVirtualHostNode.VIRTUAL_HOST_NODE_TYPE, category=false) +@ManagedObject(type=MemoryVirtualHostNode.VIRTUAL_HOST_NODE_TYPE, category=false, validChildTypes = "org.apache.qpid.server.virtualhostnode.memory.MemoryVirtualHostNode#getSupportedChildTypes()") public class MemoryVirtualHostNode extends AbstractStandardVirtualHostNode<MemoryVirtualHostNode> { public static final String VIRTUAL_HOST_NODE_TYPE = "Memory"; @@ -51,4 +53,9 @@ public class MemoryVirtualHostNode exten { return new MemoryConfigurationStore(VirtualHost.class); } + + public static Map<String, Collection<String>> getSupportedChildTypes() + { + return Collections.singletonMap(VirtualHost.class.getSimpleName(), getSupportedVirtualHostTypes(true)); + } } Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java Tue Jan 27 15:00:13 2015 @@ -41,6 +41,7 @@ import org.apache.log4j.Logger; import org.apache.qpid.common.QpidProperties; import org.apache.qpid.framing.ProtocolVersion; import org.apache.qpid.server.configuration.IllegalConfigurationException; +import org.apache.qpid.server.util.Action; import org.apache.qpid.util.FileUtils; /** @@ -454,7 +455,17 @@ public class Main protected void startBroker(final BrokerOptions options) throws Exception { - Broker broker = new Broker(true); + Broker broker = new Broker(new Action<Integer>() + { + @Override + public void performAction(final Integer exitStatusCode) + { + if (exitStatusCode != 0) + { + shutdown(exitStatusCode); + } + } + }); broker.startup(options); } Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/example/src/main/java/org/apache/qpid/example/Hello.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/example/src/main/java/org/apache/qpid/example/Hello.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/example/src/main/java/org/apache/qpid/example/Hello.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/example/src/main/java/org/apache/qpid/example/Hello.java Tue Jan 27 15:00:13 2015 @@ -42,7 +42,7 @@ public class Hello { } - public static void main(String[] args) + public static void main(String[] args) { Hello hello = new Hello(); hello.runTest(); Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java Tue Jan 27 15:00:13 2015 @@ -21,16 +21,20 @@ package org.apache.qpid.client; import java.net.ConnectException; +import java.nio.ByteBuffer; import java.nio.channels.UnresolvedAddressException; import java.text.MessageFormat; import java.util.ArrayList; import java.util.EnumSet; import java.util.Iterator; import java.util.Set; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; import javax.jms.JMSException; import javax.jms.XASession; +import org.apache.qpid.transport.Receiver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -67,6 +71,9 @@ public class AMQConnectionDelegate_8_0 i { private static final Logger _logger = LoggerFactory.getLogger(AMQConnectionDelegate_8_0.class); private final AMQConnection _conn; + private final long _timeout = Long.getLong(ClientProperties.QPID_SYNC_OP_TIMEOUT, + Long.getLong(ClientProperties.AMQJ_DEFAULT_SYNCWRITE_TIMEOUT, + ClientProperties.DEFAULT_SYNC_OPERATION_TIMEOUT)); private boolean _messageCompressionSupported; private boolean _addrSyntaxSupported; private boolean _confirmedPublishSupported; @@ -136,7 +143,9 @@ public class AMQConnectionDelegate_8_0 i OutgoingNetworkTransport transport = Transport.getOutgoingTransportInstance(getProtocolVersion()); - NetworkConnection network = transport.connect(settings, securityLayer.receiver(_conn.getProtocolHandler()), + ReceiverClosedWaiter monitoringReceiver = new ReceiverClosedWaiter(securityLayer.receiver(_conn.getProtocolHandler())); + + NetworkConnection network = transport.connect(settings, monitoringReceiver, _conn.getProtocolHandler()); try @@ -171,6 +180,19 @@ public class AMQConnectionDelegate_8_0 i network.close(); throw e; } + finally + { + // await the receiver to finish its execution (and so the IO threads too) + if (!_conn.isConnected()) + { + boolean closedWithinTimeout = monitoringReceiver.awaitClose(_timeout); + if (!closedWithinTimeout) + { + _logger.warn("Timed-out waiting for receiver for connection to " + + brokerDetail + " to be closed."); + } + } + } } @@ -503,4 +525,60 @@ public class AMQConnectionDelegate_8_0 i { return _confirmedPublishNonTransactionalSupported; } + + + private static class ReceiverClosedWaiter implements Receiver<ByteBuffer> + { + private final CountDownLatch _closedWatcher; + private final Receiver<ByteBuffer> _receiver; + + public ReceiverClosedWaiter(Receiver<ByteBuffer> receiver) + { + _receiver = receiver; + _closedWatcher = new CountDownLatch(1); + } + + @Override + public void received(ByteBuffer msg) + { + _receiver.received(msg); + } + + @Override + public void exception(Throwable t) + { + _receiver.exception(t); + } + + @Override + public void closed() + { + try + { + _receiver.closed(); + } + finally + { + _closedWatcher.countDown(); + } + } + + public boolean awaitClose(long timeout) + { + try + { + if (_logger.isDebugEnabled()) + { + _logger.debug("Waiting " + timeout + "ms for receiver to be closed"); + } + + return _closedWatcher.await(timeout, TimeUnit.MILLISECONDS); + } + catch (InterruptedException e) + { + Thread.currentThread().interrupt(); + return _closedWatcher.getCount() == 0; + } + } + }; } Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSession_0_8.java Tue Jan 27 15:00:13 2015 @@ -824,12 +824,13 @@ public class AMQSession_0_8 extends AMQS throws AMQException, FailoverException { _currentPrefetch.set(0); - BasicQosBody basicQosBody = getProtocolHandler().getMethodRegistry().createBasicQosBody(sizePrefetch, messagePrefetch, false); - - // todo send low water mark when protocol allows. - // todo Be aware of possible changes to parameter order as versions change. - getProtocolHandler().syncWrite(basicQosBody.generateFrame(getChannelId()), BasicQosOkBody.class); + if(messagePrefetch > 0 || sizePrefetch > 0) + { + BasicQosBody basicQosBody = + getProtocolHandler().getMethodRegistry().createBasicQosBody(sizePrefetch, messagePrefetch, false); + getProtocolHandler().syncWrite(basicQosBody.generateFrame(getChannelId()), BasicQosOkBody.class); + } } @@ -842,13 +843,17 @@ public class AMQSession_0_8 extends AMQS public Boolean execute() throws AMQException, FailoverException { int currentPrefetch = _currentPrefetch.get(); - if (currentPrefetch >= getPrefetch()) + if (currentPrefetch >= getPrefetch() && getPrefetch() >= 0) { BasicQosBody basicQosBody = getProtocolHandler().getMethodRegistry() .createBasicQosBody(0, currentPrefetch + 1, false); getProtocolHandler().syncWrite(basicQosBody.generateFrame(getChannelId()), BasicQosOkBody.class); + if(currentPrefetch == 0 && !isSuspended()) + { + sendSuspendChannel(false); + } _creditChanged.set(true); return true; } @@ -863,8 +868,7 @@ public class AMQSession_0_8 extends AMQS protected void reduceCreditAfterAcknowledge() throws AMQException { - int acknowledgeMode = getAcknowledgeMode(); - boolean manageCredit = acknowledgeMode == javax.jms.Session.CLIENT_ACKNOWLEDGE || acknowledgeMode == javax.jms.Session.SESSION_TRANSACTED; + boolean manageCredit = isManagingCredit(); if(manageCredit && _creditChanged.compareAndSet(true,false)) { @@ -873,18 +877,40 @@ public class AMQSession_0_8 extends AMQS { public Void execute() throws AMQException, FailoverException { - BasicQosBody basicQosBody = - getProtocolHandler().getMethodRegistry() - .createBasicQosBody(0, getPrefetch(), false); + int prefetch = getPrefetch(); + if(prefetch == 0) + { + sendSuspendChannel(true); + } + else + { + BasicQosBody basicQosBody = + getProtocolHandler().getMethodRegistry() + .createBasicQosBody(0, prefetch == -1 ? 0 : prefetch, false); - getProtocolHandler().syncWrite(basicQosBody.generateFrame(getChannelId()), - BasicQosOkBody.class); + getProtocolHandler().syncWrite(basicQosBody.generateFrame(getChannelId()), + BasicQosOkBody.class); + } return null; } }, getProtocolHandler().getConnection()).execute(); } } + protected void reduceCreditInPostDeliver() + { + int acknowledgeMode = getAcknowledgeMode(); + boolean manageCredit = (acknowledgeMode == AUTO_ACKNOWLEDGE || acknowledgeMode == DUPS_OK_ACKNOWLEDGE) && getPrefetch() == 0; + + if(manageCredit && _creditChanged.compareAndSet(true,false)) + { + ChannelFlowBody body = getMethodRegistry().createChannelFlowBody(false); + AMQFrame channelFlowFrame = body.generateFrame(getChannelId()); + getProtocolHandler().writeFrame(channelFlowFrame, true); + } + } + + protected void updateCurrentPrefetch(int delta) { _currentPrefetch.addAndGet(delta); @@ -1414,6 +1440,15 @@ public class AMQSession_0_8 extends AMQS } } + boolean isManagingCredit() + { + int acknowledgeMode = getAcknowledgeMode(); + return acknowledgeMode == CLIENT_ACKNOWLEDGE + || acknowledgeMode == SESSION_TRANSACTED + || ((acknowledgeMode == AUTO_ACKNOWLEDGE || acknowledgeMode == DUPS_OK_ACKNOWLEDGE) && getPrefetch() == 0); + } + + public boolean isFlowBlocked() { synchronized (_flowControl) Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer.java Tue Jan 27 15:00:13 2015 @@ -645,6 +645,12 @@ public abstract class BasicMessageConsum _receivingThread.interrupt(); } + + + if(!(isBrowseOnly() || getSession().isClosing())) + { + rollback(); + } } } Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_8.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_8.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_8.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/BasicMessageConsumer_0_8.java Tue Jan 27 15:00:13 2015 @@ -170,8 +170,7 @@ public class BasicMessageConsumer_0_8 ex @Override public Message receive(final long l) throws JMSException { - int acknowledgeMode = getSession().getAcknowledgeMode(); - boolean manageCredit = acknowledgeMode == Session.CLIENT_ACKNOWLEDGE || acknowledgeMode == Session.SESSION_TRANSACTED; + boolean manageCredit = getSession().isManagingCredit(); boolean creditModified = false; try { @@ -184,7 +183,8 @@ public class BasicMessageConsumer_0_8 ex { getSession().reduceCreditAfterAcknowledge(); } - if (manageCredit && message != null) + if (manageCredit && !(getSession().getAcknowledgeMode() == Session.AUTO_ACKNOWLEDGE + || getSession().getAcknowledgeMode() == Session.DUPS_OK_ACKNOWLEDGE) && message != null) { getSession().updateCurrentPrefetch(1); } @@ -199,8 +199,7 @@ public class BasicMessageConsumer_0_8 ex @Override public Message receiveNoWait() throws JMSException { - int acknowledgeMode = getSession().getAcknowledgeMode(); - boolean manageCredit = acknowledgeMode == Session.CLIENT_ACKNOWLEDGE || acknowledgeMode == Session.SESSION_TRANSACTED; + boolean manageCredit = getSession().isManagingCredit(); boolean creditModified = false; try { @@ -217,7 +216,8 @@ public class BasicMessageConsumer_0_8 ex { getSession().reduceCreditAfterAcknowledge(); } - if (manageCredit && message != null) + if (manageCredit && !(getSession().getAcknowledgeMode() == Session.AUTO_ACKNOWLEDGE + || getSession().getAcknowledgeMode() == Session.DUPS_OK_ACKNOWLEDGE) && message != null) { getSession().updateCurrentPrefetch(1); } @@ -228,4 +228,11 @@ public class BasicMessageConsumer_0_8 ex throw new JMSAMQException(e); } } + + + void postDeliver(AbstractJMSMessage msg) + { + getSession().reduceCreditInPostDeliver(); + super.postDeliver(msg); + } } Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java Tue Jan 27 15:00:13 2015 @@ -240,7 +240,7 @@ public class AMQProtocolHandler implemen } catch (Exception e) { - _logger.warn("Exception occured on closing the sender", e); + _logger.warn("Exception occurred on closing the sender", e); } if (_connection.failoverAllowed()) { Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java Tue Jan 27 15:00:13 2015 @@ -20,9 +20,6 @@ */ package org.apache.qpid.properties; -import java.lang.management.ManagementFactory; -import java.lang.management.RuntimeMXBean; - import org.apache.qpid.transport.util.Logger; import org.apache.qpid.util.SystemUtils; @@ -62,30 +59,18 @@ public class ConnectionStartProperties public static final String QPID_CONFIRMED_PUBLISH_SUPPORTED = "qpid.confirmed_publish_supported"; - public static int _pid; + public static final int _pid; public static final String _platformInfo; static { - RuntimeMXBean rtb = ManagementFactory.getRuntimeMXBean(); - String processName = rtb.getName(); - if (processName != null && processName.indexOf('@') > 0) - { - try - { - _pid = Integer.parseInt(processName.substring(0,processName.indexOf('@'))); - } - catch(Exception e) - { - LOGGER.warn("Unable to get the PID due to error",e); - _pid = -1; - } - } - else + + _pid = SystemUtils.getProcessPidAsInt(); + + if (_pid == -1) { - LOGGER.warn("Unable to get the PID due to unsupported format : " + processName); - _pid = -1; + LOGGER.warn("Unable to get the process's PID"); } StringBuilder fullSystemInfo = new StringBuilder(System.getProperty("java.runtime.name")); Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidClientX509KeyManager.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidClientX509KeyManager.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidClientX509KeyManager.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/QpidClientX509KeyManager.java Tue Jan 27 15:00:13 2015 @@ -27,6 +27,7 @@ import javax.net.ssl.SSLEngine; import javax.net.ssl.X509ExtendedKeyManager; import java.io.IOException; import java.net.Socket; +import java.net.URL; import java.security.GeneralSecurityException; import java.security.KeyStore; import java.security.Principal; @@ -48,6 +49,16 @@ public class QpidClientX509KeyManager ex KeyManagerFactory kmf = KeyManagerFactory.getInstance(keyManagerFactoryAlgorithmName); kmf.init(ks, keyStorePassword.toCharArray()); this.delegate = (X509ExtendedKeyManager)kmf.getKeyManagers()[0]; + } + + public QpidClientX509KeyManager(String alias, URL keyStoreUrl, String keyStoreType, + String keyStorePassword, String keyManagerFactoryAlgorithmName) throws GeneralSecurityException, IOException + { + this.alias = alias; + KeyStore ks = SSLUtil.getInitializedKeyStore(keyStoreUrl,keyStorePassword,keyStoreType); + KeyManagerFactory kmf = KeyManagerFactory.getInstance(keyManagerFactoryAlgorithmName); + kmf.init(ks, keyStorePassword.toCharArray()); + this.delegate = (X509ExtendedKeyManager)kmf.getKeyManagers()[0]; } public String chooseClientAlias(String[] keyType, Principal[] issuers, Socket socket) Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLUtil.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLUtil.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLUtil.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLUtil.java Tue Jan 27 15:00:13 2015 @@ -24,6 +24,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.net.URL; import java.security.GeneralSecurityException; import java.security.KeyStore; import java.security.Principal; @@ -247,6 +248,23 @@ public class SSLUtil } return ks; } + + public static KeyStore getInitializedKeyStore(URL storePath, String storePassword, String keyStoreType) throws GeneralSecurityException, IOException + { + KeyStore ks = KeyStore.getInstance(keyStoreType); + try(InputStream in = storePath.openStream()) + { + if (in == null && !"PKCS11".equalsIgnoreCase(keyStoreType)) // PKCS11 will not require an explicit path + { + throw new IOException("Unable to load keystore resource: " + storePath); + } + + char[] storeCharPassword = storePassword == null ? null : storePassword.toCharArray(); + + ks.load(in, storeCharPassword); + } + return ks; + } public static void removeSSLv3Support(final SSLEngine engine) { Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/util/FileUtils.java Tue Jan 27 15:00:13 2015 @@ -22,6 +22,7 @@ package org.apache.qpid.util; import java.io.BufferedInputStream; import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -51,39 +52,32 @@ public class FileUtils * * @return The contents of the file. */ - public static String readFileAsString(String filename) + public static byte[] readFileAsBytes(String filename) { - BufferedInputStream is = null; - try + try(BufferedInputStream is = new BufferedInputStream(new FileInputStream(filename))) { - try - { - is = new BufferedInputStream(new FileInputStream(filename)); - } - catch (FileNotFoundException e) - { - throw new RuntimeException(e); - } - return readStreamAsString(is); } - finally + catch (IOException e) { - if (is != null) - { - try - { - is.close(); - } - catch (IOException e) - { - throw new RuntimeException(e); - } - } + throw new RuntimeException(e); } } + + /** + * Reads a text file as a string. + * + * @param filename The name of the file. + * + * @return The contents of the file. + */ + public static String readFileAsString(String filename) + { + return new String(readFileAsBytes(filename)); + } + /** * Reads a text file as a string. * @@ -93,18 +87,15 @@ public class FileUtils */ public static String readFileAsString(File file) { - BufferedInputStream is = null; - - try + try(BufferedInputStream is = new BufferedInputStream(new FileInputStream(file))) { - is = new BufferedInputStream(new FileInputStream(file)); + + return new String(readStreamAsString(is)); } - catch (FileNotFoundException e) + catch (IOException e) { throw new RuntimeException(e); } - - return readStreamAsString(is); } /** @@ -115,23 +106,20 @@ public class FileUtils * * @return The contents of the reader. */ - private static String readStreamAsString(BufferedInputStream is) + private static byte[] readStreamAsString(BufferedInputStream is) { - try + try(ByteArrayOutputStream inBuffer = new ByteArrayOutputStream()) { byte[] data = new byte[4096]; - StringBuffer inBuffer = new StringBuffer(); - int read; while ((read = is.read(data)) != -1) { - String s = new String(data, 0, read); - inBuffer.append(s); + inBuffer.write(data, 0, read); } - return inBuffer.toString(); + return inBuffer.toByteArray(); } catch (IOException e) { Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/util/SystemUtils.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/util/SystemUtils.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/util/SystemUtils.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/common/src/main/java/org/apache/qpid/util/SystemUtils.java Tue Jan 27 15:00:13 2015 @@ -20,6 +20,9 @@ */ package org.apache.qpid.util; +import java.lang.management.ManagementFactory; +import java.lang.management.RuntimeMXBean; + /** * SystemUtils provides some simple helper methods for working with the current * Operating System. @@ -38,9 +41,29 @@ public class SystemUtils private static final String _osName = System.getProperty("os.name", UNKNOWN_OS); private static final String _osVersion = System.getProperty("os.version", UNKNOWN_VERSION); private static final String _osArch = System.getProperty("os.arch", UNKNOWN_ARCH); - private static final boolean _isWindows = _osName.toLowerCase().contains("windows"); + /** Process identifier of underlying process or null if it cannot be determined */ + private static final String _osPid; + private static int _osPidInt; + + static + { + RuntimeMXBean rtb = ManagementFactory.getRuntimeMXBean(); + String processName = rtb.getName(); + int atIndex; + if(processName != null && (atIndex = processName.indexOf('@')) > 0) + { + _osPid = processName.substring(0, atIndex); + _osPidInt = parseInt(_osPid, -1); + } + else + { + _osPid = null; + } + } + + private SystemUtils() { } @@ -60,6 +83,16 @@ public class SystemUtils return _osArch; } + public final static String getProcessPid() + { + return _osPid; + } + + public final static int getProcessPidAsInt() + { + return _osPidInt; + } + public final static boolean isWindows() { return _isWindows; @@ -78,4 +111,17 @@ public class SystemUtils { return _osName + " " + _osVersion + " " + _osArch; } + + private static int parseInt(String str, int defaultVal) + { + try + { + return Integer.parseInt(str); + } + catch(NumberFormatException e) + { + return defaultVal; + } + } + } Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/etc/chartdefs/1015-VaryingNumberOfProducers-SessionTrans.chartdef URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/etc/chartdefs/1015-VaryingNumberOfProducers-SessionTrans.chartdef?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/etc/chartdefs/1015-VaryingNumberOfProducers-SessionTrans.chartdef (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/etc/chartdefs/1015-VaryingNumberOfProducers-SessionTrans.chartdef Tue Jan 27 15:00:13 2015 @@ -20,7 +20,7 @@ chartType=XYLINE chartTitle=Varying number of producers - transacted chartSubtitle=Persistent 1KB messages -chartDescription=1,2,5,10 P/Cs, single queue, persistent, transacted, with message payload 1KB. +chartDescription=1,2,5,10,20,40 P/Cs, single queue, persistent, transacted, with message payload 1KB. xAxisTitle=Producers yAxisTitle=Throughput (messages/s) @@ -40,8 +40,18 @@ series.3.legend=10 Consumer series.3.dir=${csvCurrentDir} series.3.colourName=green -series.4.statement=SELECT totalNumberOfProducers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfConsumers = '1' and acknowledgeMode = '0' -series.4.legend=1 Consumer (baseline ${baselineName}) -series.4.dir=${csvBaselineDir} -series.4.colourName=dark_red -series.4.strokeWidth=-1 +series.4.statement=SELECT totalNumberOfProducers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfConsumers = '20' and acknowledgeMode = '0' +series.4.legend=20 Consumer +series.4.dir=${csvCurrentDir} +series.4.colourName=magenta + +series.5.statement=SELECT totalNumberOfProducers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfConsumers = '40' and acknowledgeMode = '0' +series.5.legend=40 Consumer +series.5.dir=${csvCurrentDir} +series.5.colourName=orange + +series.6.statement=SELECT totalNumberOfProducers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfConsumers = '1' and acknowledgeMode = '0' +series.6.legend=1 Consumer (baseline ${baselineName}) +series.6.dir=${csvBaselineDir} +series.6.colourName=dark_red +series.6.strokeWidth=-1 Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/etc/chartdefs/1016-VaryingNumberOfConsumers-SessionTrans.chartdef URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/etc/chartdefs/1016-VaryingNumberOfConsumers-SessionTrans.chartdef?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/etc/chartdefs/1016-VaryingNumberOfConsumers-SessionTrans.chartdef (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/etc/chartdefs/1016-VaryingNumberOfConsumers-SessionTrans.chartdef Tue Jan 27 15:00:13 2015 @@ -20,7 +20,7 @@ chartType=XYLINE chartTitle=Varying number of consumers - transacted chartSubtitle=Persistent 1KB messages -chartDescription=1,2,5,10 P/Cs, single queue, persistent, transacted, with message payload 1KB. +chartDescription=1,2,5,10,20,40 P/Cs, single queue, persistent, transacted, with message payload 1KB. xAxisTitle=Consumers yAxisTitle=Throughput (messages/s) @@ -40,8 +40,18 @@ series.3.legend=10 Producers series.3.dir=${csvCurrentDir} series.3.colourName=red -series.4.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfProducers = '10' and acknowledgeMode = '0' -series.4.legend=10 Producers (baseline ${baselineName}) -series.4.dir=${csvBaselineDir} -series.4.colourName=dark_red -series.4.strokeWidth=-1 +series.4.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfProducers = '20' and acknowledgeMode = '0' +series.4.legend=20 Producers +series.4.dir=${csvCurrentDir} +series.4.colourName=magenta + +series.5.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfProducers = '40' and acknowledgeMode = '0' +series.5.legend=40 Producers +series.5.dir=${csvCurrentDir} +series.5.colourName=yellow + +series.6.statement=SELECT totalNumberOfConsumers, throughputMessagesPerS FROM VaryingNumberOfParticipants WHERE participantName = 'All' and totalNumberOfProducers = '10' and acknowledgeMode = '0' +series.6.legend=10 Producers (baseline ${baselineName}) +series.6.dir=${csvBaselineDir} +series.6.colourName=dark_red +series.6.strokeWidth=-1 Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/etc/perftests-jndi.properties URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/etc/perftests-jndi.properties?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/etc/perftests-jndi.properties (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/etc/perftests-jndi.properties Tue Jan 27 15:00:13 2015 @@ -18,6 +18,7 @@ java.naming.factory.initial = org.apache.qpid.jndi.PropertiesFileInitialContextFactory connectionfactory.connectionfactory = amqp://guest:guest@clientid/?brokerlist='tcp://localhost:5672' +connectionfactory.sslconnectionfactory = amqp://guest:guest@clientid/?ssl='true'&brokerlist='tcp://localhost:5671' destination.controllerqueue = direct://amq.direct//controllerqueue?autodelete='true' Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/etc/testdefs/VaryingNumberOfParticipants.js URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/etc/testdefs/VaryingNumberOfParticipants.js?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/etc/testdefs/VaryingNumberOfParticipants.js (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/etc/testdefs/VaryingNumberOfParticipants.js Tue Jan 27 15:00:13 2015 @@ -25,8 +25,8 @@ var jsonObject = { var duration = 30000; var queueName = "direct://amq.direct//varNumOfParticipants?durable='true'"; -var numbersOfProducers = [1, 2, 5, 10]; -var numbersOfConsumers = [1, 2, 5, 10]; +var numbersOfProducers = [1, 2, 5, 10, 20, 40]; +var numbersOfConsumers = [1, 2, 5, 10, 20, 40]; for(producersIndex=0; producersIndex < numbersOfProducers.length; producersIndex++) { Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/visualisation-jfc/pom.xml URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/visualisation-jfc/pom.xml?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/visualisation-jfc/pom.xml (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/perftests/visualisation-jfc/pom.xml Tue Jan 27 15:00:13 2015 @@ -120,6 +120,52 @@ <skip>true</skip> </configuration> </plugin> + + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>1.3.2</version> + <executions> + <execution> + <goals> + <goal>java</goal> + </goals> + </execution> + </executions> + <configuration> + <mainClass>org.apache.qpid.disttest.charting.ChartingUtil</mainClass> + <includePluginDependencies>true</includePluginDependencies> + <arguments> + <argument>chart-defs=${basedir}/../etc/chartdefs</argument> + </arguments> + <systemProperties> + <systemProperty> + <key>log4j.configuration</key><value>file:log4j.properties</value> + </systemProperty> + <systemProperty> + <key>java.awt.headless</key><value>true</value> + </systemProperty> + <systemProperty> + <key>csvCurrentDir</key><value>${basedir}/../target/data/current</value> + </systemProperty> + <systemProperty> + <key>csvBaselineDir</key><value>${basedir}/../target/data/baseline</value> + </systemProperty> + </systemProperties> + </configuration> + <dependencies> + <dependency> + <groupId>net.sourceforge.csvjdbc</groupId> + <artifactId>csvjdbc</artifactId> + <version>${csvjdbc-version}</version> + </dependency> + <dependency> + <groupId>jfree</groupId> + <artifactId>jfreechart</artifactId> + <version>${jfreechart-version}</version> + </dependency> + </dependencies> + </plugin> </plugins> </build> Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/pom.xml URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/pom.xml?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/pom.xml (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/pom.xml Tue Jan 27 15:00:13 2015 @@ -54,7 +54,7 @@ <!-- test profile properties and defaults--> <qpid.home>${basedir}</qpid.home> <!-- override for broker tests --> - <qpid.home.qbtc.output>${qpid.home}${file.separator}target${file.separator}qbtc-output</qpid.home.qbtc.output> <!-- override for broker tests --> + <qpid.home.qbtc.output>${qpid.home}${file.separator}target${file.separator}qbtc-test-config</qpid.home.qbtc.output> <!-- override for broker tests --> <qpid.work>${project.build.directory}${file.separator}QPID_WORK</qpid.work> <profile>java-mms.0-10</profile> @@ -73,6 +73,7 @@ <profile.broker.clean.between.tests>true</profile.broker.clean.between.tests> <dollar.sign>$</dollar.sign> <at.sign>@</at.sign> + <bdb-version>5.0.104</bdb-version> </properties> <modules> @@ -218,9 +219,6 @@ <amqj.server.logging.level>debug</amqj.server.logging.level> <amqj.protocol.logging.level>debug</amqj.protocol.logging.level> <root.logging.level>warn</root.logging.level> - <log4j.configuration.file>${project.basedir}${file.separator}test-profiles${file.separator}log4j-test.xml</log4j.configuration.file> - <log4j.configuration>log4j-test.xml</log4j.configuration> - <log4j.debug>false</log4j.debug> <test.port>15672</test.port> <test.mport>18999</test.mport> <test.cport>19099</test.cport> Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/qpid-perftests-systests/pom.xml URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/qpid-perftests-systests/pom.xml?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/qpid-perftests-systests/pom.xml (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/qpid-perftests-systests/pom.xml Tue Jan 27 15:00:13 2015 @@ -110,6 +110,14 @@ </dependencies> <build> + <resources> + <resource> + <directory>src/main/resources</directory> + </resource> + <resource> + <directory>${test.resource.directory}/test-profiles/test_resources</directory> + </resource> + </resources> <testResources> <testResource> <directory>src/test/java</directory> Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/qpid-systests-parent/pom.xml URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/qpid-systests-parent/pom.xml?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/qpid-systests-parent/pom.xml (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/qpid-systests-parent/pom.xml Tue Jan 27 15:00:13 2015 @@ -34,8 +34,9 @@ <broker.home.dir>target${file.separator}qpid-broker${file.separator}${project.version}</broker.home.dir> <!-- test properties --> <qpid.home>${basedir}${file.separator}${broker.home.dir}</qpid.home> - <qpid.home.qbtc.output>${qpid.home}${file.separator}qbtc-output</qpid.home.qbtc.output> - <test.log4j.configuration.file>${project.basedir}${file.separator}..${file.separator}test-profiles${file.separator}log4j-test.xml</test.log4j.configuration.file> + <qpid.home.qbtc.output>${qpid.home}${file.separator}qbtc-test-config</qpid.home.qbtc.output> + <test.output.dir>${basedir}${file.separator}target${file.separator}surefire-reports</test.output.dir> + <test.working.directory>${basedir}/..</test.working.directory> <test.resource.directory>${basedir}/..</test.resource.directory> <test.systest.resource.directory>${basedir}</test.systest.resource.directory> @@ -83,7 +84,14 @@ integration-test phase below instead --> <skip>true</skip> <systemPropertyVariables> - <log4j.configuration.file>${test.log4j.configuration.file}</log4j.configuration.file> + <test.output.dir>${test.output.dir}</test.output.dir> + <log4j.configuration.file>${basedir}${file.separator}target${file.separator}classes/log4j.xml</log4j.configuration.file> + <!-- Let the tests themselves configure logging so that we can have a separate log file per test + named after the test. --> + <log4j.debug>false</log4j.debug> + <log4j.defaultInitOverride>true</log4j.defaultInitOverride> + <!-- A log4j config file that sends all the Broker's output to stdout --> + <spawnedbroker.log4j.configuration.file>${basedir}${file.separator}target${file.separator}classes/spawned-broker-log4j.xml</spawnedbroker.log4j.configuration.file> </systemPropertyVariables> </configuration> <executions> Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java Tue Jan 27 15:00:13 2015 @@ -46,7 +46,7 @@ public class QpidTestCase extends TestCa public static final String TEST_RESOURCES_DIR = QPID_HOME + "/../test-profiles/test_resources/"; public static final String TEST_PROFILES_DIR = QPID_HOME + "/../test-profiles/"; public static final String TMP_FOLDER = System.getProperty("java.io.tmpdir"); - public static final String LOG4J_CONFIG_FILE_PATH = System.getProperty("log4j.configuration.file"); + public static final String SPAWNED_BROKER_LOG4J_CONFIG_FILE_PATH = System.getProperty("spawnedbroker.log4j.configuration.file"); private static final Logger _logger = Logger.getLogger(QpidTestCase.class); Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/TestSSLConstants.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/TestSSLConstants.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/TestSSLConstants.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/qpid-test-utils/src/main/java/org/apache/qpid/test/utils/TestSSLConstants.java Tue Jan 27 15:00:13 2015 @@ -28,6 +28,7 @@ public interface TestSSLConstants String BROKER_KEYSTORE = "test-profiles/test_resources/ssl/java_broker_keystore.jks"; String BROKER_KEYSTORE_PASSWORD = "password"; + Object BROKER_KEYSTORE_ALIAS = "rootca"; String BROKER_PEERSTORE = "test-profiles/test_resources/ssl/java_broker_peerstore.jks"; String BROKER_PEERSTORE_PASSWORD = "password"; Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/pom.xml URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/pom.xml?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/pom.xml (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/pom.xml Tue Jan 27 15:00:13 2015 @@ -189,4 +189,15 @@ </dependencies> + <build> + <resources> + <resource> + <directory>src/main/resources</directory> + </resource> + <resource> + <directory>${test.resource.directory}/test-profiles/test_resources</directory> + </resource> + </resources> + </build> + </project> Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/Asserts.java Tue Jan 27 15:00:13 2015 @@ -76,7 +76,6 @@ public class Asserts ConfiguredObject.DESCRIPTION, ConfiguredObject.CONTEXT, ConfiguredObject.DESIRED_STATE, - VirtualHost.SUPPORTED_QUEUE_TYPES, VirtualHost.TYPE); assertEquals("Unexpected value of attribute " + VirtualHost.NAME, @@ -93,12 +92,6 @@ public class Asserts virtualHost.get(VirtualHost.QUEUE_DEAD_LETTER_QUEUE_ENABLED)); @SuppressWarnings("unchecked") - Collection<String> exchangeTypes = (Collection<String>) virtualHost.get(VirtualHost.SUPPORTED_EXCHANGE_TYPES); - assertEquals("Unexpected value of attribute " + VirtualHost.SUPPORTED_EXCHANGE_TYPES, - new HashSet<String>(Arrays.asList("headers", "topic", "direct", "fanout")), - new HashSet<String>(exchangeTypes)); - - @SuppressWarnings("unchecked") Map<String, Object> statistics = (Map<String, Object>) virtualHost.get(STATISTICS_ATTRIBUTE); Asserts.assertAttributesPresent(statistics, "queueCount","exchangeCount","bytesIn","bytesOut","messagesIn", "messagesOut"); Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/BrokerHolder.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/BrokerHolder.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/BrokerHolder.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/BrokerHolder.java Tue Jan 27 15:00:13 2015 @@ -20,10 +20,19 @@ */ package org.apache.qpid.test.utils; +import org.apache.qpid.server.BrokerOptions; + public interface BrokerHolder { - String getWorkingDirectory(); + public void start(BrokerOptions options) throws Exception; void shutdown(); void kill(); String dumpThreads(); + + enum BrokerType + { + EXTERNAL /** Test case relies on a Broker started independently of the test-suite */, + INTERNAL /** Test case starts an embedded broker within this JVM */, + SPAWNED /** Test case spawns a new broker as a separate process */ + } } Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/InternalBrokerHolder.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/InternalBrokerHolder.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/InternalBrokerHolder.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/InternalBrokerHolder.java Tue Jan 27 15:00:13 2015 @@ -21,12 +21,13 @@ package org.apache.qpid.test.utils; import java.security.PrivilegedAction; +import java.util.Map; import java.util.Set; import org.apache.log4j.Logger; import org.apache.qpid.server.Broker; -import org.apache.qpid.server.security.auth.TaskPrincipal; +import org.apache.qpid.server.BrokerOptions; import org.apache.qpid.server.security.SecurityManager; import javax.security.auth.Subject; @@ -35,27 +36,22 @@ public class InternalBrokerHolder implem { private static final Logger LOGGER = Logger.getLogger(InternalBrokerHolder.class); - private final Broker _broker; - private final String _workingDirectory; + private Broker _broker; private Set<Integer> _portsUsedByBroker; - public InternalBrokerHolder(final Broker broker, String workingDirectory, Set<Integer> portsUsedByBroker) + public InternalBrokerHolder(Set<Integer> portsUsedByBroker) { - if(broker == null) - { - throw new IllegalArgumentException("Broker must not be null"); - } - - _broker = broker; - _workingDirectory = workingDirectory; _portsUsedByBroker = portsUsedByBroker; } @Override - public String getWorkingDirectory() + public void start(BrokerOptions options) throws Exception { - return _workingDirectory; + LOGGER.info("Starting internal broker (same JVM)"); + + _broker = new Broker(); + _broker.startup(options); } public void shutdown() Modified: qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/Piper.java URL: http://svn.apache.org/viewvc/qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/Piper.java?rev=1655057&r1=1655056&r2=1655057&view=diff ============================================================================== --- qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/Piper.java (original) +++ qpid/branches/QPID-6262-JavaBrokerNIO/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/Piper.java Tue Jan 27 15:00:13 2015 @@ -35,27 +35,21 @@ public final class Piper extends Thread private static final Logger LOGGER = Logger.getLogger(Piper.class); private final BufferedReader _in; - private final PrintStream _out; + private final Logger _out; private final String _ready; private final CountDownLatch _latch; private final String _stopped; - private final String _prefix; private volatile boolean _seenReady; private volatile String _stopLine; - public Piper(InputStream in, PrintStream out, String ready, String stopped) - { - this(in, out, ready, stopped, null); - } - - public Piper(InputStream in, PrintStream out, String ready, String stopped, String prefix) + public Piper(InputStream in, String ready, String stopped, String threadName, String loggerName) { + super(threadName); _in = new BufferedReader(new InputStreamReader(in)); - _out = out; + _out = Logger.getLogger(loggerName); _ready = ready; _stopped = stopped; _seenReady = false; - _prefix = prefix; if (this._ready != null && !this._ready.equals("")) { @@ -87,11 +81,7 @@ public final class Piper extends Thread String line; while ((line = _in.readLine()) != null) { - if (_prefix != null) - { - line = _prefix + line; - } - _out.println(line); + _out.info(line); if (_latch != null && line.contains(_ready)) { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
