Merge pull request #2194 from metamx/DRUID-2160

Fixes to JDBCExtractionNamespaceTest
This commit is contained in:
Fangjin Yang 2016-01-04 15:00:50 -08:00
commit 863d84e30e
2 changed files with 26 additions and 28 deletions

View File

@ -363,7 +363,7 @@ public abstract class NamespaceExtractionCacheManager
tasksStarted.incrementAndGet();
final String newVersion = runnable.call();
if (preVersion != null && preVersion.equals(newVersion)) {
throw new IllegalStateException("Already exists");
throw new CancellationException(String.format("Version `%s` already exists", preVersion));
}
if (newVersion != null) {
lastVersion.put(namespaceName, newVersion);
@ -379,6 +379,9 @@ public abstract class NamespaceExtractionCacheManager
} else {
log.error(t, "Failed update namespace [%s]", namespace);
}
if(Thread.currentThread().isInterrupted()) {
throw Throwables.propagate(t);
}
}
}
};

View File

@ -140,24 +140,7 @@ public class JDBCExtractionNamespaceTest
);
handle.createStatement(String.format("TRUNCATE TABLE %s", tableName)).setQueryTimeout(1).execute();
handle.commit();
closer.register(
new Closeable()
{
@Override
public void close() throws IOException
{
// Register first so it gets run last and checks for cleanup
final NamespaceExtractionCacheManager.NamespaceImplData implData =
extractionCacheManager.implData.get(namespace);
if (implData != null && implData.future != null) {
implData.future.cancel(true);
Assert.assertTrue(implData.future.isDone());
}
}
}
);
closer.register(
new Closeable()
closer.register(new Closeable()
{
@Override
public void close() throws IOException
@ -165,8 +148,21 @@ public class JDBCExtractionNamespaceTest
handle.createStatement("DROP TABLE " + tableName).setQueryTimeout(1).execute();
handle.close();
}
});
closer.register(new Closeable()
{
@Override
public void close() throws IOException
{
// Register first so it gets run last and checks for cleanup
final NamespaceExtractionCacheManager.NamespaceImplData implData = extractionCacheManager.implData.get(
namespace);
if (implData != null && implData.future != null) {
implData.future.cancel(true);
Assert.assertTrue(implData.future.isDone());
}
);
}
});
for (Map.Entry<String, String> entry : renames.entrySet()) {
try {
insertValues(entry.getKey(), entry.getValue(), "2015-01-01 00:00:00");
@ -427,7 +423,6 @@ public class JDBCExtractionNamespaceTest
assertUpdated(extractionNamespace.getNamespace(), "foo", "bar");
}
@Ignore // https://github.com/druid-io/druid/issues/2160
@Test(timeout = 60_000L)
public void testFindNew()
throws NoSuchFieldException, IllegalAccessException, ExecutionException, InterruptedException