Search in sources :

Example 46 with JanusGraphException

use of org.janusgraph.core.JanusGraphException in project atlas by apache.

the class ElasticSearch7Index method checkForOrCreateIndex.

/**
 * If ES already contains this instance's target index, then do nothing.
 * Otherwise, create the index, then wait .
 * <p>
 * The {@code client} field must point to a live, connected client.
 * The {@code indexName} field must be non-null and point to the name
 * of the index to check for existence or create.
 *
 * @param index index name
 * @throws IOException if the index status could not be checked or index could not be created
 */
private void checkForOrCreateIndex(String index) throws IOException {
    Objects.requireNonNull(client);
    Objects.requireNonNull(index);
    // Create index if it does not useExternalMappings and if it does not already exist
    if (!useExternalMappings && !client.indexExists(index)) {
        client.createIndex(index, indexSetting);
        client.updateIndexSettings(index, MAX_RESULT_WINDOW);
        try {
            log.debug("Sleeping {} ms after {} index creation returned from actionGet()", createSleep, index);
            Thread.sleep(createSleep);
        } catch (final InterruptedException e) {
            throw new JanusGraphException("Interrupted while waiting for index to settle in", e);
        }
    }
    Preconditions.checkState(client.indexExists(index), "Could not create index: %s", index);
    client.addAlias(indexName, index);
}
Also used : JanusGraphException(org.janusgraph.core.JanusGraphException)

Aggregations

JanusGraphException (org.janusgraph.core.JanusGraphException)46 BackendException (org.janusgraph.diskstorage.BackendException)18 PropertyKey (org.janusgraph.core.PropertyKey)9 Test (org.junit.jupiter.api.Test)7 JanusGraphIndex (org.janusgraph.core.schema.JanusGraphIndex)6 StandardScanner (org.janusgraph.diskstorage.keycolumnvalue.scan.StandardScanner)6 Set (java.util.Set)5 JanusGraphManagement (org.janusgraph.core.schema.JanusGraphManagement)5 CompositeIndexType (org.janusgraph.graphdb.types.CompositeIndexType)5 IndexType (org.janusgraph.graphdb.types.IndexType)5 MixedIndexType (org.janusgraph.graphdb.types.MixedIndexType)5 RepeatedIfExceptionsTest (io.github.artsok.RepeatedIfExceptionsTest)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 ExecutionException (java.util.concurrent.ExecutionException)4 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)4 JanusGraphVertex (org.janusgraph.core.JanusGraphVertex)4 RelationTypeIndex (org.janusgraph.core.schema.RelationTypeIndex)4 ScanMetrics (org.janusgraph.diskstorage.keycolumnvalue.scan.ScanMetrics)4