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 9, 2024
1 parent ed70c75 commit 3e239de
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 2 deletions.
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
4 changes: 4 additions & 0 deletions application/src/main/resources/ecc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ 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), that will be used
## as ecchronos_id (partition key in nodes_sync table).
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
3 changes: 2 additions & 1 deletion docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Configuration is available on ecc.yml in the below format.
connection:
cql:
agent:
instanceName: Each instance must have unique instance name. This will be used as ecchronos_id (partition key in nodes_sync table)
type: datacenterAware
contactPoints:
- host: 127.0.0.1
Expand Down Expand Up @@ -80,7 +81,7 @@ connection:
### Nodes Sync
To keep track about nodes and instances, the Agent implementation uses the table nodes_sync, that declare nodes by specific ecChronos instances, so to use the Agent is mandatory to create the table below:
To keep track about nodes and instances, the Agent implementation uses the table nodes_sync, that declare nodes by specific ecChronos instances, each instance must have unique instance name, that must be defined in connection.cql.agent.instanceName in ecc.yml. This will be used as ecchronos_id (partition key in nodes_sync table), to use the agent, is mandatory to create the table below:
```cql
CREATE TABLE ecchronos.nodes_sync
Expand Down

0 comments on commit 3e239de

Please sign in to comment.