Added Service Discovery

This commit is contained in:
Ahmed Salah Tawfik Ibrahim 2023-12-06 16:40:46 +01:00
parent 68a7532379
commit 02bc40b6e8
3 changed files with 23 additions and 13 deletions

View File

@ -45,21 +45,33 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
* use this constructor carefully from test classes
* @param dropSchema set true if you want do drop the current and set up new one
*/
protected DBCassandraAstyanaxImpl(boolean dropSchema) throws Exception {
conn = new CassandraClusterConnection(dropSchema);
protected DBCassandraAstyanaxImpl(boolean dropSchema) {
try {
conn = new CassandraClusterConnection(dropSchema);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* public constructor, no dropping schema is allowed
*/
public DBCassandraAstyanaxImpl() throws Exception {
conn = new CassandraClusterConnection(false);
public DBCassandraAstyanaxImpl() {
try {
conn = new CassandraClusterConnection(false);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* public constructor, no dropping schema is allowed, infrastructureName is given.
*/
public DBCassandraAstyanaxImpl(String infrastructureName) throws Exception {
conn = new CassandraClusterConnection(false, infrastructureName);
public DBCassandraAstyanaxImpl(String infrastructureName) {
try {
conn = new CassandraClusterConnection(false, infrastructureName);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/*

View File

@ -72,7 +72,7 @@ public class RunningCluster implements Serializable {
* @param infrastructureName could be null
* @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) {
singleton = new RunningCluster(infrastructureName);
}
@ -81,7 +81,7 @@ public class RunningCluster implements Serializable {
/**
* private constructor
*/
private RunningCluster(String infrastructureName) throws Exception {
private RunningCluster(String infrastructureName){
//Query the IS (for the future)
try{
List<ServiceEndpoint> resources = getConfigurationFromIS(infrastructureName);
@ -116,7 +116,7 @@ public class RunningCluster implements Serializable {
* @return the
* @throws Exception
*/
private List<ServiceEndpoint> getConfigurationFromIS(String infrastructureName) throws Exception {
private List<ServiceEndpoint> getConfigurationFromIS(String infrastructureName) {
_log.debug("getConfigurationFromIS infrastructureName="+infrastructureName );
String scope = "/";
if(infrastructureName != null && !infrastructureName.isEmpty())

View File

@ -2,7 +2,6 @@ package org.gcube.portal.databook.server;
import org.gcube.portal.databook.shared.*;
import org.gcube.portal.databook.shared.ex.*;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -19,18 +18,17 @@ public class Tester {
private static DBCassandraAstyanaxImpl store;
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
}
public static void main(String[] args) throws Exception {
public static void main(String[] args) throws ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException, FeedIDNotFoundException, FeedTypeNotFoundException {
Tester test = new Tester();
//test.getComment();
test.testFunc();
System.exit(0);
}
@Test
public void testFunc() throws ColumnNameNotFoundException, PrivacyLevelTypeNotFoundException, FeedIDNotFoundException, FeedTypeNotFoundException {
String postIdToUpdate = "047c601d-2291-4974-9224-d6732b1fbe26";
Post read = store.readPost(postIdToUpdate);