Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.datastax.oss.driver.api.core.metadata.Node;
import com.datastax.oss.driver.api.core.ssl.SslEngineFactory;
import com.ericsson.bss.cassandra.ecchronos.application.config.Config;
import com.ericsson.bss.cassandra.ecchronos.application.config.connection.AgentConnectionConfig;
import com.ericsson.bss.cassandra.ecchronos.application.config.connection.CQLRetryPolicyConfig;
import com.ericsson.bss.cassandra.ecchronos.application.config.connection.DistributedNativeConnection;
import com.ericsson.bss.cassandra.ecchronos.application.config.security.ReloadingAuthProvider;
Expand Down Expand Up @@ -70,9 +69,6 @@ public AgentNativeConnectionProvider(
final CertificateHandler certificateHandler,
final DefaultRepairConfigurationProvider defaultRepairConfigurationProvider)
{
AgentConnectionConfig agentConnectionConfig = config.getConnectionConfig()
.getCqlConnection()
.getAgentConnectionConfig();
DistributedNativeConnection distributedNativeConfig = config.getConnectionConfig()
.getCqlConnection();

Expand All @@ -94,15 +90,15 @@ public AgentNativeConnectionProvider(

DistributedNativeBuilder nativeConnectionBuilder =
DistributedNativeConnectionProviderImpl.builder()
.withInitialContactPoints(myConnectionHelper.resolveInitialContactPoints(agentConnectionConfig.getContactPoints()))
.withAgentType(agentConnectionConfig.getType())
.withLocalDatacenter(agentConnectionConfig.getLocalDatacenter())
.withInitialContactPoints(myConnectionHelper.resolveInitialContactPoints(distributedNativeConfig.getContactPoints()))
.withAgentType(distributedNativeConfig.getType())
.withLocalDatacenter(distributedNativeConfig.getLocalDatacenter())
.withAuthProvider(authProvider)
.withSslEngineFactory(sslEngineFactory)
.withSchemaChangeListener(defaultRepairConfigurationProvider)
.withNodeStateListener(defaultRepairConfigurationProvider);
LOG.info("Preparing Agent Connection Config");
nativeConnectionBuilder = resolveAgentProviderBuilder(nativeConnectionBuilder, agentConnectionConfig);
nativeConnectionBuilder = resolveAgentProviderBuilder(nativeConnectionBuilder, distributedNativeConfig);
LOG.info("Establishing Connection With Nodes");
myDistributedNativeConnectionProviderImpl = establishConnection(nativeConnectionBuilder, retryPolicyConfig);
}
Expand All @@ -113,33 +109,33 @@ public AgentNativeConnectionProvider(
*
* @param builder
* the {@link DistributedNativeBuilder} instance to configure.
* @param agentConnectionConfig
* @param distributedNativeConfig
* the connection configuration object.
* @return the configured {@link DistributedNativeBuilder}.
*/
public final DistributedNativeBuilder resolveAgentProviderBuilder(
final DistributedNativeBuilder builder,
final AgentConnectionConfig agentConnectionConfig)
final DistributedNativeConnection distributedNativeConfig)
{
return switch (agentConnectionConfig.getType())
return switch (distributedNativeConfig.getType())
{
case datacenterAware ->
{
LOG.info("Using DatacenterAware as Agent Config");
yield builder.withDatacenterAware(myConnectionHelper.resolveDatacenterAware(
agentConnectionConfig.getDatacenterAware()));
distributedNativeConfig.getDatacenterAware()));
}
case rackAware ->
{
LOG.info("Using RackAware as Agent Config");
yield builder.withRackAware(myConnectionHelper.resolveRackAware(
agentConnectionConfig.getRackAware()));
distributedNativeConfig.getRackAware()));
}
case hostAware ->
{
LOG.info("Using HostAware as Agent Config");
yield builder.withHostAware(myConnectionHelper.resolveHostAware(
agentConnectionConfig.getHostAware()));
distributedNativeConfig.getHostAware()));
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.List;
import java.util.Map;

import com.ericsson.bss.cassandra.ecchronos.application.config.connection.AgentConnectionConfig;
import com.ericsson.bss.cassandra.ecchronos.application.config.connection.DistributedNativeConnection;

