Beispiel #1
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public org.neo4j.graphdb.schema.Schema_IndexState getIndexState(final org.neo4j.graphdb.schema.IndexDefinition index)
        public override Org.Neo4j.Graphdb.schema.Schema_IndexState GetIndexState(IndexDefinition index)
        {
            KernelTransaction transaction = SafeAcquireTransaction(_transactionSupplier);

            try
            {
                using (Statement ignore = transaction.AcquireStatement())
                {
                    SchemaRead         schemaRead = transaction.SchemaRead();
                    IndexReference     reference  = GetIndexReference(schemaRead, transaction.TokenRead(), (IndexDefinitionImpl)index);
                    InternalIndexState indexState = schemaRead.IndexGetState(reference);
                    switch (indexState)
                    {
                    case InternalIndexState.POPULATING:
                        return(POPULATING);

                    case InternalIndexState.ONLINE:
                        return(ONLINE);

                    case InternalIndexState.FAILED:
                        return(FAILED);

                    default:
                        throw new System.ArgumentException(string.Format("Illegal index state {0}", indexState));
                    }
                }
            }
            catch (Exception e) when(e is SchemaRuleNotFoundException || e is IndexNotFoundKernelException)
            {
                throw NewIndexNotFoundException(index, e);
            }
        }
Beispiel #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static org.neo4j.internal.kernel.api.IndexReference awaitOnline(org.neo4j.internal.kernel.api.SchemaRead schemRead, org.neo4j.internal.kernel.api.IndexReference index) throws org.neo4j.internal.kernel.api.exceptions.KernelException
        private static IndexReference AwaitOnline(SchemaRead schemRead, IndexReference index)
        {
            long start = DateTimeHelper.CurrentUnixTimeMillis();
            long end   = start + 20_000;

            while (DateTimeHelper.CurrentUnixTimeMillis() < end)
            {
                switch (schemRead.IndexGetState(index))
                {
                case ONLINE:
                    return(index);

                case FAILED:
                    throw new System.InvalidOperationException("Index failed instead of becoming ONLINE");

                default:
                    break;
                }

                try
                {
                    Thread.Sleep(100);
                }
                catch (InterruptedException)
                {
                    // ignored
                }
            }
            throw new System.InvalidOperationException("Index did not become ONLINE within reasonable time");
        }
Beispiel #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void awaitIndexOnline(org.neo4j.internal.kernel.api.SchemaRead schemaRead, org.neo4j.internal.kernel.api.IndexReference index) throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException
        public static void AwaitIndexOnline(SchemaRead schemaRead, IndexReference index)
        {
            long start = DateTimeHelper.CurrentUnixTimeMillis();

            while (schemaRead.IndexGetState(index) != InternalIndexState.ONLINE)
            {
                if (start + 1000 * 10 < DateTimeHelper.CurrentUnixTimeMillis())
                {
                    throw new Exception("Index didn't come online within a reasonable time.");
                }
            }
        }
Beispiel #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static org.neo4j.kernel.api.KernelTransaction mockKernelTransaction() throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException
        private static KernelTransaction MockKernelTransaction()
        {
            SchemaRead schemaRead = mock(typeof(SchemaRead));

            when(schemaRead.IndexGetState(any(typeof(IndexReference)))).thenReturn(InternalIndexState.FAILED);
            when(schemaRead.IndexGetFailure(any(typeof(IndexReference)))).thenReturn(Exceptions.stringify(_cause));

            KernelTransaction kt = mock(typeof(KernelTransaction));

            when(kt.TokenRead()).thenReturn(mock(typeof(TokenRead)));
            when(kt.SchemaRead()).thenReturn(schemaRead);
            when(kt.Terminated).thenReturn(false);
            when(kt.AcquireStatement()).thenReturn(mock(typeof(Statement)));
            return(kt);
        }