John Roesler created KAFKA-10630:
------------------------------------

             Summary: State Directory config could be improved
                 Key: KAFKA-10630
                 URL: https://issues.apache.org/jira/browse/KAFKA-10630
             Project: Kafka
          Issue Type: Task
          Components: streams
            Reporter: John Roesler


During [https://github.com/apache/kafka/pull/9477,] I noticed that many tests 
wind up providing a state directory config purely to ensure a unique temp 
directory for the test. Since TopologyTestDriver and MockProcessorContext tests 
are typically unit tests, it would be more convenient to initialize those 
components with their own unique temp state directory, following the universal 
pattern from such tests:
{code:java}
props.setProperty(StreamsConfig.STATE_DIR_CONFIG, 
TestUtils.tempDirectory().getAbsolutePath()); {code}
Note that this literal setting is not ideal, since it actually creates a 
directory regardless of whether the application needs one. Instead, we should 
create a new TestUtil method to lazily generate a temp directory _name_ and 
then register a shutdown handler to delete it if it exists. Then, Streams would 
only create the directory if it actually needs persistence.

Also, the default value for that config is not platform independent. It is 
simply: {color:#067d17}"/tmp/kafka-streams"{color}. Perhaps instead we should 
set the default to something like "unset" or "" or "none". Then, instead of 
reading the property directly, when Streams actually needs the state directory, 
it could log a warning that the state directory config is not set and call the 
platform-independent Java api for creating a temporary directory.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to