Added Service Discovery
This commit is contained in:
parent
68a7532379
commit
02bc40b6e8
|
@ -45,21 +45,33 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
||||||
* use this constructor carefully from test classes
|
* use this constructor carefully from test classes
|
||||||
* @param dropSchema set true if you want do drop the current and set up new one
|
* @param dropSchema set true if you want do drop the current and set up new one
|
||||||
*/
|
*/
|
||||||
protected DBCassandraAstyanaxImpl(boolean dropSchema) throws Exception {
|
protected DBCassandraAstyanaxImpl(boolean dropSchema) {
|
||||||
|
try {
|
||||||
conn = new CassandraClusterConnection(dropSchema);
|
conn = new CassandraClusterConnection(dropSchema);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* public constructor, no dropping schema is allowed
|
* public constructor, no dropping schema is allowed
|
||||||
*/
|
*/
|
||||||
public DBCassandraAstyanaxImpl() throws Exception {
|
public DBCassandraAstyanaxImpl() {
|
||||||
|
try {
|
||||||
conn = new CassandraClusterConnection(false);
|
conn = new CassandraClusterConnection(false);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* public constructor, no dropping schema is allowed, infrastructureName is given.
|
* public constructor, no dropping schema is allowed, infrastructureName is given.
|
||||||
*/
|
*/
|
||||||
public DBCassandraAstyanaxImpl(String infrastructureName) throws Exception {
|
public DBCassandraAstyanaxImpl(String infrastructureName) {
|
||||||
|
try {
|
||||||
conn = new CassandraClusterConnection(false, infrastructureName);
|
conn = new CassandraClusterConnection(false, infrastructureName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class RunningCluster implements Serializable {
|
||||||
* @param infrastructureName could be null
|
* @param infrastructureName could be null
|
||||||
* @return an instance of the RunningCluster
|
* @return an instance of the RunningCluster
|
||||||
*/
|
*/
|
||||||
public static synchronized RunningCluster getInstance(String infrastructureName) throws Exception {
|
public static synchronized RunningCluster getInstance(String infrastructureName){
|
||||||
if (singleton == null) {
|
if (singleton == null) {
|
||||||
singleton = new RunningCluster(infrastructureName);
|
singleton = new RunningCluster(infrastructureName);
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ public class RunningCluster implements Serializable {
|
||||||
/**
|
/**
|
||||||
* private constructor
|
* private constructor
|
||||||
*/
|
*/
|
||||||
private RunningCluster(String infrastructureName) throws Exception {
|
private RunningCluster(String infrastructureName){
|
||||||
//Query the IS (for the future)
|
//Query the IS (for the future)
|
||||||
try{
|
try{
|
||||||
List<ServiceEndpoint> resources = getConfigurationFromIS(infrastructureName);
|
List<ServiceEndpoint> resources = getConfigurationFromIS(infrastructureName);
|
||||||
|
@ -116,7 +116,7 @@ public class RunningCluster implements Serializable {
|
||||||
* @return the
|
* @return the
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private List<ServiceEndpoint> getConfigurationFromIS(String infrastructureName) throws Exception {
|
private List<ServiceEndpoint> getConfigurationFromIS(String infrastructureName) {
|
||||||
_log.debug("getConfigurationFromIS infrastructureName="+infrastructureName );
|
_log.debug("getConfigurationFromIS infrastructureName="+infrastructureName );
|
||||||
String scope = "/";
|
String scope = "/";
|
||||||
if(infrastructureName != null && !infrastructureName.isEmpty())
|
if(infrastructureName != null && !infrastructureName.isEmpty())
|
||||||
|
|
|
@ -2,7 +2,6 @@ package org.gcube.portal.databook.server;
|
||||||
|
|
||||||
import org.gcube.portal.databook.shared.*;
|
import org.gcube.portal.databook.shared.*;
|
||||||
import org.gcube.portal.databook.shared.ex.*;
|
import org.gcube.portal.databook.shared.ex.*;
|
||||||
import org.junit.Test;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -19,18 +18,17 @@ public class Tester {
|
||||||
private static DBCassandraAstyanaxImpl store;
|
private static DBCassandraAstyanaxImpl store;
|
||||||
private static Logger LOGGER = LoggerFactory.getLogger(Tester.class);
|
private static Logger LOGGER = LoggerFactory.getLogger(Tester.class);
|
||||||
|
|
||||||
public Tester() throws Exception {
|
public Tester() {
|
||||||
store = new DBCassandraAstyanaxImpl("gcube"); //set to true if you want to drop the KeySpace and recreate it
|
store = new DBCassandraAstyanaxImpl("gcube"); //set to true if you want to drop the KeySpace and recreate it
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException, FeedIDNotFoundException, FeedTypeNotFoundException {
|
||||||
Tester test = new Tester();
|
Tester test = new Tester();
|
||||||
//test.getComment();
|
//test.getComment();
|
||||||
test.testFunc();
|
test.testFunc();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
@Test
|
|
||||||
public void testFunc() throws ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException, FeedIDNotFoundException, FeedTypeNotFoundException {
|
public void testFunc() throws ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException, FeedIDNotFoundException, FeedTypeNotFoundException {
|
||||||
String postIdToUpdate = "047c601d-2291-4974-9224-d6732b1fbe26";
|
String postIdToUpdate = "047c601d-2291-4974-9224-d6732b1fbe26";
|
||||||
Post read = store.readPost(postIdToUpdate);
|
Post read = store.readPost(postIdToUpdate);
|
||||||
|
|
Loading…
Reference in New Issue