Search in sources :

Example 31 with TableExistsException

use of org.apache.accumulo.core.client.TableExistsException in project gora by apache.

the class AccumuloStore method createSchema.

@Override
public void createSchema() throws GoraException {
    try {
        conn.tableOperations().create(mapping.tableName);
        Set<Entry<String, String>> es = mapping.tableConfig.entrySet();
        for (Entry<String, String> entry : es) {
            conn.tableOperations().setProperty(mapping.tableName, entry.getKey(), entry.getValue());
        }
    } catch (TableExistsException e) {
        LOG.debug(e.getMessage(), e);
    // Assume this is not an error
    } catch (AccumuloException | AccumuloSecurityException e) {
        throw new GoraException(e);
    }
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) Entry(java.util.Map.Entry) GoraException(org.apache.gora.util.GoraException) TableExistsException(org.apache.accumulo.core.client.TableExistsException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException)

Example 32 with TableExistsException

use of org.apache.accumulo.core.client.TableExistsException in project hive by apache.

the class AccumuloStorageHandler method preCreateTable.

@Override
public void preCreateTable(Table table) throws MetaException {
    if (table.getSd().getLocation() != null) {
        throw new MetaException("Location can't be specified for Accumulo");
    }
    Map<String, String> serdeParams = table.getSd().getSerdeInfo().getParameters();
    String columnMapping = serdeParams.get(AccumuloSerDeParameters.COLUMN_MAPPINGS);
    if (columnMapping == null) {
        throw new MetaException(AccumuloSerDeParameters.COLUMN_MAPPINGS + " missing from SERDEPROPERTIES");
    }
    try {
        String tblName = getTableName(table);
        Connector connector = connectionParams.getConnector();
        TableOperations tableOpts = connector.tableOperations();
        // Attempt to create the table, taking EXTERNAL into consideration
        if (!tableOpts.exists(tblName)) {
            tableOpts.create(tblName);
        }
        String idxTable = getIndexTableName(table);
        if (idxTable != null && !idxTable.isEmpty()) {
            // create the index table if it does not exist
            if (!tableOpts.exists(idxTable)) {
                tableOpts.create(idxTable);
            }
        }
    } catch (AccumuloSecurityException e) {
        throw new MetaException(StringUtils.stringifyException(e));
    } catch (TableExistsException e) {
        throw new MetaException(StringUtils.stringifyException(e));
    } catch (AccumuloException e) {
        throw new MetaException(StringUtils.stringifyException(e));
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) AccumuloException(org.apache.accumulo.core.client.AccumuloException) TableOperations(org.apache.accumulo.core.client.admin.TableOperations) TableExistsException(org.apache.accumulo.core.client.TableExistsException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException)

Aggregations

TableExistsException (org.apache.accumulo.core.client.TableExistsException)32 AccumuloException (org.apache.accumulo.core.client.AccumuloException)21 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)17 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)17 Connector (org.apache.accumulo.core.client.Connector)9 IOException (java.io.IOException)8 BatchWriter (org.apache.accumulo.core.client.BatchWriter)8 BatchWriterConfig (org.apache.accumulo.core.client.BatchWriterConfig)7 Value (org.apache.accumulo.core.data.Value)7 HashMap (java.util.HashMap)6 Mutation (org.apache.accumulo.core.data.Mutation)6 ByteBuffer (java.nio.ByteBuffer)5 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)4 MutationsRejectedException (org.apache.accumulo.core.client.MutationsRejectedException)4 Key (org.apache.accumulo.core.data.Key)4 Text (org.apache.hadoop.io.Text)4 Map (java.util.Map)3 Entry (java.util.Map.Entry)3 NamespaceExistsException (org.apache.accumulo.core.client.NamespaceExistsException)3 NamespaceNotFoundException (org.apache.accumulo.core.client.NamespaceNotFoundException)3