Created
September 6, 2011 21:41
-
-
Save ryankennedy/1199062 to your computer and use it in GitHub Desktop.
solr wtf?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Set the duration for which commit point is to be reserved by the deletion policy. | |
* | |
* @param indexVersion version of the commit point to be reserved | |
* @param reserveTime time in milliseconds for which the commit point is to be reserved | |
*/ | |
public void setReserveDuration(Long indexVersion, long reserveTime) { | |
long timeToSet = System.currentTimeMillis() + reserveTime; | |
for(;;) { | |
Long previousTime = reserves.put(indexVersion, timeToSet); | |
// this is the common success case: the older time didn't exist, or | |
// came before the new time. | |
if (previousTime == null || previousTime <= timeToSet) break; | |
// At this point, we overwrote a longer reservation, so we want to restore the older one. | |
// the problem is that an even longer reservation may come in concurrently | |
// and we don't want to overwrite that one too. We simply keep retrying in a loop | |
// with the maximum time value we have seen. | |
timeToSet = previousTime; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment