Skip to content
Browse files

new branch

configuration stored in local H2 database
helenos.properties file not required since now
comments in source code added
logging fixed
adhoc cluster reconnection implemented
  • Loading branch information...
1 parent 0df8689 commit 44f563298f2ae06a95b167a20e2e4127d64fea9f tomek committed Sep 17, 2012
Showing with 578 additions and 144 deletions.
  1. +2 −1 .gitignore
  2. +21 −0 pom.xml
  3. +1 −1 runClean.bat
  4. +1 −3 src/main/frontend/source/class/helenos/components/RightContentPane.js.js
  5. +9 −3 src/main/frontend/source/class/helenos/components/SchemaPane.js
  6. +6 −2 src/main/frontend/source/class/helenos/components/tab/browse/GetSlicePage.js
  7. +7 −8 src/main/frontend/source/class/helenos/simulation/DemoSimulation.js
  8. +23 −0 src/main/frontend/source/class/helenos/ui/table/model/EditableSimple.js
  9. +83 −0 src/main/java/com/kuprowski/helenos/ClusterConfiguration.java
  10. +0 −4 src/main/java/com/kuprowski/helenos/Converter.java
  11. +58 −0 src/main/java/com/kuprowski/helenos/context/PostConfiguringClusterListener.java
  12. +88 −0 src/main/java/com/kuprowski/helenos/jdbc/core/support/ClusterConfigDao.java
  13. +17 −0 src/main/java/com/kuprowski/helenos/service/ClusterConfigAware.java
  14. +29 −0 src/main/java/com/kuprowski/helenos/service/ClusterConnectionProvider.java
  15. +0 −5 src/main/java/com/kuprowski/helenos/service/StandardQueryProvider.java
  16. +0 −5 src/main/java/com/kuprowski/helenos/service/SuperQueryProvider.java
  17. +12 −11 src/main/java/com/kuprowski/helenos/service/impl/AbstractProvider.java
  18. +87 −0 src/main/java/com/kuprowski/helenos/service/impl/ClusterConnectionProviderImpl.java
  19. +2 −1 src/main/java/com/kuprowski/helenos/service/impl/SchemaProviderImpl.java
  20. +2 −15 src/main/java/com/kuprowski/helenos/service/impl/StandardQueryProviderImpl.java
  21. +2 −1 src/main/java/com/kuprowski/helenos/service/impl/SuperQueryProviderImpl.java
  22. +6 −5 src/main/java/com/kuprowski/helenos/types/JsonColumnDefinition.java
  23. +6 −5 src/main/java/com/kuprowski/helenos/types/JsonColumnFamilyDefinition.java
  24. +6 −5 src/main/java/com/kuprowski/helenos/types/JsonComparatorType.java
  25. +6 −5 src/main/java/com/kuprowski/helenos/types/JsonKeyspaceDefinition.java
  26. +7 −12 src/main/java/com/kuprowski/helenos/types/SliceResult.java
  27. +6 −5 src/main/java/com/kuprowski/helenos/types/qx/QxJsonColumnFamilyDefinition.java
  28. +6 −5 src/main/java/com/kuprowski/helenos/types/qx/QxJsonKeyspaceDefinition.java
  29. +0 −4 src/main/java/com/kuprowski/helenos/types/qx/query/AbstractQuery.java
  30. +0 −4 src/main/java/com/kuprowski/helenos/types/qx/query/AbstractSliceQuery.java
  31. +6 −5 src/main/java/com/kuprowski/helenos/types/qx/query/SingleColumnQuery.java
  32. +6 −5 src/main/java/com/kuprowski/helenos/types/qx/query/SingleSubColumnQuery.java
  33. +6 −5 src/main/java/com/kuprowski/helenos/types/qx/query/SliceQuery.java
  34. +6 −5 src/main/java/com/kuprowski/helenos/types/qx/query/SubSliceQuery.java
  35. +6 −0 src/main/resources/queries.properties
  36. +2 −13 src/main/webapp/WEB-INF/context/applicationContext-hector.xml
  37. +21 −0 src/main/webapp/WEB-INF/context/applicationContext-jdbc.xml
  38. +7 −1 src/main/webapp/WEB-INF/context/applicationContext.xml
  39. +5 −0 src/main/webapp/WEB-INF/helenos-servlet.xml
  40. +20 −0 src/main/webapp/WEB-INF/web.xml
