All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fasterxml.clustermate.service.util.StoreUtil Maven / Gradle / Ivy

The newest version!
package com.fasterxml.clustermate.service.util;

import com.fasterxml.storemate.shared.hash.HashConstants;

public class StoreUtil
{
    public static boolean needToPullRemoteToResolve(long localTimestamp, int localContentHash,
            long remoteTimestamp, int remoteContentHash)
    {
        // If hashes match, no need to pull; ditto of remote is missing hash
        if (localContentHash == remoteContentHash || remoteContentHash == HashConstants.NO_CHECKSUM) {
            return false;
        }
        // but needs to pull if (a) remote has lower timestamp (added earlier), or,
        // (b) timestamps same, but remote has higher hash value
        if (localTimestamp < remoteTimestamp) {
            return false;
        }
        if (localTimestamp == remoteTimestamp && localContentHash > remoteContentHash) {
            return false;
        }
        return true;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy