This project demonstrates a concurrent Java client designed to interact with a like-counting service, likely simulating multiple users sending "like" requests simultaneously. It also includes Java Concurrency Stress (JCStress) tests to verify the correctness of concurrent operations within the application's domain logic.
- Java Development Kit (JDK) 17 or newer: Ensure you have a compatible JDK installed.
- Gradle: This project uses the Gradle Wrapper, so you don't need to install Gradle separately.
To build the project, including compiling Java code and packaging JARs, use the Gradle wrapper:
# On Linux/macOS
./gradlew build
# On Windows (using Command Prompt or PowerShell)
.\gradlew.bat buildThis will generate the necessary build artifacts in the build/ and app/build/ directories.
The ConcurrentVoteClient simulates concurrent votes across multiple items ("item1" to "item4"). This tests both the individual counters and the integrity of the underlying HashMap.
You can reset the counts using DELETE requests:
# Reset votes
curl -X DELETE http://localhost:7070/votesTo run JCStress tests:
# On Linux/macOS
./gradlew jcstresscd scripts
./jcstress-jmm-test.shcd scripts
./jcstress-db-test.sh.\gradlew.bat jcstress
After execution, the JCStress reports, including detailed results and findings, can be found in:
build/reports/jcstress/build/tmp/jcstress/(for raw output and intermediate files)
Specifically, look for index.html in build/reports/jcstress/ for a readable report.