qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1573336 [2/2] - in /qpid/trunk/qpid/java: broker-core/src/main/java/org/apache/qpid/server/binding/ broker-core/src/main/java/org/apache/qpid/server/exchange/ broker-core/src/main/java/org/apache/qpid/server/filter/ broker-core/src/main/ja...
Date Sun, 02 Mar 2014 18:24:28 GMT
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java?rev=1573336&r1=1573335&r2=1573336&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueConsumerImpl.java
Sun Mar  2 18:24:27 2014
@@ -22,6 +22,8 @@ package org.apache.qpid.server.queue;
 
 import org.apache.log4j.Logger;
 import org.apache.qpid.server.filter.FilterManager;
+import org.apache.qpid.server.filter.JMSSelectorFilter;
+import org.apache.qpid.server.filter.MessageFilter;
 import org.apache.qpid.server.logging.LogActor;
 import org.apache.qpid.server.logging.LogSubject;
 import org.apache.qpid.server.logging.actors.CurrentActor;
@@ -43,11 +45,7 @@ import org.apache.qpid.server.util.State
 
 import java.security.AccessControlException;
 import java.text.MessageFormat;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EnumMap;
-import java.util.EnumSet;
-import java.util.UUID;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.locks.Lock;
@@ -70,7 +68,6 @@ class QueueConsumerImpl
     private final MessageInstance.ConsumerAcquiredState<QueueConsumerImpl> _owningState
= new MessageInstance.ConsumerAcquiredState<QueueConsumerImpl>(this);
     private final boolean _acquires;
     private final boolean _seesRequeues;
-    private final String _consumerName;
     private final boolean _isTransient;
     private final AtomicLong _deliveredCount = new AtomicLong(0);
     private final AtomicLong _deliveredBytes = new AtomicLong(0);
@@ -78,7 +75,6 @@ class QueueConsumerImpl
     private final Class<? extends ServerMessage> _messageClass;
     private final Object _sessionReference;
     private final AbstractQueue _queue;
-    private final boolean _exclusive;
     private GenericActor _logActor = new GenericActor("[" + MessageFormat.format(SUBSCRIPTION_FORMAT,
getConsumerNumber())
                                                       + "(UNKNOWN)"
                                                       + "] ");
@@ -103,7 +99,12 @@ class QueueConsumerImpl
             CurrentActor.get().message(SubscriptionMessages.STATE(newState.toString()));
         }
     };
-    private final boolean _noLocal;
+    private boolean _durable;
+    private boolean _exclusive;
+    private boolean _noLocal;
+    private String _distributionMode;
+    private String _settlementMode;
+    private String _selector;
 
     QueueConsumerImpl(final AbstractQueue queue,
                       ConsumerTarget target, final String consumerName,
@@ -111,8 +112,8 @@ class QueueConsumerImpl
                       final Class<? extends ServerMessage> messageClass,
                       EnumSet<Option> optionSet)
     {
-        super(UUID.randomUUID(), Collections.<String,Object>emptyMap(),
-              Collections.<String,Object>emptyMap(),
+        super(Collections.<String,Object>emptyMap(),
+              createAttributeMap(consumerName,filters,optionSet),
               queue.getVirtualHost().getTaskExecutor());
         _messageClass = messageClass;
         _sessionReference = target.getSessionModel().getConnectionReference();
@@ -120,13 +121,10 @@ class QueueConsumerImpl
         _filters = filters;
         _acquires = optionSet.contains(Option.ACQUIRES);
         _seesRequeues = optionSet.contains(Option.SEES_REQUEUES);
-        _consumerName = consumerName;
         _isTransient = optionSet.contains(Option.TRANSIENT);
         _target = target;
         _queue = queue;
-        _noLocal = optionSet.contains(Option.NO_LOCAL);
-        _exclusive = optionSet.contains(Option.EXCLUSIVE);
-        setupLogging(optionSet.contains(Option.EXCLUSIVE));
+        setupLogging();
 
         // Access control
         _queue.getVirtualHost().getSecurityManager().authoriseCreateConsumer(this);
@@ -145,6 +143,32 @@ class QueueConsumerImpl
                     });
     }
 
+    private static Map<String, Object> createAttributeMap(String name, FilterManager
filters, EnumSet<Option> optionSet)
+    {
+        Map<String,Object> attributes = new HashMap<String, Object>();
+        attributes.put(ID, UUID.randomUUID());
+        attributes.put(NAME, name);
+        attributes.put(EXCLUSIVE, optionSet.contains(Option.EXCLUSIVE));
+        attributes.put(NO_LOCAL, optionSet.contains(Option.NO_LOCAL));
+        attributes.put(DISTRIBUTION_MODE, optionSet.contains(Option.ACQUIRES) ? "MOVE" :
"COPY");
+        attributes.put(DURABLE,false);
+        if(filters != null)
+        {
+            Iterator<MessageFilter> iter = filters.filters();
+            while(iter.hasNext())
+            {
+                MessageFilter filter = iter.next();
+                if(filter instanceof JMSSelectorFilter)
+                {
+                    attributes.put(SELECTOR, ((JMSSelectorFilter) filter).getSelector());
+                    break;
+                }
+            }
+        }
+
+        return attributes;
+    }
+
     private void targetStateChanged(final ConsumerTarget.State oldState, final ConsumerTarget.State
newState)
     {
         if(oldState != newState)
@@ -269,7 +293,7 @@ class QueueConsumerImpl
         return _queue;
     }
 
