Search in sources :

Example 6 with ReplicationMessage

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());
}
Also used : ReplicationMessageList(dvoraka.avservice.client.service.response.ReplicationMessageList) ReplicationMessage(dvoraka.avservice.common.data.ReplicationMessage)

Aggregations

ReplicationMessage (dvoraka.avservice.common.data.ReplicationMessage)6 ReplicationMessageList (dvoraka.avservice.client.service.response.ReplicationMessageList)5 ReplicationServiceClient (dvoraka.avservice.client.service.ReplicationServiceClient)3 ReplicationResponseClient (dvoraka.avservice.client.service.response.ReplicationResponseClient)3 ReplicationMessageListener (dvoraka.avservice.common.ReplicationMessageListener)3 Command (dvoraka.avservice.common.data.Command)3 MessageRouting (dvoraka.avservice.common.data.MessageRouting)3 ReplicationStatus (dvoraka.avservice.common.data.ReplicationStatus)3 ReplicationHelper (dvoraka.avservice.common.replication.ReplicationHelper)3 HashingService (dvoraka.avservice.common.service.HashingService)3 Md5HashingService (dvoraka.avservice.common.service.Md5HashingService)3 StandardCharsets (java.nio.charset.StandardCharsets)3 HashSet (java.util.HashSet)3 Optional (java.util.Optional)3 Set (java.util.Set)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 Lock (java.util.concurrent.locks.Lock)3 ReentrantLock (java.util.concurrent.locks.ReentrantLock)3 PostConstruct (javax.annotation.PostConstruct)3 LogManager (org.apache.logging.log4j.LogManager)3