-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1144 from shreyabiradar07/dsmetadata_operator
Add DataSourceMetadataOperator and DataSourceManager
- Loading branch information
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
src/main/java/com/autotune/common/datasource/DataSourceManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.autotune.common.datasource; | ||
|
||
import com.autotune.common.exceptions.KruizeDatasourceDoesNotExist; | ||
import com.autotune.utils.KruizeConstants; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* DataSourceManager is an interface to manage (create and update) metadata | ||
* of data sources | ||
* | ||
* | ||
* Currently Supported Implementations: | ||
* - importMetadataFromDataSource | ||
* - getMetadataFromDataSource | ||
* TODO - Implement update and delete functionalities | ||
*/ | ||
public class DataSourceManager { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(DataSourceManager.class); | ||
DataSourceMetadataOperator dataSourceMetadataOperator = DataSourceMetadataOperator.getInstance(); | ||
|
||
public DataSourceManager() { | ||
} | ||
|
||
/** | ||
* Imports Metadata for a specific data source using associated DataSourceInfo. | ||
*/ | ||
public void importMetadataFromDataSource(DataSourceInfo dataSource) { | ||
try { | ||
if (null == dataSource) { | ||
throw new KruizeDatasourceDoesNotExist(KruizeConstants.DataSourceConstants.DataSourceErrorMsgs.MISSING_DATASOURCE_INFO); | ||
} | ||
dataSourceMetadataOperator.createDataSourceMetadata(dataSource); | ||
} catch (Exception e) { | ||
LOGGER.error(e.getMessage()); | ||
} | ||
} | ||
|
||
/** | ||
* Retrieves Metadata from the specified data source information. | ||
* | ||
* @param dataSource The information about the data source to retrieve data from. | ||
* @return DataSourceMetadataInfo containing details about the data source, or null if not found. | ||
* @throws KruizeDatasourceDoesNotExist Thrown when the provided data source information is null. | ||
*/ | ||
public void getMetadataFromDataSource(DataSourceInfo dataSource) { | ||
try { | ||
if (null == dataSource) { | ||
throw new KruizeDatasourceDoesNotExist(KruizeConstants.DataSourceConstants.DataSourceErrorMsgs.MISSING_DATASOURCE_INFO); | ||
} | ||
dataSourceMetadataOperator.getDataSourceMetadataInfo(dataSource); | ||
} catch (Exception e) { | ||
LOGGER.error(e.getMessage()); | ||
} | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/autotune/common/datasource/DataSourceMetadataOperator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.autotune.common.datasource; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* DataSourceMetadataOperator is an abstraction with CRUD operations to manage DataSourceMetadataInfo Object | ||
* representing JSON for a given data source | ||
* | ||
* TODO - | ||
* object is currently stored in memory going forward need to store cluster metadata in Kruize DB | ||
* Implement methods to support update and delete operations for periodic update of DataSourceMetadataInfo | ||
*/ | ||
public class DataSourceMetadataOperator { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(DataSourceMetadataOperator.class); | ||
private static final DataSourceMetadataOperator dataSourceMetadataOperatorInstance = new DataSourceMetadataOperator(); | ||
private DataSourceMetadataOperator() { | ||
} | ||
public static DataSourceMetadataOperator getInstance() { return dataSourceMetadataOperatorInstance; } | ||
|
||
public void createDataSourceMetadata(DataSourceInfo dataSource) { | ||
//TODO - Implementation | ||
} | ||
public void getDataSourceMetadataInfo(DataSourceInfo dataSource) { | ||
//TODO - Implementation | ||
} | ||
|
||
} |