public class MountConnectionHelper
{
Expand All @@ -32,10 +32,10 @@ public class MountConnectionHelper
* @return a list of {@link InetSocketAddress} representing the resolved contact points.
*/
public final List<InetSocketAddress> resolveInitialContactPoints(
final Map<String, AgentConnectionConfig.Host> contactPoints)
final Map<String, DistributedNativeConnection.Host> contactPoints)
{
List<InetSocketAddress> resolvedContactPoints = new ArrayList<>();
for (AgentConnectionConfig.Host host : contactPoints.values())
for (DistributedNativeConnection.Host host : contactPoints.values())
{
InetSocketAddress tmpAddress = InetSocketAddress.createUnresolved(host.getHost(), host.getPort());
resolvedContactPoints.add(tmpAddress);
Expand All @@ -44,34 +44,34 @@ public final List<InetSocketAddress> resolveInitialContactPoints(
}

/**
* Resolves the datacenter-aware configuration from the specified {@link AgentConnectionConfig.DatacenterAware}
* Resolves the datacenter-aware configuration from the specified {@link DistributedNativeConnection.DatacenterAware}
* object.
*
* @param datacenterAware
* the datacenter-aware configuration object.
* @return a list of datacenter names.
*/
public final List<String> resolveDatacenterAware(final AgentConnectionConfig.DatacenterAware datacenterAware)
public final List<String> resolveDatacenterAware(final DistributedNativeConnection.DatacenterAware datacenterAware)
{
List<String> datacenterNames = new ArrayList<>();
for (AgentConnectionConfig.DatacenterAware.Datacenter datacenter : datacenterAware.getDatacenters().values())
for (DistributedNativeConnection.DatacenterAware.Datacenter datacenter : datacenterAware.getDatacenters().values())
{
datacenterNames.add(datacenter.getName());
}
return datacenterNames;
}

/**
* Resolves the rack-aware configuration from the specified {@link AgentConnectionConfig.RackAware} object.
* Resolves the rack-aware configuration from the specified {@link DistributedNativeConnection.RackAware} object.
*
* @param rackAware
* the rack-aware configuration object.
* @return a list of maps containing datacenter and rack information.
*/
public final List<Map<String, String>> resolveRackAware(final AgentConnectionConfig.RackAware rackAware)
public final List<Map<String, String>> resolveRackAware(final DistributedNativeConnection.RackAware rackAware)
{
List<Map<String, String>> rackList = new ArrayList<>();
for (AgentConnectionConfig.RackAware.Rack rack : rackAware.getRacks().values())
for (DistributedNativeConnection.RackAware.Rack rack : rackAware.getRacks().values())
{
Map<String, String> rackInfo = new HashMap<>();
rackInfo.put("datacenterName", rack.getDatacenterName());
Expand All @@ -82,16 +82,16 @@ public final List<Map<String, String>> resolveRackAware(final AgentConnectionCon
}

/**
* Resolves the host-aware configuration from the specified {@link AgentConnectionConfig.HostAware} object.
* Resolves the host-aware configuration from the specified {@link DistributedNativeConnection.HostAware} object.
*
* @param hostAware
* the host-aware configuration object.
* @return a list of {@link InetSocketAddress} representing the resolved hosts.
*/
public final List<InetSocketAddress> resolveHostAware(final AgentConnectionConfig.HostAware hostAware)
public final List<InetSocketAddress> resolveHostAware(final DistributedNativeConnection.HostAware hostAware)
{
List<InetSocketAddress> resolvedHosts = new ArrayList<>();
for (AgentConnectionConfig.Host host : hostAware.getHosts().values())
for (DistributedNativeConnection.Host host : hostAware.getHosts().values())
{
InetSocketAddress tmpAddress = new InetSocketAddress(host.getHost(), host.getPort());
resolvedHosts.add(tmpAddress);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public BeanConfigurator() throws ConfigurationException, UnknownHostException
Security security = getSecurityConfig();
cqlSecurity.set(security.getCqlSecurity());
jmxSecurity.set(security.getJmxSecurity());
ecChronosID = getConfiguration().getConnectionConfig().getCqlConnection().getAgentConnectionConfig().getInstanceName();
ecChronosID = getConfiguration().getConnectionConfig().getCqlConnection().getInstanceName();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public ECChronosInternals(
.withKeyspaceName(casLockFactoryConfig.getKeyspaceName())
.withCacheExpiryInSeconds(casLockFactoryConfig.getFailureCacheExpiryTimeInSeconds())
.withConsistencySerial(casLockFactoryConfig.getConsistencySerial())
.withLocalDatacenter(configuration.getConnectionConfig().getCqlConnection().getAgentConnectionConfig().getLocalDatacenter())
.withLocalDatacenter(configuration.getConnectionConfig().getCqlConnection().getLocalDatacenter())
.build();

myScheduleManagerImpl = ScheduleManagerImpl.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import com.ericsson.bss.cassandra.ecchronos.application.config.connection.DistributedNativeConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.stereotype.Service;

import com.datastax.oss.driver.api.core.metadata.Node;
import com.ericsson.bss.cassandra.ecchronos.application.config.Config;
import com.ericsson.bss.cassandra.ecchronos.application.config.connection.AgentConnectionConfig;
import com.ericsson.bss.cassandra.ecchronos.application.config.connection.RetryPolicyConfig;
import com.ericsson.bss.cassandra.ecchronos.application.providers.MountConnectionHelper;
import com.ericsson.bss.cassandra.ecchronos.connection.DistributedNativeConnectionProvider;
Expand Down Expand Up @@ -56,23 +56,21 @@ public ReloadSchedulerService(
this.myDefaultRepairConfigurationProvider = defaultRepairConfigurationProvider;
this.myConfig = config;
this.myDistributedNativeConnectionProvider = distributedNativeConnectionProvider;
this.myScheduleConfig = config.getConnectionConfig().getCqlConnection().getAgentConnectionConfig().getReloadSchedule();
this.myScheduleConfig = config.getConnectionConfig().getCqlConnection().getReloadSchedule();
}

private void reloadNodesMap()
{
try
{
LOG.info("Attempting to verify nodes map disagreements.");
AgentConnectionConfig agentConnectionConfig = myConfig.getConnectionConfig()
.getCqlConnection()
.getAgentConnectionConfig();
DistributedNativeConnection nativeConnectionConfig = myConfig.getConnectionConfig().getCqlConnection();

DistributedNativeBuilder nativeBuilder = new DistributedNativeBuilder()
.withAgentType(agentConnectionConfig.getType());
.withAgentType(nativeConnectionConfig.getType());

// Use helper method to resolve agent provider configuration
nativeBuilder = resolveAgentProviderBuilder(nativeBuilder, agentConnectionConfig);
nativeBuilder = resolveAgentProviderBuilder(nativeBuilder, nativeConnectionConfig);

Map<UUID, Node> nodes = nativeBuilder.createNodesMap(myDistributedNativeConnectionProvider.getCqlSession());
compareNodesMap(nodes);
Expand All @@ -86,27 +84,27 @@ private void reloadNodesMap()
@SuppressWarnings("CPD-START")
public final DistributedNativeBuilder resolveAgentProviderBuilder(
final DistributedNativeBuilder builder,
final AgentConnectionConfig agentConnectionConfig)
final DistributedNativeConnection nativeConnectionConfig)
{
return switch (agentConnectionConfig.getType())
return switch (nativeConnectionConfig.getType())
{
case datacenterAware ->
{
LOG.info("Using DatacenterAware as Agent Config");
yield builder.withDatacenterAware(myConnectionHelper.resolveDatacenterAware(
agentConnectionConfig.getDatacenterAware()));
nativeConnectionConfig.getDatacenterAware()));
}
case rackAware ->
{
LOG.info("Using RackAware as Agent Config");
yield builder.withRackAware(myConnectionHelper.resolveRackAware(
agentConnectionConfig.getRackAware()));
nativeConnectionConfig.getRackAware()));
}
case hostAware ->
{
LOG.info("Using HostAware as Agent Config");
yield builder.withHostAware(myConnectionHelper.resolveHostAware(
agentConnectionConfig.getHostAware()));
nativeConnectionConfig.getHostAware()));
}
};
}
Expand Down
Loading
Loading