From 64c86172973b3f7a58fbdce2c8d47a6b676c3424 Mon Sep 17 00:00:00 2001
From: Victor Cavichioli <79488234+VictorCavichioli@users.noreply.github.com>
Date: Fri, 20 Sep 2024 10:50:24 -0300
Subject: [PATCH] Introduce utils Module to Reuse Common Code (#724)
---
CHANGES.md | 3 +-
application/pom.xml | 6 +++
.../config/ConfigurationHelper.java | 2 +-
.../connection/AgentConnectionConfig.java | 24 +-----------
.../application/exceptions/package-info.java | 18 ---------
.../AgentNativeConnectionProvider.java | 2 +-
.../application/spring/BeanConfigurator.java | 4 +-
.../spring/RetrySchedulerService.java | 2 +-
.../application/config/TestConfig.java | 13 +++----
.../application/config/TestDefaultConfig.java | 3 --
.../spring/RetrySchedulerServiceTest.java | 2 +-
connection.impl/pom.xml | 7 ++++
.../impl/builders/DistributedJmxBuilder.java | 4 +-
.../builders/DistributedNativeBuilder.java | 6 +--
...stributedNativeConnectionProviderImpl.java | 5 ++-
core.impl/pom.xml | 2 +-
.../impl/table/MockTableReferenceFactory.java | 2 +-
core/pom.xml | 7 ++++
.../core/exceptions/EcChronosException.java | 38 -------------------
.../core/table/TableReferenceFactory.java | 4 +-
data/pom.xml | 6 +++
.../ecchronos/data/sync/EccNodesSync.java | 4 +-
.../ecchronos/data/sync/TestEccNodesSync.java | 4 +-
pom.xml | 1 +
utils/pom.xml | 30 +++++++++++++++
.../enums/connection}/ConnectionType.java | 19 ++++++++--
.../utils/enums/connection}/package-info.java | 4 +-
.../ecchronos/utils}/enums/package-info.java | 4 +-
.../utils/enums/sync}/NodeStatus.java | 3 +-
.../utils/enums/sync}/package-info.java | 4 +-
.../exceptions/ConfigurationException.java | 2 +-
.../utils}/exceptions/EcChronosException.java | 2 +-
.../utils/exceptions}/package-info.java | 4 +-
33 files changed, 117 insertions(+), 124 deletions(-)
delete mode 100644 application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/exceptions/package-info.java
delete mode 100644 core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/exceptions/EcChronosException.java
create mode 100644 utils/pom.xml
rename {connection.impl/src/main/java/com/ericsson/bss/cassandra/ecchronos/connection/impl/enums => utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/enums/connection}/ConnectionType.java (58%)
rename {core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/exceptions => utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/enums/connection}/package-info.java (82%)
rename {data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data => utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils}/enums/package-info.java (84%)
rename {data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data/enums => utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/enums/sync}/NodeStatus.java (92%)
rename {data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data/exceptions => utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/enums/sync}/package-info.java (84%)
rename {application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application => utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils}/exceptions/ConfigurationException.java (94%)
rename {data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data => utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils}/exceptions/EcChronosException.java (94%)
rename {connection.impl/src/main/java/com/ericsson/bss/cassandra/ecchronos/connection/impl/enums => utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/exceptions}/package-info.java (81%)
diff --git a/CHANGES.md b/CHANGES.md
index 9d1e61ef1..26dc1f11a 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,7 +1,8 @@
# Changes
-## Version 1.0.0 (Not yet Release)
+## Version 1.0.0 (Not yet Released)
+* Create a New Maven Module "utils" for Common Code Reuse - Issue #720
* Implement ReplicationStateImpl to Manage and Cache Token Range to Replica Mappings - Issue #719
* Implement NodeResolverImpl to Resolve Nodes by IP Address and UUID - Issue #718
* Specify Interval for Next Connection - Issue #674
diff --git a/application/pom.xml b/application/pom.xml
index 1c1bad561..a461cf35d 100644
--- a/application/pom.xml
+++ b/application/pom.xml
@@ -62,6 +62,12 @@
${project.version}
+
+ com.ericsson.bss.cassandra.ecchronos
+ utils
+ ${project.version}
+
+
org.springframework.boot
diff --git a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/config/ConfigurationHelper.java b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/config/ConfigurationHelper.java
index aad9cf25c..592d11147 100644
--- a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/config/ConfigurationHelper.java
+++ b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/config/ConfigurationHelper.java
@@ -14,13 +14,13 @@
*/
package com.ericsson.bss.cassandra.ecchronos.application.config;
+import com.ericsson.bss.cassandra.ecchronos.utils.exceptions.ConfigurationException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.FileSystems;
import java.nio.file.Path;
-import com.ericsson.bss.cassandra.ecchronos.application.exceptions.ConfigurationException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
diff --git a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/config/connection/AgentConnectionConfig.java b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/config/connection/AgentConnectionConfig.java
index 07a37a542..681898a28 100644
--- a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/config/connection/AgentConnectionConfig.java
+++ b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/config/connection/AgentConnectionConfig.java
@@ -14,13 +14,14 @@
*/
package com.ericsson.bss.cassandra.ecchronos.application.config.connection;
+import com.ericsson.bss.cassandra.ecchronos.utils.enums.connection.ConnectionType;
+import com.ericsson.bss.cassandra.ecchronos.utils.exceptions.ConfigurationException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.datastax.oss.driver.internal.core.loadbalancing.DefaultLoadBalancingPolicy;
-import com.ericsson.bss.cassandra.ecchronos.application.exceptions.ConfigurationException;
import com.ericsson.bss.cassandra.ecchronos.connection.DataCenterAwarePolicy;
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -227,27 +228,6 @@ public HostAware getHostAware()
return myHostAware;
}
- /**
- * Enum representing the connection types.
- */
- public enum ConnectionType
- {
- /**
- * ecChronos will register its control over all the nodes in the specified datacenter.
- */
- datacenterAware,
-
- /**
- * ecChronos is responsible only for a subset of racks specified in the declared list.
- */
- rackAware,
-
- /**
- * ecChronos is responsible only for the specified list of hosts.
- */
- hostAware
- }
-
/**
* Configuration for datacenter-aware connections.
*/
diff --git a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/exceptions/package-info.java b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/exceptions/package-info.java
deleted file mode 100644
index 358e33b66..000000000
--- a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/exceptions/package-info.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * 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 exceptions related to outbound connections (CQL and JMX).
- */
-package com.ericsson.bss.cassandra.ecchronos.application.exceptions;
diff --git a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/providers/AgentNativeConnectionProvider.java b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/providers/AgentNativeConnectionProvider.java
index bab6a24dc..b124ff592 100644
--- a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/providers/AgentNativeConnectionProvider.java
+++ b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/providers/AgentNativeConnectionProvider.java
@@ -86,7 +86,7 @@ public AgentNativeConnectionProvider(
DistributedNativeBuilder nativeConnectionBuilder =
DistributedNativeConnectionProviderImpl.builder()
.withInitialContactPoints(resolveInitialContactPoints(agentConnectionConfig.getContactPoints()))
- .withAgentType(agentConnectionConfig.getType().toString())
+ .withAgentType(agentConnectionConfig.getType())
.withLocalDatacenter(agentConnectionConfig.getLocalDatacenter())
.withAuthProvider(authProvider)
.withSslEngineFactory(sslEngineFactory);
diff --git a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/BeanConfigurator.java b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/BeanConfigurator.java
index 2d7ebfb7c..2b7bc8a1f 100644
--- a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/BeanConfigurator.java
+++ b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/BeanConfigurator.java
@@ -24,9 +24,10 @@
import com.ericsson.bss.cassandra.ecchronos.core.impl.state.ReplicationStateImpl;
import com.ericsson.bss.cassandra.ecchronos.core.metadata.NodeResolver;
import com.ericsson.bss.cassandra.ecchronos.core.state.ReplicationState;
-import com.ericsson.bss.cassandra.ecchronos.data.exceptions.EcChronosException;
import com.ericsson.bss.cassandra.ecchronos.data.sync.EccNodesSync;
+import com.ericsson.bss.cassandra.ecchronos.utils.exceptions.ConfigurationException;
+import com.ericsson.bss.cassandra.ecchronos.utils.exceptions.EcChronosException;
import java.net.InetAddress;
import java.io.IOException;
import java.net.UnknownHostException;
@@ -38,7 +39,6 @@
import com.ericsson.bss.cassandra.ecchronos.application.config.ConfigRefresher;
import com.ericsson.bss.cassandra.ecchronos.application.config.ConfigurationHelper;
import com.ericsson.bss.cassandra.ecchronos.application.config.security.Security;
-import com.ericsson.bss.cassandra.ecchronos.application.exceptions.ConfigurationException;
import com.ericsson.bss.cassandra.ecchronos.application.providers.AgentNativeConnectionProvider;
import com.ericsson.bss.cassandra.ecchronos.connection.CertificateHandler;
import com.ericsson.bss.cassandra.ecchronos.connection.DistributedNativeConnectionProvider;
diff --git a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/RetrySchedulerService.java b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/RetrySchedulerService.java
index ce70146cb..22a43d3e0 100644
--- a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/RetrySchedulerService.java
+++ b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/RetrySchedulerService.java
@@ -20,8 +20,8 @@
import com.ericsson.bss.cassandra.ecchronos.application.config.Config;
import com.ericsson.bss.cassandra.ecchronos.connection.DistributedJmxConnectionProvider;
import com.ericsson.bss.cassandra.ecchronos.connection.DistributedNativeConnectionProvider;
-import com.ericsson.bss.cassandra.ecchronos.data.enums.NodeStatus;
import com.ericsson.bss.cassandra.ecchronos.data.sync.EccNodesSync;
+import com.ericsson.bss.cassandra.ecchronos.utils.enums.sync.NodeStatus;
import com.google.common.annotations.VisibleForTesting;
import jakarta.annotation.PostConstruct;
import java.util.ArrayList;
diff --git a/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/config/TestConfig.java b/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/config/TestConfig.java
index ce05356e1..c0d70d24e 100644
--- a/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/config/TestConfig.java
+++ b/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/config/TestConfig.java
@@ -15,12 +15,11 @@
package com.ericsson.bss.cassandra.ecchronos.application.config;
import com.ericsson.bss.cassandra.ecchronos.application.config.connection.*;
-import com.ericsson.bss.cassandra.ecchronos.application.exceptions.ConfigurationException;
import com.ericsson.bss.cassandra.ecchronos.application.providers.AgentJmxConnectionProvider;
import com.ericsson.bss.cassandra.ecchronos.application.providers.AgentNativeConnectionProvider;
import com.ericsson.bss.cassandra.ecchronos.connection.DataCenterAwarePolicy;
-import com.fasterxml.jackson.core.exc.StreamReadException;
-import com.fasterxml.jackson.databind.DatabindException;
+import com.ericsson.bss.cassandra.ecchronos.utils.enums.connection.ConnectionType;
+import com.ericsson.bss.cassandra.ecchronos.utils.exceptions.ConfigurationException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
@@ -30,7 +29,6 @@
import java.io.File;
import java.io.IOException;
-import java.util.concurrent.TimeUnit;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
@@ -47,7 +45,7 @@ public class TestConfig
private static DistributedJmxConnection distributedJmxConnection;
@Before
- public void setup() throws StreamReadException, DatabindException, IOException
+ public void setup() throws IOException
{
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
@@ -66,7 +64,7 @@ public void setup() throws StreamReadException, DatabindException, IOException
@Test
public void testDefaultAgentType()
{
- assertThat(nativeConnection.getAgentConnectionConfig().getType()).isEqualTo(AgentConnectionConfig.ConnectionType.datacenterAware);
+ assertThat(nativeConnection.getAgentConnectionConfig().getType()).isEqualTo(ConnectionType.datacenterAware);
}
@Test
@@ -237,12 +235,13 @@ public void testMaxDelayLessThanStartDelayThrowsException()
});
assertEquals("Max delay cannot be less than start delay.", exception.getMessage());
}
+
+ @Test
public void testConnectionDelay()
{
Interval connectionDelay = config.getConnectionConfig().getConnectionDelay();
assertThat(connectionDelay.getUnit()).isEqualTo(TimeUnit.MINUTES);
assertThat(connectionDelay.getTime()).isEqualTo(45l);
}
-
}
diff --git a/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/config/TestDefaultConfig.java b/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/config/TestDefaultConfig.java
index 686aba387..f3da0a5e5 100644
--- a/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/config/TestDefaultConfig.java
+++ b/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/config/TestDefaultConfig.java
@@ -27,7 +27,6 @@
import static org.assertj.core.api.Assertions.assertThat;
-
public class TestDefaultConfig
{
private static final String DEFAULT_AGENT_FILE_NAME = "nothing_set.yml";
@@ -47,8 +46,6 @@ public void setup() throws StreamReadException, DatabindException, IOException
}
-
-
@Test
public void testConnectionDelayDefault()
{
diff --git a/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/spring/RetrySchedulerServiceTest.java b/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/spring/RetrySchedulerServiceTest.java
index ffaceddef..e74640101 100644
--- a/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/spring/RetrySchedulerServiceTest.java
+++ b/application/src/test/java/com/ericsson/bss/cassandra/ecchronos/application/spring/RetrySchedulerServiceTest.java
@@ -23,8 +23,8 @@
import com.ericsson.bss.cassandra.ecchronos.application.config.connection.RetryPolicyConfig;
import com.ericsson.bss.cassandra.ecchronos.connection.DistributedJmxConnectionProvider;
import com.ericsson.bss.cassandra.ecchronos.connection.DistributedNativeConnectionProvider;
-import com.ericsson.bss.cassandra.ecchronos.data.enums.NodeStatus;
import com.ericsson.bss.cassandra.ecchronos.data.sync.EccNodesSync;
+import com.ericsson.bss.cassandra.ecchronos.utils.enums.sync.NodeStatus;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
diff --git a/connection.impl/pom.xml b/connection.impl/pom.xml
index 9dbd0ca47..44cf3df8b 100644
--- a/connection.impl/pom.xml
+++ b/connection.impl/pom.xml
@@ -40,6 +40,13 @@
data
${project.version}
+
+
+ com.ericsson.bss.cassandra.ecchronos
+ utils
+ ${project.version}
+
+
com.datastax.oss
diff --git a/connection.impl/src/main/java/com/ericsson/bss/cassandra/ecchronos/connection/impl/builders/DistributedJmxBuilder.java b/connection.impl/src/main/java/com/ericsson/bss/cassandra/ecchronos/connection/impl/builders/DistributedJmxBuilder.java
index 948d2395d..57849c890 100644
--- a/connection.impl/src/main/java/com/ericsson/bss/cassandra/ecchronos/connection/impl/builders/DistributedJmxBuilder.java
+++ b/connection.impl/src/main/java/com/ericsson/bss/cassandra/ecchronos/connection/impl/builders/DistributedJmxBuilder.java
@@ -21,9 +21,9 @@
import com.datastax.oss.driver.api.core.metadata.Node;
import com.datastax.oss.driver.api.core.servererrors.QueryExecutionException;
import com.ericsson.bss.cassandra.ecchronos.connection.impl.providers.DistributedJmxConnectionProviderImpl;
-import com.ericsson.bss.cassandra.ecchronos.data.enums.NodeStatus;
-import com.ericsson.bss.cassandra.ecchronos.data.exceptions.EcChronosException;
import com.ericsson.bss.cassandra.ecchronos.data.sync.EccNodesSync;
+import com.ericsson.bss.cassandra.ecchronos.utils.enums.sync.NodeStatus;
+import com.ericsson.bss.cassandra.ecchronos.utils.exceptions.EcChronosException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/connection.impl/src/main/java/com/ericsson/bss/cassandra/ecchronos/connection/impl/builders/DistributedNativeBuilder.java b/connection.impl/src/main/java/com/ericsson/bss/cassandra/ecchronos/connection/impl/builders/DistributedNativeBuilder.java
index 6e7cf8e32..7a9af5f8c 100644
--- a/connection.impl/src/main/java/com/ericsson/bss/cassandra/ecchronos/connection/impl/builders/DistributedNativeBuilder.java
+++ b/connection.impl/src/main/java/com/ericsson/bss/cassandra/ecchronos/connection/impl/builders/DistributedNativeBuilder.java
@@ -16,7 +16,6 @@
import com.ericsson.bss.cassandra.ecchronos.connection.CustomDriverOption;
import com.ericsson.bss.cassandra.ecchronos.connection.DataCenterAwarePolicy;
-import com.ericsson.bss.cassandra.ecchronos.connection.impl.enums.ConnectionType;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.CqlSessionBuilder;
import com.datastax.oss.driver.api.core.auth.AuthProvider;
@@ -31,6 +30,7 @@
import com.datastax.oss.driver.shaded.guava.common.annotations.VisibleForTesting;
import com.datastax.oss.driver.api.core.metrics.DefaultSessionMetric;
import com.ericsson.bss.cassandra.ecchronos.connection.impl.providers.DistributedNativeConnectionProviderImpl;
+import com.ericsson.bss.cassandra.ecchronos.utils.enums.connection.ConnectionType;
import com.google.common.collect.ImmutableList;
import java.net.InetSocketAddress;
@@ -95,9 +95,9 @@ public final DistributedNativeBuilder withInitialContactPoints(final List realNodesList = provider.testResolveRackNodes(mySessionMock, rackList);
@@ -155,7 +156,7 @@ public void testResolveHostAware()
hostList.add(new InetSocketAddress("127.0.0.3", 9042));
DistributedNativeBuilder provider = DistributedNativeConnectionProviderImpl.builder()
.withInitialContactPoints(contactPoints)
- .withAgentType("hostAware")
+ .withAgentType(ConnectionType.hostAware)
.withHostAware(hostList);
List realNodesList = provider.testResolveHostAware(mySessionMock, hostList);
assertEquals(3, realNodesList.size());
diff --git a/core.impl/pom.xml b/core.impl/pom.xml
index 675e2eb89..cc6c80ee7 100644
--- a/core.impl/pom.xml
+++ b/core.impl/pom.xml
@@ -41,12 +41,12 @@
${project.version}
+
com.datastax.oss
java-driver-core
-
com.datastax.oss
java-driver-query-builder
diff --git a/core.impl/src/test/java/com/ericsson/bss/cassandra/ecchronos/core/impl/table/MockTableReferenceFactory.java b/core.impl/src/test/java/com/ericsson/bss/cassandra/ecchronos/core/impl/table/MockTableReferenceFactory.java
index 087b17852..26448839b 100644
--- a/core.impl/src/test/java/com/ericsson/bss/cassandra/ecchronos/core/impl/table/MockTableReferenceFactory.java
+++ b/core.impl/src/test/java/com/ericsson/bss/cassandra/ecchronos/core/impl/table/MockTableReferenceFactory.java
@@ -14,9 +14,9 @@
*/
package com.ericsson.bss.cassandra.ecchronos.core.impl.table;
-import com.ericsson.bss.cassandra.ecchronos.core.exceptions.EcChronosException;
import com.ericsson.bss.cassandra.ecchronos.core.table.TableReference;
import com.ericsson.bss.cassandra.ecchronos.core.table.TableReferenceFactory;
+import com.ericsson.bss.cassandra.ecchronos.utils.exceptions.EcChronosException;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
diff --git a/core/pom.xml b/core/pom.xml
index 89900e10f..891e3d190 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -28,6 +28,13 @@
core
+
+
+ com.ericsson.bss.cassandra.ecchronos
+ utils
+ ${project.version}
+
+
com.datastax.oss
diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/exceptions/EcChronosException.java b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/exceptions/EcChronosException.java
deleted file mode 100644
index 1c468e839..000000000
--- a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/exceptions/EcChronosException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.exceptions;
-
-/**
- * Generic exception thrown by schedulers to signal that something went wrong.
- */
-public class EcChronosException extends Exception
-{
- private static final long serialVersionUID = 1148561336907867613L;
-
- public EcChronosException(final String message)
- {
- super(message);
- }
-
- public EcChronosException(final Throwable t)
- {
- super(t);
- }
-
- public EcChronosException(final String message, final Throwable t)
- {
- super(message, t);
- }
-}
diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/table/TableReferenceFactory.java b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/table/TableReferenceFactory.java
index 8c9f08750..2bc8d3c88 100644
--- a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/table/TableReferenceFactory.java
+++ b/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/table/TableReferenceFactory.java
@@ -15,7 +15,7 @@
package com.ericsson.bss.cassandra.ecchronos.core.table;
import com.datastax.oss.driver.api.core.metadata.schema.TableMetadata;
-import com.ericsson.bss.cassandra.ecchronos.core.exceptions.EcChronosException;
+import com.ericsson.bss.cassandra.ecchronos.utils.exceptions.EcChronosException;
import java.util.Set;
/**
@@ -44,7 +44,7 @@ public interface TableReferenceFactory
* Get all table references in keyspace.
*
* @param keyspace The keyspace name
- * @throws com.ericsson.bss.cassandra.ecchronos.core.exceptions.EcChronosException if keyspace does not exist.
+ * @throws EcChronosException if keyspace does not exist.
* @return A unique set of all table references for a specific keyspace.
*/
Set forKeyspace(String keyspace) throws EcChronosException;
diff --git a/data/pom.xml b/data/pom.xml
index b765ab205..135d7d9bf 100644
--- a/data/pom.xml
+++ b/data/pom.xml
@@ -35,6 +35,12 @@
${project.version}
+
+ com.ericsson.bss.cassandra.ecchronos
+ utils
+ ${project.version}
+
+
io.micrometer
micrometer-core
diff --git a/data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data/sync/EccNodesSync.java b/data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data/sync/EccNodesSync.java
index 5b8025c37..960c05e30 100644
--- a/data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data/sync/EccNodesSync.java
+++ b/data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data/sync/EccNodesSync.java
@@ -22,8 +22,8 @@
import com.datastax.oss.driver.api.core.metadata.Node;
import com.datastax.oss.driver.api.querybuilder.QueryBuilder;
import com.datastax.oss.driver.shaded.guava.common.annotations.VisibleForTesting;
-import com.ericsson.bss.cassandra.ecchronos.data.enums.NodeStatus;
-import com.ericsson.bss.cassandra.ecchronos.data.exceptions.EcChronosException;
+import com.ericsson.bss.cassandra.ecchronos.utils.enums.sync.NodeStatus;
+import com.ericsson.bss.cassandra.ecchronos.utils.exceptions.EcChronosException;
import com.google.common.base.Preconditions;
import java.net.UnknownHostException;
diff --git a/data/src/test/java/com/ericsson/bss/cassandra/ecchronos/data/sync/TestEccNodesSync.java b/data/src/test/java/com/ericsson/bss/cassandra/ecchronos/data/sync/TestEccNodesSync.java
index 3fa826689..ce0dc9d1f 100644
--- a/data/src/test/java/com/ericsson/bss/cassandra/ecchronos/data/sync/TestEccNodesSync.java
+++ b/data/src/test/java/com/ericsson/bss/cassandra/ecchronos/data/sync/TestEccNodesSync.java
@@ -18,9 +18,9 @@
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import com.datastax.oss.driver.api.core.metadata.Node;
-import com.ericsson.bss.cassandra.ecchronos.data.enums.NodeStatus;
-import com.ericsson.bss.cassandra.ecchronos.data.exceptions.EcChronosException;
import com.ericsson.bss.cassandra.ecchronos.data.utils.AbstractCassandraTest;
+import com.ericsson.bss.cassandra.ecchronos.utils.enums.sync.NodeStatus;
+import com.ericsson.bss.cassandra.ecchronos.utils.exceptions.EcChronosException;
import java.io.IOException;
import net.jcip.annotations.NotThreadSafe;
import org.junit.After;
diff --git a/pom.xml b/pom.xml
index df2ac8dcb..f70705665 100644
--- a/pom.xml
+++ b/pom.xml
@@ -76,6 +76,7 @@
data
core
core.impl
+ utils
diff --git a/utils/pom.xml b/utils/pom.xml
new file mode 100644
index 000000000..82421b3ef
--- /dev/null
+++ b/utils/pom.xml
@@ -0,0 +1,30 @@
+
+
+
+ 4.0.0
+
+ com.ericsson.bss.cassandra.ecchronos
+ agent
+ 1.0.0-SNAPSHOT
+
+
+ utils
+
+
\ No newline at end of file
diff --git a/connection.impl/src/main/java/com/ericsson/bss/cassandra/ecchronos/connection/impl/enums/ConnectionType.java b/utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/enums/connection/ConnectionType.java
similarity index 58%
rename from connection.impl/src/main/java/com/ericsson/bss/cassandra/ecchronos/connection/impl/enums/ConnectionType.java
rename to utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/enums/connection/ConnectionType.java
index f09c1216a..868466631 100644
--- a/connection.impl/src/main/java/com/ericsson/bss/cassandra/ecchronos/connection/impl/enums/ConnectionType.java
+++ b/utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/enums/connection/ConnectionType.java
@@ -12,12 +12,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.ericsson.bss.cassandra.ecchronos.connection.impl.enums;
+package com.ericsson.bss.cassandra.ecchronos.utils.enums.connection;
/**
- * The type of agent strategy to use for repair management.
+ * Enum representing the connection types.
*/
public enum ConnectionType
{
- datacenterAware, rackAware, hostAware
+ /**
+ * ecChronos will register its control over all the nodes in the specified datacenter.
+ */
+ datacenterAware,
+
+ /**
+ * ecChronos is responsible only for a subset of racks specified in the declared list.
+ */
+ rackAware,
+
+ /**
+ * ecChronos is responsible only for the specified list of hosts.
+ */
+ hostAware
}
diff --git a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/exceptions/package-info.java b/utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/enums/connection/package-info.java
similarity index 82%
rename from core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/exceptions/package-info.java
rename to utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/enums/connection/package-info.java
index 423bced6e..60f98395f 100644
--- a/core/src/main/java/com/ericsson/bss/cassandra/ecchronos/core/exceptions/package-info.java
+++ b/utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/enums/connection/package-info.java
@@ -13,6 +13,6 @@
* limitations under the License.
*/
/**
- * Contains custom ecChronos exceptions.
+ * Contains the enums related with ecChronos connections.
*/
-package com.ericsson.bss.cassandra.ecchronos.core.exceptions;
+package com.ericsson.bss.cassandra.ecchronos.utils.enums.connection;
diff --git a/data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data/enums/package-info.java b/utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/enums/package-info.java
similarity index 84%
rename from data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data/enums/package-info.java
rename to utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/enums/package-info.java
index e643c759a..8a4bc674b 100644
--- a/data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data/enums/package-info.java
+++ b/utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/enums/package-info.java
@@ -13,6 +13,6 @@
* limitations under the License.
*/
/**
- * Contains enums definitions for data configs.
+ * Contains the enums related with ecChronos operations.
*/
-package com.ericsson.bss.cassandra.ecchronos.data.enums;
+package com.ericsson.bss.cassandra.ecchronos.utils.enums;
diff --git a/data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data/enums/NodeStatus.java b/utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/enums/sync/NodeStatus.java
similarity index 92%
rename from data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data/enums/NodeStatus.java
rename to utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/enums/sync/NodeStatus.java
index 845b35e1e..9a636fc68 100644
--- a/data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data/enums/NodeStatus.java
+++ b/utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/enums/sync/NodeStatus.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.ericsson.bss.cassandra.ecchronos.data.enums;
+package com.ericsson.bss.cassandra.ecchronos.utils.enums.sync;
/**
* The status of nodes after creating jmx connection.
@@ -23,3 +23,4 @@ public enum NodeStatus
AVAILABLE,
UNREACHABLE
}
+
diff --git a/data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data/exceptions/package-info.java b/utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/enums/sync/package-info.java
similarity index 84%
rename from data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data/exceptions/package-info.java
rename to utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/enums/sync/package-info.java
index 6a241f019..c95689987 100644
--- a/data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data/exceptions/package-info.java
+++ b/utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/enums/sync/package-info.java
@@ -13,6 +13,6 @@
* limitations under the License.
*/
/**
- * Contains exceptions related to I/O in data tables.
+ * Contains the enums related with nodes_sync table.
*/
-package com.ericsson.bss.cassandra.ecchronos.data.exceptions;
+package com.ericsson.bss.cassandra.ecchronos.utils.enums.sync;
diff --git a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/exceptions/ConfigurationException.java b/utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/exceptions/ConfigurationException.java
similarity index 94%
rename from application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/exceptions/ConfigurationException.java
rename to utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/exceptions/ConfigurationException.java
index 5c41c3234..b25adf401 100644
--- a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/exceptions/ConfigurationException.java
+++ b/utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/exceptions/ConfigurationException.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.ericsson.bss.cassandra.ecchronos.application.exceptions;
+package com.ericsson.bss.cassandra.ecchronos.utils.exceptions;
public class ConfigurationException extends Exception
{
diff --git a/data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data/exceptions/EcChronosException.java b/utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/exceptions/EcChronosException.java
similarity index 94%
rename from data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data/exceptions/EcChronosException.java
rename to utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/exceptions/EcChronosException.java
index ee5e65983..83795abda 100644
--- a/data/src/main/java/com/ericsson/bss/cassandra/ecchronos/data/exceptions/EcChronosException.java
+++ b/utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/exceptions/EcChronosException.java
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.ericsson.bss.cassandra.ecchronos.data.exceptions;
+package com.ericsson.bss.cassandra.ecchronos.utils.exceptions;
/**
* Generic exception thrown by schedulers to signal that something went wrong.
diff --git a/connection.impl/src/main/java/com/ericsson/bss/cassandra/ecchronos/connection/impl/enums/package-info.java b/utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/exceptions/package-info.java
similarity index 81%
rename from connection.impl/src/main/java/com/ericsson/bss/cassandra/ecchronos/connection/impl/enums/package-info.java
rename to utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/exceptions/package-info.java
index 123d0854b..42979b279 100644
--- a/connection.impl/src/main/java/com/ericsson/bss/cassandra/ecchronos/connection/impl/enums/package-info.java
+++ b/utils/src/main/java/com/ericsson/bss/cassandra/ecchronos/utils/exceptions/package-info.java
@@ -13,6 +13,6 @@
* limitations under the License.
*/
/**
- * Contains enums definitions for connections configs (CQL and JMX).
+ * Contains exceptions related to outbound with ecChronos operations.
*/
-package com.ericsson.bss.cassandra.ecchronos.connection.impl.enums;
+package com.ericsson.bss.cassandra.ecchronos.utils.exceptions;