Skip to content

Commit

Permalink
undo reflection
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 13, 2024
1 parent af971e7 commit f4e90e4
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,15 @@

package org.opensearch.flint.core;

import java.lang.reflect.Constructor;
import org.opensearch.flint.core.storage.FlintOpenSearchClient;
import org.opensearch.flint.core.metadata.log.FlintMetadataLogService;
import org.opensearch.flint.core.storage.FlintOpenSearchMetadataLogService;

/**
* {@link FlintClient} builder.
*/
public class FlintClientBuilder {

public static FlintClient build(FlintOptions options) {
return new FlintOpenSearchClient(options,
instantiateFlintMetadataLogService(options.getCustomFlintMetadataLogServiceClass(), options));
}

/**
* Attempts to instantiate Flint metadata log service using reflection.
*/
private static FlintMetadataLogService instantiateFlintMetadataLogService(String className, FlintOptions options) {
try {
Class<?> flintMetadataLogServiceClass = Class.forName(className);
Constructor<?> constructor = flintMetadataLogServiceClass.getConstructor(FlintOptions.class);
return (FlintMetadataLogService) constructor.newInstance(options);
} catch (Exception e) {
throw new RuntimeException("Failed to instantiate FlintMetadataLogService: " + className, e);
}
return new FlintOpenSearchClient(options, new FlintOpenSearchMetadataLogService(options));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ public class FlintOptions implements Serializable {

public static final String DEFAULT_BATCH_BYTES = "1mb";

public static final String CUSTOM_FLINT_METADATA_LOG_SERVICE_CLASS = "customFlintMetadataLogServiceClass";

public static final String DEFAULT_FLINT_METADATA_LOG_SERVICE_CLASS = "org.opensearch.flint.core.storage.FlintOpenSearchMetadataLogService";

public FlintOptions(Map<String, String> options) {
this.options = options;
this.retryOptions = new FlintRetryOptions(options);
Expand Down Expand Up @@ -166,8 +162,4 @@ public int getBatchBytes() {
return (int) org.apache.spark.network.util.JavaUtils
.byteStringAs(options.getOrDefault(BATCH_BYTES, DEFAULT_BATCH_BYTES), ByteUnit.BYTE);
}

public String getCustomFlintMetadataLogServiceClass() {
return options.getOrDefault(CUSTOM_FLINT_METADATA_LOG_SERVICE_CLASS, DEFAULT_FLINT_METADATA_LOG_SERVICE_CLASS);
}
}

This file was deleted.

0 comments on commit f4e90e4

Please sign in to comment.