Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,14 @@ public abstract class Controller
static final boolean ALLOW_UNSAFE_AGGRESSIVE_SSTABLE_EXPIRATION = Boolean.parseBoolean(System.getProperty(ALLOW_UNSAFE_AGGRESSIVE_SSTABLE_EXPIRATION_PROPERTY));
static final boolean DEFAULT_ALLOW_UNSAFE_AGGRESSIVE_SSTABLE_EXPIRATION = false;

/**
* System property to control writing scaling parameters to JSON configuration file.
* When set to true (default), the controller will persist scaling parameters and flush size to disk.
* When set to false, persistence is disabled.
*/
public static final String SCALING_PARAMETER_PERSISTENCE_PROPERTY = PREFIX + "scaling_parameter_persistence";
public static final boolean SCALING_PARAMETER_PERSISTENCE = Boolean.parseBoolean(System.getProperty(SCALING_PARAMETER_PERSISTENCE_PROPERTY, "true"));

/**
* This property allows seperate defaults for vector and non-vector tables. If this property is set to true
* and the table has a {@link VectorType}, the "vector" defaults are used over the regular defaults. For instance,
Expand Down Expand Up @@ -439,6 +447,12 @@ public static File getControllerConfigPath(TableMetadata metadata)

public static void storeOptions(TableMetadata metadata, int[] scalingParameters, long flushSizeBytes)
{
if (!SCALING_PARAMETER_PERSISTENCE)
{
logger.debug("Scaling parameter persistence is disabled via {}. Skipping write to disk.", SCALING_PARAMETER_PERSISTENCE_PROPERTY);
return;
}

if (SchemaConstants.isSystemKeyspace(metadata.keyspace))
return;
File f = getControllerConfigPath(metadata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -914,4 +914,41 @@ public void testGetLargestFactorizedShardCount()
assertEquals(1, controller.getLargestFactorizedShardCount(-1.0));
assertEquals(1, controller.getLargestFactorizedShardCount(-100.0));
}

@Test
public void testScalingParameterPersistenceEnabled()
{
// Verify that by default (SCALING_PARAMETER_PERSISTENCE = true), storeOptions creates a file
assertTrue("Scaling parameter persistence should be enabled by default", Controller.SCALING_PARAMETER_PERSISTENCE);

TableMetadata testMetadata = standardCFMD("test_ks", "test_table").build();
int[] scalingParameters = new int[] { 0, 2, 4 };
long flushSize = 100 << 20; // 100 MB

// Store the options - should create a file when persistence is enabled
Controller.storeOptions(testMetadata, scalingParameters, flushSize);

// Verify the file was created
org.apache.cassandra.io.util.File configPath = Controller.getControllerConfigPath(testMetadata);
assertTrue("Config file should exist when persistence is enabled", configPath.exists());

// Clean up
configPath.delete();
}

@Test
public void testScalingParameterPersistenceSystemKeyspace()
{
// Verify that system keyspaces never write config files regardless of persistence setting
TableMetadata systemMetadata = standardCFMD("system", "test_table").build();
int[] scalingParameters = new int[] { 0, 2, 4 };
long flushSize = 100 << 20; // 100 MB

// Store the options - should not create a file for system keyspace
Controller.storeOptions(systemMetadata, scalingParameters, flushSize);

// Verify the file was NOT created
org.apache.cassandra.io.util.File configPath = Controller.getControllerConfigPath(systemMetadata);
assertFalse("Config file should not exist for system keyspace", configPath.exists());
}
}
Loading