/** @return last modified time of all packs, in milliseconds. */ public long getLastModified() { if (lastModified < 0) { long max = 0; for (DfsPackFile pack : packs) { max = Math.max(max, pack.getPackDescription().getLastModified()); } lastModified = max; } return lastModified; }
private boolean packIsExpiredGarbage(DfsPackDescription d, long now) { // Consider the garbage pack as expired when it's older than // garbagePackTtl. This check gives concurrent inserter threads // sufficient time to identify an object is not in the graph and should // have a new copy written, rather than relying on something from an // UNREACHABLE_GARBAGE pack. return d.getPackSource() == UNREACHABLE_GARBAGE && garbageTtlMillis > 0 && now - d.getLastModified() >= garbageTtlMillis; }
static Comparator<DfsPackDescription> reftableComparator() { return (a, b) -> { // GC, COMPACT reftables first by reversing default order. int c = PackSource.DEFAULT_COMPARATOR.reversed() .compare(a.getPackSource(), b.getPackSource()); if (c != 0) { return c; } // Lower maxUpdateIndex first. c = Long.signum(a.getMaxUpdateIndex() - b.getMaxUpdateIndex()); if (c != 0) { return c; } // Older reftable first. return Long.signum(a.getLastModified() - b.getLastModified()); }; }
int cmp = Long.signum(b.getLastModified() - a.getLastModified()); if (cmp != 0) { return cmp;
long lastModified = d.getLastModified(); long dayStartLastModified = dayStartInMillis(lastModified); long dayStartToday = dayStartInMillis(now);
/** @return last modified time of all packs, in milliseconds. */ public long getLastModified() { if (lastModified < 0) { long max = 0; for (DfsPackFile pack : packs) { max = Math.max(max, pack.getPackDescription().getLastModified()); } lastModified = max; } return lastModified; }
/** @return last modified time of all packs, in milliseconds. */ public long getLastModified() { if (lastModified < 0) { long max = 0; for (DfsPackFile pack : packs) { max = Math.max(max, pack.getPackDescription().getLastModified()); } lastModified = max; } return lastModified; }
private boolean packIsExpiredGarbage(DfsPackDescription d, long now) { // Consider the garbage pack as expired when it's older than // garbagePackTtl. This check gives concurrent inserter threads // sufficient time to identify an object is not in the graph and should // have a new copy written, rather than relying on something from an // UNREACHABLE_GARBAGE pack. return d.getPackSource() == UNREACHABLE_GARBAGE && garbageTtlMillis > 0 && now - d.getLastModified() >= garbageTtlMillis; }
private boolean packIsExpiredGarbage(DfsPackDescription d, long mostRecentGC, long now) { // It should be safe to remove an UNREACHABLE_GARBAGE pack if it: // // (a) Predates the most recent prior run of this class. This check // ensures the graph traversal algorithm had a chance to consider // all objects in this pack and copied them into a GC or GC_REST // pack if the graph contained live edges to the objects. // // This check is safe because of the ordering of packing; the GC // packs are written first and then the UNREACHABLE_GARBAGE is // constructed. Any UNREACHABLE_GARBAGE dated earlier than the GC // was input to the prior GC's graph traversal. // // (b) Is older than garbagePackTtl. This check gives concurrent // inserter threads sufficient time to identify an object is not // in the graph and should have a new copy written, rather than // relying on something from an UNREACHABLE_GARBAGE pack. // // Both (a) and (b) must be met to safely remove UNREACHABLE_GARBAGE. return d.getPackSource() == UNREACHABLE_GARBAGE && d.getLastModified() < mostRecentGC && garbageTtlMillis > 0 && now - d.getLastModified() >= garbageTtlMillis; }
static Comparator<DfsPackDescription> reftableComparator() { return (a, b) -> { // GC, COMPACT reftables first by reversing default order. int c = PackSource.DEFAULT_COMPARATOR.reversed() .compare(a.getPackSource(), b.getPackSource()); if (c != 0) { return c; } // Lower maxUpdateIndex first. c = Long.signum(a.getMaxUpdateIndex() - b.getMaxUpdateIndex()); if (c != 0) { return c; } // Older reftable first. return Long.signum(a.getLastModified() - b.getLastModified()); }; }
private static long mostRecentGC(DfsPackFile[] packs) { long r = 0; for (DfsPackFile p : packs) { DfsPackDescription d = p.getPackDescription(); if (d.getPackSource() == GC || d.getPackSource() == GC_REST) { r = Math.max(r, d.getLastModified()); } } return r; }
/** * Sort packs according to the optimal lookup ordering. * <p> * This method tries to position packs in the order readers should examine * them when looking for objects by SHA-1. The default tries to sort packs * with more recent modification dates before older packs, and packs with * fewer objects before packs with more objects. * * @param b * the other pack. */ public int compareTo(DfsPackDescription b) { // Cluster by PackSource, pushing UNREACHABLE_GARBAGE to the end. PackSource as = getPackSource(); PackSource bs = b.getPackSource(); if (as != null && bs != null) { int cmp = as.category - bs.category; if (cmp != 0) return cmp; } // Newer packs should sort first. int cmp = Long.signum(b.getLastModified() - getLastModified()); if (cmp != 0) return cmp; // Break ties on smaller index. Readers may get lucky and find // the object they care about in the smaller index. This also pushes // big historical packs to the end of the list, due to more objects. return Long.signum(getObjectCount() - b.getObjectCount()); }
int cmp = Long.signum(b.getLastModified() - a.getLastModified()); if (cmp != 0) { return cmp;
long lastModified = d.getLastModified(); long dayStartLastModified = dayStartInMillis(lastModified); long dayStartToday = dayStartInMillis(now);