Used a constant to define connection strategy

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@146955 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2017-04-19 12:39:29 +00:00
parent 0bd37933bc
commit 583c63797a
2 changed files with 6 additions and 8 deletions

View File

@ -12,7 +12,6 @@ import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseInt
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.orientechnologies.orient.client.remote.OStorageRemote;
import com.tinkerpop.blueprints.impls.orient.OrientGraph; import com.tinkerpop.blueprints.impls.orient.OrientGraph;
import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory; import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory;
@ -51,8 +50,7 @@ public abstract class SecurityContextMapper {
DatabaseEnvironment.CHANGED_ADMIN_PASSWORD) DatabaseEnvironment.CHANGED_ADMIN_PASSWORD)
.setupPool(1, 10); .setupPool(1, 10);
factory.setConnectionStrategy(OStorageRemote.CONNECTION_STRATEGY factory.setConnectionStrategy(DatabaseIntializator.CONNECTION_STRATEGY_PARAMETER.toString());
.ROUND_ROBIN_CONNECT.toString());
for (PermissionMode p : PermissionMode.values()) { for (PermissionMode p : PermissionMode.values()) {
OrientGraphFactory f = new OrientGraphFactory( OrientGraphFactory f = new OrientGraphFactory(
@ -61,8 +59,7 @@ public abstract class SecurityContextMapper {
DatabaseEnvironment.CHANGED_ADMIN_PASSWORD) DatabaseEnvironment.CHANGED_ADMIN_PASSWORD)
.setupPool(1, 10); .setupPool(1, 10);
f.setConnectionStrategy(OStorageRemote.CONNECTION_STRATEGY f.setConnectionStrategy(DatabaseIntializator.CONNECTION_STRATEGY_PARAMETER.toString());
.ROUND_ROBIN_CONNECT.toString());
Map<UUID, OrientGraphFactory> map = new HashMap<>(); Map<UUID, OrientGraphFactory> map = new HashMap<>();
map.put(ADMIN_SECURITY_CONTEXT_UUID, f); map.put(ADMIN_SECURITY_CONTEXT_UUID, f);
@ -140,8 +137,7 @@ public abstract class SecurityContextMapper {
factory = new OrientGraphFactory(DatabaseEnvironment.DB_URI, factory = new OrientGraphFactory(DatabaseEnvironment.DB_URI,
username, password).setupPool(1, 10); username, password).setupPool(1, 10);
factory.setConnectionStrategy(OStorageRemote.CONNECTION_STRATEGY factory.setConnectionStrategy(DatabaseIntializator.CONNECTION_STRATEGY_PARAMETER.toString());
.ROUND_ROBIN_CONNECT.toString());
permissionSecurityContextFactories.put(context, factory); permissionSecurityContextFactories.put(context, factory);
} }

View File

@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory;
import com.orientechnologies.common.log.OLogManager; import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.orient.client.remote.OServerAdmin; import com.orientechnologies.orient.client.remote.OServerAdmin;
import com.orientechnologies.orient.client.remote.OStorageRemote.CONNECTION_STRATEGY;
import com.orientechnologies.orient.core.metadata.OMetadata; import com.orientechnologies.orient.core.metadata.OMetadata;
import com.orientechnologies.orient.core.metadata.schema.OClass; import com.orientechnologies.orient.core.metadata.schema.OClass;
import com.orientechnologies.orient.core.metadata.schema.OSchema; import com.orientechnologies.orient.core.metadata.schema.OSchema;
@ -26,7 +27,6 @@ import com.tinkerpop.blueprints.impls.orient.OrientVertexType;
/** /**
* @author Luca Frosini (ISTI - CNR) * @author Luca Frosini (ISTI - CNR)
*
*/ */
public class DatabaseIntializator { public class DatabaseIntializator {
@ -37,6 +37,8 @@ public class DatabaseIntializator {
private static final String STORAGE_MODE = "plocal"; private static final String STORAGE_MODE = "plocal";
public static final String O_RESTRICTED_CLASS = "ORestricted"; public static final String O_RESTRICTED_CLASS = "ORestricted";
public static final CONNECTION_STRATEGY CONNECTION_STRATEGY_PARAMETER = CONNECTION_STRATEGY.ROUND_ROBIN_CONNECT;
public static boolean initGraphDB() throws Exception { public static boolean initGraphDB() throws Exception {