Search in sources :

Example 36 with PermanentBackendException

use of org.janusgraph.diskstorage.PermanentBackendException in project janusgraph by JanusGraph.

the class BerkeleyJETx method openCursor.

Cursor openCursor(Database db) throws BackendException {
    synchronized (openCursors) {
        if (!isOpen) {
            throw new PermanentBackendException("Transaction already closed");
        }
        Cursor cursor = db.openCursor(tx, null);
        openCursors.add(cursor);
        return cursor;
    }
}
Also used : PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) Cursor(com.sleepycat.je.Cursor)

Example 37 with PermanentBackendException

use of org.janusgraph.diskstorage.PermanentBackendException in project janusgraph by JanusGraph.

the class BerkeleyJEStoreManager method openDatabase.

@Override
public BerkeleyJEKeyValueStore openDatabase(String name) throws BackendException {
    Preconditions.checkNotNull(name);
    if (stores.containsKey(name)) {
        return stores.get(name);
    }
    try {
        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setReadOnly(false);
        dbConfig.setAllowCreate(true);
        dbConfig.setTransactional(transactional);
        dbConfig.setKeyPrefixing(true);
        if (batchLoading) {
            dbConfig.setDeferredWrite(true);
        }
        Database db = environment.openDatabase(null, name, dbConfig);
        log.debug("Opened database {}", name);
        BerkeleyJEKeyValueStore store = new BerkeleyJEKeyValueStore(name, db, this);
        stores.put(name, store);
        return store;
    } catch (DatabaseException e) {
        throw new PermanentBackendException("Could not open BerkeleyJE data store", e);
    }
}
Also used : PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) Database(com.sleepycat.je.Database) DatabaseException(com.sleepycat.je.DatabaseException) DatabaseConfig(com.sleepycat.je.DatabaseConfig)

Example 38 with PermanentBackendException

use of org.janusgraph.diskstorage.PermanentBackendException in project janusgraph by JanusGraph.

the class BerkeleyJEStoreManager method beginTransaction.

@Override
public BerkeleyJETx beginTransaction(final BaseTransactionConfig txCfg) throws BackendException {
    try {
        Transaction tx = null;
        Configuration effectiveCfg = new MergedConfiguration(txCfg.getCustomOptions(), getStorageConfig());
        if (transactional) {
            TransactionConfig txnConfig = new TransactionConfig();
            ConfigOption.getEnumValue(effectiveCfg.get(ISOLATION_LEVEL), IsolationLevel.class).configure(txnConfig);
            tx = environment.beginTransaction(null, txnConfig);
        } else {
            if (txCfg instanceof TransactionConfiguration) {
                if (!((TransactionConfiguration) txCfg).isSingleThreaded()) {
                    // Non-transactional cursors can't shared between threads, more info ThreadLocker.checkState
                    throw new PermanentBackendException("BerkeleyJE does not support non-transactional for multi threaded tx");
                }
            }
        }
        BerkeleyJETx btx = new BerkeleyJETx(tx, ConfigOption.getEnumValue(effectiveCfg.get(LOCK_MODE), LockMode.class), ConfigOption.getEnumValue(effectiveCfg.get(CACHE_MODE), CacheMode.class), txCfg);
        if (log.isTraceEnabled()) {
            log.trace("Berkeley tx created", new TransactionBegin(btx.toString()));
        }
        return btx;
    } catch (DatabaseException e) {
        throw new PermanentBackendException("Could not start BerkeleyJE transaction", e);
    }
}
Also used : TransactionConfiguration(org.janusgraph.graphdb.transaction.TransactionConfiguration) MergedConfiguration(org.janusgraph.diskstorage.configuration.MergedConfiguration) StoreTransaction(org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction) Transaction(com.sleepycat.je.Transaction) MergedConfiguration(org.janusgraph.diskstorage.configuration.MergedConfiguration) Configuration(org.janusgraph.diskstorage.configuration.Configuration) GraphDatabaseConfiguration(org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration) TransactionConfiguration(org.janusgraph.graphdb.transaction.TransactionConfiguration) PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) CacheMode(com.sleepycat.je.CacheMode) TransactionConfig(com.sleepycat.je.TransactionConfig) BaseTransactionConfig(org.janusgraph.diskstorage.BaseTransactionConfig) LockMode(com.sleepycat.je.LockMode) DatabaseException(com.sleepycat.je.DatabaseException)

Example 39 with PermanentBackendException

use of org.janusgraph.diskstorage.PermanentBackendException in project janusgraph by JanusGraph.

the class HBaseSnapshotBinaryInputFormat method setConf.

