public boolean migrate(PersistentRequestRoot newRoot, ObjectContainer container, NodeClientCore core,
ClientContext context) {
int migrated = 0;
int failed = 0;
try {
PersistentRequestClient newClient;
if(isGlobalQueue) {
newClient = newRoot.getGlobalForeverClient();
Logger.error(this, "Migrating global queue");
} else {
newClient = newRoot.registerForeverClient(name, null);
Logger.error(this, "Migrating client \""+name+"\"");
}
container.activate(runningPersistentRequests, 2);
for(ClientRequest req : runningPersistentRequests) {
if(req == null) continue;
try {
freenet.clients.fcp.ClientRequest request = req.migrate(newClient, container, core);
// FIXME it doesn't count as failure if it's already been migrated
if(request == null) {
failed++;
continue;
}
newClient.register(request);
request.start(context);
// FIXME catch standard exceptions.
migrated++;
} catch (Throwable t) {
Logger.error(this, "Unable to migrate request: "+t, t);
failed++;
}
}
container.activate(completedUnackedRequests, 2);
for(ClientRequest req : completedUnackedRequests) {
if(req == null) continue;
try {
freenet.clients.fcp.ClientRequest request = req.migrate(newClient, container, core);
// FIXME it doesn't count as failure if it's already been migrated
if(request == null) {
failed++;
continue;
}
newClient.register(request);
request.start(context);
// FIXME catch standard exceptions.
migrated++;
} catch (Throwable t) {
Logger.error(this, "Unable to migrate request: "+t, t);