-    private void setupLogging(final boolean exclusive)
+    private void setupLogging()
     {
         String queueString = new QueueLogSubject(_queue).toLogString();
 
@@ -285,7 +309,7 @@ class QueueConsumerImpl
         if (CurrentActor.get().getRootMessageLogger().isMessageEnabled(_logActor, _logActor.getLogSubject(),
SubscriptionMessages.CREATE_LOG_HIERARCHY))
         {
             final String filterLogString = getFilterLogString();
-            CurrentActor.get().message(_logActor.getLogSubject(), SubscriptionMessages.CREATE(filterLogString,
_queue.isDurable() && exclusive,
+            CurrentActor.get().message(_logActor.getLogSubject(), SubscriptionMessages.CREATE(filterLogString,
_queue.isDurable() && _exclusive,
                                                                                 filterLogString.length()
> 0));
         }
     }
@@ -442,11 +466,6 @@ class QueueConsumerImpl
         return _seesRequeues;
     }
 
-    public final String getName()
-    {
-        return _consumerName;
-    }
-
     public final boolean isTransient()
     {
         return _isTransient;
@@ -479,13 +498,13 @@ class QueueConsumerImpl
     @Override
     public String getDistributionMode()
     {
-        return acquires() ? "MOVE" : "COPY";
+        return _distributionMode;
     }
 
     @Override
     public String getSettlementMode()
     {
-        return null;
+        return _settlementMode;
     }
 
     @Override
@@ -497,13 +516,13 @@ class QueueConsumerImpl
     @Override
     public boolean isNoLocal()
     {
-        return isNoLocal();
+        return _noLocal;
     }
 
     @Override
     public String getSelector()
     {
-        return null;
+        return _selector;
     }
 
     @Override
@@ -516,7 +535,7 @@ class QueueConsumerImpl
     @Override
     public boolean isDurable()
     {
-        return false;
+        return _durable;
     }
 
     @Override
@@ -548,34 +567,10 @@ class QueueConsumerImpl
     @Override
     public Object getAttribute(final String name)
     {
-        if(ID.equals(name))
-        {
-            return getId();
-        }
-        else if(NAME.equals(name))
-        {
-            return getName();
-        }
-        else if(DURABLE.equals(name))
-        {
-            return isDurable();
-        }
-        else if(DISTRIBUTION_MODE.equals(name))
-        {
-            return getDistributionMode();
-        }
-        else if(SETTLEMENT_MODE.equals(name))
-        {
-            return getSettlementMode();
-        }
-        else if(LIFETIME_POLICY.equals(name))
+        if(LIFETIME_POLICY.equals(name))
         {
             return getLifetimePolicy();
         }
-        else if(EXCLUSIVE.equals(name))
-        {
-            return isExclusive();
-        }
         return super.getAttribute(name);
     }
 

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/KeyStoreRecovererTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/KeyStoreRecovererTest.java?rev=1573336&r1=1573335&r2=1573336&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/KeyStoreRecovererTest.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/KeyStoreRecovererTest.java
Sun Mar  2 18:24:27 2014
@@ -34,6 +34,7 @@ import javax.security.auth.Subject;
 import junit.framework.TestCase;
 
 import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.KeyStore;
 import org.apache.qpid.server.model.adapter.AbstractKeyStoreAdapter;

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostRecovererTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostRecovererTest.java?rev=1573336&r1=1573335&r2=1573336&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostRecovererTest.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/configuration/startup/VirtualHostRecovererTest.java
Sun Mar  2 18:24:27 2014
@@ -127,6 +127,10 @@ public class VirtualHostRecovererTest ex
             {
                 // pass
             }
+            catch(IllegalArgumentException e)
+            {
+                // pass
+            }
         }
     }
 }

Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java?rev=1573336&r1=1573335&r2=1573336&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java
(original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/adapter/FileSystemPreferencesProviderTest.java
Sun Mar  2 18:24:27 2014
@@ -96,6 +96,7 @@ public class FileSystemPreferencesProvid
         {
             Map<String, Object> attributes = new HashMap<String, Object>();
             attributes.put(FileSystemPreferencesProvider.PATH, nonExistingFile.getAbsolutePath());
+            attributes.put(FileSystemPreferencesProvider.NAME, getTestName());
             _preferencesProvider = new FileSystemPreferencesProvider(UUID.randomUUID(), attributes,
_authenticationProvider, _broker.getTaskExecutor());
             _preferencesProvider.createStoreIfNotExist();
             assertEquals(State.INITIALISING, _preferencesProvider.getState());
@@ -115,6 +116,7 @@ public class FileSystemPreferencesProvid
         try
         {
             Map<String, Object> attributes = new HashMap<String, Object>();
+            attributes.put(FileSystemPreferencesProvider.NAME, getTestName());
             attributes.put(FileSystemPreferencesProvider.PATH, emptyPrefsFile.getAbsolutePath());
             _preferencesProvider = new FileSystemPreferencesProvider(UUID.randomUUID(), attributes,
_authenticationProvider, _broker.getTaskExecutor());
             assertEquals(State.INITIALISING, _preferencesProvider.getState());

Modified: qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java?rev=1573336&r1=1573335&r2=1573336&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
(original)
+++ qpid/trunk/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
Sun Mar  2 18:24:27 2014
@@ -420,13 +420,6 @@ public class HttpManagement extends Abst
         return httpPorts;
     }
 
-
-    @Override
-    public String getName()
-    {
-        return (String)getAttribute(NAME);
-    }
-
     @Override
     public Collection<String> getAttributeNames()
     {

Modified: qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java?rev=1573336&r1=1573335&r2=1573336&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java
(original)
+++ qpid/trunk/qpid/java/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagement.java
Sun Mar  2 18:24:27 2014
@@ -310,12 +310,6 @@ public class JMXManagement extends Abstr
     }
 
     @Override
-    public String getName()
-    {
-        return (String)getAttribute(NAME);
-    }
-
-    @Override
     public Collection<String> getAttributeNames()
     {
         return getAttributeNames(JMXManagement.class);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message