move the close method to the segment object

This commit is contained in:
fjy 2013-07-30 12:24:01 -07:00
parent f55e12040f
commit 35d8a82879
8 changed files with 43 additions and 4 deletions

View File

@ -24,13 +24,21 @@ import com.metamx.druid.kv.Indexed;
import org.joda.time.Interval;
import java.io.Closeable;
import java.io.IOException;
/**
*/
public interface QueryableIndex extends ColumnSelector, Closeable
public interface QueryableIndex extends ColumnSelector
{
public Interval getDataInterval();
public int getNumRows();
public Indexed<String> getColumnNames();
public Indexed<String> getAvailableDimensions();
/**
* The close method shouldn't actually be here as this is nasty. We will adjust it in the future.
* @throws IOException
*/
@Deprecated
public void close() throws IOException;
}

View File

@ -38,7 +38,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<metamx.java-util.version>0.22.5-SNAPSHOT</metamx.java-util.version>
<metamx.java-util.version>0.22.5</metamx.java-util.version>
<apache.curator.version>2.1.0-incubating</apache.curator.version>
</properties>

View File

@ -185,7 +185,7 @@ public class ServerManager implements QuerySegmentWalker
}
try {
oldQueryable.asQueryableIndex().close();
oldQueryable.close();
}
catch (Exception e) {
log.error("Unable to close queryable index %s", oldQueryable.getIdentifier());

View File

@ -24,6 +24,8 @@ import com.metamx.druid.index.v1.IncrementalIndex;
import com.metamx.druid.index.v1.IncrementalIndexStorageAdapter;
import org.joda.time.Interval;
import java.io.IOException;
/**
*/
public class IncrementalIndexSegment implements Segment
@ -60,4 +62,10 @@ public class IncrementalIndexSegment implements Segment
{
return new IncrementalIndexStorageAdapter(index);
}
@Override
public void close() throws IOException
{
// do nothing
}
}

View File

@ -23,6 +23,8 @@ import com.metamx.druid.StorageAdapter;
import com.metamx.druid.index.v1.QueryableIndexStorageAdapter;
import org.joda.time.Interval;
import java.io.IOException;
/**
*/
public class QueryableIndexSegment implements Segment
@ -59,4 +61,11 @@ public class QueryableIndexSegment implements Segment
{
return new QueryableIndexStorageAdapter(index);
}
@Override
public void close() throws IOException
{
// this is kinda nasty
index.close();
}
}

View File

@ -22,9 +22,11 @@ package com.metamx.druid.index;
import com.metamx.druid.StorageAdapter;
import org.joda.time.Interval;
import java.io.Closeable;
/**
*/
public interface Segment
public interface Segment extends Closeable
{
public String getIdentifier();
public Interval getDataInterval();

View File

@ -352,6 +352,12 @@ public class ServerManagerTest
{
throw new UnsupportedOperationException();
}
@Override
public void close() throws IOException
{
}
}
public static class MyQueryRunnerFactory implements QueryRunnerFactory<Result<SearchResultValue>, SearchQuery>

View File

@ -27,6 +27,7 @@ import com.metamx.druid.index.Segment;
import org.joda.time.Interval;
import java.io.File;
import java.io.IOException;
import java.util.Map;
/**
@ -68,6 +69,11 @@ public class CacheTestSegmentLoader implements SegmentLoader
{
throw new UnsupportedOperationException();
}
@Override
public void close() throws IOException
{
}
};
}