use of com.orientechnologies.orient.core.db.record.OCurrentStorageComponentsFactory in project orientdb by orientechnologies.
the class OStorageRemote method open.
public void open(final String iUserName, final String iUserPassword, final Map<String, Object> iOptions) {
stateLock.acquireWriteLock();
addUser();
try {
OStorageRemoteSession session = getCurrentSession();
if (status == STATUS.CLOSED || !iUserName.equals(session.connectionUserName) || !iUserPassword.equals(session.connectionUserPassword) || session.sessions.isEmpty()) {
OCredentialInterceptor ci = OSecurityManager.instance().newCredentialInterceptor();
if (ci != null) {
ci.intercept(getURL(), iUserName, iUserPassword);
session.connectionUserName = ci.getUsername();
session.connectionUserPassword = ci.getPassword();
} else // Do Nothing
{
session.connectionUserName = iUserName;
session.connectionUserPassword = iUserPassword;
}
parseOptions(iOptions);
openRemoteDatabase();
final OStorageConfiguration storageConfiguration = new OStorageRemoteConfiguration(this, recordFormat);
storageConfiguration.load(iOptions);
configuration = storageConfiguration;
componentsFactory = new OCurrentStorageComponentsFactory(configuration);
} else {
reopenRemoteDatabase();
}
} catch (Exception e) {
removeUser();
if (e instanceof RuntimeException)
// PASS THROUGH
throw (RuntimeException) e;
else
throw OException.wrapException(new OStorageException("Cannot open the remote storage: " + name), e);
} finally {
stateLock.releaseWriteLock();
}
}
use of com.orientechnologies.orient.core.db.record.OCurrentStorageComponentsFactory in project orientdb by orientechnologies.
the class OAbstractPaginatedStorage method open.
public void open(final String iUserName, final String iUserPassword, final Map<String, Object> iProperties) {
stateLock.acquireReadLock();
try {
if (status == STATUS.OPEN)
// REUSED
return;
} finally {
stateLock.releaseReadLock();
}
stateLock.acquireWriteLock();
try {
if (status == STATUS.OPEN)
// REUSED
return;
if (!exists())
throw new OStorageException("Cannot open the storage '" + name + "' because it does not exist in path: " + url);
configuration.load(iProperties);
final String cs = configuration.getConflictStrategy();
if (cs != null) {
// SET THE CONFLICT STORAGE STRATEGY FROM THE LOADED CONFIGURATION
setConflictStrategy(Orient.instance().getRecordConflictStrategy().getStrategy(cs));
}
componentsFactory = new OCurrentStorageComponentsFactory(configuration);
preOpenSteps();
try {
performanceStatisticManager.registerMBean(name, id);
} catch (Exception e) {
OLogManager.instance().error(this, "MBean for profiler cannot be registered.");
}
initWalAndDiskCache();
atomicOperationsManager = new OAtomicOperationsManager(this);
try {
atomicOperationsManager.registerMBean();
} catch (Exception e) {
OLogManager.instance().error(this, "MBean for atomic operations manager cannot be registered", e);
}
recoverIfNeeded();
openClusters();
openIndexes();
if (OGlobalConfiguration.STORAGE_MAKE_FULL_CHECKPOINT_AFTER_OPEN.getValueAsBoolean())
makeFullCheckpoint();
writeCache.startFuzzyCheckpoints();
status = STATUS.OPEN;
readCache.loadCacheState(writeCache);
} catch (Exception e) {
for (OCluster c : clusters) {
try {
if (c != null)
c.close(false);
} catch (IOException e1) {
OLogManager.instance().error(this, "Cannot close cluster after exception on open");
}
}
try {
status = STATUS.OPEN;
close(true, false);
} catch (RuntimeException re) {
OLogManager.instance().error(this, "Error during storage close", e);
}
status = STATUS.CLOSED;
throw OException.wrapException(new OStorageException("Cannot open local storage '" + url + "' with mode=" + mode), e);
} finally {
stateLock.releaseWriteLock();
}
}
use of com.orientechnologies.orient.core.db.record.OCurrentStorageComponentsFactory in project orientdb by orientechnologies.
the class OAbstractPaginatedStorage method openIndexes.
protected void openIndexes() {
OCurrentStorageComponentsFactory cf = componentsFactory;
if (cf == null)
throw new OStorageException("Storage '" + name + "' is not properly initialized");
final Set<String> indexNames = configuration.indexEngines();
for (String indexName : indexNames) {
final OStorageConfiguration.IndexEngineData engineData = configuration.getIndexEngine(indexName);
final OIndexEngine engine = OIndexes.createIndexEngine(engineData.getName(), engineData.getAlgorithm(), engineData.getIndexType(), engineData.getDurableInNonTxMode(), this, engineData.getVersion(), engineData.getEngineProperties(), null);
try {
engine.load(engineData.getName(), cf.binarySerializerFactory.getObjectSerializer(engineData.getValueSerializerId()), engineData.isAutomatic(), cf.binarySerializerFactory.getObjectSerializer(engineData.getKeySerializedId()), engineData.getKeyTypes(), engineData.isNullValuesSupport(), engineData.getKeySize(), engineData.getEngineProperties());
indexEngineNameMap.put(engineData.getName().toLowerCase(configuration.getLocaleInstance()), engine);
indexEngines.add(engine);
} catch (RuntimeException e) {
OLogManager.instance().error(this, "Index '" + engineData.getName() + "' cannot be created and will be removed from configuration", e);
engine.deleteWithoutLoad(engineData.getName());
}
}
}
use of com.orientechnologies.orient.core.db.record.OCurrentStorageComponentsFactory in project orientdb by orientechnologies.
the class OAbstractPaginatedStorage method create.
public void create(final Map<String, Object> iProperties) {
stateLock.acquireWriteLock();
try {
if (status != STATUS.CLOSED)
throw new OStorageExistsException("Cannot create new storage '" + getURL() + "' because it is not closed");
if (exists())
throw new OStorageExistsException("Cannot create new storage '" + getURL() + "' because it already exists");
if (!configuration.getContextConfiguration().getContextKeys().contains(OGlobalConfiguration.STORAGE_COMPRESSION_METHOD.getKey())) {
final String compression = iProperties != null ? (String) iProperties.get(OGlobalConfiguration.STORAGE_COMPRESSION_METHOD.getKey().toLowerCase(configuration.getLocaleInstance())) : null;
if (compression != null)
configuration.getContextConfiguration().setValue(OGlobalConfiguration.STORAGE_COMPRESSION_METHOD, compression);
else
configuration.getContextConfiguration().setValue(OGlobalConfiguration.STORAGE_COMPRESSION_METHOD, OGlobalConfiguration.STORAGE_COMPRESSION_METHOD.getValue());
}
if (!configuration.getContextConfiguration().getContextKeys().contains(OGlobalConfiguration.STORAGE_ENCRYPTION_METHOD.getKey())) {
final String encryption = iProperties != null ? (String) iProperties.get(OGlobalConfiguration.STORAGE_ENCRYPTION_METHOD.getKey().toLowerCase(configuration.getLocaleInstance())) : null;
if (encryption != null)
configuration.getContextConfiguration().setValue(OGlobalConfiguration.STORAGE_ENCRYPTION_METHOD, encryption);
else
configuration.getContextConfiguration().setValue(OGlobalConfiguration.STORAGE_ENCRYPTION_METHOD, OGlobalConfiguration.STORAGE_ENCRYPTION_METHOD.getValue());
}
// SAVE COMPRESSION OPTIONS IF ANY. THIS IS USED FOR ENCRYPTION AT REST WHERE IN THE 'STORAGE_ENCRYPTION_KEY' IS STORED
// THE KEY
final String encryptionKey = iProperties != null ? (String) iProperties.get(OGlobalConfiguration.STORAGE_ENCRYPTION_KEY.getKey().toLowerCase(configuration.getLocaleInstance())) : null;
if (encryptionKey != null)
configuration.getContextConfiguration().setValue(OGlobalConfiguration.STORAGE_ENCRYPTION_KEY, encryptionKey);
else
configuration.getContextConfiguration().setValue(OGlobalConfiguration.STORAGE_ENCRYPTION_KEY, OGlobalConfiguration.STORAGE_ENCRYPTION_KEY.getValue());
componentsFactory = new OCurrentStorageComponentsFactory(configuration);
try {
performanceStatisticManager.registerMBean(name, id);
} catch (Exception e) {
OLogManager.instance().error(this, "MBean for profiler cannot be registered.");
}
initWalAndDiskCache();
atomicOperationsManager = new OAtomicOperationsManager(this);
try {
atomicOperationsManager.registerMBean();
} catch (Exception e) {
OLogManager.instance().error(this, "MBean for atomic operations manager cannot be registered", e);
}
preCreateSteps();
status = STATUS.OPEN;
// ADD THE METADATA CLUSTER TO STORE INTERNAL STUFF
doAddCluster(OMetadataDefault.CLUSTER_INTERNAL_NAME, null);
configuration.create();
// ADD THE INDEX CLUSTER TO STORE, BY DEFAULT, ALL THE RECORDS OF
// INDEXING
doAddCluster(OMetadataDefault.CLUSTER_INDEX_NAME, null);
// ADD THE INDEX CLUSTER TO STORE, BY DEFAULT, ALL THE RECORDS OF
// INDEXING
doAddCluster(OMetadataDefault.CLUSTER_MANUAL_INDEX_NAME, null);
// ADD THE DEFAULT CLUSTER
defaultClusterId = doAddCluster(CLUSTER_DEFAULT_NAME, null);
clearStorageDirty();
if (OGlobalConfiguration.STORAGE_MAKE_FULL_CHECKPOINT_AFTER_CREATE.getValueAsBoolean())
makeFullCheckpoint();
writeCache.startFuzzyCheckpoints();
postCreateSteps();
} catch (OStorageException e) {
close();
throw e;
} catch (IOException e) {
close();
throw OException.wrapException(new OStorageException("Error on creation of storage '" + name + "'"), e);
} finally {
stateLock.releaseWriteLock();
}
}
Aggregations