use of io.crate.exceptions.TableUnknownException in project crate by crate.
the class DropBlobTableAnalyzerTest method testDeletingNoExistingTableSetsNoopIfIgnoreNonExistentTablesIsSet.
@Test
public void testDeletingNoExistingTableSetsNoopIfIgnoreNonExistentTablesIsSet() throws Exception {
when(schemas.getTableInfo(tableIdent)).thenThrow(new TableUnknownException(tableIdent));
DropBlobTableAnalyzedStatement statement = analyzer.analyze(new DropBlobTable(table, true));
assertThat(statement.noop(), is(true));
}
use of io.crate.exceptions.TableUnknownException in project crate by crate.
the class DropBlobTableAnalyzerTest method testDeletingNonExistingTableRaisesException.
@Test
public void testDeletingNonExistingTableRaisesException() throws Exception {
when(schemas.getTableInfo(tableIdent)).thenThrow(new TableUnknownException(tableIdent));
expectedException.expect(TableUnknownException.class);
expectedException.expectMessage("Table 'blob.Irrelevant' unknown");
analyzer.analyze(new DropBlobTable(table, false));
}
use of io.crate.exceptions.TableUnknownException in project crate by crate.
the class DocTableInfoBuilder method docIndexMetaData.
private DocIndexMetaData docIndexMetaData() {
DocIndexMetaData docIndexMetaData;
String templateName = PartitionName.templateName(ident.schema(), ident.name());
boolean createdFromTemplate = false;
if (metaData.getTemplates().containsKey(templateName)) {
docIndexMetaData = buildDocIndexMetaDataFromTemplate(ident.indexName(), templateName);
createdFromTemplate = true;
concreteIndices = indexNameExpressionResolver.concreteIndices(state, IndicesOptions.lenientExpandOpen(), ident.indexName());
} else {
try {
concreteIndices = indexNameExpressionResolver.concreteIndices(state, IndicesOptions.strictExpandOpen(), ident.indexName());
if (concreteIndices.length == 0) {
// no matching index found
throw new TableUnknownException(ident);
}
docIndexMetaData = buildDocIndexMetaData(concreteIndices[0]);
} catch (IndexNotFoundException ex) {
throw new TableUnknownException(ident.fqn(), ex);
}
}
if ((!createdFromTemplate && concreteIndices.length == 1) || !checkAliasSchema) {
return docIndexMetaData;
}
for (String concreteIndice : concreteIndices) {
if (IndexMetaData.State.CLOSE.equals(metaData.indices().get(concreteIndice).getState())) {
throw new UnhandledServerException(String.format(Locale.ENGLISH, "Unable to access the partition %s, it is closed", concreteIndice));
}
try {
docIndexMetaData = docIndexMetaData.merge(buildDocIndexMetaData(concreteIndice), transportPutIndexTemplateAction, createdFromTemplate);
} catch (IOException e) {
throw new UnhandledServerException("Unable to merge/build new DocIndexMetaData", e);
}
}
return docIndexMetaData;
}
use of io.crate.exceptions.TableUnknownException in project crate by crate.
the class InternalBlobTableInfoFactory method resolveIndexMetaData.
private IndexMetaData resolveIndexMetaData(String tableName, ClusterState state) {
String index = BlobIndex.fullIndexName(tableName);
String[] concreteIndices;
try {
concreteIndices = indexNameExpressionResolver.concreteIndices(state, IndicesOptions.strictExpandOpen(), index);
} catch (IndexNotFoundException ex) {
throw new TableUnknownException(index, ex);
}
return state.metaData().index(concreteIndices[0]);
}
use of io.crate.exceptions.TableUnknownException in project crate by crate.
the class Schemas method getTableInfo.
/**
* @param ident the table ident to get a TableInfo for
* @return an instance of TableInfo for the given ident, guaranteed to be not null
* @throws io.crate.exceptions.SchemaUnknownException if schema given in <code>ident</code>
* does not exist
* @throws io.crate.exceptions.TableUnknownException if table given in <code>ident</code> does
* not exist in the given schema
*/
public TableInfo getTableInfo(TableIdent ident) {
SchemaInfo schemaInfo = getSchemaInfo(ident);
TableInfo info;
info = schemaInfo.getTableInfo(ident.name());
if (info == null) {
throw new TableUnknownException(ident);
}
return info;
}
Aggregations