-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from nlnwa/priority
Ensure all seeds gets fair scheduling
- Loading branch information
Showing
13 changed files
with
253 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,48 @@ | ||
--- | ||
--- KEYS[1]: jobExecutionKey | ||
--- ARGV[1]: oldState | ||
--- ARGV[2]: newState | ||
--- ARGV[3]: documentsCrawled | ||
--- ARGV[4]: documentsDenied | ||
--- ARGV[5]: documentsFailed | ||
--- ARGV[6]: documentsOutOfScope | ||
--- ARGV[7]: documentsRetried | ||
--- ARGV[8]: urisCrawled | ||
--- ARGV[9]: bytesCrawled | ||
--- | ||
|
||
if ARGV[2] == 'CREATED' or redis.call('EXISTS', KEYS[1]) == 1 then | ||
local jobExecutionKey = KEYS[1] | ||
local oldState = ARGV[1] | ||
local newState = ARGV[2] | ||
local documentsCrawled = ARGV[3] | ||
local documentsDenied = ARGV[4] | ||
local documentsFailed = ARGV[5] | ||
local documentsOutOfScope = ARGV[6] | ||
local documentsRetried = ARGV[7] | ||
local urisCrawled = ARGV[8] | ||
local bytesCrawled = ARGV[9] | ||
|
||
if newState == 'CREATED' or redis.call('EXISTS', jobExecutionKey) == 1 then | ||
-- Update states | ||
if ARGV[1] ~= 'UNDEFINED' then | ||
redis.call('HINCRBY', KEYS[1], ARGV[1], -1) | ||
if oldState ~= 'UNDEFINED' then | ||
redis.call('HINCRBY', jobExecutionKey, oldState, -1) | ||
end | ||
|
||
if ARGV[2] ~= 'UNDEFINED' then | ||
redis.call('HINCRBY', KEYS[1], ARGV[2], 1) | ||
if newState ~= 'UNDEFINED' then | ||
redis.call('HINCRBY', jobExecutionKey, newState, 1) | ||
end | ||
|
||
-- Update stats | ||
redis.call('HINCRBY', KEYS[1], "documentsCrawled", ARGV[3]) | ||
redis.call('HINCRBY', KEYS[1], "documentsDenied", ARGV[4]) | ||
redis.call('HINCRBY', KEYS[1], "documentsFailed", ARGV[5]) | ||
redis.call('HINCRBY', KEYS[1], "documentsOutOfScope", ARGV[6]) | ||
redis.call('HINCRBY', KEYS[1], "documentsRetried", ARGV[7]) | ||
redis.call('HINCRBY', KEYS[1], "urisCrawled", ARGV[8]) | ||
redis.call('HINCRBY', KEYS[1], "bytesCrawled", ARGV[9]) | ||
redis.call('HINCRBY', jobExecutionKey, "documentsCrawled", documentsCrawled) | ||
redis.call('HINCRBY', jobExecutionKey, "documentsDenied", documentsDenied) | ||
redis.call('HINCRBY', jobExecutionKey, "documentsFailed", documentsFailed) | ||
redis.call('HINCRBY', jobExecutionKey, "documentsOutOfScope", documentsOutOfScope) | ||
redis.call('HINCRBY', jobExecutionKey, "documentsRetried", documentsRetried) | ||
redis.call('HINCRBY', jobExecutionKey, "urisCrawled", urisCrawled) | ||
redis.call('HINCRBY', jobExecutionKey, "bytesCrawled", bytesCrawled) | ||
|
||
local running = 0 | ||
if redis.call('HEXISTS', jobExecutionKey, 'UNDEFINED') == 1 then | ||
running = running + tonumber(redis.call('HGET', jobExecutionKey, 'UNDEFINED')) | ||
end | ||
if redis.call('HEXISTS', jobExecutionKey, 'CREATED') == 1 then | ||
running = running + tonumber(redis.call('HGET', jobExecutionKey, 'CREATED')) | ||
end | ||
if redis.call('HEXISTS', jobExecutionKey, 'FETCHING') == 1 then | ||
running = running + tonumber(redis.call('HGET', jobExecutionKey, 'FETCHING')) | ||
end | ||
if redis.call('HEXISTS', jobExecutionKey, 'SLEEPING') == 1 then | ||
running = running + tonumber(redis.call('HGET', jobExecutionKey, 'SLEEPING')) | ||
end | ||
|
||
return running | ||
end | ||
|
||
end | ||
return -1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.