All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.instaclustr.cassandra.sidecar.service.CassandraSchemaVersionService Maven / Gradle / Ivy

There is a newer version: 2.0.0-alpha8
Show newest version
package com.instaclustr.cassandra.sidecar.service;

import com.google.inject.Inject;
import com.instaclustr.operations.FunctionWithEx;
import jmx.org.apache.cassandra.service.CassandraJMXService;
import jmx.org.apache.cassandra.service.cassandra3.StorageServiceMBean;

public class CassandraSchemaVersionService {

    private final CassandraJMXService cassandraJMXService;

    @Inject
    public CassandraSchemaVersionService(final CassandraJMXService cassandraJMXService) {
        this.cassandraJMXService = cassandraJMXService;
    }

    public CassandraSchemaVersion getCassandraSchemaVersion() {
        final CassandraSchemaVersion version = new CassandraSchemaVersion();

        try {
            final String schemaVersion = cassandraJMXService.doWithStorageServiceMBean(new FunctionWithEx() {
                @Override
                public String apply(final StorageServiceMBean ssMBean) throws Exception {
                    return ssMBean.getSchemaVersion();
                }
            });

            version.setSchemaVersion(schemaVersion);
        } catch (final Exception ex) {
            version.setException(ex);
        }

        return version;
    }

    public static class CassandraSchemaVersion {

        private String schemaVersion;

        private Exception exception;

        public String getSchemaVersion() {
            return schemaVersion;
        }

        public void setSchemaVersion(final String schemaVersion) {
            this.schemaVersion = schemaVersion;
        }

        public Exception getException() {
            return exception;
        }

        public void setException(final Exception exception) {
            this.exception = exception;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy