Skip to content

Commit

Permalink
Remove useless codes on DataSourceNodePersistService
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed May 25, 2024
1 parent c1349eb commit fb0f49d
Showing 1 changed file with 0 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -106,45 +105,6 @@ public void delete(final String databaseName, final String dataSourceName) {
repository.delete(DataSourceMetaDataNode.getDataSourceNodeNode(databaseName, dataSourceName));
}

/**
* Delete data source pool configuration.
*
* @param databaseName database name
* @param dataSourceConfigs to be deleted configurations
* @return meta data versions
*/
public Collection<MetaDataVersion> deleteConfigurations(final String databaseName, final Map<String, DataSourcePoolProperties> dataSourceConfigs) {
Collection<MetaDataVersion> result = new LinkedList<>();
for (Entry<String, DataSourcePoolProperties> entry : dataSourceConfigs.entrySet()) {
String delKey = DataSourceMetaDataNode.getDataSourceNodeNode(databaseName, entry.getKey());
repository.delete(delKey);
result.add(new MetaDataVersion(delKey));
}
return result;
}

/**
* Persist data source pool configurations.
*
* @param databaseName database name
* @param dataSourceConfigs to be persisted configurations
* @return meta data versions
*/
public Collection<MetaDataVersion> persistConfigurations(final String databaseName, final Map<String, DataSourcePoolProperties> dataSourceConfigs) {
Collection<MetaDataVersion> result = new LinkedList<>();
for (Entry<String, DataSourcePoolProperties> entry : dataSourceConfigs.entrySet()) {
List<String> versions = repository.getChildrenKeys(DataSourceMetaDataNode.getDataSourceNodeVersionsNode(databaseName, entry.getKey()));
String nextActiveVersion = versions.isEmpty() ? MetaDataVersion.DEFAULT_VERSION : String.valueOf(Integer.parseInt(versions.get(0)) + 1);
repository.persist(DataSourceMetaDataNode.getDataSourceNodeVersionNode(databaseName, entry.getKey(), nextActiveVersion),
YamlEngine.marshal(new YamlDataSourceConfigurationSwapper().swapToMap(entry.getValue())));
if (Strings.isNullOrEmpty(getDataSourceActiveVersion(databaseName, entry.getKey()))) {
repository.persist(DataSourceMetaDataNode.getDataSourceNodeActiveVersionNode(databaseName, entry.getKey()), MetaDataVersion.DEFAULT_VERSION);
}
result.add(new MetaDataVersion(DataSourceMetaDataNode.getDataSourceNodeNode(databaseName, entry.getKey()), getDataSourceActiveVersion(databaseName, entry.getKey()), nextActiveVersion));
}
return result;
}

private String getDataSourceActiveVersion(final String databaseName, final String dataSourceName) {
return repository.query(DataSourceMetaDataNode.getDataSourceNodeActiveVersionNode(databaseName, dataSourceName));
}
Expand Down

0 comments on commit fb0f49d

Please sign in to comment.