A multi-threaded server application that provides document indexing and search capabilities. This system allows clients to connect, index documents, and perform search queries across the indexed content.
-
FileRetrievalServer
- Main entry point of the application
- Initializes core components and starts the server
- Handles command-line configuration for server port
-
IndexStore
- Core data structure maintaining document indexes
- Thread-safe implementation using ReentrantLocks
- Manages:
- Document mapping (document number → path)
- Inverted index (term → document-frequency pairs)
-
IndexWorker
- Handles individual client connections
- Processes indexing and search requests
- Maintains client-specific input/output streams
-
ServerProcessingEngine
- Manages server operations
- Dispatches client connections to workers
- Maintains thread pool for worker execution
- Tracks connected clients
-
ServerAppInterface
- Provides command-line interface for server management
- Supports commands for listing clients and shutting down the server
- Java Development Kit (JDK) 8 or higher
- Java build tool (e.g., Maven, Gradle) or direct compilation capability
javac csc435/app/*.javajava csc435.app.FileRetrievalServer [port][port]: Optional port number (default: 8080)
-
list- Lists all currently connected clients
- Shows client IDs and connection information
-
quit- Gracefully shuts down the server
- Closes all client connections
- Cleans up resources
Command: "INDEX"
Parameters:
1. Document Path (String)
2. Word Frequencies (HashMap<String, Long>)
Response:
1. "INDEX_REPLY"
2. Document Number (Long)
Command: "SEARCH"
Parameters:
1. Search Terms (ArrayList<String>)
Response:
1. "SEARCH_REPLY"
2. Top 10 Results (ArrayList<String>)
Format: "documentPath (score: frequency)"
Command: "QUIT"
Parameters: None
Response: None (Connection closes)
The system implements thread safety through several mechanisms:
- ReentrantLocks for document map and term index access
- ConcurrentHashMap for client tracking
- AtomicLong for document number generation
- Thread pool for worker management
-
Search Operations
- Results are sorted by frequency score
- Limited to top 10 matches for efficiency
- Combines scores across multiple search terms
-
Index Operations
- Thread-safe document number generation
- Atomic updates to prevent data corruption
- Efficient lock management to minimize contention
-
Connection Management
- Dynamic thread pool scaling
- Efficient resource cleanup
- Non-blocking client acceptance
The system implements robust error handling:
- Socket connection errors
- Invalid client requests
- Resource cleanup on client disconnection
- Graceful server shutdown
-
Memory Usage
- All indexes are stored in memory
- No persistent storage implementation
- Memory usage grows with indexed documents
-
Search Capabilities
- Basic term-frequency based ranking
- No advanced text analysis or stemming
- Limited to exact term matches
- Add persistent storage support
- Implement advanced text analysis
- Add support for document deletion
- Implement connection timeout handling
- Add support for batch indexing
- Implement query result pagination
When contributing to this project:
- Follow existing code style and patterns
- Maintain thread safety in new features
- Add appropriate error handling
- Update documentation as needed
- Include unit tests for new functionality