wip on HostPool and tests
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
package com.muwire.hostcache
|
||||||
|
|
||||||
|
class Host {
|
||||||
|
|
||||||
|
def destination
|
||||||
|
def verifyTime
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.muwire.hostcache
|
||||||
|
|
||||||
|
class HostPool {
|
||||||
|
|
||||||
|
def verified = new HashSet()
|
||||||
|
|
||||||
|
synchronized def getVerified(int max) {
|
||||||
|
def asList = verified.asList()
|
||||||
|
Collections.shuffle(asList)
|
||||||
|
return asList[0..max].collect { it -> it.destination }
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized def addUnverified(host) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized def verify(host) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.muwire.hostcache
|
||||||
|
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class HostPoolTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
def testGetVerified() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user