use of org.apache.drill.exec.store.StoragePluginRegistry.PluginException in project drill by apache.
the class StorageResources method deletePlugin.
@DELETE
@Path("/storage/{name}.json")
@Produces(MediaType.APPLICATION_JSON)
public Response deletePlugin(@PathParam("name") String name) {
try {
TokenRegistry tokenRegistry = ((AbstractStoragePlugin) storage.getPlugin(name)).getContext().getoAuthTokenProvider().getOauthTokenRegistry();
// Delete a token registry table if it exists
tokenRegistry.deleteTokenTable(name);
storage.remove(name);
return Response.ok().entity(message("Success")).build();
} catch (PluginException e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message("Error while deleting plugin: %s", e.getMessage())).build();
}
}
use of org.apache.drill.exec.store.StoragePluginRegistry.PluginException in project drill by apache.
the class DescribeSchemaHandler method getPlan.
@Override
public PhysicalPlan getPlan(SqlNode sqlNode) throws ForemanSetupException {
SqlIdentifier schema = unwrap(sqlNode, SqlDescribeSchema.class).getSchema();
SchemaPlus schemaPlus = SchemaUtilites.findSchema(config.getConverter().getDefaultSchema(), schema.names);
if (schemaPlus == null) {
throw UserException.validationError().message("Invalid schema name [%s]", Joiner.on(".").join(schema.names)).build(logger);
}
AbstractSchema drillSchema = SchemaUtilites.unwrapAsDrillSchemaInstance(schemaPlus);
StoragePlugin storagePlugin;
try {
storagePlugin = context.getStorage().getPlugin(drillSchema.getSchemaPath().get(0));
if (storagePlugin == null) {
throw new DrillRuntimeException(String.format("Unable to find storage plugin with the following name [%s].", drillSchema.getSchemaPath().get(0)));
}
} catch (PluginException e) {
throw new DrillRuntimeException("Failure while retrieving storage plugin", e);
}
try {
Map configMap = mapper.convertValue(storagePlugin.getConfig(), Map.class);
if (storagePlugin instanceof FileSystemPlugin) {
transformWorkspaces(drillSchema.getSchemaPath(), configMap);
}
String properties = mapper.writeValueAsString(configMap);
return DirectPlan.createDirectPlan(context, new DescribeSchemaResult(drillSchema.getFullSchemaName(), properties));
} catch (JsonProcessingException e) {
throw new DrillRuntimeException("Error while trying to convert storage config to json string", e);
}
}
Aggregations