predicate)
- {
- return delegateRepairHistoryProvider.iterate(nodeId, tableReference, to, from, predicate);
- }
-
- @ObjectClassDefinition
- public @interface Configuration
- {
- @AttributeDefinition(name = "The provider to use for repair history",
- description = "The provider to use for repair history")
- Provider provider() default Provider.ECC;
-
- @AttributeDefinition(name = "Provider keyspace", description = "The keyspace used for ecc history if enabled")
- String providerKeyspace() default DEFAULT_PROVIDER_KEYSPACE;
-
- @AttributeDefinition(name = "Repair history lookback time",
- description = "The lookback time in seconds for when the repair_history table is queried to get "
- + "initial repair state at startup")
- long lookbackTimeSeconds() default DEFAULT_REPAIR_HISTORY_LOOKBACK_SECONDS;
- }
-}
diff --git a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/RepairSchedulerService.java b/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/RepairSchedulerService.java
deleted file mode 100644
index 991e3173b..000000000
--- a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/RepairSchedulerService.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright 2018 Telefonaktiebolaget LM Ericsson
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ericsson.bss.cassandra.ecchronos.core.osgi;
-
-import java.util.List;
-
-import com.ericsson.bss.cassandra.ecchronos.core.repair.RepairConfiguration;
-import com.ericsson.bss.cassandra.ecchronos.core.repair.RepairLockType;
-import com.ericsson.bss.cassandra.ecchronos.core.repair.RepairScheduler;
-import com.ericsson.bss.cassandra.ecchronos.core.repair.RepairSchedulerImpl;
-import com.ericsson.bss.cassandra.ecchronos.core.repair.ScheduledRepairJobView;
-import com.ericsson.bss.cassandra.ecchronos.core.repair.TableRepairPolicy;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.osgi.service.component.annotations.ReferencePolicy;
-import org.osgi.service.metatype.annotations.AttributeDefinition;
-import org.osgi.service.metatype.annotations.Designate;
-import org.osgi.service.metatype.annotations.ObjectClassDefinition;
-
-import com.ericsson.bss.cassandra.ecchronos.core.JmxProxyFactory;
-import com.ericsson.bss.cassandra.ecchronos.core.TableStorageStates;
-import com.ericsson.bss.cassandra.ecchronos.core.metrics.TableRepairMetrics;
-
-import com.ericsson.bss.cassandra.ecchronos.core.repair.state.RepairHistory;
-import com.ericsson.bss.cassandra.ecchronos.core.repair.state.RepairStateFactory;
-import com.ericsson.bss.cassandra.ecchronos.core.scheduling.ScheduleManager;
-import com.ericsson.bss.cassandra.ecchronos.core.utils.TableReference;
-import com.ericsson.bss.cassandra.ecchronos.fm.RepairFaultReporter;
-
-/**
- * A factory creating TableRepairJob's for tables that replicates data over multiple nodes.
- *
- * This factory will schedule new jobs automatically when new tables are added.
- */
-@Component(service = RepairScheduler.class)
-@Designate(ocd = RepairSchedulerService.Configuration.class)
-public class RepairSchedulerService implements RepairScheduler
-{
- @Reference(service = RepairFaultReporter.class,
- cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.STATIC)
- private volatile RepairFaultReporter myFaultReporter;
-
- @Reference(service = JmxProxyFactory.class,
- cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.STATIC)
- private volatile JmxProxyFactory myJmxProxyFactory;
-
- @Reference(service = TableRepairMetrics.class,
- cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.STATIC)
- private volatile TableRepairMetrics myTableRepairMetrics;
-
- @Reference(service = ScheduleManager.class,
- cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.STATIC)
- private volatile ScheduleManager myScheduleManager;
-
- @Reference(service = RepairStateFactory.class,
- cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.STATIC)
- private volatile RepairStateFactory myRepairStateFactory;
-
- @Reference(service = TableStorageStates.class,
- cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.STATIC)
- private volatile TableStorageStates myTableStorageStates;
-
- @Reference(service = TableRepairPolicy.class,
- cardinality = ReferenceCardinality.AT_LEAST_ONE, policy = ReferencePolicy.STATIC)
- private volatile List myRepairPolicies;
-
- @Reference(service = RepairHistory.class,
- cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.STATIC)
- private volatile RepairHistory myRepairHistory;
-
- private volatile RepairSchedulerImpl myDelegateRepairSchedulerImpl;
-
- @Activate
- public final synchronized void activate(final Configuration configuration)
- {
- myDelegateRepairSchedulerImpl = RepairSchedulerImpl.builder()
- .withFaultReporter(myFaultReporter)
- .withJmxProxyFactory(myJmxProxyFactory)
- .withTableRepairMetrics(myTableRepairMetrics)
- .withScheduleManager(myScheduleManager)
- .withRepairStateFactory(myRepairStateFactory)
- .withRepairLockType(configuration.repairLockType())
- .withTableStorageStates(myTableStorageStates)
- .withRepairPolicies(myRepairPolicies)
- .withRepairHistory(myRepairHistory)
- .build();
- }
-
- @Deactivate
- public final synchronized void deactivate()
- {
- myDelegateRepairSchedulerImpl.close();
- }
-
- @Override
- public final void putConfiguration(final TableReference tableReference,
- final RepairConfiguration repairConfiguration)
- {
- myDelegateRepairSchedulerImpl.putConfiguration(tableReference, repairConfiguration);
- }
-
- @Override
- public final void removeConfiguration(final TableReference tableReference)
- {
- myDelegateRepairSchedulerImpl.removeConfiguration(tableReference);
- }
-
- @Override
- public final List getCurrentRepairJobs()
- {
- return myDelegateRepairSchedulerImpl.getCurrentRepairJobs();
- }
-
- @ObjectClassDefinition
- public @interface Configuration
- {
- @AttributeDefinition(name = "Type of repair lock", description = "The type of locks to take for repair jobs")
- RepairLockType repairLockType() default RepairLockType.VNODE;
- }
-}
diff --git a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/RepairStateFactoryService.java b/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/RepairStateFactoryService.java
deleted file mode 100644
index 1c3816bd6..000000000
--- a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/RepairStateFactoryService.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2018 Telefonaktiebolaget LM Ericsson
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ericsson.bss.cassandra.ecchronos.core.osgi;
-
-import com.ericsson.bss.cassandra.ecchronos.core.HostStates;
-import com.ericsson.bss.cassandra.ecchronos.core.metrics.TableRepairMetrics;
-import com.ericsson.bss.cassandra.ecchronos.core.repair.RepairConfiguration;
-import com.ericsson.bss.cassandra.ecchronos.core.repair.state.PostUpdateHook;
-import com.ericsson.bss.cassandra.ecchronos.core.repair.state.RepairHistoryProvider;
-import com.ericsson.bss.cassandra.ecchronos.core.repair.state.RepairState;
-import com.ericsson.bss.cassandra.ecchronos.core.repair.state.RepairStateFactory;
-import com.ericsson.bss.cassandra.ecchronos.core.repair.state.RepairStateFactoryImpl;
-import com.ericsson.bss.cassandra.ecchronos.core.repair.state.ReplicationState;
-import com.ericsson.bss.cassandra.ecchronos.core.utils.TableReference;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.osgi.service.component.annotations.ReferencePolicy;
-
-@Component(service = RepairStateFactory.class)
-public class RepairStateFactoryService implements RepairStateFactory
-{
- @Reference(service = HostStates.class,
- cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.STATIC)
- private volatile HostStates myHostStates;
-
- @Reference(service = TableRepairMetrics.class,
- cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.STATIC)
- private volatile TableRepairMetrics myTableRepairMetrics;
-
- @Reference(service = RepairHistoryProvider.class,
- cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.STATIC)
- private volatile RepairHistoryProvider myRepairHistoryProvider;
-
- @Reference(service = ReplicationState.class,
- cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.STATIC)
- private volatile ReplicationState myReplicationState;
-
- private volatile RepairStateFactoryImpl myDelegateRepairStateFactory;
-
- @Activate
- public final void activate()
- {
- myDelegateRepairStateFactory = RepairStateFactoryImpl.builder()
- .withReplicationState(myReplicationState)
- .withHostStates(myHostStates)
- .withRepairHistoryProvider(myRepairHistoryProvider)
- .withTableRepairMetrics(myTableRepairMetrics)
- .build();
- }
-
- @Override
- public final RepairState create(final TableReference tableReference,
- final RepairConfiguration repairConfiguration,
- final PostUpdateHook postUpdateHook)
- {
- return myDelegateRepairStateFactory.create(tableReference, repairConfiguration, postUpdateHook);
- }
-}
diff --git a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/ReplicatedTableProviderService.java b/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/ReplicatedTableProviderService.java
deleted file mode 100644
index 5b541d35a..000000000
--- a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/ReplicatedTableProviderService.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2018 Telefonaktiebolaget LM Ericsson
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ericsson.bss.cassandra.ecchronos.core.osgi;
-
-import com.datastax.oss.driver.api.core.CqlSession;
-import com.datastax.oss.driver.api.core.metadata.Node;
-import com.ericsson.bss.cassandra.ecchronos.connection.NativeConnectionProvider;
-import com.ericsson.bss.cassandra.ecchronos.core.utils.ReplicatedTableProvider;
-import com.ericsson.bss.cassandra.ecchronos.core.utils.ReplicatedTableProviderImpl;
-import com.ericsson.bss.cassandra.ecchronos.core.utils.TableReference;
-import com.ericsson.bss.cassandra.ecchronos.core.utils.TableReferenceFactory;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.osgi.service.component.annotations.ReferencePolicy;
-
-import java.util.Set;
-
-@Component(service = ReplicatedTableProvider.class)
-public class ReplicatedTableProviderService implements ReplicatedTableProvider
-{
- private volatile ReplicatedTableProvider myDelegateReplicatedTableProvider;
-
- @Reference(service = NativeConnectionProvider.class, cardinality = ReferenceCardinality.MANDATORY,
- policy = ReferencePolicy.STATIC)
- private volatile NativeConnectionProvider myNativeConnectionProvider;
-
- @Reference(service = TableReferenceFactory.class, cardinality = ReferenceCardinality.MANDATORY,
- policy = ReferencePolicy.STATIC)
- private volatile TableReferenceFactory myTableReferenceFactory;
-
- @Activate
- public final void activate()
- {
- CqlSession session = myNativeConnectionProvider.getSession();
- Node localhost = myNativeConnectionProvider.getLocalNode();
-
- myDelegateReplicatedTableProvider = new ReplicatedTableProviderImpl(localhost, session,
- myTableReferenceFactory);
- }
-
- @Override
- public final Set getAll()
- {
- return myDelegateReplicatedTableProvider.getAll();
- }
-
- @Override
- public final boolean accept(final String keyspace)
- {
- return myDelegateReplicatedTableProvider.accept(keyspace);
- }
-}
diff --git a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/ReplicationStateService.java b/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/ReplicationStateService.java
deleted file mode 100644
index 8615f4862..000000000
--- a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/ReplicationStateService.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2020 Telefonaktiebolaget LM Ericsson
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ericsson.bss.cassandra.ecchronos.core.osgi;
-
-import com.datastax.oss.driver.api.core.CqlSession;
-import com.datastax.oss.driver.api.core.metadata.Node;
-import com.ericsson.bss.cassandra.ecchronos.connection.NativeConnectionProvider;
-import com.ericsson.bss.cassandra.ecchronos.core.repair.state.ReplicationState;
-import com.ericsson.bss.cassandra.ecchronos.core.repair.state.ReplicationStateImpl;
-import com.ericsson.bss.cassandra.ecchronos.core.utils.LongTokenRange;
-import com.ericsson.bss.cassandra.ecchronos.core.utils.DriverNode;
-import com.ericsson.bss.cassandra.ecchronos.core.utils.NodeResolver;
-import com.ericsson.bss.cassandra.ecchronos.core.utils.TableReference;
-import com.google.common.collect.ImmutableSet;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.osgi.service.component.annotations.ReferencePolicy;
-
-import java.util.Map;
-
-@Component(service = ReplicationState.class)
-public class ReplicationStateService implements ReplicationState
-{
- @Reference(service = NativeConnectionProvider.class, cardinality = ReferenceCardinality.MANDATORY,
- policy = ReferencePolicy.STATIC)
- private volatile NativeConnectionProvider nativeConnectionProvider;
-
- @Reference(service = NodeResolver.class, cardinality = ReferenceCardinality.MANDATORY,
- policy = ReferencePolicy.STATIC)
- private volatile NodeResolver nodeResolver;
-
- private volatile ReplicationState delegateReplicationState;
-
- @Activate
- public final void activate()
- {
- CqlSession session = nativeConnectionProvider.getSession();
- Node localNode = nativeConnectionProvider.getLocalNode();
-
- delegateReplicationState = new ReplicationStateImpl(nodeResolver, session, localNode);
- }
-
- @Override
- public final ImmutableSet getNodes(final TableReference tableReference,
- final LongTokenRange tokenRange)
- {
- return delegateReplicationState.getNodes(tableReference, tokenRange);
- }
-
- @Override
- public final ImmutableSet getNodesClusterWide(final TableReference tableReference,
- final LongTokenRange tokenRange)
- {
- return delegateReplicationState.getNodesClusterWide(tableReference, tokenRange);
- }
-
- @Override
- public final Map> getTokenRangeToReplicas(
- final TableReference tableReference)
- {
- return delegateReplicationState.getTokenRangeToReplicas(tableReference);
- }
-
- @Override
- public final Map> getTokenRanges(final TableReference tableReference)
- {
- return delegateReplicationState.getTokenRanges(tableReference);
- }
-}
diff --git a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/ScheduleManagerService.java b/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/ScheduleManagerService.java
deleted file mode 100644
index fef48ef72..000000000
--- a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/ScheduleManagerService.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2018 Telefonaktiebolaget LM Ericsson
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ericsson.bss.cassandra.ecchronos.core.osgi;
-
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-import com.ericsson.bss.cassandra.ecchronos.core.scheduling.LockFactory;
-import com.ericsson.bss.cassandra.ecchronos.core.scheduling.RunPolicy;
-import com.ericsson.bss.cassandra.ecchronos.core.scheduling.ScheduleManager;
-import com.ericsson.bss.cassandra.ecchronos.core.scheduling.ScheduleManagerImpl;
-import com.ericsson.bss.cassandra.ecchronos.core.scheduling.ScheduledJob;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.osgi.service.component.annotations.ReferencePolicy;
-import org.osgi.service.metatype.annotations.AttributeDefinition;
-import org.osgi.service.metatype.annotations.Designate;
-import org.osgi.service.metatype.annotations.ObjectClassDefinition;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.Sets;
-
-@Component(service = ScheduleManager.class)
-@Designate(ocd = ScheduleManagerService.Configuration.class)
-public class ScheduleManagerService implements ScheduleManager
-{
- private static final Logger LOG = LoggerFactory.getLogger(ScheduleManagerService.class);
-
- private static final long DEFAULT_SCHEDULE_INTERVAL_IN_SECONDS = 60L;
-
- @Reference(service = RunPolicy.class,
- cardinality = ReferenceCardinality.MULTIPLE,
- policy = ReferencePolicy.DYNAMIC,
- bind = "bindRunPolicy",
- unbind = "unbindRunPolicy")
- private final Set myRunPolicies = Sets.newConcurrentHashSet();
-
- @Reference (service = LockFactory.class,
- cardinality = ReferenceCardinality.MANDATORY,
- policy = ReferencePolicy.STATIC)
- private volatile LockFactory myLockFactory;
-
- private volatile ScheduleManagerImpl myDelegateSchedulerManager;
-
- @Activate
- public final synchronized void activate(final Configuration configuration)
- {
- long scheduleIntervalInSeconds = configuration.scheduleIntervalInSeconds();
-
- myDelegateSchedulerManager = ScheduleManagerImpl.builder()
- .withLockFactory(myLockFactory)
- .withRunInterval(scheduleIntervalInSeconds, TimeUnit.SECONDS)
- .build();
-
- for (RunPolicy runPolicy : myRunPolicies)
- {
- myDelegateSchedulerManager.addRunPolicy(runPolicy);
- }
- }
-
- @Deactivate
- public final synchronized void deactivate()
- {
- myDelegateSchedulerManager.close();
- }
-
- @Override
- public final void schedule(final ScheduledJob job)
- {
- myDelegateSchedulerManager.schedule(job);
- }
-
- @Override
- public final void deschedule(final ScheduledJob job)
- {
- myDelegateSchedulerManager.deschedule(job);
- }
-
- public final synchronized void bindRunPolicy(final RunPolicy runPolicy)
- {
- if (myRunPolicies.add(runPolicy))
- {
- LOG.trace("Run policy {} added", runPolicy);
- if (myDelegateSchedulerManager != null)
- {
- myDelegateSchedulerManager.addRunPolicy(runPolicy);
- }
- }
- else
- {
- LOG.warn("Run policy {} already added", runPolicy);
- }
- }
-
- public final synchronized void unbindRunPolicy(final RunPolicy runPolicy)
- {
- if (myRunPolicies.remove(runPolicy))
- {
- LOG.trace("Run policy {} removed", runPolicy);
- if (myDelegateSchedulerManager != null)
- {
- myDelegateSchedulerManager.removeRunPolicy(runPolicy);
- }
- }
- else
- {
- LOG.warn("Run policy {} already removed", runPolicy);
- }
- }
-
- @ObjectClassDefinition
- public @interface Configuration
- {
- @AttributeDefinition(name = "Schedule interval in seconds",
- description = "The interval in which jobs will be scheduled to run")
- long scheduleIntervalInSeconds() default DEFAULT_SCHEDULE_INTERVAL_IN_SECONDS;
- }
-}
diff --git a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/TableReferenceFactoryService.java b/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/TableReferenceFactoryService.java
deleted file mode 100644
index 2bc9421d2..000000000
--- a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/TableReferenceFactoryService.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2020 Telefonaktiebolaget LM Ericsson
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ericsson.bss.cassandra.ecchronos.core.osgi;
-
-import com.datastax.oss.driver.api.core.CqlSession;
-import com.datastax.oss.driver.api.core.metadata.schema.TableMetadata;
-import com.ericsson.bss.cassandra.ecchronos.connection.NativeConnectionProvider;
-import com.ericsson.bss.cassandra.ecchronos.core.exceptions.EcChronosException;
-import com.ericsson.bss.cassandra.ecchronos.core.utils.TableReference;
-import com.ericsson.bss.cassandra.ecchronos.core.utils.TableReferenceFactory;
-import com.ericsson.bss.cassandra.ecchronos.core.utils.TableReferenceFactoryImpl;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.osgi.service.component.annotations.ReferencePolicy;
-
-import java.util.Set;
-
-@Component(service = TableReferenceFactory.class)
-public class TableReferenceFactoryService implements TableReferenceFactory
-{
- @Reference(service = NativeConnectionProvider.class, cardinality = ReferenceCardinality.MANDATORY,
- policy = ReferencePolicy.STATIC)
- private volatile NativeConnectionProvider nativeConnectionProvider;
-
- private volatile TableReferenceFactory delegateTableReferenceFactory;
-
- @Activate
- public final void activate()
- {
- CqlSession session = nativeConnectionProvider.getSession();
-
- delegateTableReferenceFactory = new TableReferenceFactoryImpl(session);
- }
-
- @Override
- public final TableReference forTable(final String keyspace, final String table)
- {
- return delegateTableReferenceFactory.forTable(keyspace, table);
- }
-
- @Override
- public final TableReference forTable(final TableMetadata table)
- {
- return delegateTableReferenceFactory.forTable(table);
- }
-
- @Override
- public final Set forKeyspace(final String keyspace) throws EcChronosException
- {
- return delegateTableReferenceFactory.forKeyspace(keyspace);
- }
-
- @Override
- public final Set forCluster()
- {
- return delegateTableReferenceFactory.forCluster();
- }
-}
diff --git a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/TableRepairMetricsService.java b/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/TableRepairMetricsService.java
deleted file mode 100644
index 8defefb7b..000000000
--- a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/TableRepairMetricsService.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2018 Telefonaktiebolaget LM Ericsson
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ericsson.bss.cassandra.ecchronos.core.osgi;
-
-import java.util.Optional;
-import java.util.concurrent.TimeUnit;
-
-import com.ericsson.bss.cassandra.ecchronos.core.TableStorageStates;
-import com.ericsson.bss.cassandra.ecchronos.core.metrics.TableRepairMetrics;
-import com.ericsson.bss.cassandra.ecchronos.core.metrics.TableRepairMetricsImpl;
-import com.ericsson.bss.cassandra.ecchronos.core.metrics.TableRepairMetricsProvider;
-import com.ericsson.bss.cassandra.ecchronos.core.utils.TableReference;
-import io.micrometer.core.instrument.Metrics;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.osgi.service.component.annotations.ReferencePolicy;
-import org.osgi.service.metatype.annotations.AttributeDefinition;
-import org.osgi.service.metatype.annotations.Designate;
-import org.osgi.service.metatype.annotations.ObjectClassDefinition;
-
-@Component(service = {TableRepairMetrics.class, TableRepairMetricsProvider.class})
-@Designate(ocd = TableRepairMetricsService.Configuration.class)
-public final class TableRepairMetricsService implements TableRepairMetrics, TableRepairMetricsProvider
-{
- private static final long DEFAULT_STATISTICS_REPORT_INTERVAL_IN_SECONDS = 60L;
-
- @Reference(service = TableStorageStates.class,
- cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.STATIC)
- private volatile TableStorageStates myTableStorageStates;
-
- private volatile TableRepairMetricsImpl myDelegateTableRepairMetrics;
-
- @Activate
- public void activate(final Configuration configuration)
- {
- myDelegateTableRepairMetrics = TableRepairMetricsImpl.builder()
- .withTableStorageStates(myTableStorageStates)
- .withMeterRegistry(Metrics.globalRegistry)
- .build();
- }
-
- @Deactivate
- public void deactivate()
- {
- myDelegateTableRepairMetrics.close();
- }
-
- @Override
- public void repairState(final TableReference tableReference, final int repairedRanges, final int notRepairedRanges)
- {
- myDelegateTableRepairMetrics.repairState(tableReference, repairedRanges, notRepairedRanges);
- }
-
- @Override
- public Optional getRepairRatio(final TableReference tableReference)
- {
- return myDelegateTableRepairMetrics.getRepairRatio(tableReference);
- }
-
- @Override
- public void lastRepairedAt(final TableReference tableReference, final long lastRepairedAt)
- {
- myDelegateTableRepairMetrics.lastRepairedAt(tableReference, lastRepairedAt);
- }
-
- @Override
- public void remainingRepairTime(final TableReference tableReference, final long remainingRepairTime)
- {
- myDelegateTableRepairMetrics.remainingRepairTime(tableReference, remainingRepairTime);
- }
-
- @Override
- public void repairSession(final TableReference tableReference,
- final long timeTaken,
- final TimeUnit timeUnit,
- final boolean successful)
- {
- myDelegateTableRepairMetrics.repairSession(tableReference, timeTaken, timeUnit, successful);
- }
-
- @ObjectClassDefinition
- public @interface Configuration
- {
- @AttributeDefinition(name = "Metrics directory",
- description = "The directory which the repair metrics will be stored in")
- String metricsDirectory();
-
- @AttributeDefinition(name = "Report interval in seconds",
- description = "The interval in which the metrics will be reported")
- long metricsReportIntervalInSeconds() default DEFAULT_STATISTICS_REPORT_INTERVAL_IN_SECONDS;
- }
-}
diff --git a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/TableStorageStatesService.java b/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/TableStorageStatesService.java
deleted file mode 100644
index 15aa7f020..000000000
--- a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/TableStorageStatesService.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2018 Telefonaktiebolaget LM Ericsson
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ericsson.bss.cassandra.ecchronos.core.osgi;
-
-import java.util.concurrent.TimeUnit;
-
-import com.ericsson.bss.cassandra.ecchronos.core.JmxProxyFactory;
-import com.ericsson.bss.cassandra.ecchronos.core.TableStorageStates;
-import com.ericsson.bss.cassandra.ecchronos.core.TableStorageStatesImpl;
-
-import com.ericsson.bss.cassandra.ecchronos.core.utils.ReplicatedTableProvider;
-import com.ericsson.bss.cassandra.ecchronos.core.utils.TableReference;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.osgi.service.component.annotations.ReferencePolicy;
-import org.osgi.service.metatype.annotations.AttributeDefinition;
-import org.osgi.service.metatype.annotations.Designate;
-import org.osgi.service.metatype.annotations.ObjectClassDefinition;
-
-@Component(service = TableStorageStates.class)
-@Designate(ocd = TableStorageStatesService.Configuration.class)
-public class TableStorageStatesService implements TableStorageStates
-{
- private static final short DEFAULT_UPDATE_DELAY_IN_SECONDS = 60;
-
- @Reference(service = ReplicatedTableProvider.class,
- cardinality = ReferenceCardinality.MANDATORY,
- policy = ReferencePolicy.STATIC)
- private volatile ReplicatedTableProvider myReplicatedTableProvider;
-
- @Reference (service = JmxProxyFactory.class,
- cardinality = ReferenceCardinality.MANDATORY,
- policy = ReferencePolicy.STATIC)
- private volatile JmxProxyFactory myJmxProxyFactory;
-
- private volatile TableStorageStatesImpl myDelegateTableStorageStates;
-
- @Activate
- public final synchronized void activate(final Configuration configuration)
- {
- long updateDelayInSeconds = configuration.updateStartupDelayInSeconds();
-
- myDelegateTableStorageStates = TableStorageStatesImpl.builder()
- .withReplicatedTableProvider(myReplicatedTableProvider)
- .withJmxProxyFactory(myJmxProxyFactory)
- .withUpdateDelay(updateDelayInSeconds, TimeUnit.SECONDS)
- .build();
- }
-
- @Deactivate
- public final synchronized void deactivate()
- {
- myDelegateTableStorageStates.close();
- }
-
- @Override
- public final long getDataSize(final TableReference tableReference)
- {
- return myDelegateTableStorageStates.getDataSize(tableReference);
- }
-
- @Override
- public final long getDataSize()
- {
- return myDelegateTableStorageStates.getDataSize();
- }
-
- @ObjectClassDefinition
- public @interface Configuration
- {
- @AttributeDefinition(name = "Startup delay of fetching storage state",
- description = "The interval in seconds between updates of the storage states of tables")
- long updateStartupDelayInSeconds() default DEFAULT_UPDATE_DELAY_IN_SECONDS;
- }
-}
diff --git a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/TimeBasedRunPolicyService.java b/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/TimeBasedRunPolicyService.java
deleted file mode 100644
index 1d666b2f1..000000000
--- a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/TimeBasedRunPolicyService.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2018 Telefonaktiebolaget LM Ericsson
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ericsson.bss.cassandra.ecchronos.core.osgi;
-
-import com.ericsson.bss.cassandra.ecchronos.core.TimeBasedRunPolicy;
-
-import com.ericsson.bss.cassandra.ecchronos.connection.NativeConnectionProvider;
-import com.ericsson.bss.cassandra.ecchronos.connection.StatementDecorator;
-import com.ericsson.bss.cassandra.ecchronos.core.repair.TableRepairPolicy;
-import com.ericsson.bss.cassandra.ecchronos.core.scheduling.RunPolicy;
-import com.ericsson.bss.cassandra.ecchronos.core.scheduling.ScheduledJob;
-import com.ericsson.bss.cassandra.ecchronos.core.utils.TableReference;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.component.annotations.ReferenceCardinality;
-import org.osgi.service.component.annotations.ReferencePolicy;
-import org.osgi.service.metatype.annotations.AttributeDefinition;
-import org.osgi.service.metatype.annotations.Designate;
-import org.osgi.service.metatype.annotations.ObjectClassDefinition;
-
-@Component(service = {RunPolicy.class, TableRepairPolicy.class})
-@Designate(ocd = TimeBasedRunPolicyService.Configuration.class)
-public class TimeBasedRunPolicyService implements RunPolicy, TableRepairPolicy
-{
- private static final String DEFAULT_KEYSPACE_NAME = "ecchronos";
-
- @Reference(service = NativeConnectionProvider.class,
- cardinality = ReferenceCardinality.MANDATORY,
- policy = ReferencePolicy.STATIC)
- private volatile NativeConnectionProvider myNativeConnectionProvider;
-
- @Reference (service = StatementDecorator.class,
- cardinality = ReferenceCardinality.MANDATORY,
- policy = ReferencePolicy.STATIC)
- private volatile StatementDecorator myStatementDecorator;
-
- private volatile TimeBasedRunPolicy myDelegatePolicy;
-
- @Activate
- public final synchronized void activate(final Configuration configuration)
- {
- myDelegatePolicy = TimeBasedRunPolicy.builder()
- .withSession(myNativeConnectionProvider.getSession())
- .withStatementDecorator(myStatementDecorator)
- .withKeyspaceName(configuration.keyspaceName())
- .build();
- }
-
- @Deactivate
- public final synchronized void deactivate()
- {
- myDelegatePolicy.close();
- }
-
- @Override
- public final long validate(final ScheduledJob job)
- {
- return myDelegatePolicy.validate(job);
- }
-
- @Override
- public final boolean shouldRun(final TableReference tableReference)
- {
- return myDelegatePolicy.shouldRun(tableReference);
- }
-
- @ObjectClassDefinition
- public @interface Configuration
- {
- @AttributeDefinition(name = "The time based runpolicy keyspace to use",
- description = "The name of the keyspace containing the time based runpolicy tables")
- String keyspaceName() default DEFAULT_KEYSPACE_NAME;
- }
-}
diff --git a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/commands/PrintUtils.java b/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/commands/PrintUtils.java
deleted file mode 100644
index fbf60ba62..000000000
--- a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/commands/PrintUtils.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2019 Telefonaktiebolaget LM Ericsson
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ericsson.bss.cassandra.ecchronos.core.osgi.commands;
-
-import java.time.Duration;
-import java.time.Instant;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.format.DateTimeFormatter;
-import java.time.temporal.ChronoUnit;
-
-final class PrintUtils
-{
- private static final int PERCENT_FACTOR = 100;
-
- private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-
- private PrintUtils()
- {
- }
-
- public static String epochToHumanReadable(final long timeInMillis)
- {
- return DATE_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(timeInMillis),
- ZoneId.systemDefault()));
- }
-
- public static String durationToHumanReadable(final long durationInMillis)
- {
- Duration currentDuration = Duration.of(durationInMillis, ChronoUnit.MILLIS);
-
- long days = currentDuration.toDays();
- currentDuration = currentDuration.minusDays(days);
- long hours = currentDuration.toHours();
- currentDuration = currentDuration.minusHours(hours);
- long minutes = currentDuration.toMinutes();
- currentDuration = currentDuration.minusMinutes(minutes);
- long seconds = currentDuration.getSeconds();
-
- StringBuilder sb = new StringBuilder();
-
- if (days > 0)
- {
- sb.append(days).append("d ");
- }
- if (hours > 0)
- {
- sb.append(hours).append("h ");
- }
- if (minutes > 0)
- {
- sb.append(minutes).append("m ");
- }
- if (seconds > 0)
- {
- sb.append(seconds).append("s ");
- }
-
- return sb.toString().trim();
- }
-
- public static String toPercentage(final Double ratio)
- {
- return String.format("%.0f%%", ratio * PERCENT_FACTOR);
- }
-}
diff --git a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/commands/RepairConfigCommand.java b/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/commands/RepairConfigCommand.java
deleted file mode 100644
index 96d4fa441..000000000
--- a/core.osgi/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/osgi/commands/RepairConfigCommand.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2019 Telefonaktiebolaget LM Ericsson
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ericsson.bss.cassandra.ecchronos.core.osgi.commands;
-
-import com.ericsson.bss.cassandra.ecchronos.core.repair.RepairConfiguration;
-import com.ericsson.bss.cassandra.ecchronos.core.repair.RepairScheduler;
-import com.ericsson.bss.cassandra.ecchronos.core.repair.ScheduledRepairJobView;
-import com.ericsson.bss.cassandra.ecchronos.core.utils.TableReference;
-import com.google.common.annotations.VisibleForTesting;
-import org.apache.karaf.shell.api.action.Action;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.lifecycle.Reference;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.karaf.shell.support.table.ShellTable;
-
-import java.io.PrintStream;
-import java.util.Arrays;
-import java.util.List;
-
-@Service
-@Command(scope = "repair", name = "config", description = "Give the current repair configuration")
-public class RepairConfigCommand implements Action
-{
- @Reference
- private RepairScheduler myRepairScheduler;
-
- public RepairConfigCommand()
- {
- }
-
- @VisibleForTesting
- RepairConfigCommand(final RepairScheduler repairScheduler)
- {
- myRepairScheduler = repairScheduler;
- }
-
- @Override
- public final Object execute() throws Exception
- {
- printConfig(System.out);
- return null;
- }
-
- public final void printConfig(final PrintStream out)
- {
- ShellTable table = createShellTable();
-
- myRepairScheduler.getCurrentRepairJobs()
- .stream()
- .sorted(RepairConfigCommand::sortedByName)
- .forEach(job -> table.addRow().addContent(createRowContent(job)));
-
- table.print(out);
- }
-
- private ShellTable createShellTable()
- {
- ShellTable table = new ShellTable();
- table.column("Table name");
- table.column("Interval");
- table.column("Parallelism");
- table.column("Unwind ratio");
- table.column("Warning time");
- table.column("Error time");
- return table;
- }
-
- private List