View
3 .gitignore
@@ -4,4 +4,5 @@
/src/main/frontend/build/
/src/main/frontend/source/script/
/src/main/webapp/helenos/
-/src/main/frontend/contribs/dialog/build/
+/src/main/frontend/contribs/dialog/build/
+/src/main/webapp/WEB-INF/logs/
View
21 pom.xml
@@ -95,6 +95,27 @@
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.3.168</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-jdbc</artifactId>
+ <version>3.1.2.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
<build>
View
2 runClean.bat
@@ -1,3 +1,3 @@
SET MAVEN_OPTS=-Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n
cls
-mvn -o clean jetty:run
+mvn -o clean tomcat7:run
View
4 src/main/frontend/source/class/helenos/components/RightContentPane.js.js
@@ -20,8 +20,6 @@ qx.Class.define("helenos.components.RightContentPane",
construct : function()
{
this.base(arguments);
-
- var welcomePage = new helenos.components.tab.WelcomePage();
- this.add(welcomePage);
+ this.add(new helenos.components.tab.WelcomePage());
}
});
View
12 src/main/frontend/source/class/helenos/components/SchemaPane.js
@@ -110,6 +110,10 @@ qx.Class.define("helenos.components.SchemaPane",
},
__renderKeyspaces : function(ksDefs) {
+ if (ksDefs == undefined) {
+ // AHDC
+ return;
+ }
for (var i = 0; i < ksDefs.length; i++) {
var ks = ksDefs[i];
@@ -144,9 +148,11 @@ qx.Class.define("helenos.components.SchemaPane",
ttt += 'Key validator: <b>' + cfDef.keyValidationClass + '</b><br/>';
ttt += 'Default validator: <b>' + cfDef.defaultValidationClass + '</b><br/>';
var tooltip = new qx.ui.tooltip.ToolTip(ttt);
- tooltip.setWidth(350);
- tooltip.setRich(true);
- tooltip.setShowTimeout(100);
+ tooltip.set({
+ width : 350,
+ rich : true,
+ showTimeout : 100
+ });
return tooltip;
},
View
8 src/main/frontend/source/class/helenos/components/tab/browse/GetSlicePage.js
@@ -39,10 +39,14 @@ qx.Class.define("helenos.components.tab.browse.GetSlicePage",
},
_getResultComponent : function(result) {
- var tableModel = new qx.ui.table.model.Simple();
+ var tableModel = new helenos.ui.table.model.EditableSimple();
tableModel.setColumns(['Column','Value'],['name','value']);
tableModel.setDataAsMapArray(result);
- return new qx.ui.table.Table(tableModel);
+
+ var tablePane = new qx.ui.core.scroll.ScrollPane();
+ tablePane.set({allowGrowX : true, allowGrowY : true});
+ tablePane.add(new qx.ui.table.Table(tableModel));
+ return tablePane;
},
_getCriteriaComponents : function() {
View
15 src/main/frontend/source/class/helenos/simulation/DemoSimulation.js
@@ -1,12 +1,11 @@
/* ************************************************************************
-
- Copyright:
-
- License:
-
- Authors:
-
-************************************************************************ */
+Copyright:
+ 2012 Tomek Kuprowski
+License:
+ GPLv2: http://www.gnu.org/licences/gpl.html
+Authors:
+ Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ ************************************************************************ */
/**
* This class demonstrates how to define simulated interaction tests for your
View
23 src/main/frontend/source/class/helenos/ui/table/model/EditableSimple.js
@@ -0,0 +1,23 @@
+/* ************************************************************************
+Copyright:
+ 2012 Tomek Kuprowski
+License:
+ GPLv2: http://www.gnu.org/licences/gpl.html
+Authors:
+ Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ ************************************************************************ */
+qx.Class.define("helenos.ui.table.model.EditableSimple",
+{
+ extend : qx.ui.table.model.Simple,
+
+ construct : function()
+ {
+ this.base(arguments);
+ },
+
+ members : {
+ isColumnEditable : function(index) {
+ return true;
+ }
+ }
+});
View
83 src/main/java/com/kuprowski/helenos/ClusterConfiguration.java
@@ -0,0 +1,83 @@
+package com.kuprowski.helenos;
+
+import java.util.HashMap;
+import java.util.Map;
+import me.prettyprint.cassandra.service.CassandraHostConfigurator;
+import me.prettyprint.cassandra.service.ThriftCluster;
+import me.prettyprint.hector.api.Cluster;
+import org.springframework.util.Assert;
+
+/**
+ * ********************************************************
+ * Copyright: 2012 Tomek Kuprowski
+ *
+ * License: GPLv2: http://www.gnu.org/licences/gpl.html
+ *
+ * @author Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ * *******************************************************
+ */
+public class ClusterConfiguration {
+
+ private String hosts;
+ private String clusterName;
+ private boolean active;
+ private String alias;
+
+ public ClusterConfiguration() {
+ }
+
+ public ClusterConfiguration(String alas, String hosts, String clusterName, boolean active) {
+ setAlias(alias);
+ setHosts(hosts);
+ setClusterName(clusterName);
+ setActive(active);
+ }
+
+ public void setAlias(String alias) {
+ this.alias = alias;
+ }
+
+ public String getAlias() {
+ return alias;
+ }
+
+ public String getHosts() {
+ return hosts;
+ }
+
+ public void setHosts(String hosts) {
+ this.hosts = hosts;
+ }
+
+ public String getClusterName() {
+ return clusterName;
+ }
+
+ public void setClusterName(String clusterName) {
+ this.clusterName = clusterName;
+ }
+
+ public boolean isActive() {
+ return active;
+ }
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
+
+ public Cluster createCluster() {
+ return new ThriftCluster(clusterName, new CassandraHostConfigurator(hosts));
+ }
+
+ public Map<String, ?> toParametersMap() {
+ Assert.hasLength(hosts);
+ Assert.hasLength(clusterName);
+
+ Map<String, Object> map = new HashMap<String, Object>(3);
+ map.put("alias", alias);
+ map.put("hosts", hosts);
+ map.put("clustername", clusterName);
+ map.put("active", active);
+ return map;
+ }
+}
View
4 src/main/java/com/kuprowski/helenos/Converter.java
@@ -1,7 +1,3 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package com.kuprowski.helenos;
import java.util.UUID;
View
58 src/main/java/com/kuprowski/helenos/context/PostConfiguringClusterListener.java
@@ -0,0 +1,58 @@
+package com.kuprowski.helenos.context;
+
+import com.kuprowski.helenos.ClusterConfiguration;
+import com.kuprowski.helenos.jdbc.core.support.ClusterConfigDao;
+import com.kuprowski.helenos.service.ClusterConfigAware;
+import java.util.Map;
+import me.prettyprint.hector.api.Cluster;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.web.context.support.XmlWebApplicationContext;
+
+/**
+ * ********************************************************
+ * Copyright: 2012 Tomek Kuprowski
+ *
+ * License: GPLv2: http://www.gnu.org/licences/gpl.html
+ *
+ * @author Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ * *******************************************************
+ */
+public class PostConfiguringClusterListener implements ApplicationListener<ContextRefreshedEvent> {
+
+ @Autowired
+ private ClusterConfigDao clusterConfigDao;
+
+ public PostConfiguringClusterListener() {
+ }
+
+ @Required
+ public void setClusterConfigDao(ClusterConfigDao clusterConfigDao) {
+ this.clusterConfigDao = clusterConfigDao;
+ }
+
+ private boolean isReady(ContextRefreshedEvent event) {
+ XmlWebApplicationContext context = (XmlWebApplicationContext) event.getSource();
+ return context.getServletConfig() != null;
+ }
+
+ public static void propagadeConfigChanges(ApplicationContext applicationContext, Cluster cluster) {
+ Map<String, ClusterConfigAware> beans = applicationContext.getBeansOfType(ClusterConfigAware.class);
+ for (ClusterConfigAware bean : beans.values()) {
+ bean.setNewCluster(cluster);
+ }
+ }
+
+ @Override
+ public void onApplicationEvent(ContextRefreshedEvent event) {
+ if (isReady(event)) {
+ ApplicationContext applicationContext = event.getApplicationContext();
+ ClusterConfiguration configuration = clusterConfigDao.getActive();
+
+ propagadeConfigChanges(applicationContext.getParent(), configuration.createCluster());
+ }
+ }
+}
View
88 src/main/java/com/kuprowski/helenos/jdbc/core/support/ClusterConfigDao.java
@@ -0,0 +1,88 @@
+package com.kuprowski.helenos.jdbc.core.support;
+
+import com.kuprowski.helenos.ClusterConfiguration;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.Properties;
+import javax.sql.DataSource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+import org.springframework.jdbc.core.RowMapper;
+import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
+import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
+import org.springframework.jdbc.core.namedparam.SqlParameterSource;
+import org.springframework.util.CollectionUtils;
+
+/**
+ * ********************************************************
+ * Copyright: 2012 Tomek Kuprowski
+ *
+ * License: GPLv2: http://www.gnu.org/licences/gpl.html
+ *
+ * @author Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ * *******************************************************
+ */
+public class ClusterConfigDao {
+
+ private Properties queries;
+ @Autowired
+ protected NamedParameterJdbcTemplate jdbcTemplate;
+
+ @Required
+ public void setJdbcTemplate(NamedParameterJdbcTemplate jdbcTemplate) {
+ this.jdbcTemplate = jdbcTemplate;
+ }
+
+ @Required
+ public void setQueries(Properties queries) {
+ this.queries = queries;
+ }
+
+ public ClusterConfiguration getActive() {
+ List<ClusterConfiguration> configuration = jdbcTemplate.query(queries.getProperty("clusterconfig.select.star.wa"), new MapSqlParameterSource("active", true), new ClusterConfigurationMapper());
+
+ if (CollectionUtils.isEmpty(configuration)) {
+ this.createDefaultConfiguration();
+ return this.getActive();
+ }
+
+ return configuration.get(0);
+ }
+
+ public List<ClusterConfiguration> loadAll() {
+ return jdbcTemplate.query(queries.getProperty("clusterconfig.select.star"), new MapSqlParameterSource(), new ClusterConfigurationMapper());
+ }
+
+ private void createDefaultConfiguration() {
+ jdbcTemplate.update(queries.getProperty("clusterconfig.insert"), prepareParameterSource(new ClusterConfiguration("default", "localhost:9160", "TestCluster", true)));
+ }
+
+ private SqlParameterSource prepareParameterSource(ClusterConfiguration configuration) {
+ return new MapSqlParameterSource(configuration.toParametersMap());
+ }
+
+ public void store(ClusterConfiguration configuration) {
+ if (configuration.isActive()) {
+ jdbcTemplate.update(queries.getProperty("clusterconfig.update.all.active.false"), new MapSqlParameterSource());
+ }
+ jdbcTemplate.update(queries.getProperty("clusterconfig.merge"), prepareParameterSource(configuration));
+ }
+
+ public void delete(String alias) {
+ jdbcTemplate.update(queries.getProperty("clusterconfig.delete"), new MapSqlParameterSource("alias", alias));
+ }
+
+ private static final class ClusterConfigurationMapper implements RowMapper<ClusterConfiguration> {
+
+ @Override
+ public ClusterConfiguration mapRow(ResultSet rs, int rowNum) throws SQLException {
+ ClusterConfiguration cc = new ClusterConfiguration();
+ cc.setAlias(rs.getString("ALIAS"));
+ cc.setHosts(rs.getString("HOSTS"));
+ cc.setClusterName(rs.getString("CLUSTERNAME"));
+ cc.setActive(rs.getBoolean("ACTIVE"));
+ return cc;
+ }
+ }
+}
View
17 src/main/java/com/kuprowski/helenos/service/ClusterConfigAware.java
@@ -0,0 +1,17 @@
+package com.kuprowski.helenos.service;
+
+import me.prettyprint.hector.api.Cluster;
+
+/**
+ * ********************************************************
+ * Copyright: 2012 Tomek Kuprowski
+ *
+ * License: GPLv2: http://www.gnu.org/licences/gpl.html
+ *
+ * @author Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ * *******************************************************
+ */
+public interface ClusterConfigAware {
+
+ void setNewCluster(Cluster cluster);
+}
View
29 src/main/java/com/kuprowski/helenos/service/ClusterConnectionProvider.java
@@ -0,0 +1,29 @@
+package com.kuprowski.helenos.service;
+
+import com.kuprowski.helenos.ClusterConfiguration;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import me.prettyprint.cassandra.service.CassandraHost;
+
+/**
+ * ********************************************************
+ * Copyright: 2012 Tomek Kuprowski
+ *
+ * License: GPLv2: http://www.gnu.org/licences/gpl.html
+ *
+ * @author Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ * *******************************************************
+ */
+public interface ClusterConnectionProvider {
+
+ List<ClusterConfiguration> loadAll();
+
+ void store(ClusterConfiguration configuration);
+
+ void delete(String hosts);
+
+ void activate(ClusterConfiguration configuration);
+
+ Map<String, Set<CassandraHost>> getConnectionStatus();
+}
View
5 src/main/java/com/kuprowski/helenos/service/StandardQueryProvider.java
@@ -1,15 +1,10 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package com.kuprowski.helenos.service;
import com.googlecode.jsonrpc4j.JsonRpcParam;
import com.kuprowski.helenos.types.SliceResult;
import com.kuprowski.helenos.types.qx.query.SingleColumnQuery;
import com.kuprowski.helenos.types.qx.query.SliceQuery;
import java.util.List;
-import java.util.UUID;
/**
* ********************************************************
View
5 src/main/java/com/kuprowski/helenos/service/SuperQueryProvider.java
@@ -1,15 +1,10 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package com.kuprowski.helenos.service;
import com.googlecode.jsonrpc4j.JsonRpcParam;
import com.kuprowski.helenos.types.SliceResult;
import com.kuprowski.helenos.types.qx.query.SingleSubColumnQuery;
import com.kuprowski.helenos.types.qx.query.SubSliceQuery;
import java.util.List;
-import java.util.UUID;
/**
* ********************************************************
View
23 src/main/java/com/kuprowski/helenos/service/impl/AbstractProvider.java
@@ -1,11 +1,11 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package com.kuprowski.helenos.service.impl;
+import com.kuprowski.helenos.ClusterConfiguration;
import me.prettyprint.cassandra.serializers.ObjectSerializer;
import me.prettyprint.cassandra.serializers.SerializerTypeInferer;
+import me.prettyprint.cassandra.service.CassandraHost;
+import me.prettyprint.cassandra.service.CassandraHostConfigurator;
+import me.prettyprint.cassandra.service.ThriftCluster;
import me.prettyprint.hector.api.Cluster;
import me.prettyprint.hector.api.ConsistencyLevelPolicy;
import me.prettyprint.hector.api.Keyspace;
@@ -29,9 +29,8 @@
@Autowired
protected Mapper mapper;
@Autowired
- protected Cluster cluster;
- @Autowired
protected ConsistencyLevelPolicy consistencyLevelPolicy;
+ protected Cluster cluster;
protected <V> Serializer<V> getSerializer(Class<V> clazz) {
Serializer<V> serializer = SerializerTypeInferer.getSerializer(clazz);
@@ -42,6 +41,9 @@
}
protected Keyspace getKeyspace(String keyspaceName) {
+ if (cluster == null) {
+ throw new IllegalStateException("not ready yet");
+ }
return HFactory.createKeyspace(keyspaceName, cluster, consistencyLevelPolicy);
}
@@ -51,12 +53,11 @@ public void setMapper(Mapper mapper) {
}
@Required
- public void setCluster(Cluster cluster) {
- this.cluster = cluster;
- }
-
- @Required
public void setConsistencyLevelPolicy(ConsistencyLevelPolicy consistencyLevelPolicy) {
this.consistencyLevelPolicy = consistencyLevelPolicy;
}
+
+ public final void setNewCluster(Cluster cluster) {
+ this.cluster = cluster;
+ }
}
View
87 src/main/java/com/kuprowski/helenos/service/impl/ClusterConnectionProviderImpl.java
@@ -0,0 +1,87 @@
+package com.kuprowski.helenos.service.impl;
+
+import com.kuprowski.helenos.ClusterConfiguration;
+import com.kuprowski.helenos.context.PostConfiguringClusterListener;
+import com.kuprowski.helenos.jdbc.core.support.ClusterConfigDao;
+import com.kuprowski.helenos.service.ClusterConfigAware;
+import com.kuprowski.helenos.service.ClusterConnectionProvider;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import me.prettyprint.cassandra.connection.HConnectionManager;
+import me.prettyprint.cassandra.service.CassandraHost;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
+
+/**
+ * ********************************************************
+ * Copyright: 2012 Tomek Kuprowski
+ *
+ * License: GPLv2: http://www.gnu.org/licences/gpl.html
+ *
+ * @author Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ * *******************************************************
+ */
+@Component("clusterConnectionProvider")
+public class ClusterConnectionProviderImpl extends AbstractProvider implements ClusterConnectionProvider, ApplicationContextAware, ClusterConfigAware {
+
+ @Autowired
+ protected ClusterConfigDao clusterConfigDao;
+ private ApplicationContext applicationContext;
+
+ @Required
+ public void setClusterConfigDao(ClusterConfigDao clusterConfigDao) {
+ this.clusterConfigDao = clusterConfigDao;
+ }
+
+ @Override
+ public List<ClusterConfiguration> loadAll() {
+ return clusterConfigDao.loadAll();
+ }
+
+ @Override
+ public void store(ClusterConfiguration configuration) {
+ clusterConfigDao.store(configuration);
+ }
+
+ @Override
+ public void activate(ClusterConfiguration configuration) {
+ if (cluster != null) {
+ cluster.getConnectionManager().shutdown();
+ cluster = null;
+ }
+ if (!configuration.isActive()) {
+ configuration.setActive(true);
+ store(configuration);
+ }
+ PostConfiguringClusterListener.propagadeConfigChanges(applicationContext, configuration.createCluster());
+ }
+
+ @Override
+ public void delete(String hosts) {
+ clusterConfigDao.delete(hosts);
+ }
+
+ @Override
+ public Map<String, Set<CassandraHost>> getConnectionStatus() {
+ HConnectionManager connectionManager = cluster.getConnectionManager();
+
+ Map<String, Set<CassandraHost>> ret = new HashMap<String, Set<CassandraHost>>(3);
+
+ ret.put("LIVE", connectionManager.getHosts());
+ ret.put("DOWN", connectionManager.getDownedHosts());
+ ret.put("SUSPENDED", connectionManager.getSuspendedCassandraHosts());
+
+ return ret;
+ }
+
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+ this.applicationContext = applicationContext;
+ }
+}
View
3 src/main/java/com/kuprowski/helenos/service/impl/SchemaProviderImpl.java
@@ -1,5 +1,6 @@
package com.kuprowski.helenos.service.impl;
+import com.kuprowski.helenos.service.ClusterConfigAware;
import com.kuprowski.helenos.service.SchemaProvider;
import com.kuprowski.helenos.types.JsonColumnFamilyDefinition;
import com.kuprowski.helenos.types.JsonKeyspaceDefinition;
@@ -25,7 +26,7 @@
* *******************************************************
*/
@Component("schemaProvider")
-public class SchemaProviderImpl extends AbstractProvider implements SchemaProvider {
+public class SchemaProviderImpl extends AbstractProvider implements SchemaProvider, ClusterConfigAware {
@Override
public String describeClusterName() {
View
17 src/main/java/com/kuprowski/helenos/service/impl/StandardQueryProviderImpl.java
@@ -2,35 +2,22 @@
import com.googlecode.jsonrpc4j.JsonRpcParam;
import com.kuprowski.helenos.Converter;
+import com.kuprowski.helenos.service.ClusterConfigAware;
import com.kuprowski.helenos.service.StandardQueryProvider;
import com.kuprowski.helenos.types.SliceResult;
import com.kuprowski.helenos.types.qx.query.SingleColumnQuery;
import java.util.ArrayList;
import java.util.List;
-import java.util.UUID;
-import javax.swing.text.StyledEditorKit;
-import me.prettyprint.cassandra.serializers.SerializerTypeInferer;
import me.prettyprint.cassandra.serializers.StringSerializer;
-import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate;
-import me.prettyprint.cassandra.service.template.ThriftColumnFamilyTemplate;
-import me.prettyprint.hector.api.Keyspace;
-import me.prettyprint.hector.api.Serializer;
import me.prettyprint.hector.api.beans.ColumnSlice;
import me.prettyprint.hector.api.beans.HColumn;
import me.prettyprint.hector.api.factory.HFactory;
import me.prettyprint.hector.api.query.ColumnQuery;
import me.prettyprint.hector.api.query.QueryResult;
import me.prettyprint.hector.api.query.SliceQuery;
-import me.prettyprint.hector.api.query.SubColumnQuery;
import org.springframework.stereotype.Component;
/**
- *
- * {
- * "id" : 1, "method" : "singleColumn", "params" : ["java.lang.String",
- * "java.lang.String", "lookminders", "Users", "mama", "userdata"] }
- */
-/**
* ********************************************************
* Copyright: 2012 Tomek Kuprowski
*
@@ -40,7 +27,7 @@
* *******************************************************
*/
@Component("standardQueryProvider")
-public class StandardQueryProviderImpl extends AbstractProvider implements StandardQueryProvider {
+public class StandardQueryProviderImpl extends AbstractProvider implements StandardQueryProvider, ClusterConfigAware {
@Override
public <K, N> String singleColumn(@JsonRpcParam("query") SingleColumnQuery<K, N> query) {
View
3 src/main/java/com/kuprowski/helenos/service/impl/SuperQueryProviderImpl.java
@@ -2,6 +2,7 @@
import com.googlecode.jsonrpc4j.JsonRpcParam;
import com.kuprowski.helenos.Converter;
+import com.kuprowski.helenos.service.ClusterConfigAware;
import com.kuprowski.helenos.service.StandardQueryProvider;
import com.kuprowski.helenos.service.SuperQueryProvider;
import com.kuprowski.helenos.types.SliceResult;
@@ -32,7 +33,7 @@
* *******************************************************
*/
@Component("superQueryProvider")
-public class SuperQueryProviderImpl extends AbstractProvider implements SuperQueryProvider {
+public class SuperQueryProviderImpl extends AbstractProvider implements SuperQueryProvider, ClusterConfigAware {
@Override
public <K, SN, N> String singleColumn(@JsonRpcParam("query") SingleSubColumnQuery<K, SN, N> query) {
View
11 src/main/java/com/kuprowski/helenos/types/JsonColumnDefinition.java
@@ -1,15 +1,16 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package com.kuprowski.helenos.types;
import java.nio.ByteBuffer;
import me.prettyprint.hector.api.ddl.ColumnIndexType;
/**
+ * ********************************************************
+ * Copyright: 2012 Tomek Kuprowski
+ *
+ * License: GPLv2: http://www.gnu.org/licences/gpl.html
*
- * @author tomek
+ * @author Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ * *******************************************************
*/
public class JsonColumnDefinition {
View
11 src/main/java/com/kuprowski/helenos/types/JsonColumnFamilyDefinition.java
@@ -1,15 +1,16 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package com.kuprowski.helenos.types;
import java.util.List;
import java.util.Map;
/**
+ * ********************************************************
+ * Copyright: 2012 Tomek Kuprowski
+ *
+ * License: GPLv2: http://www.gnu.org/licences/gpl.html
*
- * @author tomek
+ * @author Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ * *******************************************************
*/
public class JsonColumnFamilyDefinition {
View
11 src/main/java/com/kuprowski/helenos/types/JsonComparatorType.java
@@ -1,12 +1,13 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package com.kuprowski.helenos.types;
/**
+ * ********************************************************
+ * Copyright: 2012 Tomek Kuprowski
+ *
+ * License: GPLv2: http://www.gnu.org/licences/gpl.html
*
- * @author tomek
+ * @author Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ * *******************************************************
*/
public class JsonComparatorType {
View
11 src/main/java/com/kuprowski/helenos/types/JsonKeyspaceDefinition.java
@@ -1,16 +1,17 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package com.kuprowski.helenos.types;
import java.util.List;
import java.util.Map;
import me.prettyprint.hector.api.ddl.KeyspaceDefinition;
/**
+ * ********************************************************
+ * Copyright: 2012 Tomek Kuprowski
+ *
+ * License: GPLv2: http://www.gnu.org/licences/gpl.html
*
- * @author tomek
+ * @author Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ * *******************************************************
*/
public class JsonKeyspaceDefinition {
View
19 src/main/java/com/kuprowski/helenos/types/SliceResult.java
@@ -1,23 +1,18 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package com.kuprowski.helenos.types;
import me.prettyprint.hector.api.beans.HColumn;
/**
+ * ********************************************************
+ * Copyright: 2012 Tomek Kuprowski
+ *
+ * License: GPLv2: http://www.gnu.org/licences/gpl.html
*
- * @author tomek
+ * @author Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ * *******************************************************
*/
-/*****
- * ZMIEN NAZWE ZMIEN NAZWE ZMIEN NAZWE ZMIEN NAZWE ZMIEN NAZWE ZMIEN NAZWE ZMIEN NAZWE ZMIEN NAZWE
- * ZMIEN NAZWE ZMIEN NAZWE ZMIEN NAZWE ZMIEN NAZWE ZMIEN NAZWE ZMIEN NAZWE ZMIEN NAZWE ZMIEN NAZWE
- * ZMIEN NAZWE ZMIEN NAZWE ZMIEN NAZWE ZMIEN NAZWE ZMIEN NAZWE ZMIEN NAZWE ZMIEN NAZWE ZMIEN NAZWE
- * @author tomek
- * @param <N>
- */
+/* TODO change name */
public class SliceResult<N> {
private N name;
View
11 src/main/java/com/kuprowski/helenos/types/qx/QxJsonColumnFamilyDefinition.java
@@ -1,12 +1,13 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package com.kuprowski.helenos.types.qx;
/**
+ * ********************************************************
+ * Copyright: 2012 Tomek Kuprowski
+ *
+ * License: GPLv2: http://www.gnu.org/licences/gpl.html
*
- * @author tomek
+ * @author Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ * *******************************************************
*/
public class QxJsonColumnFamilyDefinition {
View
11 src/main/java/com/kuprowski/helenos/types/qx/QxJsonKeyspaceDefinition.java
@@ -1,12 +1,13 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package com.kuprowski.helenos.types.qx;
/**
+ * ********************************************************
+ * Copyright: 2012 Tomek Kuprowski
+ *
+ * License: GPLv2: http://www.gnu.org/licences/gpl.html
*
- * @author tomek
+ * @author Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ * *******************************************************
*/
public class QxJsonKeyspaceDefinition {
View
4 src/main/java/com/kuprowski/helenos/types/qx/query/AbstractQuery.java
@@ -1,7 +1,3 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package com.kuprowski.helenos.types.qx.query;
/**
View
4 src/main/java/com/kuprowski/helenos/types/qx/query/AbstractSliceQuery.java
@@ -1,7 +1,3 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package com.kuprowski.helenos.types.qx.query;
/**
View
11 src/main/java/com/kuprowski/helenos/types/qx/query/SingleColumnQuery.java
@@ -1,12 +1,13 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package com.kuprowski.helenos.types.qx.query;
/**
+ * ********************************************************
+ * Copyright: 2012 Tomek Kuprowski
+ *
+ * License: GPLv2: http://www.gnu.org/licences/gpl.html
*
- * @author tomek
+ * @author Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ * *******************************************************
*/
public class SingleColumnQuery<K, N> extends AbstractQuery<K, N> {
View
11 src/main/java/com/kuprowski/helenos/types/qx/query/SingleSubColumnQuery.java
@@ -1,12 +1,13 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package com.kuprowski.helenos.types.qx.query;
/**
+ * ********************************************************
+ * Copyright: 2012 Tomek Kuprowski
+ *
+ * License: GPLv2: http://www.gnu.org/licences/gpl.html
*
- * @author tomek
+ * @author Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ * *******************************************************
*/
public class SingleSubColumnQuery<K,SN,N> extends SingleColumnQuery<K, N> {
View
11 src/main/java/com/kuprowski/helenos/types/qx/query/SliceQuery.java
@@ -1,12 +1,13 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package com.kuprowski.helenos.types.qx.query;
/**
+ * ********************************************************
+ * Copyright: 2012 Tomek Kuprowski
+ *
+ * License: GPLv2: http://www.gnu.org/licences/gpl.html
*
- * @author tomek
+ * @author Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ * *******************************************************
*/
public class SliceQuery<K, N> extends AbstractSliceQuery<K, N> {
View
11 src/main/java/com/kuprowski/helenos/types/qx/query/SubSliceQuery.java
@@ -1,12 +1,13 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
package com.kuprowski.helenos.types.qx.query;
/**
+ * ********************************************************
+ * Copyright: 2012 Tomek Kuprowski
+ *
+ * License: GPLv2: http://www.gnu.org/licences/gpl.html
*
- * @author tomek
+ * @author Tomek Kuprowski (tomekkuprowski at gmail dot com)
+ * *******************************************************
*/
public class SubSliceQuery<K,SN,N> extends SliceQuery<K, N> {
View
6 src/main/resources/queries.properties
@@ -0,0 +1,6 @@
+clusterconfig.select.star=SELECT * FROM CLUSTERCONFIG
+clusterconfig.select.star.wa=SELECT * FROM CLUSTERCONFIG WHERE ACTIVE=:active
+clusterconfig.insert=INTO CLUSTERCONFIG VALUES(:alias,:hosts,:clustername,:active)
+clusterconfig.merge=MERGE INTO CLUSTERCONFIG(ALIAS, HOSTS ,CLUSTERNAME ,ACTIVE) KEY (ALIAS,HOSTS,CLUSTERNAME) VALUES (:alias,:hosts,:clustername,:active)
+clusterconfig.update.all.active.false=UPDATE CLUSTERCONFIG SET ACTIVE=FALSE
+clusterconfig.delete=DELETE FROM CLUSTERCONFIG WHERE ALIAS=:alias
View
15 src/main/webapp/WEB-INF/context/applicationContext-hector.xml
@@ -1,18 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans default-autowire="byName" xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
- http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd">
-
- <bean id="cassandraHostConfigurator" class="me.prettyprint.cassandra.service.CassandraHostConfigurator">
- <constructor-arg value="${hosts?localhost:9160}" />
- </bean>
-
- <bean id="cluster" class="me.prettyprint.cassandra.service.ThriftCluster">
- <constructor-arg value="${cluster.name?TestCluster}" />
- <constructor-arg ref="cassandraHostConfigurator" />
- </bean>
+ xmlns:p="http://www.springframework.org/schema/p"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<bean id="consistencyLevelPolicy" class="me.prettyprint.cassandra.model.ConfigurableConsistencyLevel">
<property name="defaultReadConsistencyLevel" value="ONE" />
View
21 src/main/webapp/WEB-INF/context/applicationContext-jdbc.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans default-autowire="byName" xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:p="http://www.springframework.org/schema/p" xmlns:c="http://www.springframework.org/schema/c"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
+
+ <bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource" p:driverClassName="org.h2.Driver">
+ <property name="url" value="${db.url}"/>
+ <property name="username" value="${db.user}"/>
+ <property name="password" value="${db.password}"/>
+ </bean>
+
+ <bean id="queriesPropertyResource" class="org.springframework.core.io.ClassPathResource" c:path="queries.properties"/>
+
+ <bean id="queriesProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
+ <property name="location" ref="queriesPropertyResource"/>
+ </bean>
+
+ <bean id="jdbcTemplate" class="org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate" c:dataSource-ref="dataSource"/>
+
+ <bean id="clusterConfigDao" class="com.kuprowski.helenos.jdbc.core.support.ClusterConfigDao" p:queries-ref="queriesProperties" />
+</beans>
View
8 src/main/webapp/WEB-INF/context/applicationContext.xml
@@ -8,7 +8,13 @@
<context:annotation-config />
<context:component-scan base-package="com.kuprowski.helenos.service"/>
- <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" p:valueSeparator="?" p:location="classpath:helenos.properties" p:fileEncoding="UTF-8" p:ignoreResourceNotFound="true" p:ignoreUnresolvablePlaceholders="true" />
+ <bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
+ <property name="environment">
+ <bean class="org.springframework.web.context.support.StandardServletEnvironment"/>
+ </property>
+ </bean>
+
+ <bean class="com.kuprowski.helenos.context.PostConfiguringClusterListener" />
<bean id="mapper" class="org.dozer.DozerBeanMapper" scope="singleton">
<property name="mappingFiles">
View
5 src/main/webapp/WEB-INF/helenos-servlet.xml
@@ -20,4 +20,9 @@
<property name="service" ref="superQueryProvider"/>
<property name="serviceInterface" value="com.kuprowski.helenos.service.SuperQueryProvider"/>
</bean>
+
+ <bean name="/ClusterConnectionProvider.json" class="com.googlecode.jsonrpc4j.spring.JsonServiceExporter">
+ <property name="service" ref="clusterConnectionProvider"/>
+ <property name="serviceInterface" value="com.kuprowski.helenos.service.ClusterConnectionProvider"/>
+ </bean>
</beans>
View
20 src/main/webapp/WEB-INF/web.xml
@@ -23,6 +23,22 @@
<param-name>log4jRefreshInterval</param-name>
<param-value>360000</param-value>
</context-param>
+ <context-param>
+ <param-name>db.url</param-name>
+ <param-value>jdbc:h2:~/helenos;INIT=CREATE SCHEMA IF NOT EXISTS helenos AUTHORIZATION helenos\;CREATE TABLE IF NOT EXISTS CLUSTERCONFIG(ALIAS VARCHAR(128) PRIMARY KEY,HOSTS VARCHAR(255), CLUSTERNAME VARCHAR(255), ACTIVE BOOLEAN)\;</param-value>
+ </context-param>
+ <context-param>
+ <param-name>db.user</param-name>
+ <param-value>helenos</param-value>
+ </context-param>
+ <context-param>
+ <param-name>db.password</param-name>
+ <param-value>helenos</param-value>
+ </context-param>
+ <context-param>
+ <param-name>db.tcpServer</param-name>
+ <param-value>-tcpAllowOthers</param-value>
+ </context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
@@ -32,6 +48,10 @@
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
+ <listener>
+ <listener-class>org.h2.server.web.DbStarter</listener-class>
+ </listener>
+
<!-- Override init parameter to avoid nasty file locking issue on windows (Jetty only) -->
<!--
<servlet>

0 comments on commit 44f5632

Please sign in to comment.
Something went wrong with that request. Please try again.