hide decrement and update close logic to call decrement

This commit is contained in:
fjy 2013-08-01 13:24:56 -07:00
parent e92e0c35a4
commit dc169d9fcd
2 changed files with 14 additions and 4 deletions

View File

@ -56,6 +56,7 @@ import com.metamx.emitter.service.ServiceMetricEvent;
import org.joda.time.Interval;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@ -191,7 +192,12 @@ public class ServerManager implements QuerySegmentWalker
dataSourceCounts.add(dataSource, -1L);
}
oldQueryable.decrement();
try {
oldQueryable.close();
}
catch (IOException e) {
throw new SegmentLoadingException(e, "Unable to close segment %s", segment.getIdentifier());
}
} else {
log.info(
"Told to delete a queryable on dataSource[%s] for interval[%s] and version [%s] that I don't have.",

View File

@ -112,8 +112,12 @@ public class ReferenceCountingSegment implements Segment
{
synchronized (lock) {
if (!isClosed) {
baseSegment.close();
isClosed = true;
if (numReferences > 0) {
decrement();
} else {
baseSegment.close();
isClosed = true;
}
}
}
}
@ -140,7 +144,7 @@ public class ReferenceCountingSegment implements Segment
}
}
public void decrement()
private void decrement()
{
synchronized (lock) {
if (!isClosed) {