Skip to content

Commit

Permalink
Merge pull request #1144 from shreyabiradar07/dsmetadata_operator
Browse files Browse the repository at this point in the history
Add DataSourceMetadataOperator and DataSourceManager
  • Loading branch information
dinogun authored Apr 11, 2024
2 parents 8c2e141 + df09db1 commit 5d16548
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
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());
}
}

}
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
}

}

0 comments on commit 5d16548

Please sign in to comment.