Exemple #1
0
        protected bool IsKnownStaticBlock(BlockContainer block)
        {
            // If the block was written to less than 3 minutes ago, return false
            if (block.LastWrite > DateTime.Now.AddMinutes(-(3 * 60 * 1000)))
            {
                return(false);
            }
            // Extract the server key from the block id
            BlockId blockId  = block.Id;
            int     serverId = ((int)blockId.Low & 0x0FF);

            // Look up the max known block id for the manager server,
            BlockId maxBlockId;

            lock (maxKnownBlockId) {
                maxKnownBlockId.TryGetValue(serverId, out maxBlockId);
            }

            // If the block is less than the max, the block can be compressed!
            if (maxBlockId != null && blockId.CompareTo(maxBlockId) < 0)
            {
                return(true);
            }
            // Otherwise update the last write flag (so we only check the max block id
            // every 3 mins).
            block.TouchLastWrite();
            return(false);
        }
Exemple #2
0
 public int CompareTo(BlockContainer other)
 {
     return(blockId.CompareTo(other.blockId));
 }