Skip to content

Commit

Permalink
fix IndexMetadata retrieval in agent
Browse files Browse the repository at this point in the history
  • Loading branch information
smiklosovic committed Jun 27, 2024
1 parent 5177e1c commit 53a09e4
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.zegelin.cassandra.exporter;

import com.zegelin.cassandra.exporter.MetadataFactory;
import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.gms.Gossiper;
import org.apache.cassandra.cql3.statements.schema.IndexTarget;
import org.apache.cassandra.locator.IEndpointSnitch;
import org.apache.cassandra.locator.InetAddressAndPort;
import org.apache.cassandra.utils.FBUtilities;
Expand All @@ -13,6 +12,7 @@
import java.util.Set;

public class InternalMetadataFactory extends MetadataFactory {

private static Optional<org.apache.cassandra.schema.TableMetadata> getTableMetaData(final String keyspaceName, final String tableName) {
return Optional.ofNullable(Schema.instance.getTableMetadata(keyspaceName, tableName));
}
Expand All @@ -24,11 +24,10 @@ private static Optional<org.apache.cassandra.schema.TableMetadataRef> getIndexMe
@Override
public Optional<IndexMetadata> indexMetadata(final String keyspaceName, final String tableName, final String indexName) {
return getIndexMetadata(keyspaceName, indexName)
.flatMap(m -> m.get().indexName())
.map(m -> {
final IndexMetadata.IndexType indexType = IndexMetadata.IndexType.valueOf(m);
final Optional<String> className = Optional.ofNullable(m);

.flatMap(tableMetadata -> tableMetadata.get().indexes.get(indexName))
.map(indexMetadata -> {
final IndexMetadata.IndexType indexType = IndexMetadata.IndexType.valueOf(indexMetadata.kind.name());
final Optional<String> className = Optional.ofNullable(indexMetadata.options.get(IndexTarget.CUSTOM_INDEX_OPTION_NAME));
return new IndexMetadata() {
@Override
public IndexType indexType() {
Expand Down

0 comments on commit 53a09e4

Please sign in to comment.