org.neo4j.graphdb.schema.Schema.getIndexFailure()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中org.neo4j.graphdb.schema.Schema.getIndexFailure()方法的一些代码示例,展示了Schema.getIndexFailure()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Schema.getIndexFailure()方法的具体详情如下:
包路径:org.neo4j.graphdb.schema.Schema
类名称:Schema
方法名:getIndexFailure

Schema.getIndexFailure介绍

[英]If #getIndexState(IndexDefinition) return IndexState#FAILED this method will return the failure description.
[中]如果#getIndexState(IndexDefinition)返回IndexState#失败,此方法将返回失败描述。

代码示例

代码示例来源:origin: neo4j/neo4j

private boolean indexesAreOnline( GraphDatabaseService db )
{
  try ( Transaction tx = db.beginTx() )
  {
    for ( IndexDefinition index : db.schema().getIndexes() )
    {
      switch ( db.schema().getIndexState( index ) )
      {
      case ONLINE:
        break; // Good
      case POPULATING:
        return false; // Still populating
      case FAILED:
        fail( index + " entered failed state: " + db.schema().getIndexFailure( index ) );
      default:
        throw new UnsupportedOperationException();
      }
    }
    tx.success();
  }
  return true;
}

代码示例来源:origin: neo4j/neo4j

@Test
public void uniquenessConstraintShouldBeCheckedOnBatchInserterShutdownAndFailIfViolated() throws Exception
{
  // Given
  Label label = label( "Foo" );
  String property = "Bar";
  String value = "Baz";
  BatchInserter inserter = newBatchInserter();
  // When
  inserter.createDeferredConstraint( label ).assertPropertyIsUnique( property ).create();
  inserter.createNode( Collections.singletonMap( property, value ), label );
  inserter.createNode( Collections.singletonMap( property, value ), label );
  // Then
  GraphDatabaseService db = switchToEmbeddedGraphDatabaseService( inserter );
  try ( Transaction tx = db.beginTx() )
  {
    IndexDefinition index = db.schema().getIndexes( label ).iterator().next();
    String indexFailure = db.schema().getIndexFailure( index );
    assertThat( indexFailure, containsString( "IndexEntryConflictException" ) );
    assertThat( indexFailure, containsString( value ) );
    tx.success();
  }
  finally
  {
    db.shutdown();
  }
}

代码示例来源:origin: neo4j/neo4j

@Test
void validateNodePropertiesOnPopulation()
{
  setUp();
  Label label = Label.label( "populationTestNodeLabel" );
  String propertyName = "populationTestPropertyName";
  try ( Transaction transaction = database.beginTx() )
  {
    Node node = database.createNode( label );
    node.setProperty( propertyName, StringUtils.repeat( "a", IndexWriter.MAX_TERM_LENGTH + 1 ) );
    transaction.success();
  }
  IndexDefinition indexDefinition = createIndex( label, propertyName );
  try
  {
    try ( Transaction ignored = database.beginTx() )
    {
      database.schema().awaitIndexesOnline( 5, TimeUnit.MINUTES );
    }
  }
  catch ( IllegalStateException e )
  {
    try ( Transaction ignored = database.beginTx() )
    {
      String indexFailure = database.schema().getIndexFailure( indexDefinition );
      assertThat( "", indexFailure, Matchers.containsString(
          "java.lang.IllegalArgumentException: Index key-value size it to large. Please see index documentation for limitations." ) );
    }
  }
}

代码示例来源:origin: neo4j/neo4j

IndexDefinition next = iterator.next();
assertEquals( "state is FAILED", Schema.IndexState.FAILED, db.schema().getIndexState( next ) );
assertThat( db.schema().getIndexFailure( next ),
    Matchers.containsString( "Index key-value size it to large. Please see index documentation for limitations." ) );
tx.success();

代码示例来源:origin: org.neo4j/neo4j-shell

@Override
public String getIndexFailure( IndexDefinition index )
{
  return actual.getIndexFailure( index );
}

代码示例来源:origin: org.neo4j/neo4j-shell

if ( verbose && state == IndexState.FAILED )
  printer.addRaw( schema.getIndexFailure( index ) );

相关文章