[hornetq-commits] JBoss hornetq SVN: r8963 - in trunk: src/main/org/hornetq/core/server and 4 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Mar 25 06:23:19 EDT 2010
Author: jmesnil
Date: 2010-03-25 06:23:18 -0400 (Thu, 25 Mar 2010)
New Revision: 8963
Modified:
trunk/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java
trunk/src/main/org/hornetq/core/management/impl/QueueControlImpl.java
trunk/src/main/org/hornetq/core/server/HornetQServer.java
trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java
trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java
trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
Log:
https://jira.jboss.org/jira/browse/HORNETQ-334: Prevent management operations until server is started
* add checkStarted() to management operations to throw a IllegalStateException if the server is not started
Modified: trunk/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java 2010-03-25 09:11:43 UTC (rev 8962)
+++ trunk/src/main/org/hornetq/core/management/impl/HornetQServerControlImpl.java 2010-03-25 10:23:18 UTC (rev 8963)
@@ -131,6 +131,8 @@
public String getVersion()
{
+ checkStarted();
+
clearIO();
try
{
@@ -144,6 +146,8 @@
public boolean isBackup()
{
+ checkStarted();
+
clearIO();
try
{
@@ -157,6 +161,8 @@
public boolean isSharedStore()
{
+ checkStarted();
+
clearIO();
try
{
@@ -170,6 +176,8 @@
public String getBackupConnectorName()
{
+ checkStarted();
+
clearIO();
try
{
@@ -183,7 +191,9 @@
public String getBindingsDirectory()
{
- clearIO();
+ checkStarted();
+
+ clearIO();
try
{
return configuration.getBindingsDirectory();
@@ -196,6 +206,8 @@
public String[] getInterceptorClassNames()
{
+ checkStarted();
+
clearIO();
try
{
@@ -210,6 +222,8 @@
public int getJournalBufferSize()
{
+ checkStarted();
+
clearIO();
try
{
@@ -224,6 +238,8 @@
public int getJournalBufferTimeout()
{
+ checkStarted();
+
clearIO();
try
{
@@ -238,6 +254,8 @@
public int getJournalMaxIO()
{
+ checkStarted();
+
clearIO();
try
{
@@ -252,6 +270,8 @@
public String getJournalDirectory()
{
+ checkStarted();
+
clearIO();
try
{
@@ -265,6 +285,8 @@
public int getJournalFileSize()
{
+ checkStarted();
+
clearIO();
try
{
@@ -278,6 +300,8 @@
public int getJournalMinFiles()
{
+ checkStarted();
+
clearIO();
try
{
@@ -291,6 +315,8 @@
public int getJournalCompactMinFiles()
{
+ checkStarted();
+
clearIO();
try
{
@@ -304,6 +330,8 @@
public int getJournalCompactPercentage()
{
+ checkStarted();
+
clearIO();
try
{
@@ -317,6 +345,8 @@
public boolean isPersistenceEnabled()
{
+ checkStarted();
+
clearIO();
try
{
@@ -330,6 +360,8 @@
public String getJournalType()
{
+ checkStarted();
+
clearIO();
try
{
@@ -343,6 +375,8 @@
public String getPagingDirectory()
{
+ checkStarted();
+
clearIO();
try
{
@@ -356,6 +390,8 @@
public int getScheduledThreadPoolMaxSize()
{
+ checkStarted();
+
clearIO();
try
{
@@ -369,7 +405,9 @@
public int getThreadPoolMaxSize()
{
- clearIO();
+ checkStarted();
+
+ clearIO();
try
{
return configuration.getThreadPoolMaxSize();
@@ -382,6 +420,8 @@
public long getSecurityInvalidationInterval()
{
+ checkStarted();
+
clearIO();
try
{
@@ -395,6 +435,8 @@
public boolean isClustered()
{
+ checkStarted();
+
clearIO();
try
{
@@ -408,6 +450,8 @@
public boolean isCreateBindingsDir()
{
+ checkStarted();
+
clearIO();
try
{
@@ -421,6 +465,8 @@
public boolean isCreateJournalDir()
{
+ checkStarted();
+
clearIO();
try
{
@@ -434,6 +480,8 @@
public boolean isJournalSyncNonTransactional()
{
+ checkStarted();
+
clearIO();
try
{
@@ -447,6 +495,8 @@
public boolean isJournalSyncTransactional()
{
+ checkStarted();
+
clearIO();
try
{
@@ -460,6 +510,8 @@
public boolean isSecurityEnabled()
{
+ checkStarted();
+
clearIO();
try
{
@@ -473,6 +525,8 @@
public boolean isAsyncConnectionExecutionEnabled()
{
+ checkStarted();
+
clearIO();
try
{
@@ -485,6 +539,8 @@
}
public void deployQueue(final String address, final String name, final String filterString) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -502,6 +558,8 @@
public void deployQueue(final String address, final String name, final String filterStr, final boolean durable) throws Exception
{
+ checkStarted();
+
SimpleString filter = filterStr == null ? null : new SimpleString(filterStr);
clearIO();
try
@@ -517,6 +575,8 @@
public void createQueue(final String address, final String name) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -530,6 +590,8 @@
public void createQueue(final String address, final String name, final boolean durable) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -543,6 +605,8 @@
public void createQueue(final String address, final String name, final String filterStr, final boolean durable) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -562,6 +626,8 @@
public String[] getQueueNames()
{
+ checkStarted();
+
clearIO();
try
{
@@ -583,6 +649,8 @@
public String[] getAddressNames()
{
+ checkStarted();
+
clearIO();
try
{
@@ -604,6 +672,8 @@
public void destroyQueue(final String name) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -619,6 +689,8 @@
public int getConnectionCount()
{
+ checkStarted();
+
clearIO();
try
{
@@ -632,6 +704,8 @@
public void enableMessageCounters()
{
+ checkStarted();
+
clearIO();
try
{
@@ -645,6 +719,8 @@
public void disableMessageCounters()
{
+ checkStarted();
+
clearIO();
try
{
@@ -658,6 +734,8 @@
public void resetAllMessageCounters()
{
+ checkStarted();
+
clearIO();
try
{
@@ -671,6 +749,8 @@
public void resetAllMessageCounterHistories()
{
+ checkStarted();
+
clearIO();
try
{
@@ -684,6 +764,8 @@
public boolean isMessageCounterEnabled()
{
+ checkStarted();
+
clearIO();
try
{
@@ -697,6 +779,8 @@
public synchronized long getMessageCounterSamplePeriod()
{
+ checkStarted();
+
clearIO();
try
{
@@ -710,6 +794,10 @@
public synchronized void setMessageCounterSamplePeriod(final long newPeriod)
{
+ checkStarted();
+
+ checkStarted();
+
clearIO();
try
{
@@ -732,6 +820,8 @@
public int getMessageCounterMaxDayCount()
{
+ checkStarted();
+
clearIO();
try
{
@@ -745,6 +835,8 @@
public void setMessageCounterMaxDayCount(final int count)
{
+ checkStarted();
+
clearIO();
try
{
@@ -762,6 +854,8 @@
public String[] listPreparedTransactions()
{
+ checkStarted();
+
clearIO();
try
{
@@ -795,6 +889,8 @@
public String[] listHeuristicCommittedTransactions()
{
+ checkStarted();
+
clearIO();
try
{
@@ -815,6 +911,8 @@
public String[] listHeuristicRolledBackTransactions()
{
+ checkStarted();
+
clearIO();
try
{
@@ -835,6 +933,8 @@
public synchronized boolean commitPreparedTransaction(final String transactionAsBase64) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -862,6 +962,7 @@
public synchronized boolean rollbackPreparedTransaction(final String transactionAsBase64) throws Exception
{
+ checkStarted();
clearIO();
try
@@ -891,6 +992,8 @@
public String[] listRemoteAddresses()
{
+ checkStarted();
+
clearIO();
try
{
@@ -913,6 +1016,8 @@
public String[] listRemoteAddresses(final String ipAddress)
{
+ checkStarted();
+
clearIO();
try
{
@@ -937,6 +1042,8 @@
public synchronized boolean closeConnectionsForAddress(final String ipAddress)
{
+ checkStarted();
+
clearIO();
try
{
@@ -965,6 +1072,8 @@
public String[] listConnectionIDs()
{
+ checkStarted();
+
clearIO();
try
{
@@ -985,6 +1094,8 @@
public String[] listSessions(final String connectionID)
{
+ checkStarted();
+
clearIO();
try
{
@@ -1005,6 +1116,8 @@
public Object[] getConnectors() throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -1035,6 +1148,8 @@
public String getConnectorsAsJSON() throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -1062,6 +1177,8 @@
String deleteTempQueueRoles,
String manageRoles)
{
+ checkStarted();
+
clearIO();
try
{
@@ -1078,6 +1195,8 @@
public void removeSecuritySettings(String addressMatch)
{
+ checkStarted();
+
clearIO();
try
{
@@ -1091,6 +1210,8 @@
public Set<Role> getSecuritySettings(String addressMatch) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -1103,6 +1224,10 @@
}
public Object[] getRoles(String addressMatch) throws Exception
{
+ checkStarted();
+
+ checkStarted();
+
clearIO();
try
{
@@ -1132,6 +1257,8 @@
public String getRolesAsJSON(String addressMatch) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -1152,6 +1279,8 @@
public String getAddressSettingsAsJSON(final String address) throws Exception
{
+ checkStarted();
+
AddressSettings addressSettings = server.getAddressSettingsRepository().getMatch(address);
Map<String, Object> settings = new HashMap<String, Object>();
if(addressSettings.getDeadLetterAddress() != null)
@@ -1176,7 +1305,7 @@
return jsonObject.toString();
}
- public void addAddressSettings(final String address,
+ public void addAddressSettings(final String address,
final String DLA,
final String expiryAddress,
final boolean lastValueQueue,
@@ -1187,7 +1316,9 @@
final long redistributionDelay,
final boolean sendToDLAOnNoRoute,
final String addressFullMessagePolicy) throws Exception
- {
+ {
+ checkStarted();
+
AddressSettings addressSettings = new AddressSettings();
addressSettings.setDeadLetterAddress(DLA == null?null:new SimpleString(DLA));
addressSettings.setExpiryAddress(expiryAddress == null?null:new SimpleString(expiryAddress));
@@ -1219,16 +1350,22 @@
public AddressSettings getAddressSettings(final String address)
{
+ checkStarted();
+
return server.getAddressSettingsRepository().getMatch(address);
}
public void removeAddressSettings(String addressMatch)
{
+ checkStarted();
+
server.getAddressSettingsRepository().removeMatch(addressMatch);
}
public void sendQueueInfoToQueue(final String queueName, final String address) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -1399,5 +1536,13 @@
{
return MBeanInfoHelper.getMBeanOperationsInfo(HornetQServerControl.class);
}
+
+ private void checkStarted()
+ {
+ if (!server.isStarted())
+ {
+ throw new IllegalStateException("HornetQ Server is not started. It can not be managed yet");
+ }
+ }
}
Modified: trunk/src/main/org/hornetq/core/management/impl/QueueControlImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/management/impl/QueueControlImpl.java 2010-03-25 09:11:43 UTC (rev 8962)
+++ trunk/src/main/org/hornetq/core/management/impl/QueueControlImpl.java 2010-03-25 10:23:18 UTC (rev 8963)
@@ -115,11 +115,15 @@
public String getAddress()
{
+ checkStarted();
+
return address;
}
public String getFilter()
{
+ checkStarted();
+
clearIO();
try
{
@@ -135,6 +139,8 @@
public boolean isDurable()
{
+ checkStarted();
+
clearIO();
try
{
@@ -148,6 +154,8 @@
public boolean isTemporary()
{
+ checkStarted();
+
clearIO();
try
{
@@ -161,6 +169,8 @@
public int getMessageCount()
{
+ checkStarted();
+
clearIO();
try
{
@@ -174,6 +184,8 @@
public int getConsumerCount()
{
+ checkStarted();
+
clearIO();
try
{
@@ -187,6 +199,8 @@
public int getDeliveringCount()
{
+ checkStarted();
+
clearIO();
try
{
@@ -200,6 +214,8 @@
public long getMessagesAdded()
{
+ checkStarted();
+
clearIO();
try
{
@@ -213,6 +229,8 @@
public long getID()
{
+ checkStarted();
+
clearIO();
try
{
@@ -226,6 +244,8 @@
public long getScheduledCount()
{
+ checkStarted();
+
clearIO();
try
{
@@ -239,6 +259,8 @@
public String getDeadLetterAddress()
{
+ checkStarted();
+
clearIO();
try
{
@@ -261,6 +283,8 @@
public void setDeadLetterAddress(final String deadLetterAddress) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -279,6 +303,8 @@
public String getExpiryAddress()
{
+ checkStarted();
+
clearIO();
try
{
@@ -301,6 +327,8 @@
public void setExpiryAddress(final String expiryAddress) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -323,6 +351,8 @@
public Map<String, Object>[] listScheduledMessages() throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -344,6 +374,8 @@
public String listScheduledMessagesAsJSON() throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -357,6 +389,8 @@
public Map<String, Object>[] listMessages(final String filterStr) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -386,6 +420,8 @@
public String listMessagesAsJSON(final String filter) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -399,6 +435,8 @@
public int countMessages(final String filterStr) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -430,6 +468,8 @@
public boolean removeMessage(final long messageID) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -447,6 +487,8 @@
public int removeMessages(final String filterStr) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -462,6 +504,8 @@
public boolean expireMessage(final long messageID) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -475,6 +519,8 @@
public int expireMessages(final String filterStr) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -493,6 +539,8 @@
public boolean moveMessage(final long messageID, final String otherQueueName) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -514,6 +562,8 @@
public int moveMessages(final String filterStr, final String otherQueueName) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -539,6 +589,8 @@
public int sendMessagesToDeadLetterAddress(final String filterStr) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -554,6 +606,8 @@
public boolean sendMessageToDeadLetterAddress(final long messageID) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -567,6 +621,8 @@
public int changeMessagesPriority(final String filterStr, final int newPriority) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -587,6 +643,8 @@
public boolean changeMessagePriority(final long messageID, final int newPriority) throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -605,6 +663,8 @@
public String listMessageCounter()
{
+ checkStarted();
+
clearIO();
try
{
@@ -622,6 +682,8 @@
public void resetMessageCounter()
{
+ checkStarted();
+
clearIO();
try
{
@@ -635,6 +697,8 @@
public String listMessageCounterAsHTML()
{
+ checkStarted();
+
clearIO();
try
{
@@ -648,6 +712,8 @@
public String listMessageCounterHistory() throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -661,6 +727,8 @@
public String listMessageCounterHistoryAsHTML()
{
+ checkStarted();
+
clearIO();
try
{
@@ -674,6 +742,8 @@
public void pause()
{
+ checkStarted();
+
clearIO();
try
{
@@ -687,6 +757,8 @@
public void resume()
{
+ checkStarted();
+
clearIO();
try
{
@@ -700,6 +772,8 @@
public boolean isPaused() throws Exception
{
+ checkStarted();
+
clearIO();
try
{
@@ -717,11 +791,20 @@
return MBeanInfoHelper.getMBeanOperationsInfo(QueueControl.class);
}
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
// Private -------------------------------------------------------
+ private void checkStarted()
+ {
+ if (!postOffice.isStarted())
+ {
+ throw new IllegalStateException("HornetQ Server is not started. Queue can not be managed yet");
+ }
+ }
+
// Inner classes -------------------------------------------------
}
Modified: trunk/src/main/org/hornetq/core/server/HornetQServer.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/HornetQServer.java 2010-03-25 09:11:43 UTC (rev 8962)
+++ trunk/src/main/org/hornetq/core/server/HornetQServer.java 2010-03-25 10:23:18 UTC (rev 8963)
@@ -63,6 +63,12 @@
Version getVersion();
+ /**
+ * Returns the resource to manage this HornetQ server.
+ *
+ * Using this control will throw IllegalStateException if the
+ * server is not properly started.
+ */
HornetQServerControlImpl getHornetQServerControl();
void registerActivateCallback(ActivateCallback callback);
Modified: trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2010-03-25 09:11:43 UTC (rev 8962)
+++ trunk/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java 2010-03-25 10:23:18 UTC (rev 8963)
@@ -1104,10 +1104,11 @@
{
for (CoreQueueConfiguration config : configuration.getQueueConfigurations())
{
- messagingServerControl.deployQueue(config.getAddress(),
- config.getName(),
- config.getFilterString(),
- config.isDurable());
+ deployQueue(SimpleString.toSimpleString(config.getAddress()),
+ SimpleString.toSimpleString(config.getName()),
+ SimpleString.toSimpleString(config.getFilterString()),
+ config.isDurable(),
+ false);
}
}
Modified: trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java 2010-03-25 09:11:43 UTC (rev 8962)
+++ trunk/src/main/org/hornetq/jms/management/impl/JMSServerControlImpl.java 2010-03-25 10:23:18 UTC (rev 8963)
@@ -16,7 +16,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import javax.management.ListenerNotFoundException;
@@ -30,7 +29,6 @@
import javax.management.StandardMBean;
import org.hornetq.api.core.Pair;
-import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.management.ManagementHelper;
import org.hornetq.api.jms.management.ConnectionFactoryControl;
@@ -38,13 +36,7 @@
import org.hornetq.api.jms.management.JMSServerControl;
import org.hornetq.api.jms.management.TopicControl;
import org.hornetq.core.management.impl.MBeanInfoHelper;
-import org.hornetq.core.security.Role;
-import org.hornetq.core.settings.impl.AddressFullMessagePolicy;
-import org.hornetq.core.settings.impl.AddressSettings;
import org.hornetq.jms.server.JMSServerManager;
-import org.hornetq.utils.SecurityFormatter;
-import org.hornetq.utils.json.JSONArray;
-import org.hornetq.utils.json.JSONObject;
/**
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -97,7 +89,7 @@
final Object[] liveConnectorTransportParams,
final Object[] backupConnectorsTransportClassNames,
final Object[] backupConnectorTransportParams)
- {
+ {
List<Pair<TransportConfiguration, TransportConfiguration>> pairs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
for (int i = 0; i < liveConnectorsTransportClassNames.length; i++)
@@ -123,13 +115,13 @@
new TransportConfiguration(backupConnectorsTransportClassNames[i].toString(), backupParams);
}
Pair<TransportConfiguration, TransportConfiguration> pair = new Pair<TransportConfiguration, TransportConfiguration>(tcLive,
- tcBackup);
+ tcBackup);
pairs.add(pair);
}
return pairs;
- }
+ }
public static MBeanNotificationInfo[] getNotificationInfos()
{
@@ -141,7 +133,7 @@
}
return new MBeanNotificationInfo[] { new MBeanNotificationInfo(names,
JMSServerControl.class.getName(),
- "Notifications emitted by a JMS Server") };
+ "Notifications emitted by a JMS Server") };
}
// Constructors --------------------------------------------------
@@ -160,120 +152,231 @@
final String liveTransportClassName,
final Map<String, Object> liveTransportParams,
final Object[] jndiBindings) throws Exception
- {
- List<String> jndiBindingsList = JMSServerControlImpl.convert(jndiBindings);
- TransportConfiguration liveTC = new TransportConfiguration(liveTransportClassName, liveTransportParams);
+ {
+ checkStarted();
- server.createConnectionFactory(name, liveTC, jndiBindingsList);
+ clearIO();
- sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
- }
+ try
+ {
+ List<String> jndiBindingsList = JMSServerControlImpl.convert(jndiBindings);
+ TransportConfiguration liveTC = new TransportConfiguration(liveTransportClassName, liveTransportParams);
+ server.createConnectionFactory(name, liveTC, jndiBindingsList);
+
+ sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
+ }
+ finally
+ {
+ blockOnIO();
+ }
+ }
+
public void createConnectionFactory(final String name,
final Object[] liveConnectorsTransportClassNames,
final Object[] liveConnectorTransportParams,
final Object[] backupConnectorsTransportClassNames,
final Object[] backupConnectorTransportParams,
final Object[] jndiBindings) throws Exception
- {
- List<Pair<TransportConfiguration, TransportConfiguration>> pairs = JMSServerControlImpl.convertToConnectorPairs(liveConnectorsTransportClassNames,
- liveConnectorTransportParams,
- backupConnectorsTransportClassNames,
- backupConnectorTransportParams);
- List<String> jndiBindingsList = JMSServerControlImpl.convert(jndiBindings);
+ {
+ checkStarted();
- server.createConnectionFactory(name, pairs, jndiBindingsList);
+ clearIO();
- sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
- }
+ try
+ {
+ List<Pair<TransportConfiguration, TransportConfiguration>> pairs = JMSServerControlImpl.convertToConnectorPairs(liveConnectorsTransportClassNames,
+ liveConnectorTransportParams,
+ backupConnectorsTransportClassNames,
+ backupConnectorTransportParams);
+ List<String> jndiBindingsList = JMSServerControlImpl.convert(jndiBindings);
+ server.createConnectionFactory(name, pairs, jndiBindingsList);
+
+ sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
+ }
+ finally
+ {
+ blockOnIO();
+ }
+ }
+
public void createConnectionFactory(final String name,
final String liveTransportClassNames,
final String liveTransportParams,
final String backupTransportClassNames,
final String backupTransportParams,
final String jndiBindings) throws Exception
- {
- Object[] liveClassNames = JMSServerControlImpl.toArray(liveTransportClassNames);
- Object[] liveParams = ManagementHelper.fromCommaSeparatedArrayOfCommaSeparatedKeyValues(liveTransportParams);
- Object[] backupClassNames = JMSServerControlImpl.toArray(backupTransportClassNames);
- Object[] backupParams = ManagementHelper.fromCommaSeparatedArrayOfCommaSeparatedKeyValues(backupTransportParams);;
- Object[] bindings = JMSServerControlImpl.toArray(jndiBindings);
- createConnectionFactory(name, liveClassNames, liveParams, backupClassNames, backupParams, bindings);
- }
+ {
+ checkStarted();
+ clearIO();
+ try
+ {
+ Object[] liveClassNames = JMSServerControlImpl.toArray(liveTransportClassNames);
+ Object[] liveParams = ManagementHelper.fromCommaSeparatedArrayOfCommaSeparatedKeyValues(liveTransportParams);
+ Object[] backupClassNames = JMSServerControlImpl.toArray(backupTransportClassNames);
+ Object[] backupParams = ManagementHelper.fromCommaSeparatedArrayOfCommaSeparatedKeyValues(backupTransportParams);;
+ Object[] bindings = JMSServerControlImpl.toArray(jndiBindings);
+ createConnectionFactory(name, liveClassNames, liveParams, backupClassNames, backupParams, bindings);
+ }
+ finally
+ {
+ blockOnIO();
+ }
+ }
+
+
public void createConnectionFactory(final String name,
final String discoveryAddress,
final int discoveryPort,
final Object[] jndiBindings) throws Exception
- {
- List<String> jndiBindingsList = JMSServerControlImpl.convert(jndiBindings);
+ {
+ checkStarted();
- server.createConnectionFactory(name, discoveryAddress, discoveryPort, jndiBindingsList);
+ clearIO();
- sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
- }
+ try
+ {
+ List<String> jndiBindingsList = JMSServerControlImpl.convert(jndiBindings);
+ server.createConnectionFactory(name, discoveryAddress, discoveryPort, jndiBindingsList);
+
+ sendNotification(NotificationType.CONNECTION_FACTORY_CREATED, name);
+ }
+ finally
+ {
+ blockOnIO();
+ }
+ }
+
public void createConnectionFactory(final String name,
final String discoveryAddress,
final int discoveryPort,
final String jndiBindings) throws Exception
- {
- Object[] bindings = JMSServerControlImpl.toArray(jndiBindings);
+ {
+ checkStarted();
- createConnectionFactory(name, discoveryAddress, discoveryPort, bindings);
- }
+ clearIO();
+ try
+ {
+ Object[] bindings = JMSServerControlImpl.toArray(jndiBindings);
+ createConnectionFactory(name, discoveryAddress, discoveryPort, bindings);
+
+ }
+ finally
+ {
+ blockOnIO();
+ }
+ }
+
+
public boolean createQueue(final String name, final String jndiBinding) throws Exception
{
- boolean created = server.createQueue(name, jndiBinding, null, true);
- if (created)
+ checkStarted();
+
+ clearIO();
+
+ try
{
- sendNotification(NotificationType.QUEUE_CREATED, name);
+ boolean created = server.createQueue(name, jndiBinding, null, true);
+ if (created)
+ {
+ sendNotification(NotificationType.QUEUE_CREATED, name);
+ }
+ return created;
}
- return created;
+ finally
+ {
+ blockOnIO();
+ }
}
public boolean destroyQueue(final String name) throws Exception
{
- boolean destroyed = server.destroyQueue(name);
- if (destroyed)
+ checkStarted();
+
+ clearIO();
+
+ try
{
- sendNotification(NotificationType.QUEUE_DESTROYED, name);
+ boolean destroyed = server.destroyQueue(name);
+ if (destroyed)
+ {
+ sendNotification(NotificationType.QUEUE_DESTROYED, name);
+ }
+ return destroyed;
}
- return destroyed;
+ finally
+ {
+ blockOnIO();
+ }
}
public boolean createTopic(final String topicName, final String jndiBinding) throws Exception
{
- boolean created = server.createTopic(topicName, jndiBinding);
- if (created)
+ checkStarted();
+
+ clearIO();
+
+ try
{
- sendNotification(NotificationType.TOPIC_CREATED, topicName);
+ boolean created = server.createTopic(topicName, jndiBinding);
+ if (created)
+ {
+ sendNotification(NotificationType.TOPIC_CREATED, topicName);
+ }
+ return created;
}
- return created;
+ finally
+ {
+ blockOnIO();
+ }
}
public boolean destroyTopic(final String name) throws Exception
{
- boolean destroyed = server.destroyTopic(name);
- if (destroyed)
+ checkStarted();
+
+ clearIO();
+
+ try
{
- sendNotification(NotificationType.TOPIC_DESTROYED, name);
+ boolean destroyed = server.destroyTopic(name);
+ if (destroyed)
+ {
+ sendNotification(NotificationType.TOPIC_DESTROYED, name);
+ }
+ return destroyed;
}
- return destroyed;
+ finally
+ {
+ blockOnIO();
+ }
}
public void destroyConnectionFactory(final String name) throws Exception
{
- boolean destroyed = server.destroyConnectionFactory(name);
- if (destroyed)
+ checkStarted();
+
+ clearIO();
+
+ try
{
- sendNotification(NotificationType.CONNECTION_FACTORY_DESTROYED, name);
+ boolean destroyed = server.destroyConnectionFactory(name);
+ if (destroyed)
+ {
+ sendNotification(NotificationType.CONNECTION_FACTORY_DESTROYED, name);
+ }
}
+ finally
+ {
+ blockOnIO();
+ }
}
public boolean isStarted()
@@ -283,45 +386,80 @@
public String getVersion()
{
+ checkStarted();
+
return server.getVersion();
}
public String[] getQueueNames()
{
- Object[] queueControls = server.getHornetQServer().getManagementService().getResources(JMSQueueControl.class);
- String[] names = new String[queueControls.length];
- for (int i = 0; i < queueControls.length; i++)
+ checkStarted();
+
+ clearIO();
+
+ try
{
- JMSQueueControl queueControl = (JMSQueueControl)queueControls[i];
- names[i] = queueControl.getName();
+ Object[] queueControls = server.getHornetQServer().getManagementService().getResources(JMSQueueControl.class);
+ String[] names = new String[queueControls.length];
+ for (int i = 0; i < queueControls.length; i++)
+ {
+ JMSQueueControl queueControl = (JMSQueueControl)queueControls[i];
+ names[i] = queueControl.getName();
+ }
+ return names;
}
- return names;
+ finally
+ {
+ blockOnIO();
+ }
}
public String[] getTopicNames()
{
- Object[] topicControls = server.getHornetQServer().getManagementService().getResources(TopicControl.class);
- String[] names = new String[topicControls.length];
- for (int i = 0; i < topicControls.length; i++)
+ checkStarted();
+
+ clearIO();
+
+ try
{
- TopicControl topicControl = (TopicControl)topicControls[i];
- names[i] = topicControl.getName();
+ Object[] topicControls = server.getHornetQServer().getManagementService().getResources(TopicControl.class);
+ String[] names = new String[topicControls.length];
+ for (int i = 0; i < topicControls.length; i++)
+ {
+ TopicControl topicControl = (TopicControl)topicControls[i];
+ names[i] = topicControl.getName();
+ }
+ return names;
}
- return names;
+ finally
+ {
+ blockOnIO();
+ }
}
public String[] getConnectionFactoryNames()
{
- Object[] cfControls = server.getHornetQServer()
- .getManagementService()
- .getResources(ConnectionFactoryControl.class);
- String[] names = new String[cfControls.length];
- for (int i = 0; i < cfControls.length; i++)
+ checkStarted();
+
+ clearIO();
+
+ try
{
- ConnectionFactoryControl cfControl = (ConnectionFactoryControl)cfControls[i];
- names[i] = cfControl.getName();
+ Object[] cfControls = server.getHornetQServer()
+ .getManagementService()
+ .getResources(ConnectionFactoryControl.class);
+ String[] names = new String[cfControls.length];
+ for (int i = 0; i < cfControls.length; i++)
+ {
+ ConnectionFactoryControl cfControl = (ConnectionFactoryControl)cfControls[i];
+ names[i] = cfControl.getName();
+ }
+ return names;
}
- return names;
+ finally
+ {
+ blockOnIO();
+ }
}
// NotificationEmitter implementation ----------------------------
@@ -329,9 +467,9 @@
public void removeNotificationListener(final NotificationListener listener,
final NotificationFilter filter,
final Object handback) throws ListenerNotFoundException
- {
+ {
broadcaster.removeNotificationListener(listener, filter, handback);
- }
+ }
public void removeNotificationListener(final NotificationListener listener) throws ListenerNotFoundException
{
@@ -341,9 +479,9 @@
public void addNotificationListener(final NotificationListener listener,
final NotificationFilter filter,
final Object handback) throws IllegalArgumentException
- {
+ {
broadcaster.addNotificationListener(listener, filter, handback);
- }
+ }
public MBeanNotificationInfo[] getNotificationInfo()
{
@@ -352,32 +490,84 @@
public String[] listRemoteAddresses() throws Exception
{
- return server.listRemoteAddresses();
+ checkStarted();
+
+ clearIO();
+
+ try
+ {
+ return server.listRemoteAddresses();
+ }
+ finally
+ {
+ blockOnIO();
+ }
}
public String[] listRemoteAddresses(final String ipAddress) throws Exception
{
- return server.listRemoteAddresses(ipAddress);
+ checkStarted();
+
+ clearIO();
+
+ try
+ {
+ return server.listRemoteAddresses(ipAddress);
+ }
+ finally
+ {
+ blockOnIO();
+ }
}
public boolean closeConnectionsForAddress(final String ipAddress) throws Exception
{
- return server.closeConnectionsForAddress(ipAddress);
+ checkStarted();
+
+ clearIO();
+
+ try
+ {
+ return server.closeConnectionsForAddress(ipAddress);
+ }
+ finally
+ {
+ blockOnIO();
+ }
}
public String[] listConnectionIDs() throws Exception
{
- return server.listConnectionIDs();
+ checkStarted();
+
+ clearIO();
+
+ try
+ {
+ return server.listConnectionIDs();
+ }
+ finally
+ {
+ blockOnIO();
+ }
}
public String[] listSessions(final String connectionID) throws Exception
{
- return server.listSessions(connectionID);
- }
+ checkStarted();
+ clearIO();
+ try
+ {
+ return server.listSessions(connectionID);
+ }
+ finally
+ {
+ blockOnIO();
+ }
+ }
-
@Override
public MBeanInfo getMBeanInfo()
{
@@ -402,6 +592,41 @@
broadcaster.sendNotification(notif);
}
+ private void checkStarted()
+ {
+ if (!server.isStarted())
+ {
+ throw new IllegalStateException("HornetQ JMS Server is not started. it can not be managed yet");
+ }
+ }
+
+ protected void clearIO()
+ {
+ // the storage manager could be null on the backup on certain components
+ if (server.getHornetQServer().getStorageManager() != null)
+ {
+ server.getHornetQServer().getStorageManager().clearContext();
+ }
+ }
+
+ protected void blockOnIO()
+ {
+ // the storage manager could be null on the backup on certain components
+ if (server.getHornetQServer().getStorageManager() != null)
+ {
+ try
+ {
+ server.getHornetQServer().getStorageManager().waitOnOperations();
+ server.getHornetQServer().getStorageManager().clearContext();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+
+ }
+
// Inner classes -------------------------------------------------
public static enum NotificationType
@@ -414,7 +639,7 @@
CONNECTION_FACTORY_DESTROYED;
}
- private static List<String> toList(final String commaSeparatedString)
+ private static List<String> toList(final String commaSeparatedString)
{
List<String> list = new ArrayList<String>();
if (commaSeparatedString == null || commaSeparatedString.trim().length() == 0)
Modified: trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2010-03-25 09:11:43 UTC (rev 8962)
+++ trunk/src/main/org/hornetq/jms/server/impl/JMSServerManagerImpl.java 2010-03-25 10:23:18 UTC (rev 8963)
@@ -234,7 +234,7 @@
public boolean isStarted()
{
- return server.getHornetQServerControl().isStarted();
+ return server.isStarted();
}
// JMSServerManager implementation -------------------------------
@@ -275,7 +275,7 @@
{
checkInitialised();
- return server.getHornetQServerControl().getVersion();
+ return server.getVersion().getFullVersion();
}
public synchronized boolean createQueue(final String queueName,
@@ -287,17 +287,18 @@
HornetQDestination jBossQueue = HornetQDestination.createQueue(queueName);
// Convert from JMS selector to core filter
- String coreFilterString = null;
+ SimpleString coreFilterString = null;
if (selectorString != null)
{
- coreFilterString = SelectorTranslator.convertToHornetQFilterString(selectorString);
+ coreFilterString = SimpleString.toSimpleString(SelectorTranslator.convertToHornetQFilterString(selectorString));
}
- server.getHornetQServerControl().deployQueue(jBossQueue.getAddress(),
- jBossQueue.getAddress(),
- coreFilterString,
- durable);
+ server.deployQueue(jBossQueue.getSimpleAddress(),
+ jBossQueue.getSimpleAddress(),
+ coreFilterString,
+ durable,
+ false);
boolean added = bindToJndi(jndiBinding, jBossQueue);
@@ -318,10 +319,12 @@
// checks when routing messages to a topic that
// does not exist - otherwise we would not be able to distinguish from a non existent topic and one with no
// subscriptions - core has no notion of a topic
- server.getHornetQServerControl().deployQueue(jBossTopic.getAddress(),
- jBossTopic.getAddress(),
- JMSServerManagerImpl.REJECT_FILTER,
- true);
+ server.deployQueue(jBossTopic.getSimpleAddress(),
+ jBossTopic.getSimpleAddress(),
+ SimpleString.toSimpleString(JMSServerManagerImpl.REJECT_FILTER),
+ true,
+ false);
+
boolean added = bindToJndi(jndiBinding, jBossTopic);
if (added)
{
@@ -359,7 +362,7 @@
destinations.remove(name);
jmsManagementService.unregisterQueue(name);
- server.getHornetQServerControl().destroyQueue(HornetQDestination.createQueueAddressFromName(name).toString());
+ server.destroyQueue(HornetQDestination.createQueueAddressFromName(name), null);
return true;
}
@@ -386,7 +389,7 @@
// We can't remove the remote binding. As this would be the bridge associated with the topic on this case
if (binding.getType() != BindingType.REMOTE_QUEUE)
{
- server.getHornetQServerControl().destroyQueue(queueName);
+ server.destroyQueue(SimpleString.toSimpleString(queueName), null);
}
}
}
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java 2010-03-25 09:11:43 UTC (rev 8962)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlTest.java 2010-03-25 10:23:18 UTC (rev 8963)
@@ -14,11 +14,6 @@
package org.hornetq.tests.integration.jms.server.management;
-import static org.hornetq.tests.util.RandomUtil.randomSimpleString;
-import static org.hornetq.tests.util.RandomUtil.randomString;
-
-import java.util.Set;
-
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Queue;
@@ -27,13 +22,10 @@
import junit.framework.Assert;
-import org.hornetq.api.core.SimpleString;
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.core.management.AddressControl;
-import org.hornetq.api.core.management.HornetQServerControl;
import org.hornetq.api.core.management.ObjectNameBuilder;
import org.hornetq.api.core.management.ResourceNames;
-import org.hornetq.api.core.management.RoleInfo;
import org.hornetq.api.jms.management.JMSServerControl;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.config.DiscoveryGroupConfiguration;
@@ -42,12 +34,10 @@
import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
import org.hornetq.core.remoting.impl.invm.TransportConstants;
-import org.hornetq.core.security.Role;
import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.HornetQServers;
import org.hornetq.jms.client.HornetQConnectionFactory;
import org.hornetq.jms.client.HornetQDestination;
-import org.hornetq.jms.client.HornetQQueueBrowser;
import org.hornetq.jms.server.JMSServerManager;
import org.hornetq.jms.server.impl.JMSServerManagerImpl;
import org.hornetq.tests.integration.management.ManagementControlHelper;
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java 2010-03-25 09:11:43 UTC (rev 8962)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java 2010-03-25 10:23:18 UTC (rev 8963)
@@ -26,7 +26,6 @@
import org.hornetq.api.jms.management.JMSServerControl;
import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
import org.hornetq.core.security.Role;
-import org.hornetq.core.settings.impl.AddressSettings;
import org.hornetq.jms.client.HornetQConnectionFactory;
import org.hornetq.jms.client.HornetQDestination;
More information about the hornetq-commits
mailing list