@Override
public void setConf(final Configuration config) {
    HBaseConfiguration.addHbaseResources(config);
    super.setConf(config);
    // Pass the extra pass-through properties directly to HBase/Hadoop config.
    final Map<String, Object> configSub = janusgraphConf.getSubset(HBaseStoreManager.HBASE_CONFIGURATION_NAMESPACE);
    for (Map.Entry<String, Object> entry : configSub.entrySet()) {
        log.info("HBase configuration: setting {}={}", entry.getKey(), entry.getValue());
        if (entry.getValue() == null)
            continue;
        config.set(entry.getKey(), entry.getValue().toString());
    }
    config.set("autotype", "none");
    final Scan scanner = new Scan();
    String cfName = mrConf.get(JanusGraphHadoopConfiguration.COLUMN_FAMILY_NAME);
    // TODO the space-saving short name mapping leaks from HBaseStoreManager here
    if (janusgraphConf.get(HBaseStoreManager.SHORT_CF_NAMES)) {
        try {
            final BiMap<String, String> shortCfMap = HBaseStoreManager.createShortCfMap(janusgraphConf);
            cfName = HBaseStoreManager.shortenCfName(shortCfMap, cfName);
        } catch (PermanentBackendException e) {
            throw new RuntimeException(e);
        }
    }
    edgeStoreFamily = Bytes.toBytes(cfName);
    scanner.addFamily(edgeStoreFamily);
    // This is a workaround, to be removed when convertScanToString becomes public in hbase package.
    Method converter;
    try {
        converter = TableMapReduceUtil.class.getDeclaredMethod("convertScanToString", Scan.class);
        converter.setAccessible(true);
        config.set(TableInputFormat.SCAN, (String) converter.invoke(null, scanner));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    final String snapshotName = janusgraphConf.get(HBaseStoreManager.HBASE_SNAPSHOT);
    final String restoreDirString = janusgraphConf.get(HBaseStoreManager.HBASE_SNAPSHOT_RESTORE_DIR);
    final Path restoreDir = new Path(restoreDirString);
    try {
        // This is a workaround. TableSnapshotInputFormat.setInput accepts a Job as parameter.
        // And the Job.getInstance(config) create clone of the config, not setting on the
        // passed in config.
        Job job = Job.getInstance(config);
        TableSnapshotInputFormat.setInput(job, snapshotName, restoreDir);
        config.set(SNAPSHOT_NAME_KEY, job.getConfiguration().get(SNAPSHOT_NAME_KEY));
        config.set(RESTORE_DIR_KEY, job.getConfiguration().get(RESTORE_DIR_KEY));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) Method(java.lang.reflect.Method) IOException(java.io.IOException) IOException(java.io.IOException) PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) TableMapReduceUtil(org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil) Scan(org.apache.hadoop.hbase.client.Scan) Job(org.apache.hadoop.mapreduce.Job) Map(java.util.Map) BiMap(com.google.common.collect.BiMap)

Example 40 with PermanentBackendException

use of org.janusgraph.diskstorage.PermanentBackendException in project janusgraph by JanusGraph.

the class ElasticSearchIndex method setupStoredScriptIfNeeded.

private void setupStoredScriptIfNeeded(String storedScriptId, String source) throws PermanentBackendException {
    ImmutableMap<String, Object> preparedScript = compat.prepareScript(source).build();
    String lang = (String) ((ImmutableMap<String, Object>) preparedScript.get(ES_SCRIPT_KEY)).get(ES_LANG_KEY);
    try {
        ESScriptResponse esScriptResponse = client.getStoredScript(storedScriptId);
        if (Boolean.FALSE.equals(esScriptResponse.getFound()) || !Objects.equals(lang, esScriptResponse.getScript().getLang()) || !Objects.equals(source, esScriptResponse.getScript().getSource())) {
            client.createStoredScript(storedScriptId, preparedScript);
        }
    } catch (final IOException e) {
        throw new PermanentBackendException(e.getMessage(), e);
    }
}
Also used : PermanentBackendException(org.janusgraph.diskstorage.PermanentBackendException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) ESScriptResponse(org.janusgraph.diskstorage.es.script.ESScriptResponse)

Aggregations

PermanentBackendException (org.janusgraph.diskstorage.PermanentBackendException)53 IOException (java.io.IOException)24 TemporaryBackendException (org.janusgraph.diskstorage.TemporaryBackendException)16 UncheckedIOException (java.io.UncheckedIOException)12 BackendException (org.janusgraph.diskstorage.BackendException)12 Configuration (org.janusgraph.diskstorage.configuration.Configuration)8 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)7 DatabaseException (com.sleepycat.je.DatabaseException)7 BaseTransactionConfig (org.janusgraph.diskstorage.BaseTransactionConfig)7 Duration (java.time.Duration)6 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 StaticBuffer (org.janusgraph.diskstorage.StaticBuffer)6 StoreTransaction (org.janusgraph.diskstorage.keycolumnvalue.StoreTransaction)6 SolrServerException (org.apache.solr.client.solrj.SolrServerException)5 KeeperException (org.apache.zookeeper.KeeperException)5 Transaction (com.sleepycat.je.Transaction)4 HashMap (java.util.HashMap)4 CloudSolrClient (org.apache.solr.client.solrj.impl.CloudSolrClient)4 KeyInformation (org.janusgraph.diskstorage.indexing.KeyInformation)4