Skip to content

Commit

Permalink
Merge branch 'agent/757' of https://github.com/paulchandler/ecchronos
Browse files Browse the repository at this point in the history
…into agent/757
  • Loading branch information
Paul Chandler committed Nov 18, 2024
2 parents 07f0fb2 + 269a5d7 commit b8c1d59
Show file tree
Hide file tree
Showing 97 changed files with 10,320 additions and 127 deletions.
22 changes: 0 additions & 22 deletions .gitignore

This file was deleted.

3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Version 1.0.0 (Not yet Released)

* Cassandra-Based Distributed Locks - Issue #741
* Create New Repair Type Called "VNODE" - Issue #755
* Create ReplicaRepairGroup Class for Grouping Replicas and Token Ranges - Issue #721
* Hot Reload of Nodes List - Issue #699
* Investigate Creation of RepairScheduler and ScheduleManager #714
* Implement ScheduledJobQueue for Prioritized Job Management and Execution - Issue #740
Expand Down
12 changes: 12 additions & 0 deletions application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.ericsson.bss.cassandra.ecchronos</groupId>
<artifactId>fault.manager</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.ericsson.bss.cassandra.ecchronos</groupId>
<artifactId>fault.manager.impl</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.ericsson.bss.cassandra.ecchronos</groupId>
<artifactId>utils</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package com.ericsson.bss.cassandra.ecchronos.application.config;

import com.ericsson.bss.cassandra.ecchronos.application.config.connection.ConnectionConfig;
import com.ericsson.bss.cassandra.ecchronos.application.config.lockfactory.LockFactoryConfig;
import com.ericsson.bss.cassandra.ecchronos.application.config.repair.GlobalRepairConfig;
import com.ericsson.bss.cassandra.ecchronos.application.config.rest.RestServerConfig;
import com.ericsson.bss.cassandra.ecchronos.application.config.runpolicy.RunPolicyConfig;
Expand All @@ -28,6 +29,7 @@ public class Config
private RunPolicyConfig myRunPolicyConfig = new RunPolicyConfig();
private SchedulerConfig mySchedulerConfig = new SchedulerConfig();
private RestServerConfig myRestServerConfig = new RestServerConfig();
private LockFactoryConfig myLockFactoryConfig = new LockFactoryConfig();

@JsonProperty("connection")
public final ConnectionConfig getConnectionConfig()
Expand Down Expand Up @@ -119,4 +121,19 @@ public final void setRestServerConfig(final RestServerConfig restServerConfig)
myRestServerConfig = restServerConfig;
}
}

@JsonProperty("lock_factory")
public final LockFactoryConfig getLockFactory()
{
return myLockFactoryConfig;
}

