Skip to content

Commit

Permalink
change service from interface to abstract class
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Kao <[email protected]>
  • Loading branch information
seankao-az committed Jun 21, 2024
1 parent 8929ddb commit e8f3e86
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,31 @@
package org.opensearch.flint.common.metadata.log;

import java.util.Optional;
import org.apache.spark.SparkConf;

/**
* Flint metadata log service provides API for metadata log related operations on a Flint index
* regardless of underlying storage.
*/
public interface FlintMetadataLogService {
public abstract class FlintMetadataLogService {

protected final SparkConf sparkConf;

/**
* Constructor.
*
* @param sparkConf spark configuration
*/
public FlintMetadataLogService(SparkConf sparkConf) {
this.sparkConf = sparkConf;
}

/**
* Default constructor.
*/
public FlintMetadataLogService() {
this(null);
}

/**
* Start a new optimistic transaction.
Expand All @@ -20,15 +39,15 @@ public interface FlintMetadataLogService {
* @param forceInit force init transaction and create empty metadata log if not exist
* @return transaction handle
*/
<T> OptimisticTransaction<T> startTransaction(String indexName, boolean forceInit);
public abstract <T> OptimisticTransaction<T> startTransaction(String indexName, boolean forceInit);

/**
* Start a new optimistic transaction.
*
* @param indexName index name
* @return transaction handle
*/
default <T> OptimisticTransaction<T> startTransaction(String indexName) {
public <T> OptimisticTransaction<T> startTransaction(String indexName) {
return startTransaction(indexName, false);
}

Expand All @@ -38,12 +57,12 @@ default <T> OptimisticTransaction<T> startTransaction(String indexName) {
* @param indexName index name
* @return optional metadata log
*/
Optional<FlintMetadataLog<FlintMetadataLogEntry>> getIndexMetadataLog(String indexName);
public abstract Optional<FlintMetadataLog<FlintMetadataLogEntry>> getIndexMetadataLog(String indexName);

/**
* Record heartbeat timestamp for index streaming job.
*
* @param indexName index name
*/
void recordHeartbeat(String indexName);
public abstract void recordHeartbeat(String indexName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.io.IOException;
import java.util.Optional;
import java.util.logging.Logger;
import org.apache.spark.SparkConf;
import org.opensearch.client.RequestOptions;
import org.opensearch.client.indices.CreateIndexRequest;
import org.opensearch.client.indices.GetIndexRequest;
Expand All @@ -24,7 +25,7 @@
/**
* Flint metadata log service implementation for OpenSearch storage.
*/
public class FlintOpenSearchMetadataLogService implements FlintMetadataLogService {
public class FlintOpenSearchMetadataLogService extends FlintMetadataLogService {

private static final Logger LOG = Logger.getLogger(FlintOpenSearchMetadataLogService.class.getName());

Expand Down

0 comments on commit e8f3e86

Please sign in to comment.