modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java | 6 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java | 2 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java | 55 ++++------ 3 files changed, 31 insertions(+), 32 deletions(-)
New commits: commit b0ff8622f259f971ef309fe086829fffd62e2605 Author: Jay Shaughnessy jshaughn@redhat.com Date: Fri Sep 27 11:20:32 2013 -0400
Fix an issue where the storage client init was using system properties to get the storage user and password. This had two issues: 1) at install the system properties were seeded in AS via -p rhq-server.properties, but this was prior to the generation of the storage cluster creds. 2) for HA installs the props file was actually not even correct, the generated values were superseded by the existing db creds.
This commit syncs the props file and the db, during install, so problem 2 really should no longer be a problem. But this was mainly done to reduce confusion for a person who may have wondered why the db and props file had different values. It didn't solve problem 1. To solve problem 1 the storage client should always get its creds from the DB, which it now does.
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 e10c993..445f41e 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 @@ -468,7 +468,8 @@ public class InstallerServiceImpl implements InstallerService { throw new Exception("Cannot connect to the database: " + testConnectionErrorMessage); }
- // write the new properties to the rhq-server.properties file (this ensures the encoded password is written out) + // write the new properties to the rhq-server.properties file (this ensures the encoded password is written + // out). Being paranoid, leaving this here despite the fact that we now write it out again, at the bottom. saveServerProperties(serverProperties);
// Prepare the db schema. @@ -548,6 +549,9 @@ public class InstallerServiceImpl implements InstallerService { ServerInstallUtil.persistStorageNodesIfNecessary(serverProperties, clearTextDbPassword, parseNodeInformation(serverProperties)); ServerInstallUtil.persistStorageClusterSettingsIfNecessary(serverProperties, clearTextDbPassword); + + // For sanity, make sure the server props file is in sync with the db settings. + saveServerProperties(serverProperties); }
@Override diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java index c484e0a..f0912fc 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java @@ -450,7 +450,7 @@ public class StartupBean implements StartupLocal { }
/** - * Initalizes the storage client subsystem which is needed for reading/writing metric data. + * Initializes the storage client subsystem which is needed for reading/writing metric data. * * @return true if the storage subsystem is running */ 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 943c53c..9cd7cc3 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 @@ -49,8 +49,11 @@ import org.apache.commons.logging.LogFactory; import org.rhq.cassandra.schema.SchemaManager; import org.rhq.cassandra.util.ClusterBuilder; import org.rhq.core.domain.cloud.StorageNode; -import org.rhq.core.util.StringUtil; +import org.rhq.core.domain.common.composite.SystemSetting; +import org.rhq.core.domain.common.composite.SystemSettings; +import org.rhq.enterprise.server.auth.SubjectManagerLocal; import org.rhq.enterprise.server.cloud.StorageNodeManagerLocal; +import org.rhq.enterprise.server.system.SystemManagerLocal; import org.rhq.server.metrics.DateTimeService; import org.rhq.server.metrics.MetricsConfiguration; import org.rhq.server.metrics.MetricsDAO; @@ -66,13 +69,17 @@ public class StorageClientManagerBean {
private final Log log = LogFactory.getLog(StorageClientManagerBean.class);
- private static final String USERNAME_PROP = "rhq.storage.username"; - private static final String PASSWORD_PROP = "rhq.storage.password"; private static final String RHQ_KEYSPACE = "rhq";
@EJB + private SubjectManagerLocal subjectManager; + + @EJB private StorageNodeManagerLocal storageNodeManager;
+ @EJB + private SystemManagerLocal systemManager; + private Cluster cluster; private StorageSession session; private MetricsConfiguration metricsConfiguration; @@ -94,8 +101,10 @@ public class StorageClientManagerBean {
log.info("Initializing storage client subsystem");
- final String username = getRequiredStorageProperty(USERNAME_PROP); - final String password = getRequiredStorageProperty(PASSWORD_PROP); + // Always get the creds from the DB, system props may not be up to date at install time + SystemSettings settings = systemManager.getSystemSettings(subjectManager.getOverlord()); + final String username = settings.get(SystemSetting.STORAGE_USERNAME); + final String password = settings.get(SystemSetting.STORAGE_PASSWORD);
List<StorageNode> storageNodes = new ArrayList<StorageNode>(); for (StorageNode storageNode : storageNodeManager.getStorageNodes()) { @@ -105,9 +114,9 @@ public class StorageClientManagerBean { // and REMOVE_MAINTENANCE, but this errors on the side of being safe. Lastly, // if a storage node does not have a resource, then that means it was was // deployed prior to installing the server. - if (storageNode.getOperationMode() == StorageNode.OperationMode.NORMAL || - storageNode.getOperationMode() == StorageNode.OperationMode.MAINTENANCE || - storageNode.getResource() == null) { + if (storageNode.getOperationMode() == StorageNode.OperationMode.NORMAL + || storageNode.getOperationMode() == StorageNode.OperationMode.MAINTENANCE + || storageNode.getResource() == null) { storageNodes.add(storageNode); } } @@ -123,9 +132,9 @@ public class StorageClientManagerBean { checkSchemaCompability(username, password, storageNodes); } catch (NoHostAvailableException e) { initialized = false; - log.warn("Storage client subsystem wasn't initialized because it wasn't possible to connect to the" + - " storage cluster. The RHQ server is set to MAINTENANCE mode. Please start the storage cluster" + - " as soon as possible."); + log.warn("Storage client subsystem wasn't initialized because it wasn't possible to connect to the" + + " storage cluster. The RHQ server is set to MAINTENANCE mode. Please start the storage cluster" + + " as soon as possible."); return initialized; } Session wrappedSession = createSession(username, password, storageNodes); @@ -231,21 +240,17 @@ public class StorageClientManagerBean { ProtocolOptions.Compression compression; if (compressionEnabled) { compression = ProtocolOptions.Compression.SNAPPY; - log.info("Compression has been enabled for the storage client. Be aware that if your storage nodes do " + - "not support compression then the client will not be able to connect to the storage cluster."); + log.info("Compression has been enabled for the storage client. Be aware that if your storage nodes do " + + "not support compression then the client will not be able to connect to the storage cluster."); } else { compression = ProtocolOptions.Compression.NONE; log.debug("Storage client compression is disabled"); }
- cluster = new ClusterBuilder() - .addContactPoints(hostNames.toArray(new String[hostNames.size()])) - .withCredentialsObfuscated(username, password) - .withPort(port) + cluster = new ClusterBuilder().addContactPoints(hostNames.toArray(new String[hostNames.size()])) + .withCredentialsObfuscated(username, password).withPort(port) .withLoadBalancingPolicy(new RoundRobinPolicy()) - .withRetryPolicy(new LoggingRetryPolicy(DefaultRetryPolicy.INSTANCE)) - .withCompression(compression) - .build(); + .withRetryPolicy(new LoggingRetryPolicy(DefaultRetryPolicy.INSTANCE)).withCompression(compression).build();
return cluster.connect(RHQ_KEYSPACE); } @@ -263,14 +268,4 @@ public class StorageClientManagerBean { metricsServer.setDateTimeService(dateTimeService); metricsServer.init(); } - - private String getRequiredStorageProperty(String property) { - String value = System.getProperty(property); - if (StringUtil.isEmpty(property)) { - throw new IllegalStateException("The system property [" + property + "] is not set. The RHQ " - + "server will not be able connect to the RHQ storage node(s). This property should be defined " - + "in rhq-server.properties."); - } - return value; - } }
rhq-commits@lists.fedorahosted.org