Skip to content

Commit

Permalink
Merge pull request #327 from aiven/ivanyu/config-package
Browse files Browse the repository at this point in the history
Create config package
  • Loading branch information
jeqo authored Jul 19, 2023
2 parents 6700ae0 + f1414cf commit 9990341
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

import io.aiven.kafka.tieredstorage.chunkmanager.ChunkManager;
import io.aiven.kafka.tieredstorage.chunkmanager.ChunkManagerFactory;
import io.aiven.kafka.tieredstorage.config.RemoteStorageManagerConfig;
import io.aiven.kafka.tieredstorage.manifest.SegmentEncryptionMetadata;
import io.aiven.kafka.tieredstorage.manifest.SegmentEncryptionMetadataV1;
import io.aiven.kafka.tieredstorage.manifest.SegmentManifest;
Expand Down Expand Up @@ -78,9 +79,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static io.aiven.kafka.tieredstorage.RemoteStorageManagerConfig.METRICS_NUM_SAMPLES_CONFIG;
import static io.aiven.kafka.tieredstorage.RemoteStorageManagerConfig.METRICS_RECORDING_LEVEL_CONFIG;
import static io.aiven.kafka.tieredstorage.RemoteStorageManagerConfig.METRICS_SAMPLE_WINDOW_MS_CONFIG;
import static io.aiven.kafka.tieredstorage.config.RemoteStorageManagerConfig.METRICS_NUM_SAMPLES_CONFIG;
import static io.aiven.kafka.tieredstorage.config.RemoteStorageManagerConfig.METRICS_RECORDING_LEVEL_CONFIG;
import static io.aiven.kafka.tieredstorage.config.RemoteStorageManagerConfig.METRICS_SAMPLE_WINDOW_MS_CONFIG;
import static org.apache.kafka.server.log.remote.storage.RemoteStorageManager.IndexType.LEADER_EPOCH;
import static org.apache.kafka.server.log.remote.storage.RemoteStorageManager.IndexType.OFFSET;
import static org.apache.kafka.server.log.remote.storage.RemoteStorageManager.IndexType.PRODUCER_SNAPSHOT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.aiven.kafka.tieredstorage;
package io.aiven.kafka.tieredstorage.config;

import java.nio.file.Path;
import java.util.Objects;
Expand All @@ -23,7 +23,7 @@ public class KeyPairPaths {
public final Path publicKey;
public final Path privateKey;

public KeyPairPaths(final Path publicKey, final Path privateKey) {
KeyPairPaths(final Path publicKey, final Path privateKey) {
this.publicKey = Objects.requireNonNull(publicKey, "publicKey cannot be null");
this.privateKey = Objects.requireNonNull(privateKey, "privateKey cannot be null");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.aiven.kafka.tieredstorage;
package io.aiven.kafka.tieredstorage.config;

import java.nio.file.Path;
import java.time.Duration;
Expand Down Expand Up @@ -274,7 +274,7 @@ private static String privateKeyFileConfig(final String keyPairId) {

private final EncryptionConfig encryptionConfig;

RemoteStorageManagerConfig(final Map<String, ?> props) {
public RemoteStorageManagerConfig(final Map<String, ?> props) {
super(CONFIG, props);
encryptionConfig = encryptionEnabled() ? EncryptionConfig.create(props) : null;
validate();
Expand All @@ -291,57 +291,57 @@ private void validateCompression() {
}
}

StorageBackend storage() {
public StorageBackend storage() {
final Class<?> storageClass = getClass(STORAGE_BACKEND_CLASS_CONFIG);
final StorageBackend storage = Utils.newInstance(storageClass, StorageBackend.class);
storage.configure(this.originalsWithPrefix(STORAGE_PREFIX));
return storage;
}

Optional<Long> segmentManifestCacheSize() {
public Optional<Long> segmentManifestCacheSize() {
final long rawValue = getLong(SEGMENT_MANIFEST_CACHE_SIZE_CONFIG);
if (rawValue == -1) {
return Optional.empty();
}
return Optional.of(rawValue);
}

Optional<Duration> segmentManifestCacheRetention() {
public Optional<Duration> segmentManifestCacheRetention() {
final long rawValue = getLong(SEGMENT_MANIFEST_CACHE_RETENTION_MS_CONFIG);
if (rawValue == -1) {
return Optional.empty();
}
return Optional.of(Duration.ofMillis(rawValue));
}

String keyPrefix() {
public String keyPrefix() {
return getString(OBJECT_KEY_PREFIX_CONFIG);
}

int chunkSize() {
public int chunkSize() {
return getInt(CHUNK_SIZE_CONFIG);
}

boolean compressionEnabled() {
public boolean compressionEnabled() {
return getBoolean(COMPRESSION_ENABLED_CONFIG);
}

boolean compressionHeuristicEnabled() {
public boolean compressionHeuristicEnabled() {
return getBoolean(COMPRESSION_HEURISTIC_ENABLED_CONFIG);
}

boolean encryptionEnabled() {
public boolean encryptionEnabled() {
return getBoolean(ENCRYPTION_CONFIG);
}

String encryptionKeyPairId() {
public String encryptionKeyPairId() {
if (!encryptionEnabled()) {
return null;
}
return encryptionConfig.activeKeyPairId();
}

Map<String, KeyPairPaths> encryptionKeyRing() {
public Map<String, KeyPairPaths> encryptionKeyRing() {
if (!encryptionEnabled()) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.aiven.kafka.tieredstorage;
package io.aiven.kafka.tieredstorage.config;

import java.io.InputStream;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.aiven.kafka.tieredstorage;
package io.aiven.kafka.tieredstorage.config;

import java.nio.file.Path;
import java.time.Duration;
Expand Down

0 comments on commit 9990341

Please sign in to comment.