Skip to content

Commit

Permalink
first implementation of backward compatible database delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Oct 6, 2016
1 parent 9111304 commit 8f2cc03
Show file tree
Hide file tree
Showing 15 changed files with 4,569 additions and 3,569 deletions.
Expand Up @@ -36,6 +36,8 @@
import com.orientechnologies.orient.core.storage.ORecordCallback;
import com.orientechnologies.orient.core.storage.OStorage;

import java.util.Set;

public interface ODatabaseDocumentInternal extends ODatabaseDocument, ODatabaseInternal<ORecord> {

/**
Expand Down Expand Up @@ -89,6 +91,8 @@ void executeDeleteRecord(OIdentifiable record, final int iVersion, final boolean

ODatabaseDocumentInternal copy();

Set<ORecord> executeReadRecords(final Set<ORecordId> iRids, final boolean ignoreCache);

void checkIfActive();

void callOnOpenListeners();
Expand Down
Expand Up @@ -151,7 +151,7 @@ public synchronized void create(String name, String user, String password, Datab
config = solveConfig(config);
OAbstractPaginatedStorage storage;
if (type == DatabaseType.MEMORY) {
storage = (OAbstractPaginatedStorage) memory.createStorage(buildName(name), new HashMap<>());
storage = (OAbstractPaginatedStorage) memory.createStorage(name, new HashMap<>());
} else {
storage = (OAbstractPaginatedStorage) disk.createStorage(buildName(name), new HashMap<>());
}
Expand Down Expand Up @@ -196,24 +196,6 @@ private void internalCreate(OrientDBConfig config, OAbstractPaginatedStorage sto
}
}

private void internalCreate(OrientDBConfig config, OAbstractPaginatedStorage storage) {
storage.create(config.getConfigurations());
ORecordSerializer serializer = ORecordSerializerFactory.instance().getDefaultRecordSerializer();
if (serializer.toString().equals("ORecordDocument2csv"))
throw new ODatabaseException("Impossible to create the database with ORecordDocument2csv serializer");
storage.getConfiguration().setRecordSerializer(serializer.toString());
storage.getConfiguration().setRecordSerializerVersion(serializer.getCurrentVersion());
// since 2.1 newly created databases use strict SQL validation by default
storage.getConfiguration().setProperty(OStatement.CUSTOM_STRICT_SQL, "true");

storage.getConfiguration().update();

try (final ODatabaseDocumentEmbedded embedded = new ODatabaseDocumentEmbedded(storage)) {
embedded.setSerializer(serializer);
embedded.internalCreate(config);
}
}

@Override
public synchronized boolean exists(String name, String user, String password) {
if (!storages.containsKey(name)) {
Expand Down
Expand Up @@ -91,6 +91,7 @@ public class OPartitionedDatabasePool extends OOrientListenerAbstract implements
private volatile boolean closed = false;
private boolean autoCreate = false;


public OPartitionedDatabasePool(String url, String userName, String password) {
this(url, userName, password, Runtime.getRuntime().availableProcessors(), -1);
}
Expand Down Expand Up @@ -412,7 +413,7 @@ private final class DatabaseDocumentTxPooled extends ODatabaseDocumentTx {
private PoolPartition partition;

private DatabaseDocumentTxPooled(String iURL) {
super(iURL, true, false);
super(iURL);
}

@Override
Expand Down
Expand Up @@ -44,7 +44,7 @@
/**
* Created by tglman on 27/06/16.
*/
public class ODatabaseDocumentEmbedded extends ODatabaseDocumentTx {
public class ODatabaseDocumentEmbedded extends ODatabaseDocumentTxOrig {

private OrientDBConfig config;

Expand Down
Expand Up @@ -42,7 +42,7 @@
/**
* Created by tglman on 30/06/16.
*/
public class ODatabaseDocumentRemote extends ODatabaseDocumentTx {
public class ODatabaseDocumentRemote extends ODatabaseDocumentTxOrig {

private OrientDBConfig config;

Expand Down

0 comments on commit 8f2cc03

Please sign in to comment.