Skip to content

Commit

Permalink
refactor: renamed the remote client implementation from storage to cl…
Browse files Browse the repository at this point in the history
…ient
  • Loading branch information
tglman committed Feb 24, 2025
1 parent 3102cea commit fb5638f
Show file tree
Hide file tree
Showing 24 changed files with 148 additions and 151 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ODatabaseDocumentRemotePooled extends ODatabaseDocumentRemote {
private ODatabasePoolInternal pool;

public ODatabaseDocumentRemotePooled(
ODatabasePoolInternal pool, OStorageRemote storage, OSharedContext sharedContext) {
ODatabasePoolInternal pool, ORemoteClient storage, OSharedContext sharedContext) {
super(storage, sharedContext);
this.pool = pool;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public ODatabaseTool setOptions(String iOptions) {
}

public void importDatabase() throws ODatabaseImportException {
OStorageRemote storage =
(OStorageRemote) ((ODatabaseDocumentRemote) getDatabase()).getStorageRemote();
ORemoteClient storage =
(ORemoteClient) ((ODatabaseDocumentRemote) getDatabase()).getRemoteClinet();
File file = new File(getFileName());
try {
storage.importDatabase(options, new FileInputStream(file), file.getName(), getListener());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@
import java.util.concurrent.locks.ReentrantReadWriteLock;

/** This object is bound to each remote ODatabase instances. */
public class OStorageRemote implements ORemotePushHandler, OStorageInfo {
private static final OLogger logger = OLogManager.instance().logger(OStorageRemote.class);
public class ORemoteClient implements ORemotePushHandler, OStorageInfo {
private static final OLogger logger = OLogManager.instance().logger(ORemoteClient.class);
@Deprecated public static final String PARAM_CONNECTION_STRATEGY = "connectionStrategy";

public static final String DRIVER_NAME = "OrientDB Java";
Expand Down Expand Up @@ -236,7 +236,7 @@ private static String buildUrl(String[] hosts, String name) {
return String.join(ADDRESS_SEPARATOR, hosts) + "/" + name;
}

public OStorageRemote(
public ORemoteClient(
final ORemoteURLs hosts,
String name,
OrientDBRemote context,
Expand All @@ -247,7 +247,7 @@ public OStorageRemote(
this(hosts, name, context, iMode, connectionManager, null, config);
}

public OStorageRemote(
public ORemoteClient(
final ORemoteURLs hosts,
String name,
OrientDBRemote context,
Expand Down Expand Up @@ -1384,7 +1384,7 @@ public boolean isRemote() {
}

public String getURL() {
return OStorageRemote.TYPE + ":" + url;
return ORemoteClient.TYPE + ":" + url;
}

public int getClusters() {
Expand All @@ -1397,7 +1397,7 @@ public int getClusters() {
}

public String getType() {
return OStorageRemote.TYPE;
return ORemoteClient.TYPE;
}

public String getUserName() {
Expand Down Expand Up @@ -1833,7 +1833,7 @@ public boolean isClosed() {
return session.isClosed();
}

public OStorageRemote copy(
public ORemoteClient copy(
final ODatabaseDocumentRemote source, final ODatabaseDocumentRemote dest) {
ODatabaseDocumentInternal origin = null;
if (ODatabaseRecordThreadLocal.instance() != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.common.log.OLogger;
import com.orientechnologies.orient.client.remote.OStorageRemote.CONNECTION_STRATEGY;
import com.orientechnologies.orient.client.remote.ORemoteClient.CONNECTION_STRATEGY;
import com.orientechnologies.orient.core.config.OContextConfiguration;
import com.orientechnologies.orient.core.config.OGlobalConfiguration;
import com.orientechnologies.orient.core.exception.OConfigurationException;
Expand Down Expand Up @@ -105,7 +105,7 @@ private static List<String> parseAddressesFromUrl(String url) {
// SHORT FORM
addresses.add(url);
} else {
for (String host : url.substring(0, dbPos).split(OStorageRemote.ADDRESS_SEPARATOR)) {
for (String host : url.substring(0, dbPos).split(ORemoteClient.ADDRESS_SEPARATOR)) {
addresses.add(host);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void closeAllSessions(
OChannelBinaryAsynchClient network = null;
try {
network =
OStorageRemote.getNetwork(
ORemoteClient.getNetwork(
nodeSession.getServerURL(), connectionManager, clientConfiguration);
OCloseRequest request = new OCloseRequest();
network.beginRequest(request.getCommand(), this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@

package com.orientechnologies.orient.client.remote;

import static com.orientechnologies.orient.client.remote.OStorageRemote.ADDRESS_SEPARATOR;
import static com.orientechnologies.orient.client.remote.ORemoteClient.ADDRESS_SEPARATOR;
import static com.orientechnologies.orient.core.config.OGlobalConfiguration.NETWORK_SOCKET_RETRY;

import com.orientechnologies.common.exception.OException;
import com.orientechnologies.common.log.OLogManager;
import com.orientechnologies.common.log.OLogger;
import com.orientechnologies.common.thread.OThreadPoolExecutors;
import com.orientechnologies.orient.client.binary.OChannelBinaryAsynchClient;
import com.orientechnologies.orient.client.remote.OStorageRemote.CONNECTION_STRATEGY;
import com.orientechnologies.orient.client.remote.ORemoteClient.CONNECTION_STRATEGY;
import com.orientechnologies.orient.client.remote.db.document.ODatabaseDocumentRemote;
import com.orientechnologies.orient.client.remote.db.document.OSharedContextRemote;
import com.orientechnologies.orient.client.remote.message.OConnect37Request;
Expand Down Expand Up @@ -102,7 +102,7 @@
public class OrientDBRemote implements OrientDBInternal {
private static final OLogger logger = OLogManager.instance().logger(OrientDBRemote.class);
protected final Map<String, OSharedContext> sharedContexts = new HashMap<>();
private final Map<String, OStorageRemote> storages = new HashMap<>();
private final Map<String, ORemoteClient> storages = new HashMap<>();
private final Set<ODatabasePoolInternal> pools = new HashSet<>();
private final String[] hosts;
private final OrientDBConfig configurations;
Expand Down Expand Up @@ -166,11 +166,11 @@ public ODatabaseDocumentInternal open(
checkOpen();
OrientDBConfig resolvedConfig = solveConfig(config);
try {
OStorageRemote storage;
ORemoteClient storage;
synchronized (this) {
storage = storages.get(name);
if (storage == null) {
storage = new OStorageRemote(urls, name, this, "rw", connectionManager, resolvedConfig);
storage = new ORemoteClient(urls, name, this, "rw", connectionManager, resolvedConfig);
storages.put(name, storage);
}
}
Expand Down Expand Up @@ -228,13 +228,13 @@ public synchronized void create(

public ODatabaseDocumentRemotePooled poolOpen(
String name, String user, String password, ODatabasePoolInternal pool) {
OStorageRemote storage;
ORemoteClient storage;
synchronized (this) {
storage = storages.get(name);
if (storage == null) {
try {
storage =
new OStorageRemote(
new ORemoteClient(
urls, name, this, "rw", connectionManager, solveConfig(pool.getConfig()));
storages.put(name, storage);
} catch (Exception e) {
Expand All @@ -249,7 +249,7 @@ public ODatabaseDocumentRemotePooled poolOpen(
return db;
}

public synchronized void closeStorage(OStorageRemote remote) {
public synchronized void closeStorage(ORemoteClient remote) {
OSharedContext ctx = sharedContexts.get(remote.getName());
if (ctx != null) {
ctx.close();
Expand Down Expand Up @@ -415,15 +415,15 @@ public void internalClose() {
timer.cancel();
}

final List<OStorageRemote> storagesCopy;
final List<ORemoteClient> storagesCopy;
synchronized (this) {
// SHUTDOWN ENGINES AVOID OTHER OPENS
open = false;
this.sharedContexts.values().forEach(x -> x.close());
storagesCopy = new ArrayList<>(storages.values());
}

for (OStorageRemote stg : storagesCopy) {
for (ORemoteClient stg : storagesCopy) {
try {
logger.info("- shutdown storage: %s ...", stg.getName());
stg.shutdown();
Expand Down Expand Up @@ -495,7 +495,7 @@ public Collection<OStorage> getStorages() {

@Override
public synchronized void forceDatabaseClose(String databaseName) {
OStorageRemote remote = storages.get(databaseName);
ORemoteClient remote = storages.get(databaseName);
if (remote != null) closeStorage(remote);
}

Expand All @@ -515,7 +515,7 @@ public ODatabaseDocumentInternal openNoAuthorization(String name) {
"impossible skip authentication and authorization in remote");
}

protected synchronized OSharedContext getOrCreateSharedContext(OStorageRemote storage) {
protected synchronized OSharedContext getOrCreateSharedContext(ORemoteClient storage) {

OSharedContext result = sharedContexts.get(storage.getName());
if (result == null) {
Expand All @@ -525,7 +525,7 @@ protected synchronized OSharedContext getOrCreateSharedContext(OStorageRemote st
return result;
}

private OSharedContext createSharedContext(OStorageRemote storage) {
private OSharedContext createSharedContext(ORemoteClient storage) {
OSharedContextRemote context = new OSharedContextRemote(storage, this);
storage.setSharedContext(context);
return context;
Expand Down Expand Up @@ -649,7 +649,7 @@ public T execute(OChannelBinaryAsynchClient network, OStorageRemoteSession sessi
}
T response = request.createResponse();
try {
OStorageRemote.beginResponse(network, session);
ORemoteClient.beginResponse(network, session);
response.read(network, session);
} finally {
network.endResponse();
Expand All @@ -673,7 +673,7 @@ public <T> T networkAdminOperation(
urls.getNextAvailableServerURL(false, session, config, CONNECTION_STRATEGY.STICKY);
do {
try {
network = OStorageRemote.getNetwork(serverUrl, connectionManager, config);
network = ORemoteClient.getNetwork(serverUrl, connectionManager, config);
} catch (OException e) {
serverUrl = urls.removeAndGet(serverUrl);
if (serverUrl == null) throw e;
Expand Down Expand Up @@ -779,6 +779,6 @@ public void create(

@Override
public String getConnectionUrl() {
return "remote:" + String.join(OStorageRemote.ADDRESS_SEPARATOR, this.urls.getUrls());
return "remote:" + String.join(ORemoteClient.ADDRESS_SEPARATOR, this.urls.getUrls());
}
}
Loading

0 comments on commit fb5638f

Please sign in to comment.