modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java
| 4
modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
| 2
modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
| 3
modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java
| 85 ++++
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBeanTest.java
| 66 ---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
| 172 ----------
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
| 20 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java
| 8
modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
| 30 +
9 files changed, 145 insertions(+), 245 deletions(-)
New commits:
commit 686716224eeaeed7179e1edc9a4532702b7bd494
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 8 09:52:51 2013 -0400
revert snashot call in avail check
also log the execution time for avail checks
diff --git
a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
index 93d758c..5e7692b 100644
---
a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
+++
b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
@@ -128,18 +128,28 @@ public class CassandraNodeComponent extends
JMXServerComponent<ResourceComponent
@Override
public AvailabilityType getAvailability() {
- ResourceContext<?> context = getResourceContext();
- ProcessInfo processInfo = context.getNativeProcess();
+ long start = System.currentTimeMillis();
+ try {
+ ResourceContext<?> context = getResourceContext();
+ ProcessInfo processInfo = context.getNativeProcess();
- if (processInfo == null) {
- return UNKNOWN;
- } else {
- // It is safe to read prior snapshot as getNativeProcess always return a
fresh instance
- ProcessInfoSnapshot processInfoSnaphot = processInfo.freshSnapshot();
- if (processInfoSnaphot.isRunning()) {
- return UP;
+ if (processInfo == null) {
+ return UNKNOWN;
} else {
- return DOWN;
+ // It is safe to read prior snapshot as getNativeProcess always return a
fresh instance
+ // ProcessInfoSnapshot processInfoSnaphot = processInfo.freshSnapshot();
+ if (processInfo.priorSnaphot().isRunning()) {
+ return UP;
+ } else {
+ return DOWN;
+ }
+ }
+ } finally {
+ long end = System.currentTimeMillis();
+ long totalTime = end - start;
+ log.debug("Finished availability check in " + totalTime + "
ms");
+ if (totalTime > (1000 * 5)) {
+ log.warn("Availability check exceeded five seconds. Total time was
" + totalTime + " ms");
}
}
}
commit 2d36e94937dd694ebfb6bab50e57db3717687363
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 8 09:46:20 2013 -0400
Create storage nodes from rhq.cassandra.seeds prop during installation
Previously we were reading rhq.cassandra.seeds at server start up and had logic
in place to see if there were any changes in the property. If changes were
detected (i.e., new node added), cluster maintenance would be scheduled. We
really only want to create/persist seeds nodes at installation time though.
Once the server has been installed, rhqctl install should be used to install
new storage nodes. This simplifies server start up logic and also reduces the
chances for screwing up the deployment.
diff --git
a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java
b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java
index 8f67ab3..2836964 100644
---
a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java
+++
b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java
@@ -98,6 +98,10 @@ public class SchemaManager {
return topology.updateTopology(isNewSchema);
}
+ public List<StorageNode> getStorageNodes() {
+ return nodes;
+ }
+
private static List<StorageNode> parseNodeInformation(String... nodes) {
List<StorageNode> parsedNodes = new ArrayList<StorageNode>();
for (String node : nodes) {
diff --git a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
index 32824e2..cfe13be 100644
--- a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
@@ -675,6 +675,8 @@ rhq.cassandra.password=${rhq.cassandra.password}
#
# hostname|jmxPort|nativeTransportPort|
#
+# Note that this is actually an installer setting. Changing the value after
+# installation will have no effect.
rhq.cassandra.seeds=
# If enabled data sent to and from storage nodes will be compressed using
diff --git
a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
index 4c87f70..284ddbd 100644
---
a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
+++
b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
@@ -499,6 +499,9 @@ public class InstallerServiceImpl implements InstallerService {
// ensure the server info is up to date and stored in the DB
ServerInstallUtil.storeServerDetails(serverProperties, clearTextDbPassword,
serverDetails);
+
+ ServerInstallUtil.persistStorageNodesIfNecessary(serverProperties,
clearTextDbPassword,
+ storageNodeSchemaManager.getStorageNodes());
}
@Override
diff --git
a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java
b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java
index 0318e0e..d0f6f3f 100644
---
a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java
+++
b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java
@@ -68,6 +68,7 @@ import org.rhq.core.db.DbUtil;
import org.rhq.core.db.OracleDatabaseType;
import org.rhq.core.db.PostgresqlDatabaseType;
import org.rhq.core.db.setup.DBSetup;
+import org.rhq.core.domain.cloud.StorageNode;
import org.rhq.core.util.PropertiesFileUpdate;
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.core.util.file.FileUtil;
@@ -950,6 +951,89 @@ public class ServerInstallUtil {
}
/**
+ * Persists the storage nodes to the database only if no storage node entities
already exist. This method is used
+ * to persist storage nodes created from the rhq.cassandra.seeds server configuration
property. The only time those
+ * seed nodes should be created is during an initial server installation. After the
initial installation storage
+ * nodes should be created using <code>rhqctl install</code>. This
ensures that any necessary cluster maintenance
+ * tasks will be performed.
+ *
+ * @param serverProperties the server properties
+ * @param password clear text password to connect to the database
+ * @param storageNodes the {@link StorageNode storage nodes} to persist
+ * @throws Exception
+ */
+ public static void persistStorageNodesIfNecessary(HashMap<String, String>
serverProperties, String password,
+ List<StorageNode> storageNodes) throws Exception {
+ DatabaseType db = null;
+ Connection connection = null;
+ Statement queryStatement = null;
+ ResultSet resultSet = null;
+ PreparedStatement insertStatement = null;
+
+ try {
+ String dbUrl =
serverProperties.get(ServerProperties.PROP_DATABASE_CONNECTION_URL);
+ String userName =
serverProperties.get(ServerProperties.PROP_DATABASE_USERNAME);
+ connection = getDatabaseConnection(dbUrl, userName, password);
+ db = DatabaseTypeFactory.getDatabaseType(connection);
+
+ if (!(db instanceof PostgresqlDatabaseType || db instanceof
OracleDatabaseType)) {
+ throw new IllegalArgumentException("Unknown database type, can't
continue: " + db);
+ }
+
+ connection = getDatabaseConnection(dbUrl, userName, password);
+ queryStatement = connection.createStatement();
+ resultSet = queryStatement.executeQuery("SELECT count(id) FROM
rhq_storage_node");
+ resultSet.next();
+
+ if (resultSet.getInt(1) == 0) {
+ connection.setAutoCommit(false);
+
+ try {
+ LOG.info("Persisting to database new storage nodes for values
specified in server configuration " +
+ "property [rhq.cassandra.seeds]");
+
+ insertStatement = connection.prepareStatement(
+ "INSERT INTO rhq_storage_node (id, address, jmx_port,
cql_port, operation_mode, ctime, mtime) " +
+ "VALUES (?, ?, ?, ?, ?, ?, ?)"
+ );
+
+ int id = 1001;
+ for (StorageNode storageNode : storageNodes) {
+ insertStatement.setInt(1, id);
+ insertStatement.setString(2, storageNode.getAddress());
+ insertStatement.setInt(3, storageNode.getJmxPort());
+ insertStatement.setInt(4, storageNode.getCqlPort());
+ insertStatement.setString(5,
StorageNode.OperationMode.INSTALLED.toString());
+ insertStatement.setLong(6, System.currentTimeMillis());
+ insertStatement.setLong(7, System.currentTimeMillis());
+
+ insertStatement.executeUpdate();
+ id += 1;
+ }
+
+ connection.commit();
+ } catch (SQLException e) {
+ LOG.error("Failed to persist to database the storage nodes
specified by server configuration " +
+ "property [rhq.cassandra.seeds]. Transaction will be rolled
back.", e);
+ connection.rollback();
+ throw e;
+ }
+ } else {
+ LOG.info("Storage nodes already exist in database. Server
configuration property " +
+ "[rhq.cassandra.seeds] will be ignored.");
+ }
+
+ } finally {
+ if (db != null) {
+ db.closeResultSet(resultSet);
+ db.closeStatement(queryStatement);
+ db.closeStatement(insertStatement);
+ db.closeConnection(connection);
+ }
+ }
+ }
+
+ /**
* Stores the server details (such as the public endpoint) in the database. If the
server definition already
* exists, it will be updated; otherwise, a new server will be added to the HA
cloud.
*
@@ -982,6 +1066,7 @@ public class ServerInstallUtil {
}
}
+
private static void updateOrInsertServer(DatabaseType db, Connection conn,
ServerDetails serverDetails) {
PreparedStatement stm = null;
ResultSet rs = null;
diff --git
a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBeanTest.java
b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBeanTest.java
index d44d637..4e04447 100644
---
a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBeanTest.java
+++
b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBeanTest.java
@@ -26,8 +26,6 @@
package org.rhq.enterprise.server.cloud;
import static
org.rhq.enterprise.server.cloud.StorageNodeManagerBean.STORAGE_NODE_GROUP_NAME;
-import static
org.rhq.enterprise.server.cloud.StorageNodeManagerBean.STORAGE_NODE_PLUGIN_NAME;
-import static
org.rhq.enterprise.server.cloud.StorageNodeManagerBean.STORAGE_NODE_RESOURCE_TYPE_NAME;
import java.util.ArrayList;
import java.util.Arrays;
@@ -81,70 +79,6 @@ public class StorageNodeManagerBeanTest extends AbstractEJB3Test {
private static final String TEST_PREFIX = "test-";
- @Test
- public void testInit() throws Exception {
- final String cassandraSeedsProperty = "rhq.cassandra.seeds";
- final String originalSeedValue = System.getProperty(cassandraSeedsProperty);
-
- try {
- prepareScheduler();
- cleanDatabase();
- executeInTransaction(new TransactionCallback() {
-
- @Override
- public void execute() throws Exception {
- String testHostName = TEST_PREFIX + "hostname";
- List<String> addresses = Arrays.asList(testHostName,
TEST_PREFIX + "hostWithNoFoundResource",
- TEST_PREFIX + "secondHostWithNoFoundResource");
- System.setProperty(cassandraSeedsProperty, addresses.get(0) +
"|123|123," + addresses.get(1)
- + "|987|987," + addresses.get(2) +
"|123|123");
-
- // create the resource type if it doesn't exist
- ResourceType testResourceType =
typeManager.getResourceTypeByNameAndPlugin("RHQ Storage Node",
- "RHQStorage");
- if (testResourceType == null) {
- testResourceType = createResourceType();
- }
- Resource testResource = createResource(testResourceType,
testHostName);
-
- // finds the storage nodes and pairs them w/ the associated
resources
- nodeManager.scanForStorageNodes();
-
- // get the storage nodes and checks some properties on them
- List<StorageNode> storageNodes =
nodeManager.getStorageNodes();
- Assert.assertNotNull(storageNodes, "The list of storage nodes
shouldn't be null.");
- Assert.assertFalse(storageNodes.isEmpty(), "The list of storage
nodes shouldn't be empty.");
- Assert.assertTrue(storageNodes.size() >= addresses.size(),
- "The size of the list of storage nodes should be at least
" + addresses.size());
-
- List<String> obtainedAddresses = new
ArrayList<String>(storageNodes.size());
- for (StorageNode storageNode : storageNodes) {
- Assert.assertNotNull(storageNode.getAddress(), "Address of
storage node cannot be null.");
- obtainedAddresses.add(storageNode.getAddress());
- if (storageNode.getAddress().equals(testHostName)) {
- Assert.assertEquals(storageNode.getResource().getId(),
testResource.getId());
- Assert.assertNotNull(storageNode.getResource(),
"Associated resource cannot be null.");
- } else {
- Assert.assertNull(storageNode.getResource(),
- "The resource field should be null at this
point.");
- }
- }
-
- Assert.assertTrue(obtainedAddresses.containsAll(addresses),
- "There are some storage nodes that should be created but
were not discovered and returned."
- + " The storage nodes that should be returned: " +
addresses
- + " The storage nodes that were returned: " +
obtainedAddresses
- + " (the second should be a super-set (not necessarily
strict) of the first.)");
-
- }
- });
- } finally {
- unprepareScheduler();
- cleanDatabase();
- System.setProperty(cassandraSeedsProperty, originalSeedValue);
- }
- }
-
@Test(groups = "integration.ejb3")
public void testStorageNodeCriteriaFinder() throws Exception {
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
index b76d054..9d073ee 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
@@ -53,16 +53,13 @@ import org.rhq.core.domain.common.JobTrigger;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.criteria.StorageNodeCriteria;
-import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementAggregate;
import org.rhq.core.domain.measurement.MeasurementUnits;
import org.rhq.core.domain.operation.bean.GroupOperationSchedule;
-import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
import org.rhq.enterprise.server.authz.RequiredPermission;
@@ -88,22 +85,10 @@ public class StorageNodeManagerBean implements
StorageNodeManagerLocal, StorageN
private final Log log = LogFactory.getLog(StorageNodeManagerBean.class);
- private static final String RHQ_STORAGE_RESOURCE_TYPE = "RHQ Storage
Node";
- private static final String RHQ_STORAGE_PLUGIN = "RHQStorage";
-
private static final String RHQ_STORAGE_CQL_PORT_PROPERTY =
"nativeTransportPort";
private static final String RHQ_STORAGE_JMX_PORT_PROPERTY = "jmxPort";
private static final String RHQ_STORAGE_ADDRESS_PROPERTY = "host";
- private static final String SEEDS_PROP = "rhq.cassandra.seeds";
-
- // The following have package visibility to make accessible to
StorageNodeManagerBeanTest
- static final String STORAGE_NODE_GROUP_NAME = "RHQ Storage Nodes";
-
- static final String STORAGE_NODE_RESOURCE_TYPE_NAME = "RHQ Storage Node";
-
- static final String STORAGE_NODE_PLUGIN_NAME = "RHQStorage";
-
@PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
private EntityManager entityManager;
@@ -126,89 +111,6 @@ public class StorageNodeManagerBean implements
StorageNodeManagerLocal, StorageN
private OperationManagerLocal operationManager;
@Override
- public synchronized List<StorageNode> scanForStorageNodes() {
- List<StorageNode> existingStorageNodes = getStorageNodes();
- if (log.isDebugEnabled()) {
- log.debug("Found existing storage nodes [" +
StringUtil.listToString(existingStorageNodes)
- + "] in the database");
- }
-
- String seeds = System.getProperty(SEEDS_PROP);
-
- if (StringUtil.isEmpty(seeds) && existingStorageNodes.isEmpty()) {
- // We need to find storage node connection info from one or the other but
not
- // necessarily both. If this is a single server deployment where the storage
- // node(s) is running on a separate machine, then SEEDS_PROP will have to be
set
- // manually. And in this scenario during the initial deployment, there will
not
- // be any storage nodes in the db. In a HA deployment, where there are
already
- // storage nodes in the db, an RHQ server does not have to have SEEDS_PROP
set
- // since it can obtain connection info from the storage node table.
- throw new IllegalStateException("There are no existing storage nodes
defined in the RHQ database and "
- + "the system property [" + SEEDS_PROP + "] is not set.
The RHQ server will not be able to connect "
- + "to the RHQ storage node(s). The [" + SEEDS_PROP + "]
property should be defined in "
- + "rhq-server.properties.");
- }
-
- List<StorageNode> seedNodes = parseSeedsProperty(seeds);
- boolean clusterMaintenanceNeeded = false;
- List<StorageNode> newNodes = null;
-
- if (existingStorageNodes.isEmpty()) {
- // This should only happen on the very first server start upon installation.
- if (log.isDebugEnabled()) {
- log.debug("No storage node entities exist in the database");
- log.debug("Persisting seed nodes [" +
StringUtil.listToString(seedNodes) + "]");
- }
- createStorageNodeGroup();
- } else {
- // There are existing storage nodes but we need to check if the storage node
- // group exists. In the case of an upgrade, the group would not yet exist so
it
- // has to be created now.
- if (!storageNodeGroupExists()) {
- createStorageNodeGroup();
- addExistingStorageNodesToGroup();
- }
-
- newNodes = findNewStorageNodes(existingStorageNodes, seedNodes);
- if (!newNodes.isEmpty()) {
- log.info("Detected topology change. New seed nodes will be
persisted.");
- if (log.isDebugEnabled()) {
- log.debug("Persisting new seed nodes [" +
StringUtil.listToString(newNodes));
- }
-
- clusterMaintenanceNeeded = true;
- }
- }
-
- Map<String, StorageNode> storageNodeMap = new HashMap<String,
StorageNode>(existingStorageNodes.size()
- + seedNodes.size());
- for (StorageNode existingStorageNode : existingStorageNodes) {
- storageNodeMap.put(existingStorageNode.getAddress(), existingStorageNode);
- }
- // possibly overide the existing storage nodes with up to date data
- for (StorageNode seedNode : seedNodes) {
- StorageNode existing = storageNodeMap.get(seedNode.getAddress());
- if (existing != null) {
- if (existing.getJmxPort() != seedNode.getJmxPort() ||
existing.getCqlPort() != seedNode.getCqlPort()
- || existing.getResource() != seedNode.getResource()) {
- existing.setMtime(new Date().getTime());
- }
- seedNode.setResource(existing.getResource());
- }
- storageNodeMap.put(seedNode.getAddress(), seedNode);
- }
-
- this.discoverResourceInformation(storageNodeMap);
- this.updateStorageNodes(storageNodeMap);
-
- if (clusterMaintenanceNeeded) {
- this.scheduleQuartzJob(existingStorageNodes.size());
- }
-
- return new ArrayList<StorageNode>(storageNodeMap.values());
- }
-
- @Override
public void linkResource(Resource resource) {
List<StorageNode> storageNodes = this.getStorageNodes();
@@ -250,7 +152,8 @@ public class StorageNodeManagerBean implements
StorageNodeManagerLocal, StorageN
}
}
- private void createStorageNodeGroup() {
+ @Override
+ public void createStorageNodeGroup() {
log.info("Creating resource group [" + STORAGE_NODE_GROUP_NAME +
"]");
ResourceGroup group = new ResourceGroup(STORAGE_NODE_GROUP_NAME);
@@ -261,6 +164,8 @@ public class StorageNodeManagerBean implements
StorageNodeManagerLocal, StorageN
group.setRecursive(false);
resourceGroupManager.createResourceGroup(subjectManager.getOverlord(), group);
+
+ addExistingStorageNodesToGroup();
}
private void addExistingStorageNodesToGroup() {
@@ -283,13 +188,8 @@ public class StorageNodeManagerBean implements
StorageNodeManagerLocal, StorageN
new int[] {resource.getId()});
}
- /**
- * This method is very similar to {@link #getStorageNodeGroup()} but may be called
- * prior to the group being created.
- *
- * @return true if the storage node resource group exists, false otherwise.
- */
- private boolean storageNodeGroupExists() {
+ @Override
+ public boolean storageNodeGroupExists() {
Subject overlord = subjectManager.getOverlord();
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
@@ -302,14 +202,7 @@ public class StorageNodeManagerBean implements
StorageNodeManagerLocal, StorageN
return !groups.isEmpty();
}
- /**
- * Note that this method assumes the storage node resource group already exists; as
- * such, it should only be called from places in the code that are after the
point(s)
- * where the group has been created.
- *
- * @return The storage node resource group.
- * @throws IllegalStateException if the group is not found or does not exist.
- */
+ @Override
public ResourceGroup getStorageNodeGroup() {
Subject overlord = subjectManager.getOverlord();
@@ -499,24 +392,6 @@ public class StorageNodeManagerBean implements
StorageNodeManagerLocal, StorageN
return storageNodes;
}
- private List<StorageNode> findNewStorageNodes(List<StorageNode> nodes,
List<StorageNode> seedNodes) {
- if (log.isDebugEnabled()) {
- log.debug("Checking system property [" + SEEDS_PROP + "] for
any new nodes to be persisted");
- }
- List<StorageNode> newNodes = new ArrayList<StorageNode>();
- for (StorageNode seedNode : seedNodes) {
- // The contains call should be ok even though it is an O(N) operation
because
- // the number of storage nodes will be small and this is only done at start
up.
- if (!nodes.contains(seedNode)) {
- if (log.isDebugEnabled()) {
- log.debug("Detected new storage node [" + seedNode +
"]");
- }
- newNodes.add(seedNode);
- }
- }
- return newNodes;
- }
-
private void scheduleQuartzJob(int clusterSize) {
String jobName = StorageNodeMaintenanceJob.class.getName();
String jobGroupName = StorageNodeMaintenanceJob.class.getName();
@@ -552,38 +427,7 @@ public class StorageNodeManagerBean implements
StorageNodeManagerLocal, StorageN
}
entityManager.flush();
}
-
- private void discoverResourceInformation(Map<String, StorageNode>
storageNodeMap) {
- TypedQuery<ResourceType> query =
entityManager.<ResourceType>createNamedQuery(ResourceType.QUERY_FIND_BY_NAME_AND_PLUGIN,
ResourceType.class)
- .setParameter("name",
RHQ_STORAGE_RESOURCE_TYPE).setParameter("plugin", RHQ_STORAGE_PLUGIN);
- List<ResourceType> resourceTypes = query.getResultList();
-
- if (resourceTypes.isEmpty()) {
- return;
- }
-
- TypedQuery<Resource> resourceQuery =
entityManager.<Resource>createNamedQuery(Resource.QUERY_FIND_BY_TYPE_ADMIN,
Resource.class).setParameter("type",
- resourceTypes.get(0));
- List<Resource> cassandraResources = resourceQuery.getResultList();
-
- for (Resource resource : cassandraResources) {
- Configuration resourceConfiguration = resource.getPluginConfiguration();
- String host =
resourceConfiguration.getSimpleValue(RHQ_STORAGE_ADDRESS_PROPERTY);
-
- if (host != null && storageNodeMap.containsKey(host)) {
- StorageNode storageNode = storageNodeMap.get(host);
-
- storageNode.setResource(resource);
- if (resource.getInventoryStatus() == InventoryStatus.NEW) {
- storageNode.setOperationMode(OperationMode.INSTALLED);
- } else if (resource.getInventoryStatus() == InventoryStatus.COMMITTED
- && resource.getCurrentAvailability().getAvailabilityType() ==
AvailabilityType.UP) {
- storageNode.setOperationMode(OperationMode.NORMAL);
- }
- }
- }
- }
-
+
private StorageNodeLoadComposite.MeasurementAggregateWithUnits
getMeasurementAggregateWithUnits(Subject subject,
int schedId, MeasurementUnits units, long beginTime, long endTime) {
MeasurementAggregate measurementAggregate =
measurementManager.getAggregate(subject, schedId, beginTime,
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
index 52e2424..5c3f092 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
@@ -33,7 +33,10 @@ import org.rhq.core.domain.util.PageList;
@Local
public interface StorageNodeManagerLocal {
- List<StorageNode> scanForStorageNodes();
+ // The following have package visibility to make accessible to
StorageNodeManagerBeanTest
+ String STORAGE_NODE_GROUP_NAME = "RHQ Storage Nodes";
+ String STORAGE_NODE_RESOURCE_TYPE_NAME = "RHQ Storage Node";
+ String STORAGE_NODE_PLUGIN_NAME = "RHQStorage";
List<StorageNode> getStorageNodes();
@@ -88,6 +91,21 @@ public interface StorageNodeManagerLocal {
void runReadRepair();
/**
+ * Creates the storage node resource group which will be named {@link
#STORAGE_NODE_GROUP_NAME}. This method should
+ * only be called at start up by {@link
org.rhq.enterprise.server.storage.StorageClientManagerBean StorageClientManagerBean}.
+ * Storage node entities created during installation will be added to the group.
+ */
+ void createStorageNodeGroup();
+
+ /**
+ * Checks whether or not the storage node resource group exists. This method is very
similar to
+ * {@link #getStorageNodeGroup()} but may be called prior to the group being
created.
+ *
+ * @return true if the storage node resource group exists, false otherwise.
+ */
+ boolean storageNodeGroupExists();
+
+ /**
* This method assumes the storage node resource group already exists; as such, it
should only be called from places
* in the code that are after the point(s) where the group has been created.
*
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java
index 0c76dee..2d48092 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java
@@ -86,10 +86,10 @@ public class StorageClientManagerBean {
log.info("Initializing storage client subsystem");
- //decide if there are no storage nodes persisted before doing anything
- boolean isNewServerInstall = storageNodeManager.getStorageNodes().isEmpty();
-
- storageNodeManager.scanForStorageNodes();
+ boolean isNewServerInstall = !storageNodeManager.storageNodeGroupExists();
+ if (isNewServerInstall) {
+ storageNodeManager.createStorageNodeGroup();
+ }
String username = getRequiredStorageProperty(USERNAME_PROP);
String password = getRequiredStorageProperty(PASSWORD_PROP);