private int addClusterInternal(String clusterName, final int clusterPos, final Object... parameters) throws IOException {
final OCluster cluster;
if (clusterName != null) {
clusterName = clusterName.toLowerCase(configuration.getLocaleInstance());
cluster = OPaginatedClusterFactory
.createCluster(clusterName, configuration.getVersion(), OPaginatedCluster.getLatestBinaryVersion(), this);
cluster.configure(this, clusterPos, clusterName, parameters);
} else {
cluster = null;
}
int createdClusterId = -1;
if (cluster != null) {
cluster.create(-1);
if (writeAheadLog != null) {
writeAheadLog.flush();
}
createdClusterId = registerCluster(cluster);
((OPaginatedCluster) cluster).registerInStorageConfig((OStorageConfigurationImpl) configuration);
((OStorageConfigurationImpl) configuration).update();
}
if (OLogManager.instance().isDebugEnabled()) {
OLogManager.instance()
.debug(this, "Created cluster '%s' in database '%s' with id %d. Clusters: %s", clusterName, url, createdClusterId,
clusters);
}
return createdClusterId;
}