}
return replicationResponses.size() == 1 ? replicationResponses.get(0) : new CompositeReplicationResponse(replicationResponses);
}
private ReplicationResponse schedule(ReplicationPackage replicationPackage) {
ReplicationResponse replicationResponse;
log.info("scheduling replication of package {}", replicationPackage);
// dispatch the replication package to the queue distribution handler
try {
boolean success = queueDistributionStrategy.add(name, replicationPackage, queueProvider);
Dictionary<Object, Object> properties = new Properties();
properties.put("replication.package.paths", replicationPackage.getPaths());
properties.put("replication.agent.name", name);
replicationEventFactory.generateEvent(ReplicationEventType.PACKAGE_QUEUED, properties);
replicationResponse = new ReplicationResponse(success? ReplicationQueueItemState.ItemState.QUEUED.toString() :
ReplicationQueueItemState.ItemState.ERROR.toString(), success);
} catch (Exception e) {
log.error("an error happened during queue processing", e);
replicationResponse = new ReplicationResponse(e.toString(), false);
}
return replicationResponse;
}