private String[][] getKeyStatus(PropertyKey[] keys, JanusGraphIndex index) { String[][] keyStatus = new String[keys.length][2]; for (int i = 0; i < keys.length; i++) { keyStatus[i][0] = keys[i].name(); keyStatus[i][1] = index.getIndexStatus(keys[i]).name(); } return keyStatus.length > 0 ? keyStatus: new String[][] {{"",""}}; }
int acceptableFields = 0; for (PropertyKey key : graphIndex.getFieldKeys()) { SchemaStatus status = graphIndex.getIndexStatus(key); if (status!=SchemaStatus.DISABLED && !acceptableStatuses.contains(status)) { isValidIndex=false;
idx = management.getGraphIndex(graphIndexName); for (PropertyKey pk : idx.getFieldKeys()) { SchemaStatus s = idx.getIndexStatus(pk); LOGGER.debug("Key {} has status {}", pk, s); if (!statuses.contains(s))
isStable = true; for (PropertyKey key : idx.getFieldKeys()) { if (!idx.getIndexStatus(key).isStable()) isStable = false;
@Test public void testIndexShouldNotBeEnabledForExistingPropertyKeyWithoutLabelConstraint() { mgmt.makePropertyKey("alreadyExistingProperty").dataType(String.class).cardinality(Cardinality.SINGLE).make(); finishSchema(); PropertyKey existingPropertyKey = mgmt.getPropertyKey("alreadyExistingProperty"); mgmt.buildIndex("newIndex", Vertex.class).addKey(existingPropertyKey).buildCompositeIndex(); finishSchema(); assertNotEquals(SchemaStatus.ENABLED, mgmt.getGraphIndex("newIndex").getIndexStatus(existingPropertyKey)); }
@Test public void shouldAwaitMultipleStatuses() throws InterruptedException, ExecutionException { final PropertyKey key1 = makeKey("key1", String.class); final JanusGraphIndex index = mgmt.buildIndex("randomMixedIndex", Vertex.class).addKey(key1).buildMixedIndex(INDEX); if (index.getIndexStatus(key1) == SchemaStatus.INSTALLED) { mgmt.updateIndex(mgmt.getGraphIndex("randomMixedIndex"), SchemaAction.REGISTER_INDEX).get(); mgmt.updateIndex(mgmt.getGraphIndex("randomMixedIndex"), SchemaAction.ENABLE_INDEX).get(); } else if (index.getIndexStatus(key1) == SchemaStatus.REGISTERED) { mgmt.updateIndex(mgmt.getGraphIndex("randomMixedIndex"), SchemaAction.ENABLE_INDEX).get(); } final PropertyKey key2 = makeKey("key2", String.class); mgmt.addIndexKey(index, key2); mgmt.commit(); //key1 now has status ENABLED, let's ensure we can watch for REGISTERED and ENABLED try { ManagementSystem.awaitGraphIndexStatus(graph, "randomMixedIndex").status(SchemaStatus.REGISTERED, SchemaStatus.ENABLED).call(); } catch (final Exception e) { Assert.fail("Failed to awaitGraphIndexStatus on multiple statuses."); } }
@Test public void testIndexShouldBeEnabledForExistingPropertyKeyAndConstrainedToNewVertexLabel() { mgmt.makePropertyKey("alreadyExistingProperty").dataType(String.class).cardinality(Cardinality.SINGLE).make(); finishSchema(); PropertyKey existingPropertyKey = mgmt.getPropertyKey("alreadyExistingProperty"); VertexLabel newLabel = mgmt.makeVertexLabel("newLabel").make(); mgmt.buildIndex("newIndex", Vertex.class).addKey(existingPropertyKey).indexOnly(newLabel).buildCompositeIndex(); finishSchema(); assertEquals(SchemaStatus.ENABLED, mgmt.getGraphIndex("newIndex").getIndexStatus(existingPropertyKey)); }
@Test public void testIndexShouldBeEnabledForExistingPropertyKeyAndConstrainedToNewEdgeLabel() { mgmt.makePropertyKey("alreadyExistingProperty").dataType(String.class).cardinality(Cardinality.SINGLE).make(); finishSchema(); PropertyKey existingPropertyKey = mgmt.getPropertyKey("alreadyExistingProperty"); EdgeLabel newLabel = mgmt.makeEdgeLabel("newLabel").make(); mgmt.buildIndex("newIndex", Edge.class).addKey(existingPropertyKey).indexOnly(newLabel).buildCompositeIndex(); finishSchema(); assertEquals(SchemaStatus.ENABLED, mgmt.getGraphIndex("newIndex").getIndexStatus(existingPropertyKey)); }
@Test public void testIndexShouldNotBeEnabledForExistingPropertyKeyAndConstrainedToExistingEdgeLabel() { mgmt.makePropertyKey("alreadyExistingProperty").dataType(String.class).cardinality(Cardinality.SINGLE).make(); mgmt.makeEdgeLabel("alreadyExistingLabel").make(); finishSchema(); PropertyKey existingPropertyKey = mgmt.getPropertyKey("alreadyExistingProperty"); EdgeLabel existingLabel = mgmt.getEdgeLabel("alreadyExistingLabel"); mgmt.buildIndex("newIndex", Edge.class).addKey(existingPropertyKey).indexOnly(existingLabel).buildCompositeIndex(); finishSchema(); assertNotEquals(SchemaStatus.ENABLED, mgmt.getGraphIndex("newIndex").getIndexStatus(existingPropertyKey)); }
@Test public void testIndexShouldNotBeEnabledForExistingPropertyKeyAndConstrainedToExistingVertexLabel() { mgmt.makePropertyKey("alreadyExistingProperty").dataType(String.class).cardinality(Cardinality.SINGLE).make(); mgmt.makeVertexLabel("alreadyExistingLabel").make(); finishSchema(); PropertyKey existingPropertyKey = mgmt.getPropertyKey("alreadyExistingProperty"); VertexLabel existingLabel = mgmt.getVertexLabel("alreadyExistingLabel"); mgmt.buildIndex("newIndex", Vertex.class).addKey(existingPropertyKey).indexOnly(existingLabel).buildCompositeIndex(); finishSchema(); assertNotEquals(SchemaStatus.ENABLED, mgmt.getGraphIndex("newIndex").getIndexStatus(existingPropertyKey)); }
else index = management.buildIndex(indexName, Vertex.class).addKey(key).buildCompositeIndex(); try { if (index.getIndexStatus(key) == INSTALLED) { management.commit(); ManagementSystem.awaitGraphIndexStatus(graph, indexName).call(); management.updateIndex(management.getGraphIndex(indexName), ENABLE_INDEX).get(); } else if (index.getIndexStatus(key) == REGISTERED) { if (propertyKeyAlreadyExisted) { management.updateIndex(management.getGraphIndex(indexName), REINDEX).get();
assertEquals(name, graphIndex.getFieldKeys()[0].name()); assertEquals("internalindex", graphIndex.getBackingIndex()); assertEquals(SchemaStatus.ENABLED, graphIndex.getIndexStatus(graphIndex.getFieldKeys()[0])); finishSchema();
assertEquals(SchemaStatus.ENABLED, index.getIndexStatus(key)); assertEquals(SchemaStatus.DISABLED, index.getIndexStatus(key));
assertEquals(SchemaStatus.REGISTERED, pindex.getIndexStatus()); assertEquals(SchemaStatus.REGISTERED, eindex.getIndexStatus()); assertEquals(SchemaStatus.REGISTERED, graphIndex.getIndexStatus(graphIndex.getFieldKeys()[0])); finishSchema(); assertEquals(SchemaStatus.ENABLED, eindex.getIndexStatus()); assertEquals(SchemaStatus.ENABLED, pindex.getIndexStatus()); assertEquals(SchemaStatus.ENABLED, graphIndex.getIndexStatus(graphIndex.getFieldKeys()[0])); graphIndex = mgmt.getGraphIndex("bySensorReading"); assertEquals(SchemaStatus.DISABLED, pindex.getIndexStatus()); assertEquals(SchemaStatus.DISABLED, graphIndex.getIndexStatus(graphIndex.getFieldKeys()[0])); finishSchema();