@JsonProperty("lock_factory")
public final void setLockFactoryConfig(final LockFactoryConfig lockFactoryConfig)
{
if (lockFactoryConfig != null)
{
myLockFactoryConfig = lockFactoryConfig;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
* Contains configurations related to outbound connections (CQL and JMX).
*/
package com.ericsson.bss.cassandra.ecchronos.application.config.connection;

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* 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.application.config.lockfactory;

import com.ericsson.bss.cassandra.ecchronos.core.impl.utils.ConsistencyType;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Locale;

public class CasLockFactoryConfig
{
private static final long DEFAULT_EXPIRY_TIME_IN_SECONDS = 30L;
private static final String DEFAULT_KEYSPACE_NAME = "ecchronos";
private String myKeyspaceName = DEFAULT_KEYSPACE_NAME;
private long myExpiryTimeInSeconds = DEFAULT_EXPIRY_TIME_IN_SECONDS;
private ConsistencyType myConsistencySerial = ConsistencyType.DEFAULT;

public final long getFailureCacheExpiryTimeInSeconds()
{
return myExpiryTimeInSeconds;
}

@JsonProperty ("cache_expiry_time_in_seconds")
public final void setFailureCacheExpiryTimeInSeconds(final long expiryTimeInSeconds)
{
myExpiryTimeInSeconds = expiryTimeInSeconds;
}

public final String getKeyspaceName()
{
return myKeyspaceName;
}

@JsonProperty ("keyspace")
public final void setKeyspaceName(final String keyspaceName)
{
myKeyspaceName = keyspaceName;
}

@JsonProperty ("consistencySerial")
public final ConsistencyType getConsistencySerial()
{
return myConsistencySerial;
}

@JsonProperty ("consistencySerial")
public final void setConsistencySerial(final String consistencySerial)
{
myConsistencySerial = ConsistencyType.valueOf(consistencySerial.toUpperCase(Locale.US));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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.application.config.lockfactory;

import com.fasterxml.jackson.annotation.JsonProperty;

public class LockFactoryConfig
{
private CasLockFactoryConfig myCasLockFactoryConfig = new CasLockFactoryConfig();

@JsonProperty("cas")
public final CasLockFactoryConfig getCasLockFactoryConfig()
{
return myCasLockFactoryConfig;
}

@JsonProperty("cas")
public final void setCasLockFactoryConfig(final CasLockFactoryConfig casLockFactoryConfig)
{
myCasLockFactoryConfig = casLockFactoryConfig;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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 configurations related to lock factory.
*/
package com.ericsson.bss.cassandra.ecchronos.application.config.lockfactory;
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.ericsson.bss.cassandra.ecchronos.connection.impl.builders.DistributedNativeBuilder;
import com.ericsson.bss.cassandra.ecchronos.connection.impl.providers.DistributedNativeConnectionProviderImpl;
import com.ericsson.bss.cassandra.ecchronos.core.impl.repair.DefaultRepairConfigurationProvider;
import com.ericsson.bss.cassandra.ecchronos.utils.enums.connection.ConnectionType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -62,13 +63,13 @@ public class AgentNativeConnectionProvider implements DistributedNativeConnectio
* the handler for managing SSL/TLS certificates.
*/
public AgentNativeConnectionProvider(
final Config config,
final Supplier<Security.CqlSecurity> cqlSecuritySupplier,
final CertificateHandler certificateHandler,
final DefaultRepairConfigurationProvider defaultRepairConfigurationProvider
)
final Config config,
final Supplier<Security.CqlSecurity> cqlSecuritySupplier,
final CertificateHandler certificateHandler,
final DefaultRepairConfigurationProvider defaultRepairConfigurationProvider)
{
AgentConnectionConfig agentConnectionConfig = config.getConnectionConfig().getCqlConnection()
AgentConnectionConfig agentConnectionConfig = config.getConnectionConfig()
.getCqlConnection()
.getAgentConnectionConfig();
Security.CqlSecurity cqlSecurity = cqlSecuritySupplier.get();
boolean authEnabled = cqlSecurity.getCqlCredentials().isEnabled();
Expand All @@ -94,7 +95,6 @@ public AgentNativeConnectionProvider(
.withSslEngineFactory(sslEngineFactory)
.withSchemaChangeListener(defaultRepairConfigurationProvider)
.withNodeStateListener(defaultRepairConfigurationProvider);

LOG.info("Preparing Agent Connection Config");
nativeConnectionBuilder = resolveAgentProviderBuilder(nativeConnectionBuilder, agentConnectionConfig);
LOG.info("Establishing Connection With Nodes");
Expand All @@ -112,25 +112,24 @@ public AgentNativeConnectionProvider(
* @return the configured {@link DistributedNativeBuilder}.
*/
public final DistributedNativeBuilder resolveAgentProviderBuilder(
final DistributedNativeBuilder builder,
final AgentConnectionConfig agentConnectionConfig
)
final DistributedNativeBuilder builder,
final AgentConnectionConfig agentConnectionConfig)
{
switch (agentConnectionConfig.getType())
{
case datacenterAware:
LOG.info("Using DatacenterAware as Agent Config");
return builder.withDatacenterAware(resolveDatacenterAware(
agentConnectionConfig.getDatacenterAware()));
case rackAware:
LOG.info("Using RackAware as Agent Config");
return builder.withRackAware(resolveRackAware(
agentConnectionConfig.getRackAware()));
case hostAware:
LOG.info("Using HostAware as Agent Config");
return builder.withHostAware(resolveHostAware(
agentConnectionConfig.getHostAware()));
default:
case datacenterAware:
LOG.info("Using DatacenterAware as Agent Config");
return builder.withDatacenterAware(resolveDatacenterAware(
agentConnectionConfig.getDatacenterAware()));
case rackAware:
LOG.info("Using RackAware as Agent Config");
return builder.withRackAware(resolveRackAware(
agentConnectionConfig.getRackAware()));
case hostAware:
LOG.info("Using HostAware as Agent Config");
return builder.withHostAware(resolveHostAware(
agentConnectionConfig.getHostAware()));
default:
}
return builder;
}
Expand All @@ -143,8 +142,7 @@ public final DistributedNativeBuilder resolveAgentProviderBuilder(
* @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, AgentConnectionConfig.Host> contactPoints)
{
List<InetSocketAddress> resolvedContactPoints = new ArrayList<>();
for (AgentConnectionConfig.Host host : contactPoints.values())
Expand All @@ -166,11 +164,7 @@ public final List<InetSocketAddress> resolveInitialContactPoints(
public final List<String> resolveDatacenterAware(final AgentConnectionConfig.DatacenterAware datacenterAware)
{
List<String> datacenterNames = new ArrayList<>();
for
(
AgentConnectionConfig.DatacenterAware.Datacenter datacenter
:
datacenterAware.getDatacenters().values())
for (AgentConnectionConfig.DatacenterAware.Datacenter datacenter : datacenterAware.getDatacenters().values())
{
datacenterNames.add(datacenter.getName());
}
Expand All @@ -187,12 +181,7 @@ public final List<String> resolveDatacenterAware(final AgentConnectionConfig.Dat
public final List<Map<String, String>> resolveRackAware(final AgentConnectionConfig.RackAware rackAware)
{
List<Map<String, String>> rackList = new ArrayList<>();
for
(
AgentConnectionConfig.RackAware.Rack rack
:
rackAware.getRacks().values()
)
for (AgentConnectionConfig.RackAware.Rack rack : rackAware.getRacks().values())
{
Map<String, String> rackInfo = new HashMap<>();
rackInfo.put("datacenterName", rack.getDatacenterName());
Expand All @@ -212,12 +201,7 @@ public final List<Map<String, String>> resolveRackAware(final AgentConnectionCon
public final List<InetSocketAddress> resolveHostAware(final AgentConnectionConfig.HostAware hostAware)
{
List<InetSocketAddress> resolvedHosts = new ArrayList<>();
for
(
AgentConnectionConfig.Host host
:
hostAware.getHosts().values()
)
for (AgentConnectionConfig.Host host : hostAware.getHosts().values())
{
InetSocketAddress tmpAddress = new InetSocketAddress(host.getHost(), host.getPort());
resolvedHosts.add(tmpAddress);
Expand All @@ -238,8 +222,8 @@ public final List<InetSocketAddress> resolveHostAware(final AgentConnectionConfi
* if the connection is in an illegal state.
*/
public final DistributedNativeConnectionProviderImpl tryEstablishConnection(
final DistributedNativeBuilder builder
) throws AllNodesFailedException, IllegalStateException
final DistributedNativeBuilder builder) throws AllNodesFailedException,
IllegalStateException
{
try
{
Expand Down Expand Up @@ -285,6 +269,7 @@ public void close() throws IOException
{
myDistributedNativeConnectionProviderImpl.close();
}

/**
* Add a nw node to the list of nodes.
* @param myNode
Expand Down Expand Up @@ -313,4 +298,18 @@ public Boolean confirmNodeValid(final Node node)
{
return myDistributedNativeConnectionProviderImpl.confirmNodeValid(node);
}

/**
* Retrieves the type of connection being used by this connection provider.
* This method delegates the call to the underlying {@code DistributedNativeConnectionProviderImpl}
* to determine the current {@link ConnectionType}.
*
* @return The {@link ConnectionType} of the connection managed by
* {@code myDistributedNativeConnectionProviderImpl}.
*/
@Override
public ConnectionType getConnectionType()
{
return myDistributedNativeConnectionProviderImpl.getConnectionType();
}
}
Loading

0 comments on commit b8c1d59

Please sign in to comment.