diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2014-05-02 20:32:16 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2014-05-02 20:32:16 +0000 |
| commit | db543bd85497285b1911c7250a9a1f76522f318b (patch) | |
| tree | 0a88c2e19a1a8e3e4bedf49ab0a4ef7248d25603 /qpid/java/bdbstore/src | |
| parent | 1af82f62bbf94323e61a415c182adf2d66ac99f0 (diff) | |
| download | qpid-python-db543bd85497285b1911c7250a9a1f76522f318b.tar.gz | |
QPID-5746 : [Java Broker] Split attribute annotations into separate annotations for derived and automated, and allow derived attributes to be persisted
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1592030 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/bdbstore/src')
6 files changed, 45 insertions, 44 deletions
diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNode.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNode.java index e18c76b986..691096f59f 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNode.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNode.java @@ -20,6 +20,7 @@ */ package org.apache.qpid.server.virtualhostnode.berkeleydb; +import org.apache.qpid.server.model.DerivedAttribute; import org.apache.qpid.server.model.ManagedAttribute; import org.apache.qpid.server.model.ManagedObject; import org.apache.qpid.server.model.RemoteReplicationNode; @@ -33,19 +34,19 @@ public interface BDBHARemoteReplicationNode<X extends BDBHARemoteReplicationNode String LAST_KNOWN_REPLICATION_TRANSACTION_ID = "lastKnownReplicationTransactionId"; String JOIN_TIME = "joinTime"; - @ManagedAttribute(derived = true) + @DerivedAttribute String getGroupName(); - @ManagedAttribute(derived = true) + @DerivedAttribute String getAddress(); - @ManagedAttribute(automate = true) + @ManagedAttribute(persist = false) String getRole(); - @ManagedAttribute(derived = true) + @DerivedAttribute long getJoinTime(); - @ManagedAttribute(derived = true) + @DerivedAttribute long getLastKnownReplicationTransactionId(); } diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeImpl.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeImpl.java index 8e94649a1a..23dd2ee5c0 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeImpl.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeImpl.java @@ -25,7 +25,10 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; +import com.sleepycat.je.rep.MasterStateException; +import com.sleepycat.je.rep.ReplicatedEnvironment; import org.apache.log4j.Logger; + import org.apache.qpid.server.configuration.IllegalConfigurationException; import org.apache.qpid.server.model.AbstractConfiguredObject; import org.apache.qpid.server.model.ConfiguredObject; @@ -34,9 +37,6 @@ import org.apache.qpid.server.model.ManagedAttributeField; import org.apache.qpid.server.model.State; import org.apache.qpid.server.store.berkeleydb.replication.ReplicatedEnvironmentFacade; -import com.sleepycat.je.rep.MasterStateException; -import com.sleepycat.je.rep.ReplicatedEnvironment; - public class BDBHARemoteReplicationNodeImpl extends AbstractConfiguredObject<BDBHARemoteReplicationNodeImpl> implements BDBHARemoteReplicationNode<BDBHARemoteReplicationNodeImpl> { private static final Logger LOGGER = Logger.getLogger(BDBHARemoteReplicationNodeImpl.class); @@ -125,7 +125,7 @@ public class BDBHARemoteReplicationNodeImpl extends AbstractConfiguredObject<BDB } @Override - protected boolean setState(State currentState, State desiredState) + protected boolean setState(State desiredState) { if (desiredState == State.DELETED) { diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNode.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNode.java index c135803717..0d0292ce58 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNode.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNode.java @@ -22,6 +22,7 @@ package org.apache.qpid.server.virtualhostnode.berkeleydb; import java.util.Map; +import org.apache.qpid.server.model.DerivedAttribute; import org.apache.qpid.server.model.ManagedAttribute; public interface BDBHAVirtualHostNode<X extends BDBHAVirtualHostNode<X>> extends BDBVirtualHostNode<X> @@ -39,39 +40,39 @@ public interface BDBHAVirtualHostNode<X extends BDBHAVirtualHostNode<X>> extends public static final String LAST_KNOWN_REPLICATION_TRANSACTION_ID = "lastKnownReplicationTransactionId"; public static final String JOIN_TIME = "joinTime"; - @ManagedAttribute(automate = true, mandatory=true) + @ManagedAttribute(mandatory=true) String getGroupName(); - @ManagedAttribute(automate = true, mandatory=true) + @ManagedAttribute(mandatory=true) String getAddress(); - @ManagedAttribute(automate = true, mandatory=true) + @ManagedAttribute(mandatory=true) String getHelperAddress(); - @ManagedAttribute(automate = true, defaultValue = "NO_SYNC,NO_SYNC,SIMPLE_MAJORITY") + @ManagedAttribute(defaultValue = "NO_SYNC,NO_SYNC,SIMPLE_MAJORITY") String getDurability(); - @ManagedAttribute(automate = true, defaultValue = "true") + @ManagedAttribute(defaultValue = "true") boolean isCoalescingSync(); - @ManagedAttribute(automate = true, defaultValue = "false") + @ManagedAttribute(defaultValue = "false") boolean isDesignatedPrimary(); - @ManagedAttribute(automate = true, defaultValue = "1") + @ManagedAttribute(defaultValue = "1") int getPriority(); - @ManagedAttribute(automate = true, defaultValue = "0") + @ManagedAttribute(defaultValue = "0") int getQuorumOverride(); - @ManagedAttribute(automate = true, persist = false) + @ManagedAttribute(persist = false) String getRole(); - @ManagedAttribute(automate = true) + @ManagedAttribute Map<String, String> getReplicatedEnvironmentConfiguration(); - @ManagedAttribute(derived = true) + @DerivedAttribute Long getLastKnownReplicationTransactionId(); - @ManagedAttribute(derived = true) + @DerivedAttribute Long getJoinTime(); } diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java index 95f542585c..a6ce1c47df 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHAVirtualHostNodeImpl.java @@ -37,9 +37,8 @@ import com.sleepycat.je.rep.ReplicatedEnvironment; import com.sleepycat.je.rep.ReplicationNode; 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; import org.apache.qpid.server.model.BrokerModel; @@ -385,7 +384,7 @@ public class BDBHAVirtualHostNodeImpl extends AbstractVirtualHostNode<BDBHAVirtu } }); } - host.setDesiredState(host.getState(), State.ACTIVE); + host.setDesiredState(State.ACTIVE); } catch (Exception e) @@ -422,7 +421,7 @@ public class BDBHAVirtualHostNodeImpl extends AbstractVirtualHostNode<BDBHAVirtu VirtualHost<?,?,?> virtualHost = getVirtualHost(); if (virtualHost!= null) { - virtualHost.setDesiredState(virtualHost.getState(), State.STOPPED); + virtualHost.setDesiredState(State.STOPPED); } } @@ -655,13 +654,13 @@ public class BDBHAVirtualHostNodeImpl extends AbstractVirtualHostNode<BDBHAVirtu } @Override - public boolean setState(State currentState, State desiredState) + public boolean setState(State desiredState) { if (desiredState != State.STOPPED) { throw new IllegalArgumentException("Unsupported state " + desiredState); } - return super.setState(currentState, desiredState); + return super.setState(desiredState); } } diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBVirtualHostNode.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBVirtualHostNode.java index 4785d47447..91b2d7ae63 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBVirtualHostNode.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBVirtualHostNode.java @@ -29,6 +29,6 @@ public interface BDBVirtualHostNode<X extends BDBVirtualHostNode<X>> extends Fil { public static final String ENVIRONMENT_CONFIGURATION = "environmentConfiguration"; - @ManagedAttribute(mandatory=false, automate=true) + @ManagedAttribute(mandatory=false) Map<String, String> getEnvironmentConfiguration(); -}
\ No newline at end of file +} diff --git a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java index 5e5458b382..49205930ea 100644 --- a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java +++ b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java @@ -33,6 +33,9 @@ import java.util.UUID; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import com.sleepycat.je.rep.ReplicatedEnvironment; +import com.sleepycat.je.rep.ReplicationConfig; + import org.apache.qpid.server.configuration.updater.TaskExecutor; import org.apache.qpid.server.configuration.updater.TaskExecutorImpl; import org.apache.qpid.server.model.Broker; @@ -52,9 +55,6 @@ import org.apache.qpid.server.virtualhostnode.berkeleydb.BDBHAVirtualHostNode; import org.apache.qpid.test.utils.QpidTestCase; import org.apache.qpid.util.FileUtils; -import com.sleepycat.je.rep.ReplicatedEnvironment; -import com.sleepycat.je.rep.ReplicationConfig; - public class BDBHAVirtualHostNodeTest extends QpidTestCase { @@ -89,7 +89,7 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase { try { - node.setDesiredState(node.getState(), State.DELETED); + node.setDesiredState(State.DELETED); } catch(Exception e) { @@ -175,7 +175,7 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase { } }); - assertEquals(State.ACTIVE, node.setDesiredState(node.getState(), State.ACTIVE)); + assertEquals(State.ACTIVE, node.setDesiredState(State.ACTIVE)); DurableConfigurationStore store = node.getConfigurationStore(); assertNotNull(store); @@ -200,13 +200,13 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase assertEquals("Unexpected virtual host store", store, virtualHost.getMessageStore()); assertEquals("Unexpected virtual host state", State.ACTIVE, virtualHost.getState()); - State currentState = node.setDesiredState(State.ACTIVE, State.STOPPED); + State currentState = node.setDesiredState(State.STOPPED); assertEquals("Unexpected state returned after stop", State.STOPPED, currentState); assertEquals("Unexpected state", State.STOPPED, node.getState()); assertNull("Virtual host is not destroyed", node.getVirtualHost()); - currentState = node.setDesiredState(State.STOPPED, State.DELETED); + currentState = node.setDesiredState(State.DELETED); assertEquals("Unexpected state returned after delete", State.DELETED, currentState); assertEquals("Unexpected state", State.DELETED, node.getState()); assertFalse("Store still exists", _bdbStorePath.exists()); @@ -228,7 +228,7 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase BDBHAVirtualHostNode<?> node = createHaVHN(attributes); - assertEquals("Failed to activate node", State.ACTIVE, node.setDesiredState(node.getState(), State.ACTIVE)); + assertEquals("Failed to activate node", State.ACTIVE, node.setDesiredState(State.ACTIVE)); BDBMessageStore bdbMessageStore = (BDBMessageStore) node.getConfigurationStore(); ReplicatedEnvironment environment = (ReplicatedEnvironment) bdbMessageStore.getEnvironmentFacade().getEnvironment(); @@ -265,7 +265,7 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase node1Attributes.put(BDBHAVirtualHostNode.STORE_PATH, _bdbStorePath + File.separator + "1"); BDBHAVirtualHostNode<?> node1 = createHaVHN(node1Attributes); - assertEquals("Failed to activate node", State.ACTIVE, node1.setDesiredState(node1.getState(), State.ACTIVE)); + assertEquals("Failed to activate node", State.ACTIVE, node1.setDesiredState(State.ACTIVE)); int node2PortNumber = getNextAvailable(node1PortNumber+1); @@ -279,7 +279,7 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase node2Attributes.put(BDBHAVirtualHostNode.STORE_PATH, _bdbStorePath + File.separator + "2"); BDBHAVirtualHostNode<?> node2 = createHaVHN(node2Attributes); - assertEquals("Failed to activate node2", State.ACTIVE, node2.setDesiredState(node2.getState(), State.ACTIVE)); + assertEquals("Failed to activate node2", State.ACTIVE, node2.setDesiredState(State.ACTIVE)); int node3PortNumber = getNextAvailable(node2PortNumber+1); Map<String, Object> node3Attributes = new HashMap<String, Object>(); @@ -291,7 +291,7 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase node3Attributes.put(BDBHAVirtualHostNode.HELPER_ADDRESS, helperAddress); node3Attributes.put(BDBHAVirtualHostNode.STORE_PATH, _bdbStorePath + File.separator + "3"); BDBHAVirtualHostNode<?> node3 = createHaVHN(node3Attributes); - assertEquals("Failed to activate node3", State.ACTIVE, node3.setDesiredState(node3.getState(), State.ACTIVE)); + assertEquals("Failed to activate node3", State.ACTIVE, node3.setDesiredState(State.ACTIVE)); BDBHAVirtualHostNode<?> replica = null; int findReplicaCount = 0; @@ -335,7 +335,7 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase node1Attributes.put(BDBHAVirtualHostNode.STORE_PATH, _bdbStorePath + File.separator + "1"); BDBHAVirtualHostNode<?> node1 = createHaVHN(node1Attributes); - assertEquals("Failed to activate node", State.ACTIVE, node1.setDesiredState(node1.getState(), State.ACTIVE)); + assertEquals("Failed to activate node", State.ACTIVE, node1.setDesiredState(State.ACTIVE)); final CountDownLatch remoteNodeLatch = new CountDownLatch(2); node1.addChangeListener(new ConfigurationChangeListener() @@ -378,7 +378,7 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase node2Attributes.put(BDBHAVirtualHostNode.STORE_PATH, _bdbStorePath + File.separator + "2"); BDBHAVirtualHostNode<?> node2 = createHaVHN(node2Attributes); - assertEquals("Failed to activate node2", State.ACTIVE, node2.setDesiredState(node2.getState(), State.ACTIVE)); + assertEquals("Failed to activate node2", State.ACTIVE, node2.setDesiredState(State.ACTIVE)); int node3PortNumber = getNextAvailable(node2PortNumber+1); Map<String, Object> node3Attributes = new HashMap<String, Object>(); @@ -390,7 +390,7 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase node3Attributes.put(BDBHAVirtualHostNode.HELPER_ADDRESS, helperAddress); node3Attributes.put(BDBHAVirtualHostNode.STORE_PATH, _bdbStorePath + File.separator + "3"); BDBHAVirtualHostNode<?> node3 = createHaVHN(node3Attributes); - assertEquals("Failed to activate node3", State.ACTIVE, node3.setDesiredState(node3.getState(), State.ACTIVE)); + assertEquals("Failed to activate node3", State.ACTIVE, node3.setDesiredState(State.ACTIVE)); assertTrue("Replication nodes have not been seen during 5s", remoteNodeLatch.await(5, TimeUnit.SECONDS)); @@ -429,7 +429,7 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase node1Attributes.put(BDBHAVirtualHostNode.STORE_PATH, _bdbStorePath + File.separator + "1"); BDBHAVirtualHostNode<?> node = createHaVHN(node1Attributes); - assertEquals("Failed to activate node", State.ACTIVE, node.setDesiredState(node.getState(), State.ACTIVE)); + assertEquals("Failed to activate node", State.ACTIVE, node.setDesiredState(State.ACTIVE)); assertNodeRole(node, "MASTER"); |
