+ * This will not terminate repairs on other nodes but will affect other nodes running repair. + */ + void forceTerminateAllRepairSessions(); + + /** + * Force the termination of all repair session on the specified node. + *
+ * @param nodeID + * The nodeID to get the JMXConnector + * This will not terminate repairs on other nodes but will affect other nodes running repair. + */ + void forceTerminateAllRepairSessionsInSpecificNode(UUID nodeID); + /** + * Remove a listener from the storage service interface. + * @param nodeID + * The nodeID to get the JMXConnector + * @param listener + * The listener to remove. + * + * @see #addStorageServiceListener(UUID, NotificationListener) + */ + void removeStorageServiceListener(UUID nodeID, NotificationListener listener); + + /** + * Get the live disk space used for the provided table. + * @param nodeID + * The nodeID to get the JMXConnector + * @param tableReference + * The table to get the live disk space for. + * @return The live disk space used by the provided table. + */ + long liveDiskSpaceUsed(UUID nodeID, TableReference tableReference); + + /** + * Get max repaired at for the provided table. + * Only usable when running incremental repairs. + * + * @param nodeID + * The nodeID to get the JMXConnector + * @param tableReference The table to get max repaired at for. + * @return Max repaired at or 0 if it cannot be determined. + */ + long getMaxRepairedAt(UUID nodeID, TableReference tableReference); + + /** + * Gets repaired ratio for a specific table. + * Only usable when running incremental repairs. + * + * @param nodeID + * The nodeID to get the JMXConnector + * @param tableReference The table to get repaired ratio for. + * @return The repaired ratio or 0 if it cannot be determined. + */ + double getPercentRepaired(UUID nodeID, TableReference tableReference); + + /** + * Retrieves the current operational status of the local Cassandra node via JMX. + * Returns a string indicating the node's state (e.g., "NORMAL", "JOINING", "LEAVING", "MOVING") + * or "Unknown" if the status is undeterminable. + * + * @param nodeID + * The nodeID to get the JMXConnector + * @return A string representing the node's status. + */ + String getNodeStatus(UUID nodeID); + + /** + * validate if the given JMXConnector is available. + * + * @param jmxConnector + * The jmxConnector to validate + * @return A boolean representing the node's connection status. + */ + boolean validateJmxConnection(JMXConnector jmxConnector); +} diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/jmx/DistributedJmxProxyFactory.java b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/jmx/DistributedJmxProxyFactory.java new file mode 100644 index 000000000..6e682787d --- /dev/null +++ b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/jmx/DistributedJmxProxyFactory.java @@ -0,0 +1,31 @@ +/* + * Copyright 2024 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.jmx; + +import java.io.IOException; + +public interface DistributedJmxProxyFactory +{ + /** + * Connect to the local Cassandra node and get a proxy instance. + *
+ * The returned {@link DistributedJmxProxy} must be closed by the caller. + * + * @return The connected {@link DistributedJmxProxy}. + * @throws IOException Thrown when unable to connect. + */ + DistributedJmxProxy connect() throws IOException; +} + diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/jmx/package-info.java b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/jmx/package-info.java new file mode 100644 index 000000000..a4b451edf --- /dev/null +++ b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/jmx/package-info.java @@ -0,0 +1,18 @@ +/* + * Copyright 2024 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. + */ +/** + * Contains the Interfaces and resources for jmx operations. + */ +package com.ericsson.bss.cassandra.ecchronos.core.jmx; diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/config/RepairOptions.java b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/config/RepairOptions.java new file mode 100644 index 000000000..cab2fd6e1 --- /dev/null +++ b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/config/RepairOptions.java @@ -0,0 +1,73 @@ +/* + * Copyright 2024 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.repair.config; + +/** + * The repair options available for the repair. + */ +@SuppressWarnings({"PMD.DataClass", "checkstyle:hideutilityclassconstructor"}) +public class RepairOptions +{ + /** + * Default constructor. + */ + public RepairOptions() + { + } + + /** + * The {@link com.ericsson.bss.cassandra.ecchronos.utils.enums.repair.RepairParallelism repair parallelism} to use for the repair. + *
+ * Possible values are defined in {@link com.ericsson.bss.cassandra.ecchronos.utils.enums.repair.RepairParallelism} + */ + public static final String PARALLELISM_KEY = "parallelism"; + + /** + * If the repair should be on the primary range of the node. + *
+ * Possible values: true | false + */ + public static final String PRIMARY_RANGE_KEY = "primaryRange"; + + /** + * If the repair should be incremental. + *
+ * Possible values: true | false + */ + public static final String INCREMENTAL_KEY = "incremental"; + + /** + * If the repair should be on a certain list of ranges. + *
+ * If this option is used the repair will not be incremental. + *
+ * The values should be of the format: [startToken1]:[endToken1],[startToken2]:[endToken2] + */ + public static final String RANGES_KEY = "ranges"; + + /** + * The tables that should be repaired. + */ + public static final String COLUMNFAMILIES_KEY = "columnFamilies"; + + /** + * The hosts that should be repaired. + *
+ * If this option is used the repair will not be incremental. + *
+ * The values should be of the format: [ip1],[ip2]
+ */
+ public static final String HOSTS_KEY = "hosts";
+}
diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/config/package-info.java b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/config/package-info.java
new file mode 100644
index 000000000..ebb772b6c
--- /dev/null
+++ b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/config/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2024 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.
+ */
+/**
+ * Contains the configs for repair operations.
+ */
+package com.ericsson.bss.cassandra.ecchronos.core.repair.config;
diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/package-info.java b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/package-info.java
new file mode 100644
index 000000000..043ff631e
--- /dev/null
+++ b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/repair/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2024 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.
+ */
+/**
+ * Contains the implementations and resources for repair operations.
+ */
+package com.ericsson.bss.cassandra.ecchronos.core.repair;
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md
index 58d55d713..055ce6cfe 100644
--- a/docs/ARCHITECTURE.md
+++ b/docs/ARCHITECTURE.md
@@ -42,8 +42,7 @@ ecChronos is built to be continuously repairing data in the background. Each ecC
Once ecChronos establishes its initial connection with the `contactPoints`, it must register its control over the nodes based on the `type` property, whether JMX or CQL, to make it clear that a single instance will be responsible for managing multiple nodes. Then it would be possible to keep track of what was the last time that the ecChronos instances was able to connect with a node, also for others ecChronos instances keep track about each other's health.
-If type is `datacenterAware`, ecChronos will register its control over all the nodes in the specified datacenter; The `rackAware` declares ecChronos is responsible just for a sub-set of racks in the declared list; The `hostAware` funcionality declares ecChronos is resposible just for the specified hosts list. When connection.cql.agent.enabled is true, it must use the AgentNativeConnectionProvider class as default provider.
-
+If type is `datacenterAware`, ecChronos will register its control over all the nodes in the specified datacenter; The `rackAware` declares ecChronos is responsible just for a sub-set of racks in the declared list; The `hostAware` functionality declares ecChronos is responsible just for the specified hosts list.
Configuration is available on ecc.yml in the below format.
```yaml
diff --git a/pmd-rules.xml b/pmd-rules.xml
index 6485e7866..62530e641 100644
--- a/pmd-rules.xml
+++ b/pmd-rules.xml
@@ -42,6 +42,7 @@