Skip to content

Commit

Permalink
specializate set of default cluster for embedded and remote
Browse files Browse the repository at this point in the history
  • Loading branch information
tglman committed Dec 29, 2017
1 parent 7aa0a66 commit 95f47e5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
Expand Up @@ -462,4 +462,13 @@ protected void setSuperClassesInternal(final List<? extends OClass> classes) {
superClasses.addAll(newSuperClasses);
}

public void setDefaultClusterId(final int defaultClusterId) {
final ODatabaseDocumentInternal database = getDatabase();
String clusterName = database.getClusterNameById(defaultClusterId);
if (clusterName != null)
throw new OSchemaException("Cluster with id '" + defaultClusterId + "' do not exists");
final String cmd = String.format("alter class `%s` DEFAULTCLUSTER `%s`", this.name, clusterName);
database.command(cmd).close();
}

}
Expand Up @@ -478,6 +478,16 @@ protected void setNameInternal(ODatabaseDocumentInternal database, final String
}
}

public void setDefaultClusterId(final int defaultClusterId) {
acquireSchemaWriteLock();
try {
checkEmbedded();
this.defaultClusterId = defaultClusterId;
} finally {
releaseSchemaWriteLock();
}
}

protected OClass addClusterIdInternal(ODatabaseDocumentInternal database, final int clusterId) {
acquireSchemaWriteLock();
try {
Expand Down
Expand Up @@ -615,16 +615,6 @@ public int getDefaultClusterId() {
}
}

public void setDefaultClusterId(final int defaultClusterId) {
acquireSchemaWriteLock();
try {
checkEmbedded();
this.defaultClusterId = defaultClusterId;
} finally {
releaseSchemaWriteLock();
}
}

public int[] getClusterIds() {
acquireSchemaReadLock();
try {
Expand Down

0 comments on commit 95f47e5

Please sign in to comment.