use of dvoraka.avservice.common.data.ReplicationMessage in project av-service by dvoraka.
the class DefaultReplicationService method whoHas.
/**
* Returns a set of neighbour IDs with a given file.
*
* @param filename the filename
* @param owner the owner
* @return the set of IDs
*/
public Set<String> whoHas(String filename, String owner) {
ReplicationMessage query = createExistsRequest(filename, owner, nodeId);
serviceClient.sendMessage(query);
Optional<ReplicationMessageList> response;
response = responseClient.getResponseWaitSize(query.getId(), MAX_RESPONSE_TIME, neighbourCount());
ReplicationMessageList messages = response.orElseGet(ReplicationMessageList::new);
return messages.stream().filter(message -> message.getReplicationStatus() == ReplicationStatus.OK).map(ReplicationMessage::getFromId).collect(Collectors.toSet());
}
Aggregations