hook up upload manager
This commit is contained in:
@@ -30,6 +30,7 @@ import com.muwire.core.search.SearchEvent
|
|||||||
import com.muwire.core.search.SearchManager
|
import com.muwire.core.search.SearchManager
|
||||||
import com.muwire.core.trust.TrustEvent
|
import com.muwire.core.trust.TrustEvent
|
||||||
import com.muwire.core.trust.TrustService
|
import com.muwire.core.trust.TrustService
|
||||||
|
import com.muwire.core.upload.UploadManager
|
||||||
import com.muwire.core.util.MuWireLogManager
|
import com.muwire.core.util.MuWireLogManager
|
||||||
|
|
||||||
import groovy.util.logging.Log
|
import groovy.util.logging.Log
|
||||||
@@ -134,6 +135,18 @@ class Core {
|
|||||||
trustService.start()
|
trustService.start()
|
||||||
trustService.waitForLoad()
|
trustService.waitForLoad()
|
||||||
|
|
||||||
|
log.info "initializing file manager"
|
||||||
|
FileManager fileManager = new FileManager(eventBus)
|
||||||
|
eventBus.register(FileHashedEvent.class, fileManager)
|
||||||
|
eventBus.register(FileLoadedEvent.class, fileManager)
|
||||||
|
eventBus.register(FileDownloadedEvent.class, fileManager)
|
||||||
|
eventBus.register(FileUnsharedEvent.class, fileManager)
|
||||||
|
eventBus.register(SearchEvent.class, fileManager)
|
||||||
|
|
||||||
|
log.info "initializing persistence service"
|
||||||
|
PersisterService persisterService = new PersisterService(new File(home, "files.json"), eventBus, 5000, fileManager)
|
||||||
|
persisterService.start()
|
||||||
|
|
||||||
log.info("initializing host cache")
|
log.info("initializing host cache")
|
||||||
File hostStorage = new File(home, "hosts.json")
|
File hostStorage = new File(home, "hosts.json")
|
||||||
HostCache hostCache = new HostCache(trustService,hostStorage, 30000, props, i2pSession.getMyDestination())
|
HostCache hostCache = new HostCache(trustService,hostStorage, 30000, props, i2pSession.getMyDestination())
|
||||||
@@ -166,9 +179,14 @@ class Core {
|
|||||||
eventBus.register(QueryEvent.class, searchManager)
|
eventBus.register(QueryEvent.class, searchManager)
|
||||||
eventBus.register(ResultsEvent.class, searchManager)
|
eventBus.register(ResultsEvent.class, searchManager)
|
||||||
|
|
||||||
|
log.info("initializing upload manager")
|
||||||
|
UploadManager uploadManager = new UploadManager(eventBus, fileManager)
|
||||||
|
|
||||||
|
|
||||||
log.info("initializing acceptor")
|
log.info("initializing acceptor")
|
||||||
I2PAcceptor i2pAcceptor = new I2PAcceptor(socketManager)
|
I2PAcceptor i2pAcceptor = new I2PAcceptor(socketManager)
|
||||||
ConnectionAcceptor acceptor = new ConnectionAcceptor(eventBus, connectionManager, props, i2pAcceptor, hostCache, trustService, searchManager)
|
ConnectionAcceptor acceptor = new ConnectionAcceptor(eventBus, connectionManager, props,
|
||||||
|
i2pAcceptor, hostCache, trustService, searchManager, uploadManager)
|
||||||
acceptor.start()
|
acceptor.start()
|
||||||
|
|
||||||
|
|
||||||
@@ -180,17 +198,6 @@ class Core {
|
|||||||
eventBus.register(FileSharedEvent.class, hasherService)
|
eventBus.register(FileSharedEvent.class, hasherService)
|
||||||
hasherService.start()
|
hasherService.start()
|
||||||
|
|
||||||
log.info "initializing file manager"
|
|
||||||
FileManager fileManager = new FileManager(eventBus)
|
|
||||||
eventBus.register(FileHashedEvent.class, fileManager)
|
|
||||||
eventBus.register(FileLoadedEvent.class, fileManager)
|
|
||||||
eventBus.register(FileDownloadedEvent.class, fileManager)
|
|
||||||
eventBus.register(FileUnsharedEvent.class, fileManager)
|
|
||||||
eventBus.register(SearchEvent.class, fileManager)
|
|
||||||
|
|
||||||
log.info "initializing persistence service"
|
|
||||||
PersisterService persisterService = new PersisterService(new File(home, "files.json"), eventBus, 5000, fileManager)
|
|
||||||
persisterService.start()
|
|
||||||
|
|
||||||
|
|
||||||
// ... at the end, sleep or execute script
|
// ... at the end, sleep or execute script
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.muwire.core.Persona
|
|||||||
import com.muwire.core.hostcache.HostCache
|
import com.muwire.core.hostcache.HostCache
|
||||||
import com.muwire.core.trust.TrustLevel
|
import com.muwire.core.trust.TrustLevel
|
||||||
import com.muwire.core.trust.TrustService
|
import com.muwire.core.trust.TrustService
|
||||||
|
import com.muwire.core.upload.UploadManager
|
||||||
import com.muwire.core.search.InvalidSearchResultException
|
import com.muwire.core.search.InvalidSearchResultException
|
||||||
import com.muwire.core.search.ResultsParser
|
import com.muwire.core.search.ResultsParser
|
||||||
import com.muwire.core.search.SearchManager
|
import com.muwire.core.search.SearchManager
|
||||||
@@ -32,13 +33,14 @@ class ConnectionAcceptor {
|
|||||||
final HostCache hostCache
|
final HostCache hostCache
|
||||||
final TrustService trustService
|
final TrustService trustService
|
||||||
final SearchManager searchManager
|
final SearchManager searchManager
|
||||||
|
final UploadManager uploadManager
|
||||||
|
|
||||||
final ExecutorService acceptorThread
|
final ExecutorService acceptorThread
|
||||||
final ExecutorService handshakerThreads
|
final ExecutorService handshakerThreads
|
||||||
|
|
||||||
ConnectionAcceptor(EventBus eventBus, UltrapeerConnectionManager manager,
|
ConnectionAcceptor(EventBus eventBus, UltrapeerConnectionManager manager,
|
||||||
MuWireSettings settings, I2PAcceptor acceptor, HostCache hostCache,
|
MuWireSettings settings, I2PAcceptor acceptor, HostCache hostCache,
|
||||||
TrustService trustService, searchManager) {
|
TrustService trustService, SearchManager searchManager, UploadManager uploadManager) {
|
||||||
this.eventBus = eventBus
|
this.eventBus = eventBus
|
||||||
this.manager = manager
|
this.manager = manager
|
||||||
this.settings = settings
|
this.settings = settings
|
||||||
@@ -46,6 +48,7 @@ class ConnectionAcceptor {
|
|||||||
this.hostCache = hostCache
|
this.hostCache = hostCache
|
||||||
this.trustService = trustService
|
this.trustService = trustService
|
||||||
this.searchManager = searchManager
|
this.searchManager = searchManager
|
||||||
|
this.uploadManager = uploadManager
|
||||||
|
|
||||||
acceptorThread = Executors.newSingleThreadExecutor { r ->
|
acceptorThread = Executors.newSingleThreadExecutor { r ->
|
||||||
def rv = new Thread(r)
|
def rv = new Thread(r)
|
||||||
@@ -170,7 +173,7 @@ class ConnectionAcceptor {
|
|||||||
dis.readFully(et)
|
dis.readFully(et)
|
||||||
if (et != "ET ".getBytes(StandardCharsets.US_ASCII))
|
if (et != "ET ".getBytes(StandardCharsets.US_ASCII))
|
||||||
throw new IOException("Invalid GET connection")
|
throw new IOException("Invalid GET connection")
|
||||||
// TODO: implement
|
uploadManager.processEndpoint(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processPOST(final Endpoint e) throws IOException {
|
private void processPOST(final Endpoint e) throws IOException {
|
||||||
|
|||||||
Reference in New Issue
Block a user