-
Notifications
You must be signed in to change notification settings - Fork 6
Desgin
Judgehost in Golang, Powered by Docker
- No Status Judgehosts
- Easy to manage
- Dockerize Each Judge
- Timing, Memory, Output limit guarantee
- Detailed Judge info feedback
- Robust
- Config File use *.toml config file
- Download certain file to downloader and cache it
- Create a docker when submission comes
- Get the CPUSet Info and ensure max docker instance do not exceed cpu count
- Register to OJ Server
- Fetching Result from Server
- Fetched Result, Start Judge
- Get Program
- Get Build Executables (from downloader)
- Create a docker to build program
- Get Run Executables, Compare Executables (from downloader)
- For each Testcase (from downloader)
- Get testcase[i]
- Create a docker to run program
- Run Compare Program
- Write Feedback
- Judged Finished
- Finished Judge, Send Feedback to Server
- Fetching Result from Server
Downloader will cache file locally, store both the file and its checksum, when looking for file, it will lookup first locally and check the integrity of the file, then it will return the file content in binary mode
It also support no-cache mode, when downloading user code we may not want to cache the code, this mode will also disable store the file into cache
Create a downloader instance with Newmethod, pass the config to downloader, config contains cache-dir, server-url, use-cache, request-method.
When need to download file, will call downloader.Download, pass the URL to the downloader, filename, md5sum, and give the destination path, it will download to the right place and ensure the integrity
When called downloader.Download it will process Process below:
1.If use-cache , check the file in cache and compare the md5sum, if matches, copy the cached file to destination
2.If file do not exist in cache, jump to 4
3.If no-use-cache, Jump to 4
4.Perform HTTP Request to download the file, and check the integrity, try max-try-times, if cannot download the correct file, then report an error ,Jump to 5
5.If use-cache jump to 6, else jump to 7
6.Check the cache-size, if max-size exceed, then cleanup-cache(We can use a better algorithm when cleanup, in the future), and then put the downloaded file into cache
cache-root/filename/data
cache-root/filename/md5sum
cache-root/filename/metadata (Used for future, store hit-times, etc)
e.g:
/var/cache/d_judge/test-1341341-1.in/data
/var/cache/d_judge/test-1341341-1.in/md5sum
/var/cache/d_judge/test-1341341-1.in/metadata