You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2014/04/29 12:50:28 UTC
svn commit: r1590945 - in /qpid/trunk/qpid/java:
bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/
broker-core/src/main/java/org/apache/qpid/server/model/
broker-core/src/test/java/org/apache/qpid/server/model/ broker-core/src/t...
Author: rgodfrey
Date: Tue Apr 29 10:50:27 2014
New Revision: 1590945
URL: http://svn.apache.org/r1590945
Log:
QPID-5730 : [Java Broker] allow configured object attributes to be maked as not to be persisted
Added:
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestModel.java
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategory.java
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategoryImpl.java
Modified:
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNode.java
qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java
Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNode.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNode.java?rev=1590945&r1=1590944&r2=1590945&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNode.java (original)
+++ qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNode.java Tue Apr 29 10:50:27 2014
@@ -63,7 +63,7 @@ public interface BDBHAVirtualHostNode<X
@ManagedAttribute(automate = true, defaultValue = "0")
int getQuorumOverride();
- @ManagedAttribute(automate = true)
+ @ManagedAttribute(automate = true, persist = false)
String getRole();
@ManagedAttribute(automate = true)
Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java?rev=1590945&r1=1590944&r2=1590945&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java (original)
+++ qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java Tue Apr 29 10:50:27 2014
@@ -23,7 +23,6 @@ package org.apache.qpid.server.virtualho
import java.security.PrivilegedAction;
import java.util.HashMap;
import java.util.Map;
-import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
@@ -31,7 +30,11 @@ import java.util.concurrent.atomic.Atomi
import javax.security.auth.Subject;
+import com.sleepycat.je.rep.ReplicatedEnvironment;
+import com.sleepycat.je.rep.StateChangeEvent;
+import com.sleepycat.je.rep.StateChangeListener;
import org.apache.log4j.Logger;
+
import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.logging.messages.ConfigStoreMessages;
import org.apache.qpid.server.model.Broker;
@@ -45,7 +48,6 @@ import org.apache.qpid.server.model.Virt
import org.apache.qpid.server.model.VirtualHostNode;
import org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory;
import org.apache.qpid.server.security.SecurityManager;
-import org.apache.qpid.server.store.ConfiguredObjectRecord;
import org.apache.qpid.server.store.DurableConfigurationStore;
import org.apache.qpid.server.store.VirtualHostStoreUpgraderAndRecoverer;
import org.apache.qpid.server.store.berkeleydb.BDBHAVirtualHost;
@@ -56,10 +58,6 @@ import org.apache.qpid.server.util.Serve
import org.apache.qpid.server.virtualhost.VirtualHostState;
import org.apache.qpid.server.virtualhostnode.AbstractVirtualHostNode;
-import com.sleepycat.je.rep.ReplicatedEnvironment;
-import com.sleepycat.je.rep.StateChangeEvent;
-import com.sleepycat.je.rep.StateChangeListener;
-
@ManagedObject( category = false, type = "BDB_HA" )
public class BDBHAVirtualHostNodeImpl extends AbstractVirtualHostNode<BDBHAVirtualHostNodeImpl> implements BDBHAVirtualHostNode<BDBHAVirtualHostNodeImpl>
{
@@ -563,42 +561,6 @@ public class BDBHAVirtualHostNodeImpl ex
}
}
- // TODO - need a better way of suppressing the persistence of the role field.
- @Override
- public ConfiguredObjectRecord asObjectRecord()
- {
- final ConfiguredObjectRecord underlying = super.asObjectRecord();
- return new ConfiguredObjectRecord()
- {
-
- @Override
- public String getType()
- {
- return underlying.getType();
- }
-
- @Override
- public Map<String, ConfiguredObjectRecord> getParents()
- {
- return underlying.getParents();
- }
-
- @Override
- public UUID getId()
- {
- return underlying.getId();
- }
-
- @Override
- public Map<String, Object> getAttributes()
- {
- Map<String, Object> copy = new HashMap<String, Object>(underlying.getAttributes());
- copy.remove(BDBHAVirtualHostNode.ROLE);
- return copy;
- }
- };
- }
-
private class ReplicaVirtualHost extends BDBHAVirtualHost
{
ReplicaVirtualHost(Map<String, Object> attributes, VirtualHostNode<?> virtualHostNode)
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java?rev=1590945&r1=1590944&r2=1590945&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java Tue Apr 29 10:50:27 2014
@@ -843,7 +843,7 @@ public abstract class AbstractConfigured
return getClass().getSimpleName() + " [id=" + _id + ", name=" + getName() + "]";
}
- public ConfiguredObjectRecord asObjectRecord()
+ public final ConfiguredObjectRecord asObjectRecord()
{
return new ConfiguredObjectRecord()
{
@@ -868,9 +868,18 @@ public abstract class AbstractConfigured
public Map<String, Object> run()
{
Map<String,Object> actualAttributes = new HashMap<String, Object>(getActualAttributes());
- for(Map.Entry<String,Object> entry : actualAttributes.entrySet())
+ Iterator<Map.Entry<String,Object>> attributeIterator = actualAttributes.entrySet().iterator();
+
+ while(attributeIterator.hasNext())
{
- if(entry.getValue() instanceof ConfiguredObject)
+ Map.Entry<String, Object> entry = attributeIterator.next();
+ ConfiguredObjectAttribute<?, ?> attributeDefinition =
+ _attributeTypes.get(entry.getKey());
+ if(attributeDefinition != null && !attributeDefinition.getAnnotation().persist())
+ {
+ attributeIterator.remove();
+ }
+ else if(entry.getValue() instanceof ConfiguredObject)
{
entry.setValue(((ConfiguredObject)entry.getValue()).getId());
}
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java?rev=1590945&r1=1590944&r2=1590945&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/ManagedAttribute.java Tue Apr 29 10:50:27 2014
@@ -32,5 +32,6 @@ public @interface ManagedAttribute
boolean automate() default false;
boolean state() default false;
boolean mandatory() default false;
+ boolean persist() default true;
String defaultValue() default "";
}
Added: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java?rev=1590945&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java (added)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/AbstractConfiguredObjectTest.java Tue Apr 29 10:50:27 2014
@@ -0,0 +1,77 @@
+/*
+ *
+ * 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.qpid.server.model;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.qpid.server.model.testmodel.TestModel;
+import org.apache.qpid.server.model.testmodel.TestRootCategory;
+import org.apache.qpid.server.store.ConfiguredObjectRecord;
+
+public class AbstractConfiguredObjectTest extends TestCase
+{
+
+
+ public void testNonPersistAttributes()
+ {
+ Model model = TestModel.getInstance();
+
+ final String objectName = "testNonPersistAttributes";
+ TestRootCategory object =
+ model.getObjectFactory().create(TestRootCategory.class,
+ Collections.<String, Object>singletonMap(ConfiguredObject.NAME,
+ objectName));
+
+ assertEquals(objectName, object.getName());
+ assertNull(object.getAutomatedNonPersistedValue());
+ assertNull(object.getAutomatedPersistedValue());
+
+ ConfiguredObjectRecord record = object.asObjectRecord();
+
+ assertEquals(objectName, record.getAttributes().get(ConfiguredObject.NAME));
+
+ assertFalse(record.getAttributes().containsKey(TestRootCategory.AUTOMATED_PERSISTED_VALUE));
+ assertFalse(record.getAttributes().containsKey(TestRootCategory.AUTOMATED_NONPERSISTED_VALUE));
+
+
+ Map<String,Object> updatedAttributes = new HashMap<>();
+
+ final String newValue = "newValue";
+
+ updatedAttributes.put(TestRootCategory.AUTOMATED_PERSISTED_VALUE, newValue);
+ updatedAttributes.put(TestRootCategory.AUTOMATED_NONPERSISTED_VALUE, newValue);
+ object.setAttributes(updatedAttributes);
+
+ assertEquals(newValue, object.getAutomatedPersistedValue());
+ assertEquals(newValue, object.getAutomatedNonPersistedValue());
+
+ record = object.asObjectRecord();
+ assertEquals(objectName, record.getAttributes().get(ConfiguredObject.NAME));
+ assertEquals(newValue, record.getAttributes().get(TestRootCategory.AUTOMATED_PERSISTED_VALUE));
+
+ assertFalse(record.getAttributes().containsKey(TestRootCategory.AUTOMATED_NONPERSISTED_VALUE));
+
+ }
+}
Added: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestModel.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestModel.java?rev=1590945&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestModel.java (added)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestModel.java Tue Apr 29 10:50:27 2014
@@ -0,0 +1,99 @@
+/*
+ *
+ * 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.qpid.server.model.testmodel;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.ConfiguredObjectFactory;
+import org.apache.qpid.server.model.ConfiguredObjectFactoryImpl;
+import org.apache.qpid.server.model.Model;
+
+public class TestModel extends Model
+{
+ private static final Model INSTANCE = new TestModel();
+ private Class<? extends ConfiguredObject>[] _supportedClasses =
+ new Class[] {
+ TestRootCategory.class
+ };
+
+ private final ConfiguredObjectFactory _objectFactory;
+
+ private TestModel()
+ {
+ this(null);
+ }
+
+ public TestModel(final ConfiguredObjectFactory objectFactory)
+ {
+ _objectFactory = objectFactory == null ? new ConfiguredObjectFactoryImpl(this) : objectFactory;
+ }
+
+
+ @Override
+ public Collection<Class<? extends ConfiguredObject>> getSupportedCategories()
+ {
+ return Arrays.asList(_supportedClasses);
+ }
+
+ @Override
+ public Collection<Class<? extends ConfiguredObject>> getChildTypes(final Class<? extends ConfiguredObject> parent)
+ {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public Class<? extends ConfiguredObject> getRootCategory()
+ {
+ return TestRootCategory.class;
+ }
+
+ @Override
+ public Collection<Class<? extends ConfiguredObject>> getParentTypes(final Class<? extends ConfiguredObject> child)
+ {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public int getMajorVersion()
+ {
+ return 99;
+ }
+
+ @Override
+ public int getMinorVersion()
+ {
+ return 99;
+ }
+
+ @Override
+ public ConfiguredObjectFactory getObjectFactory()
+ {
+ return _objectFactory;
+ }
+
+ public static Model getInstance()
+ {
+ return INSTANCE;
+ }
+}
Added: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategory.java?rev=1590945&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategory.java (added)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategory.java Tue Apr 29 10:50:27 2014
@@ -0,0 +1,38 @@
+/*
+ *
+ * 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.qpid.server.model.testmodel;
+
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.ManagedAttribute;
+import org.apache.qpid.server.model.ManagedObject;
+
+@ManagedObject( defaultType = "test" )
+public interface TestRootCategory<X extends TestRootCategory<X>> extends ConfiguredObject<X>
+{
+ String AUTOMATED_PERSISTED_VALUE = "automatedPersistedValue";
+ String AUTOMATED_NONPERSISTED_VALUE = "automatedNonPersistedValue";
+
+ @ManagedAttribute( automate = true )
+ String getAutomatedPersistedValue();
+
+ @ManagedAttribute( automate = true, persist = false )
+ String getAutomatedNonPersistedValue();
+}
Added: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategoryImpl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategoryImpl.java?rev=1590945&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategoryImpl.java (added)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/model/testmodel/TestRootCategoryImpl.java Tue Apr 29 10:50:27 2014
@@ -0,0 +1,85 @@
+/*
+ *
+ * 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.qpid.server.model.testmodel;
+
+import java.util.Map;
+
+import org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor;
+import org.apache.qpid.server.configuration.updater.TaskExecutor;
+import org.apache.qpid.server.model.AbstractConfiguredObject;
+import org.apache.qpid.server.model.ManagedAttributeField;
+import org.apache.qpid.server.model.ManagedObject;
+import org.apache.qpid.server.model.ManagedObjectFactoryConstructor;
+import org.apache.qpid.server.model.State;
+
+@ManagedObject( category = false , type = "test" )
+public class TestRootCategoryImpl extends AbstractConfiguredObject<TestRootCategoryImpl>
+ implements TestRootCategory<TestRootCategoryImpl>
+{
+ @ManagedAttributeField
+ private String _automatedPersistedValue;
+
+ @ManagedAttributeField
+ private String _automatedNonPersistedValue;
+
+ @ManagedObjectFactoryConstructor
+ public TestRootCategoryImpl(final Map<String, Object> attributes)
+ {
+ super(parentsMap(), attributes, newTaskExecutor(), TestModel.getInstance());
+ }
+
+ private static CurrentThreadTaskExecutor newTaskExecutor()
+ {
+ CurrentThreadTaskExecutor currentThreadTaskExecutor = new CurrentThreadTaskExecutor();
+ currentThreadTaskExecutor.start();
+ return currentThreadTaskExecutor;
+ }
+
+ public TestRootCategoryImpl(final Map<String, Object> attributes,
+ final TaskExecutor taskExecutor)
+ {
+ super(parentsMap(), attributes, taskExecutor);
+ }
+
+ @Override
+ protected boolean setState(final State currentState, final State desiredState)
+ {
+ return false;
+ }
+
+ @Override
+ public String getAutomatedPersistedValue()
+ {
+ return _automatedPersistedValue;
+ }
+
+ @Override
+ public String getAutomatedNonPersistedValue()
+ {
+ return _automatedNonPersistedValue;
+ }
+
+ @Override
+ public State getState()
+ {
+ return null;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org