Skip to content

Commit

Permalink
Generate Unique EcChronos ID Ericsson#678
Browse files Browse the repository at this point in the history
- eccrhonos instance name will be
 used as  eccrhonos_Id and configure
in ecc.yml file.
- each eccrhonos instance must have
unique name.
  • Loading branch information
sajid riaz committed Oct 8, 2024
1 parent ed70c75 commit 0d60022
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Version 1.0.0 (Not yet Released)

* Generate Unique EcChronos ID #678
* Create RepairConfiguration class for repair configurations - Issue #716
* Create DistributedJmxProxy and DistributedJmxProxyFactory - Issue #715
* Create a New Maven Module "utils" for Common Code Reuse - Issue #720
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public final class AgentConnectionConfig
private RackAware myRackAware = new RackAware();
private HostAware myHostAware = new HostAware();
private Class<? extends DefaultLoadBalancingPolicy> myDatacenterAwarePolicy = DataCenterAwarePolicy.class;
private String myInstanceName;

/**
* Default constructor for AgentConnectionConfig.
Expand All @@ -46,6 +47,40 @@ public AgentConnectionConfig()

}

/**
* Gets unique ecchronos instance name.
*
* @return the instance name.
*/
@JsonProperty("instanceName")
public String getInstanceName()
{
return myInstanceName;
}

/**
* Sets unique instance name.
*
* @param instanceName
* the instance name as a string.
* @throws ConfigurationException
* if the provided instance name is invalid.
*/
@JsonProperty("instanceName")
public void setInstanceName(final String instanceName) throws ConfigurationException
{
if (instanceName == null || instanceName.isBlank())
{
throw new ConfigurationException(
"Invalid instance name: "
+
instanceName
+
"\nInstance name must not be null or empty");
}
myInstanceName = instanceName;
}

/**
* Gets the connection type.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public BeanConfigurator() throws ConfigurationException, UnknownHostException
Security security = getSecurityConfig();
cqlSecurity.set(security.getCqlSecurity());
jmxSecurity.set(security.getJmxSecurity());
ecChronosID = ECCHORONS_ID_PRE_STRING.concat(InetAddress.getLocalHost().getHostName());
ecChronosID = getConfiguration().getConnectionConfig().getCqlConnection().getAgentConnectionConfig().getInstanceName();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions application/src/main/resources/ecc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ connection:
## to connect to. The application will use the configurations
## specified below, connecting to the listed hosts;
agent:
## Each ecchronos instance must have unique name
instanceName: unique_identifier
## Define the Agent strategy, it can be
## - datacenterAware;
## - rackAware; and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,5 +313,11 @@ public void testRepairType()
RepairType repairType = repairConfig.getRepairType();
assertThat(repairType).isEqualTo(RepairType.VNODE);
}

@Test
public void testInstanceName()
{
assertThat(nativeConnection.getAgentConnectionConfig().getInstanceName()).isEqualTo("unique_identifier");
}
}

1 change: 1 addition & 0 deletions application/src/test/resources/all_set.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
connection:
cql:
agent:
instanceName: unique_identifier
type: datacenterAware
localDatacenter: datacenter1
datacenterAwarePolicy: com.ericsson.bss.cassandra.ecchronos.connection.DataCenterAwarePolicy
Expand Down

0 comments on commit 0d60022

Please sign in to comment.