Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CASSSIDECAR-179: Added additional dirs required for live migration #163

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

nvharikrishna
Copy link
Contributor

Making this change as part of CEP-40.

Adding commitlog, hints, saved caches and local system data file directories to InstanceMetadata so that they migrated as part of CEP-40.

For CASSSIDECAR-179

Copy link

@bbotella bbotella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of nits. Otherwise, LGTM.

Thanks for the patch!
+1 (nb)

@@ -92,9 +112,13 @@ public InstanceConfigurationImpl(int id,
this.id = id;
this.host = host;
this.port = port;
this.dataDirs = Collections.unmodifiableList(dataDirs);
this.dataDirs = dataDirs == null ? null : Collections.unmodifiableList(dataDirs);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like an unrelated bug fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not trying to fix anything actually :). Trying to initialize the member variables in a single constructor. Earlier constructor initialized dataDirs with null, but this constructor is wrapping dataDirs with Collections.unmodifiableList which doesn't accept null. So checking for null before wrapping it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when would data dirs be null (or empty)? Maybe this needs to be validated instead of accepting null

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when would data dirs be null (or empty)? Maybe this needs to be validated instead of accepting null

It is set to null if the data_dirs is not configured in sidecar.yaml. I was not sure why it was allowed to be null earlier. So did not change the behavior. I can make changes now though.

@@ -39,6 +39,10 @@ class InstanceMetadataImplTest
private static final String DATA_DIR_2 = "test/data/data2";
private static final String CDC_DIR = "cdc_dir";
private static final String STAGING_DIR = "staging_dir";
private static final String COMMITLOG_DIR = "commitlog";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Should we append _dir to keep consistency? (both cdc and staging append it)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have used the names used in cassandra.yaml for newly introduced directories. Wanted to use default names used in Cassandra, but I don't mind changing the names if required.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not, this is the default directory name for the commit log in Cassandra, so it would be incorrect to add _dir. See https://github.com/apache/cassandra/blob/trunk/conf/cassandra.yaml#L411

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it would be incorrect to add _dir.

Wondering why CDC_DIR has "_dir" postfix. As per cassandra.yaml, cdc_raw_directory is cdc_raw.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe because it's test code, but it feels we should align with Cassandra directories

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up with setting these values to non default values in order to test that InstanceMetaImpl is not using default values when these directories are set explicitly. Using "_dir" like in previous constants.

(I wrote this test class a few days back with the same intention, could not recollect it earlier, my apologies!)

Copy link
Contributor Author

@nvharikrishna nvharikrishna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bbotella Thanks for the review. Addressed the comments.

@@ -92,9 +112,13 @@ public InstanceConfigurationImpl(int id,
this.id = id;
this.host = host;
this.port = port;
this.dataDirs = Collections.unmodifiableList(dataDirs);
this.dataDirs = dataDirs == null ? null : Collections.unmodifiableList(dataDirs);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not trying to fix anything actually :). Trying to initialize the member variables in a single constructor. Earlier constructor initialized dataDirs with null, but this constructor is wrapping dataDirs with Collections.unmodifiableList which doesn't accept null. So checking for null before wrapping it.

@@ -39,6 +39,10 @@ class InstanceMetadataImplTest
private static final String DATA_DIR_2 = "test/data/data2";
private static final String CDC_DIR = "cdc_dir";
private static final String STAGING_DIR = "staging_dir";
private static final String COMMITLOG_DIR = "commitlog";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have used the names used in cassandra.yaml for newly introduced directories. Wanted to use default names used in Cassandra, but I don't mind changing the names if required.

null,
null,
null,
null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For commit log, hints and saved caches, can we build it if it is not set. Like we do in Cassandra, by taking in CASSANDRA_HOME

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that we should simplify Sidecar configuration, where we follow Cassandra's configuration. Ideally, we will only have to configure the cassandra_home configuration per instance. And then we resolve the directory files in Cassandra unless explicitly provided.

Copy link
Contributor

@frankgh frankgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some suggestions to simplify configuration and make operability simpler

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a general comment. We should update the sidecar.yaml configuration file under conf/sidecar.yaml with configuration parameters. Ideally I think we want to only have to specify the cassandra_home_dir , and optionally specify Cassandra directories. The exception are data directories

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally I think we want to only have to specify the cassandra_home_dir , and optionally specify Cassandra directories. The exception are data directories

As per the documentation comment in cassandra.yaml, the default data directory is$CASSANDRA_HOME/data/data. Is there any reason to take exception for data directories?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followed the footsteps of existing code. I would be happy to adopt cassandra_home_dir as part of this pr.

Patch by Venkata Harikrishna Nukala; reviewed by <TBD> for CASSANDRASC-179
@nvharikrishna nvharikrishna force-pushed the 179-instace-config-additional-dirs branch 2 times, most recently from 172239a to cc203a3 Compare December 23, 2024 16:21
@nvharikrishna nvharikrishna force-pushed the 179-instace-config-additional-dirs branch from cc203a3 to b698822 Compare December 23, 2024 16:32
protected final String jmxRolePassword;

public InstanceConfigurationImpl()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this in order to reduce the confusion with what can be null and what cannot be null.


/**
* Encapsulates the basic configuration needed to connect to a single Cassandra instance
*/
public class InstanceConfigurationImpl implements InstanceConfiguration
{
@JsonProperty("id")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using constructor for this.

String jmxRolePassword)
@JsonCreator
public InstanceConfigurationImpl(@JsonProperty("id") int id,
@NotNull @JsonProperty("host") String host,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frankgh I guessing a bit for NotNull and Nullable of these fields. Please suggest changes if my interpretation is incorrect.

@@ -52,15 +65,42 @@ protected InstanceMetadataImpl(Builder builder)
id = builder.id;
host = builder.host;
port = builder.port;
cassandraHomeDir = FileUtils.maybeResolveHomeDirectory(builder.cassandraHomeDir);
Path cassandraHomeDirPath = cassandraHomeDir == null ? null : Paths.get(cassandraHomeDir);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay with having cassandraHomeDir as a mandatory configuration? If yes, then I can push changes to make it mandatory. Assuming it is not mandatory for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants