public String getClusterNameById(int iClusterId) { return database.getClusterNameById(iClusterId); }
@Override public String getClusterNameById(int iClusterId) { checkOpenness(); return internal.getClusterNameById(iClusterId); }
@Override public Set<String> getInvolvedClusters() { if (clazz != null) return Collections.singleton(getDatabase().getClusterNameById(clazz.getClusterSelection().getCluster(clazz, null))); else if (clusterName != null) return getInvolvedClustersOfClusters(Collections.singleton(clusterName)); return Collections.EMPTY_SET; }
@Override public Set<String> getInvolvedClusters() { if (clazz != null) return Collections.singleton(getDatabase().getClusterNameById(clazz.getClusterSelection().getCluster(clazz, null))); else if (clusterName != null) return getInvolvedClustersOfClusters(Collections.singleton(clusterName)); return Collections.EMPTY_SET; }
@Override public Set<String> getInvolvedClusters() { if (clazz != null) return Collections.singleton(getDatabase().getClusterNameById(clazz.getClusterSelection().getCluster(clazz, null))); else if (clusterName != null) return getInvolvedClustersOfClusters(Collections.singleton(clusterName)); return Collections.EMPTY_SET; }
@Override public Set<String> getInvolvedClusters() { if (clazz != null) return Collections.singleton(getDatabase().getClusterNameById(clazz.getClusterSelection().getCluster(clazz, null))); else if (clusterName != null) return getInvolvedClustersOfClusters(Collections.singleton(clusterName)); return Collections.EMPTY_SET; }
private void tryDropCluster(final int defaultClusterId) { if (name.toLowerCase(Locale.ENGLISH).equals(getDatabase().getClusterNameById(defaultClusterId))) { // DROP THE DEFAULT CLUSTER CALLED WITH THE SAME NAME ONLY IF EMPTY if (getDatabase().getClusterRecordSizeById(defaultClusterId) == 0) getDatabase().getStorage().dropCluster(defaultClusterId, true); } }
@Override public Set<String> getInvolvedClusters() { if (className != null) { final OClass clazz = ((OMetadataInternal) getDatabase().getMetadata()).getImmutableSchemaSnapshot().getClass(className); return Collections.singleton(getDatabase().getClusterNameById(clazz.getClusterSelection().getCluster(clazz, null))); } else if (clusterName != null) return getInvolvedClustersOfClusters(Collections.singleton(clusterName)); return Collections.EMPTY_SET; }
@Override public Set<String> getInvolvedClusters() { final HashSet<String> result = new HashSet<String>(); if (rids != null) { final ODatabaseDocumentInternal database = getDatabase(); for (ORecordId rid : rids) { result.add(database.getClusterNameById(rid.getClusterId())); } } else if (query != null) { final OCommandExecutor executor = OCommandManager.instance().getExecutor((OCommandRequestInternal) query); // COPY THE CONTEXT FROM THE REQUEST executor.setContext(context); executor.parse(query); return executor.getInvolvedClusters(); } return result; }
@Override public Set<String> getInvolvedClusters() { final HashSet<String> result = new HashSet<String>(); if (rids != null) { final ODatabaseDocumentInternal database = getDatabase(); for (ORecordId rid : rids) { result.add(database.getClusterNameById(rid.getClusterId())); } } else if (query != null) { final OCommandExecutor executor = OCommandManager.instance().getExecutor((OCommandRequestInternal) query); // COPY THE CONTEXT FROM THE REQUEST executor.setContext(context); executor.parse(query); return executor.getInvolvedClusters(); } return result; }
protected Set<String> getInvolvedClustersOfIndex(final String iIndexName) { final ODatabaseDocumentInternal db = getDatabase(); final Set<String> clusters = new HashSet<String>(); final OMetadataInternal metadata = (OMetadataInternal) db.getMetadata(); final OIndex<?> idx = metadata.getIndexManager().getIndex(iIndexName); if (idx != null && idx.getDefinition() != null) { final String clazz = idx.getDefinition().getClassName(); if (clazz != null) { final OClass cls = metadata.getImmutableSchemaSnapshot().getClass(clazz); if (cls != null) for (int clId : cls.getClusterIds()) { final String clName = db.getClusterNameById(clId); if (clName != null) clusters.add(clName.toLowerCase(Locale.ENGLISH)); } } } return clusters; }
private void removeClusterFromIndexes(final int iId) { if (getDatabase().getStorage().getUnderlying() instanceof OAbstractPaginatedStorage) { final String clusterName = getDatabase().getClusterNameById(iId); final List<String> indexesToRemove = new ArrayList<String>(); for (final OIndex<?> index : getIndexes()) indexesToRemove.add(index.getName()); final OIndexManager indexManager = getDatabase().getMetadata().getIndexManager(); for (final String indexName : indexesToRemove) indexManager.removeClusterFromIndex(clusterName, indexName); } }
private void exportClusters() throws IOException { listener.onMessage("\nExporting clusters..."); writer.beginCollection(1, true, "clusters"); int exportedClusters = 0; int maxClusterId = getMaxClusterId(); for (int clusterId = 0; clusterId <= maxClusterId; ++clusterId) { final String clusterName = database.getClusterNameById(clusterId); // exclude removed clusters if (clusterName == null) continue; // CHECK IF THE CLUSTER IS INCLUDED if (includeClusters != null) { if (!includeClusters.contains(clusterName.toUpperCase(Locale.ENGLISH))) continue; } else if (excludeClusters != null) { if (excludeClusters.contains(clusterName.toUpperCase(Locale.ENGLISH))) continue; } writer.beginObject(2, true, null); writer.writeAttribute(0, false, "name", clusterName); writer.writeAttribute(0, false, "id", clusterId); exportedClusters++; writer.endObject(2, false); } listener.onMessage("OK (" + exportedClusters + " clusters)"); writer.endCollection(1, true); }
private void addClusterIdToIndexes(int iId) { ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (database != null && database.getStorage().getUnderlying() instanceof OAbstractPaginatedStorage) { final String clusterName = getDatabase().getClusterNameById(iId); final List<String> indexesToAdd = new ArrayList<String>(); for (OIndex<?> index : getIndexes()) indexesToAdd.add(index.getName()); final OIndexManager indexManager = getDatabase().getMetadata().getIndexManager(); for (String indexName : indexesToAdd) indexManager.addClusterToIndex(clusterName, indexName); } }
public String getClusterName(final ORecord record) { if (ODatabaseRecordThreadLocal.instance().get().getStorage().isRemote()) // DON'T ASSIGN CLUSTER WITH REMOTE: SERVER KNOWS THE RIGHT CLUSTER BASED ON LOCALITY return null; int clusterId = record.getIdentity().getClusterId(); if (clusterId == ORID.CLUSTER_ID_INVALID) { // COMPUTE THE CLUSTER ID OClass schemaClass = null; if (record instanceof ODocument) schemaClass = ODocumentInternal.getImmutableSchemaClass(getDatabase(), (ODocument) record); if (schemaClass != null) { // FIND THE RIGHT CLUSTER AS CONFIGURED IN CLASS if (schemaClass.isAbstract()) throw new OSchemaException("Document belongs to abstract class '" + schemaClass.getName() + "' and cannot be saved"); clusterId = schemaClass.getClusterForNewInstance((ODocument) record); return database.getClusterNameById(clusterId); } else { return database.getClusterNameById(database.getStorage().getDefaultClusterId()); } } else { return database.getClusterNameById(clusterId); } }
involvedClusters.add(database.getClusterNameById(rid.getClusterId())); lastRid = rid;
private void invalidateCommandCache(OClass clazz, ODatabase db) { if (clazz == null) { return; } OCommandCache commandCache = ((OMetadataInternal)db.getMetadata()).getCommandCache(); if (commandCache != null && commandCache.isEnabled()) { int[] clusterIds = clazz.getClusterIds(); if (clusterIds != null) { for (int i : clusterIds) { String clusterName = getDatabase().getClusterNameById(i); if (clusterName != null) { commandCache.invalidateResultsOfCluster(clusterName); } } } } }
private void invalidateCommandCache(OClass clazz) { if (clazz == null) { return; } OCommandCache commandCache = getDatabase().getMetadata().getCommandCache(); if (commandCache != null && commandCache.isEnabled()) { int[] clusterIds = clazz.getClusterIds(); if (clusterIds != null) { for (int i : clusterIds) { String clusterName = getDatabase().getClusterNameById(i); if (clusterName != null) { commandCache.invalidateResultsOfCluster(clusterName); } } } } }
final String[] clusterNames = new String[clustersToIndex.length]; for (int i = 0; i < clustersToIndex.length; i++) clusterNames[i] = database.getClusterNameById(clustersToIndex[i]);
getDatabase().getMetadata().getCommandCache().invalidateResultsOfCluster(getDatabase().getClusterNameById(clId));