mirror of
https://github.com/gmbrax/MediaManager-core.git
synced 2026-11-09 22:10:17 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41a2b97122 | ||
|
|
4f3ee4ed74 | ||
|
|
281618a725 |
@@ -0,0 +1,28 @@
|
|||||||
|
name: Qodana
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches: # Specify your branches here
|
||||||
|
- main # The 'main' branch
|
||||||
|
- 'releases/*' # The release branches
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
qodana:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
checks: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
|
||||||
|
fetch-depth: 0 # a full history is required for pull request analysis
|
||||||
|
- name: 'Qodana Scan'
|
||||||
|
uses: JetBrains/qodana-action@v2025.2
|
||||||
|
with:
|
||||||
|
pr-mode: false
|
||||||
|
env:
|
||||||
|
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN_268690425 }}
|
||||||
|
QODANA_ENDPOINT: 'https://qodana.cloud'
|
||||||
+103
@@ -0,0 +1,103 @@
|
|||||||
|
# Refactoring History—MediaManager Core
|
||||||
|
|
||||||
|
This document records the refactorings applied during development.
|
||||||
|
|
||||||
|
## Refactoring #1: Connection Pool Implementation
|
||||||
|
|
||||||
|
**Date**: 2025-11-13
|
||||||
|
**Commits**: ```22476abb27d95e88ae0439d97ef97467b6a4f985```
|
||||||
|
|
||||||
|
### Problem Identified
|
||||||
|
- Database connections were created multiple times
|
||||||
|
- No centralized control
|
||||||
|
- Possible resource leaks
|
||||||
|
|
||||||
|
### Technique Applied
|
||||||
|
- **Pattern**: Singleton Pattern
|
||||||
|
- **Refactoring**: Extract Class + Introduce Singleton
|
||||||
|
|
||||||
|
### Solution
|
||||||
|
Created `DatabaseManager` class that:
|
||||||
|
- Maintains single instance (Singleton)
|
||||||
|
- Manages connection pool
|
||||||
|
- Provides centralized `getConnection()` method
|
||||||
|
|
||||||
|
### Result
|
||||||
|
- ✅ Single reusable connection
|
||||||
|
- ✅ Code centralized in one class
|
||||||
|
- ✅ Thread-safe
|
||||||
|
- ✅ Easier to test
|
||||||
|
|
||||||
|
### Extracted Component
|
||||||
|
`DatabaseManager` - available in `mediamanager-components`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Refactoring #2: Thread Pool for IPC
|
||||||
|
|
||||||
|
**Date**: 2025-11-14
|
||||||
|
**Commits**: ```f1071dca03da33f7355a6927497509b5aedaa4a2```
|
||||||
|
|
||||||
|
### Problem Identified
|
||||||
|
- New thread created for each IPC client
|
||||||
|
- Doesn't scale well
|
||||||
|
- Thread creation overhead
|
||||||
|
|
||||||
|
### Technique Applied
|
||||||
|
- **Pattern**: Thread Pool Pattern
|
||||||
|
- **Refactoring**: Replace Thread Creation with Thread Pool
|
||||||
|
|
||||||
|
### Solution
|
||||||
|
Implemented `ExecutorService` with:
|
||||||
|
- Fixed thread pool
|
||||||
|
- Thread reuse
|
||||||
|
- Ordered shutdown
|
||||||
|
|
||||||
|
### Result
|
||||||
|
- ✅ Better performance
|
||||||
|
- ✅ Controlled resource usage
|
||||||
|
- ✅ Scalability
|
||||||
|
|
||||||
|
### Extracted Component
|
||||||
|
`IPCServer` - available in `mediamanager-components`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Refactoring #3: Graceful Shutdown
|
||||||
|
|
||||||
|
**Date**: 2025-11-13
|
||||||
|
**Commits**: ```65e14930076db71a312feae373d6c5daee3c4d29```,```b7ff9d1e16c85bf986a770676827bee390f0d53c```
|
||||||
|
|
||||||
|
### Problem Identified
|
||||||
|
- Resources weren't released on exit
|
||||||
|
- Database connections remained open
|
||||||
|
- Thread pool didn't terminate correctly
|
||||||
|
|
||||||
|
### Technique Applied
|
||||||
|
- **Pattern**: Shutdown Hook Pattern
|
||||||
|
- **Refactoring**: Introduce Shutdown Protocol
|
||||||
|
|
||||||
|
### Solution
|
||||||
|
Implemented shutdown hooks that:
|
||||||
|
- Close database connections
|
||||||
|
- Terminate thread pools
|
||||||
|
- Release sockets
|
||||||
|
- In specific order with timeouts
|
||||||
|
|
||||||
|
### Result
|
||||||
|
- ✅ Ordered cleanup
|
||||||
|
- ✅ No resource leaks
|
||||||
|
- ✅ Shutdown logging
|
||||||
|
- ✅ Timeout to prevent hanging
|
||||||
|
|
||||||
|
### Extracted Component
|
||||||
|
Logic incorporated in `DatabaseManager` and `IPCServer`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Applied Principles
|
||||||
|
|
||||||
|
- **DRY** (Don't Repeat Yourself): Elimination of duplicated code
|
||||||
|
- **SOLID**: Especially Single Responsibility Principle
|
||||||
|
- **Design Patterns**: Singleton, Thread Pool, Shutdown Hook
|
||||||
|
- **Clean Code**: Clear names, small methods, well-defined responsibilities
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
####################################################################################################################
|
||||||
|
# WARNING: Do not store sensitive information in this file, as its contents will be included in the Qodana report. #
|
||||||
|
####################################################################################################################
|
||||||
|
|
||||||
|
version: "1.0"
|
||||||
|
linter: jetbrains/qodana-jvm:2025.2
|
||||||
|
profile:
|
||||||
|
name: qodana.recommended
|
||||||
|
include:
|
||||||
|
- name: CheckDependencyLicenses
|
||||||
Reference in New Issue
Block a user