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 4f40bc1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 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 @@ -24,7 +24,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
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class FlintMetadataLogITSuite extends OpenSearchTransactionSuite with Matchers {
}
}

case class TestMetadataLogService(sparkConf: SparkConf) extends FlintMetadataLogService {
case class TestMetadataLogService(sparkConfParam: SparkConf) extends FlintMetadataLogService(sparkConfParam) {
override def startTransaction[T](
indexName: String,
forceInit: Boolean): OptimisticTransaction[T] = {
Expand Down

0 comments on commit 4f40bc1

Please sign in to comment.