mirror of https://github.com/apache/druid.git
Merge pull request #2183 from druid-io/fix-jdbc
increase timeouts for jdbc tearDown
This commit is contained in:
commit
9d179b96a8
|
@ -139,29 +139,33 @@ public class JDBCExtractionNamespaceTest
|
||||||
);
|
);
|
||||||
handle.createStatement(String.format("TRUNCATE TABLE %s", tableName)).setQueryTimeout(1).execute();
|
handle.createStatement(String.format("TRUNCATE TABLE %s", tableName)).setQueryTimeout(1).execute();
|
||||||
handle.commit();
|
handle.commit();
|
||||||
closer.register(new Closeable()
|
closer.register(
|
||||||
{
|
new Closeable()
|
||||||
@Override
|
{
|
||||||
public void close() throws IOException
|
@Override
|
||||||
{
|
public void close() throws IOException
|
||||||
// Register first so it gets run last and checks for cleanup
|
{
|
||||||
final NamespaceExtractionCacheManager.NamespaceImplData implData = extractionCacheManager.implData.get(
|
// Register first so it gets run last and checks for cleanup
|
||||||
namespace);
|
final NamespaceExtractionCacheManager.NamespaceImplData implData =
|
||||||
if (implData != null && implData.future != null) {
|
extractionCacheManager.implData.get(namespace);
|
||||||
implData.future.cancel(true);
|
if (implData != null && implData.future != null) {
|
||||||
Assert.assertTrue(implData.future.isDone());
|
implData.future.cancel(true);
|
||||||
|
Assert.assertTrue(implData.future.isDone());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
});
|
closer.register(
|
||||||
closer.register(new Closeable()
|
new Closeable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException
|
public void close() throws IOException
|
||||||
{
|
{
|
||||||
handle.createStatement("DROP TABLE " + tableName).setQueryTimeout(1).execute();
|
handle.createStatement("DROP TABLE " + tableName).setQueryTimeout(1).execute();
|
||||||
handle.close();
|
handle.close();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
for (Map.Entry<String, String> entry : renames.entrySet()) {
|
for (Map.Entry<String, String> entry : renames.entrySet()) {
|
||||||
try {
|
try {
|
||||||
insertValues(entry.getKey(), entry.getValue(), "2015-01-01 00:00:00");
|
insertValues(entry.getKey(), entry.getValue(), "2015-01-01 00:00:00");
|
||||||
|
@ -219,36 +223,42 @@ public class JDBCExtractionNamespaceTest
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
throw Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
}
|
}
|
||||||
closer.register(new Closeable()
|
closer.register(
|
||||||
{
|
new Closeable()
|
||||||
@Override
|
{
|
||||||
public void close() throws IOException
|
@Override
|
||||||
{
|
public void close() throws IOException
|
||||||
lifecycle.stop();
|
{
|
||||||
}
|
lifecycle.stop();
|
||||||
});
|
}
|
||||||
closer.register(new Closeable()
|
}
|
||||||
{
|
);
|
||||||
@Override
|
closer.register(
|
||||||
public void close() throws IOException
|
new Closeable()
|
||||||
{
|
{
|
||||||
Assert.assertTrue("Delete failed", extractionCacheManager.delete(namespace));
|
@Override
|
||||||
}
|
public void close() throws IOException
|
||||||
});
|
{
|
||||||
|
Assert.assertTrue("Delete failed", extractionCacheManager.delete(namespace));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
final Closer setupCloser = Closer.create();
|
final Closer setupCloser = Closer.create();
|
||||||
setupCloser.register(new Closeable()
|
setupCloser.register(
|
||||||
{
|
new Closeable()
|
||||||
@Override
|
{
|
||||||
public void close() throws IOException
|
@Override
|
||||||
{
|
public void close() throws IOException
|
||||||
if (!setupFuture.isDone() && !setupFuture.cancel(true) && !setupFuture.isDone()) {
|
{
|
||||||
throw new IOException("Unable to stop future");
|
if (!setupFuture.isDone() && !setupFuture.cancel(true) && !setupFuture.isDone()) {
|
||||||
|
throw new IOException("Unable to stop future");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
});
|
|
||||||
try {
|
try {
|
||||||
setupFuture.get(10, TimeUnit.SECONDS);
|
setupFuture.get(10, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
@ -264,21 +274,24 @@ public class JDBCExtractionNamespaceTest
|
||||||
public void tearDown() throws InterruptedException, ExecutionException, TimeoutException, IOException
|
public void tearDown() throws InterruptedException, ExecutionException, TimeoutException, IOException
|
||||||
{
|
{
|
||||||
final Closer tearDownCloser = Closer.create();
|
final Closer tearDownCloser = Closer.create();
|
||||||
tearDownCloser.register(new Closeable()
|
tearDownCloser.register(
|
||||||
{
|
new Closeable()
|
||||||
@Override
|
{
|
||||||
public void close() throws IOException
|
@Override
|
||||||
{
|
public void close() throws IOException
|
||||||
setupTeardownService.shutdownNow();
|
{
|
||||||
try {
|
setupTeardownService.shutdownNow();
|
||||||
setupTeardownService.awaitTermination(10, TimeUnit.SECONDS);
|
try {
|
||||||
|
setupTeardownService.awaitTermination(60, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
throw new IOException("Interrupted", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (InterruptedException e) {
|
);
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
throw new IOException("Interrupted", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
try {
|
try {
|
||||||
setupTeardownService.submit(
|
setupTeardownService.submit(
|
||||||
new Runnable()
|
new Runnable()
|
||||||
|
@ -294,7 +307,7 @@ public class JDBCExtractionNamespaceTest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
).get(10, TimeUnit.SECONDS);
|
).get(60, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
catch (Throwable t) {
|
catch (Throwable t) {
|
||||||
throw closer.rethrow(t);
|
throw closer.rethrow(t);
|
||||||
|
|
Loading…
Reference in New Issue