Is Accumulo TableOperations.createTable synchronous?

时间:2015-06-25 19:14:52

标签: java accumulo

I'm working with Accumulo 1.6.2 and I am seeing an issue where it appears that TableOperations.createTable may return without an exception, but the table still isn't ready. For example in the following code: String tableName = "foo"; TableOperations operations = connector.tableOperations(); if(!operations.exists(tableName)) { operations.createTable(tableName); } //Make a bunch of mutations that write to the table BatchWriter batchWriter = connector.createBatchWriter(tableName, someConfig); batchWriter.addMutations(mutations); batchWriter.close(); When I run a unit test with the above code, I will sometimes get an exception indicating that table foo does not exist. However, the code just created table foo. The only thing I can think of is that there is a window of time after createTable() returns where the table still might not exist. The Javadoc doesn't explain the behavior. I also have read an early release copy of Orielly's Accumulo book and it doesn't say either. What is the correct pattern here? I could add something like the following: //Make table while(!operations.exists(tableName){} //Do stuff with table However that seems like a really ugly and potentially bug prone thing to do. I'm hoping there is a better pattern here.

1 个答案:

答案 0 :(得分:1)

创建表应该是同步操作。您不应该在上面的示例中看到异常。

如果您可以提供特定的例外,那可能暗示需要修复的错误。