@Override public void replaceStorage(final OStorage storage) { DatabasePoolSupport pool; synchronized (pools) { pool = pools.get(storage.getName()); } if (pool != null) { pool.replaceStorage(storage); } } }
/** * Returns an optional {@link EntityAdapter} that 'owns' the clusterId and is interested in resolving its conflicts. */ private Optional<EntityAdapter<?>> findResolvingAdapter(final OStorage storage, final int clusterId) { if (!enabled) { return empty(); } String clusterKey = storage.getName() + '#' + clusterId; // clusterIds are not unique across DBs String typeName = typeNamesByClusterKey.computeIfAbsent(clusterKey, k -> findTypeName(storage.getPhysicalClusterNameById(clusterId))); return ofNullable(typeName).map(resolvingAdapters::get); }
protected OIndex<?> getRemoteIndexInstance(boolean isMultiValueIndex, String type, String name, String algorithm, Set<String> clustersToIndex, OIndexDefinition indexDefinition, ORID identity, ODocument configuration) { if (isMultiValueIndex) return new OIndexRemoteMultiValue(name, type, algorithm, identity, indexDefinition, configuration, clustersToIndex, getStorage().getName()); return new OIndexRemoteOneValue(name, type, algorithm, identity, indexDefinition, configuration, clustersToIndex, getStorage().getName()); }
@Override public String getName() { return getStorage() != null ? getStorage().getName() : url; }
protected void replaceStorage(final OPartitionedDatabasePool pool, final OStorage storage) { if (partitionsField != null) { ODatabaseDocumentInternal originalDb = ODatabaseRecordThreadLocal.instance().getIfDefined(); try { // use reflection as workaround until public API is available for (Object partition : (Object[]) partitionsField.get(pool)) { for (ODatabaseDocumentTx db : (Iterable<ODatabaseDocumentTx>) partitionQueueField.get(partition)) { replaceStorage(db, storage); } } } catch (Exception | LinkageError e) { log.warn("Problem replacing storage for {}", storage.getName(), e); } finally { ODatabaseRecordThreadLocal.instance().set(originalDb); } } }
public OIndexAbstract(String name, final String type, final String algorithm, final String valueContainerAlgorithm, final ODocument metadata, final int version, final OStorage storage, int binaryFormatVersion) { this.binaryFormatVersion = binaryFormatVersion; acquireExclusiveLock(); try { databaseName = storage.getName(); this.version = version; this.name = name; this.type = type; this.algorithm = algorithm; this.metadata = metadata; this.valueContainerAlgorithm = valueContainerAlgorithm; this.storage = (OAbstractPaginatedStorage) storage.getUnderlying(); } finally { releaseExclusiveLock(); } }
ODatabaseRecordThreadLocal.instance() != null ? ODatabaseRecordThreadLocal.instance().getIfDefined() : null; if (db != null && db.getStorage() != null && db.getStorage() instanceof OAbstractPaginatedStorage) { final String dbName = db.getStorage().getName(); if (dbName != null) iMessage = "$ANSI{green {db=" + dbName + "}} " + iMessage;
public OCommandCacheSoftRefs(final OStorage storage) { databaseName = storage.getName(); if (storage instanceof OLocalPaginatedStorage) { fileConfigPath = ((OLocalPaginatedStorage) storage).getStoragePath().resolve(CONFIG_FILE).toString(); } else fileConfigPath = null; OContextConfiguration configuration = storage.getConfiguration().getContextConfiguration(); enable = configuration.getValueAsBoolean(OGlobalConfiguration.COMMAND_CACHE_ENABLED); minExecutionTime = configuration.getValueAsInteger(OGlobalConfiguration.COMMAND_CACHE_MIN_EXECUTION_TIME); maxResultsetSize = configuration.getValueAsInteger(OGlobalConfiguration.COMMAND_CACHE_MAX_RESULSET_SIZE); initCache(); }
} catch (Exception e) { OLogManager.instance().error(this, "Error during closing of database % when storage %s was already closed", e, getUrl(), storage.getName());
s.getName(), totalDiskCacheUsedMemory, maxDiskCacheUsedMemory, jvmTotMemory / OFileUtils.MEGABYTE, jvmMaxMemory / OFileUtils.MEGABYTE, suggestedMaxHeap / OFileUtils.MEGABYTE, suggestedDiskCache);
public synchronized void load(ODatabaseDocumentInternal database) { final long timer = PROFILER.startChrono(); try { if (!loaded) { schema.load(database); indexManager.load(database); //The Immutable snapshot should be after index and schema that require and before everything else that use it schema.forceSnapshot(database); security.load(); functionLibrary.load(database); scheduler.load(database); sequenceLibrary.load(database); schema.onPostIndexManagement(); loaded = true; } } finally { PROFILER .stopChrono(PROFILER.getDatabaseMetric(database.getStorage().getName(), "metadata.load"), "Loading of database metadata", timer, "db.*.metadata.load"); } }
result.setProperty("conflictStrategy", storage.getConflictStrategy() == null ? null : storage.getConflictStrategy().getName()); result.setProperty("name", storage.getName()); result.setProperty("size", storage.getSize()); result.setProperty("type", storage.getType());
public OSharedContextEmbedded(OStorage storage) { schema = new OSchemaEmbedded(this); security = OSecurityManager.instance().newSecurity(); indexManager = new OIndexManagerShared(storage); functionLibrary = new OFunctionLibraryImpl(); scheduler = new OSchedulerImpl(); sequenceLibrary = new OSequenceLibraryImpl(); liveQueryOps = new OLiveQueryHook.OLiveQueryOps(); liveQueryOpsV2 = new OLiveQueryHookV2.OLiveQueryOps(); commandCache = new OCommandCacheSoftRefs(storage.getUnderlying()); statementCache = new OStatementCache( storage.getConfiguration().getContextConfiguration().getValueAsInteger(OGlobalConfiguration.STATEMENT_CACHE_SIZE)); executionPlanCache = new OExecutionPlanCache( storage.getConfiguration().getContextConfiguration().getValueAsInteger(OGlobalConfiguration.STATEMENT_CACHE_SIZE)); this.registerListener(executionPlanCache); queryStats = new OQueryStats(); activeDistributedQueries = new HashMap<>(); ((OAbstractPaginatedStorage) storage).setStorageConfigurationUpdateListener(update -> { for (OMetadataUpdateListener listener : browseListeners()) { listener.onStorageConfigurationUpdate(storage.getName(), update); } }); }