//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @TestFactory Stream<org.junit.jupiter.api.DynamicTest> testMildlyForFalseDeadlocks() internal virtual Stream <DynamicTest> TestMildlyForFalseDeadlocks() { ThrowingConsumer <Fixture> fixtureConsumer = fixture => loopRunTest(fixture, TEST_RUNS); //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: return(DynamicTest.stream(Fixtures(), Fixture::toString, fixtureConsumer)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void verifyAsyncActionCausesConcurrentFlushingRush(org.neo4j.function.ThrowingConsumer<CheckPointerImpl,java.io.IOException> asyncAction) throws Exception private void VerifyAsyncActionCausesConcurrentFlushingRush(ThrowingConsumer <CheckPointerImpl, IOException> asyncAction) { AtomicLong limitDisableCounter = new AtomicLong(); AtomicLong observedRushCount = new AtomicLong(); BinaryLatch backgroundCheckPointStartedLatch = new BinaryLatch(); BinaryLatch forceCheckPointStartLatch = new BinaryLatch(); _limiter = new IOLimiterAnonymousInnerClass4(this, limitDisableCounter, forceCheckPointStartLatch); MockTxIdStore(); CheckPointerImpl checkPointer = checkPointer(); doAnswer(invocation => { backgroundCheckPointStartedLatch.Release(); forceCheckPointStartLatch.Await(); long newValue = limitDisableCounter.get(); observedRushCount.set(newValue); return(null); }).when(_storageEngine).flushAndForce(_limiter); Future <object> forceCheckPointer = forkFuture(() => { backgroundCheckPointStartedLatch.Await(); asyncAction.Accept(checkPointer); return(null); }); when(_threshold.isCheckPointingNeeded(anyLong(), eq(_info))).thenReturn(true); checkPointer.CheckPointIfNeeded(_info); forceCheckPointer.get(); assertThat(observedRushCount.get(), @is(1L)); }
public Procedures(EmbeddedProxySPI proxySPI, ThrowingConsumer <Procedures, ProcedureException> builtin, File pluginDir, Log log, ProcedureConfig config) { this._builtin = builtin; this._pluginDir = pluginDir; this._log = log; this._typeMappers = new TypeMappers(proxySPI); this._compiler = new ReflectiveProcedureCompiler(_typeMappers, _safeComponents, _allComponents, log, config); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private ArchiveOperation(org.neo4j.function.ThrowingConsumer<org.apache.commons.compress.archivers.ArchiveOutputStream, java.io.IOException> operation, java.nio.file.Path root, java.nio.file.Path file) throws java.io.IOException internal ArchiveOperation(ThrowingConsumer <ArchiveOutputStream, IOException> operation, Path root, Path file) { this.Operation = operation; this.IsFile = Files.isRegularFile(file); this.Size = IsFile ? Files.size(file) : 0; this.Root = root; this.File = file; }
private void InitializeInstanceFields() { _init = Lifecycle.init; _start = Lifecycle.start; _stop = Lifecycle.stop; _shutdown = Lifecycle.shutdown; _ops = new ThrowingConsumer[] { _init, _start, _stop, _shutdown }; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void testDisconnectWithUnpackableValue(org.neo4j.function.ThrowingConsumer<org.neo4j.bolt.messaging.Neo4jPack_Packer, java.io.IOException> valuePacker, String expectedMessage) throws Exception private void TestDisconnectWithUnpackableValue(ThrowingConsumer <Org.Neo4j.Bolt.messaging.Neo4jPack_Packer, IOException> valuePacker, string expectedMessage) { _connection.connect(_address).send(_util.defaultAcceptedVersions()); assertThat(_connection, _util.eventuallyReceivesSelectedProtocolVersion()); _connection.send(_util.chunk(new InitMessage(USER_AGENT, Collections.emptyMap()))); assertThat(_connection, _util.eventuallyReceives(msgSuccess())); _connection.send(_util.chunk(64, CreateRunWith(valuePacker))); assertThat(_connection, eventuallyDisconnects()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void runFailing(org.neo4j.function.ThrowingConsumer<SuspendableLifeCycle,Throwable> consumer) throws Throwable private void RunFailing(ThrowingConsumer <SuspendableLifeCycle, Exception> consumer) { try { consumer.Accept(_lifeCycle); fail(); } catch (System.InvalidOperationException) { } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void updateStore(final Store store, long transaction) throws java.io.IOException //JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: private void UpdateStore(Store store, long transaction) { ThrowingConsumer <long, IOException> update = u => { using (EntryUpdater <string> updater = store.Updater(u).get()) { updater.Apply("key " + u, Value("value " + u)); } }; update.Accept(transaction); }
internal virtual void Start(ThrowingConsumer <Clock, Exception> electionAction, ThrowingConsumer <Clock, Exception> heartbeatAction) { lock (this) { this._electionTimer = _timerService.create(Timeouts.ELECTION, Group.RAFT_TIMER, Renewing(electionAction)); this._electionTimer.set(uniformRandomTimeout(_electionTimeout, _electionTimeout * 2, MILLISECONDS)); this._heartbeatTimer = _timerService.create(Timeouts.HEARTBEAT, Group.RAFT_TIMER, Renewing(heartbeatAction)); this._heartbeatTimer.set(fixedTimeout(_heartbeatInterval, MILLISECONDS)); _lastElectionRenewalMillis = _clock.millis(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.neo4j.bolt.v1.runtime.bookmarking.Bookmark streamResult(org.neo4j.function.ThrowingConsumer<org.neo4j.bolt.runtime.BoltResult, Exception> resultConsumer) throws Exception public override Bookmark StreamResult(ThrowingConsumer <BoltResult, Exception> resultConsumer) { Before(); try { EnsureNoPendingTerminationNotice(); return(StateConflict.streamResult(Ctx, Spi, resultConsumer)); } finally { After(); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private byte[] createRunWith(org.neo4j.function.ThrowingConsumer<org.neo4j.bolt.messaging.Neo4jPack_Packer, java.io.IOException> valuePacker) throws java.io.IOException private sbyte[] CreateRunWith(ThrowingConsumer <Org.Neo4j.Bolt.messaging.Neo4jPack_Packer, IOException> valuePacker) { PackedOutputArray @out = new PackedOutputArray(); Org.Neo4j.Bolt.messaging.Neo4jPack_Packer packer = (new Neo4jPackV2()).newPacker(@out); packer.PackStructHeader(2, RunMessage.SIGNATURE); packer.Pack("RETURN $x"); packer.PackMapHeader(1); packer.Pack("x"); valuePacker.Accept(packer); return(@out.Bytes()); }
private void ForEachPopulation(ThrowingConsumer <IndexPopulation, Exception> action) { foreach (IndexPopulation population in Populations) { try { action.Accept(population); } catch (Exception failure) { Fail(population, failure); } } }
private void ForToken(ThrowingConsumer <Token, KernelException> f) { try { using (Transaction tx = beginTransaction()) { f.Accept(tx.Token()); } } catch (KernelException e) { fail("Unwanted exception: " + e.Message); } }
private TimeoutHandler Renewing(ThrowingConsumer <Clock, Exception> action) { return(timeout => { try { action.Accept(_clock); } catch (Exception e) { _log.error("Failed to process timeout.", e); } timeout.reset(); }); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: void write(org.neo4j.storageengine.api.WritableChannel channel) throws java.io.IOException internal virtual void Write(WritableChannel channel) { NextJob.accept(channel); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: if (Commands.hasNext()) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: StorageCommand storageCommand = Commands.next(); NextJob = c => (new StorageCommandSerializer(c)).visit(storageCommand); } else { NextJob = null; } }
private ThrowingFunction <CyclicBarrier, Node, Exception> MergeThen <T1>(ThrowingConsumer <T1> action) where T1 : Exception { return(barrier => { using (Transaction tx = Db.beginTx()) { Node node = MergeNode(); barrier.await(); action.Accept(node); tx.success(); return node; } }); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: void withPopulator(IndexPopulator populator, org.neo4j.function.ThrowingConsumer<IndexPopulator,Exception> runWithPopulator, boolean closeSuccessfully) throws Exception internal virtual void WithPopulator(IndexPopulator populator, ThrowingConsumer <IndexPopulator, Exception> runWithPopulator, bool closeSuccessfully) { try { populator.Create(); runWithPopulator.Accept(populator); if (closeSuccessfully) { populator.ScanCompleted(Org.Neo4j.Kernel.Impl.Api.index.PhaseTracker_Fields.NullInstance); TestSuite.consistencyCheck(populator); } } finally { populator.Close(closeSuccessfully); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @TestFactory Stream<org.junit.jupiter.api.DynamicTest> shouldGetAndSetRandomItems() internal virtual Stream <DynamicTest> ShouldGetAndSetRandomItems() { ThrowingConsumer <NumberArrayTestData> throwingConsumer = data => { using (NumberArray array = data.array) { IDictionary <int, object> key = new Dictionary <int, object>(); Reader reader = data.reader; object defaultValue = reader.read(array, 0); // WHEN setting random items for (int i = 0; i < INDEXES * 2; i++) { int index = _random.Next(INDEXES); object value = data.valueGenerator.apply(_random); data.writer.write(i % 2 == 0 ? array : array.at(index), index, value); key.put(index, value); } // THEN they should be read correctly AssertAllValues(key, defaultValue, reader, array); // AND WHEN swapping some for (int i = 0; i < INDEXES / 2; i++) { int fromIndex = _random.Next(INDEXES); int toIndex; do { toIndex = _random.Next(INDEXES); } while (toIndex == fromIndex); object fromValue = reader.read(array, fromIndex); object toValue = reader.read(array, toIndex); key.put(fromIndex, toValue); key.put(toIndex, fromValue); array.swap(fromIndex, toIndex); } // THEN they should end up in the correct places AssertAllValues(key, defaultValue, reader, array); } }; return(DynamicTest.stream(Arrays().GetEnumerator(), data => data.name, throwingConsumer)); }
private void AssertIllegalToken(ThrowingConsumer <Token, KernelException> f) { try { using (Transaction tx = beginTransaction()) { f.Accept(tx.Token()); fail("Expected IllegalTokenNameException"); } } catch (IllegalTokenNameException) { // wanted } catch (KernelException e) { fail("Unwanted exception: " + e.Message); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @TestFactory Stream<org.junit.jupiter.api.DynamicTest> shouldHandleSomeRandomSetAndGet() internal virtual Stream <DynamicTest> ShouldHandleSomeRandomSetAndGet() { // GIVEN ThrowingConsumer <NumberArrayFactory> arrayFactoryConsumer = factory => { int length = _random.Next(100_000) + 100; int defaultValue = _random.Next(2) - 1; // 0 or -1 using (IntArray array = factory.newIntArray(length, defaultValue)) { int[] expected = new int[length]; Arrays.Fill(expected, defaultValue); // WHEN int operations = _random.Next(1_000) + 10; for (int i = 0; i < operations; i++) { // THEN int index = _random.Next(length); int value = _random.Next(); switch (_random.Next(3)) { case 0: // set array.Set(index, value); expected[index] = value; break; case 1: // get assertEquals(expected[index], array.Get(index), "Seed:" + _seed); break; default: // swap int toIndex = _random.Next(length); array.Swap(index, toIndex); Swap(expected, index, toIndex); break; } } } }; return(stream(ArrayFactories(), NumberArrayFactoryName, arrayFactoryConsumer)); }
/// <summary> /// Method for calling a lambda function on many objects when it is expected that the function might /// throw an exception. First exception will be thrown and subsequent will be suppressed. /// This method guarantees that all subjects will be consumed, unless <seealso cref="System.OutOfMemoryException"/> or some other serious error happens. /// </summary> /// <param name="consumer"> lambda function to call on each object passed </param> /// <param name="subjects"> <seealso cref="System.Collections.IEnumerable"/> of objects to call the function on </param> /// @param <E> the type of exception anticipated, inferred from the lambda </param> /// <exception cref="E"> if consumption fails with this exception </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static <T, E extends Exception> void safeForAll(org.neo4j.function.ThrowingConsumer<T,E> consumer, Iterable<T> subjects) throws E public static void SafeForAll <T, E>(ThrowingConsumer <T, E> consumer, IEnumerable <T> subjects) where E : Exception { E exception = null; foreach (T instance in subjects) { try { consumer.Accept(instance); } catch (Exception e) { exception = Exceptions.chain(exception, ( E )e); } } if (exception != null) { throw exception; } }
internal TransactionRepresentationWriter(TransactionRepresentation tx) { NextJob = channel => { channel.putInt(tx.AuthorId); channel.putInt(tx.MasterId); channel.putLong(tx.LatestCommittedTxWhenStarted); channel.putLong(tx.TimeStarted); channel.putLong(tx.TimeCommitted); channel.putInt(tx.LockSessionId); sbyte[] additionalHeader = tx.AdditionalHeader(); if (additionalHeader != null) { channel.putInt(additionalHeader.Length); channel.put(additionalHeader, additionalHeader.Length); } else { channel.putInt(0); } }; Commands = tx.GetEnumerator(); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: void withPopulator(IndexPopulator populator, org.neo4j.function.ThrowingConsumer<IndexPopulator,Exception> runWithPopulator) throws Exception internal virtual void WithPopulator(IndexPopulator populator, ThrowingConsumer <IndexPopulator, Exception> runWithPopulator) { WithPopulator(populator, runWithPopulator, true); }
public DecoratorAnonymousInnerClass3(FileVisitor <Path> wrapped, ThrowingConsumer <Path, IOException> operation) : base(wrapped) { this._operation = operation; }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void withEntry(org.neo4j.function.ThrowingConsumer<org.apache.commons.compress.archivers.ArchiveOutputStream, java.io.IOException> operation, java.nio.file.Path root, java.nio.file.Path file) throws java.io.IOException private void WithEntry(ThrowingConsumer <ArchiveOutputStream, IOException> operation, Path root, Path file) { _operations.Add(new ArchiveOperation(operation, root, file)); }
/// <summary> /// See <seealso cref="forAll(ThrowingConsumer, object[])"/> /// /// Method for calling a lambda function on many objects when it is expected that the function might /// throw an exception. First exception will be thrown and subsequent will be suppressed. /// /// For example, in FusionIndexAccessor: /// <pre> /// public void drop() throws IOException /// { /// forAll( IndexAccessor::drop, accessorList ); /// } /// </pre> /// </summary> /// <param name="consumer"> lambda function to call on each object passed </param> /// <param name="subjects"> <seealso cref="System.Collections.IEnumerable"/> of objects to call the function on </param> /// @param <E> the type of exception anticipated, inferred from the lambda </param> /// <exception cref="E"> if consumption fails with this exception </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static <T, E extends Exception> void forAll(org.neo4j.function.ThrowingConsumer<T,E> consumer, Iterable<T> subjects) throws E public static void ForAll <T, E>(ThrowingConsumer <T, E> consumer, IEnumerable <T> subjects) where E : Exception { Iterables.safeForAll(consumer, subjects); }
/// <summary> /// See <seealso cref="forAll(ThrowingConsumer, System.Collections.IEnumerable)"/> /// /// Method for calling a lambda function on many objects when it is expected that the function might /// throw an exception. First exception will be thrown and subsequent will be suppressed. /// /// For example, in FusionIndexAccessor: /// <pre> /// public void drop() throws IOException /// { /// forAll( IndexAccessor::drop, firstAccessor, secondAccessor, thirdAccessor ); /// } /// </pre> /// </summary> /// <param name="consumer"> lambda function to call on each object passed </param> /// <param name="subjects"> varargs array of objects to call the function on </param> /// @param <E> the type of exception anticipated, inferred from the lambda </param> /// <exception cref="E"> if consumption fails with this exception </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public static <T, E extends Exception> void forAll(org.neo4j.function.ThrowingConsumer<T,E> consumer, T[] subjects) throws E public static void ForAll <T, E>(ThrowingConsumer <T, E> consumer, T[] subjects) where E : Exception { ForAll(consumer, Arrays.asList(subjects)); }
/// <summary> /// Iterate over some schema suppliers, and invoke a callback for every supplier that matches the node. To match the /// node N the supplier must supply a LabelSchemaDescriptor D, such that N has the label of D, and values for all /// the properties of D. /// <para> /// To avoid unnecessary store lookups, this implementation only gets propertyKeyIds for the node if some /// descriptor has a valid label. /// /// </para> /// </summary> /// @param <SUPPLIER> the type to match. Must implement SchemaDescriptorSupplier </param> /// @param <EXCEPTION> The type of exception that can be thrown when taking the action </param> /// <param name="schemaSuppliers"> The suppliers to match </param> /// <param name="specialPropertyId"> This property id will always count as a match for the descriptor, regardless of /// whether the node has this property or not </param> /// <param name="existingPropertyIds"> sorted array of property ids for the entity to match schema for. </param> /// <param name="callback"> The action to take on match </param> /// <exception cref="EXCEPTION"> This exception is propagated from the action </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: static <SUPPLIER extends org.neo4j.internal.kernel.api.schema.SchemaDescriptorSupplier, EXCEPTION extends Exception> void onMatchingSchema(java.util.Iterator<SUPPLIER> schemaSuppliers, long[] labels, int specialPropertyId, int[] existingPropertyIds, org.neo4j.function.ThrowingConsumer<SUPPLIER,EXCEPTION> callback) throws EXCEPTION internal static void OnMatchingSchema <SUPPLIER, EXCEPTION>(IEnumerator <SUPPLIER> schemaSuppliers, long[] labels, int specialPropertyId, int[] existingPropertyIds, ThrowingConsumer <SUPPLIER, EXCEPTION> callback) where SUPPLIER : [email protected] where EXCEPTION : Exception { Debug.Assert(isSortedSet(existingPropertyIds)); Debug.Assert(isSortedSet(labels)); while (schemaSuppliers.MoveNext()) { SUPPLIER schemaSupplier = schemaSuppliers.Current; SchemaDescriptor schema = schemaSupplier.schema(); if (!Schema.isAffected(labels)) { continue; } if (NodeHasSchemaProperties(existingPropertyIds, Schema.PropertyIds, specialPropertyId)) { callback.Accept(schemaSupplier); } } }
/// <summary> /// In order to avoid browsers popping up an auth box when using the Neo4j Browser, it sends us a special header. /// When we get that special header, we send a crippled authentication challenge back that the browser does not /// understand, which lets the Neo4j Browser handle auth on its own. /// /// Otherwise, we send a regular basic auth challenge. This method adds the appropriate header depending on the /// inbound request. /// </summary> private static ThrowingConsumer <HttpServletResponse, IOException> RequestAuthentication(HttpServletRequest req, ThrowingConsumer <HttpServletResponse, IOException> responseGen) { if ("true".Equals(req.getHeader("X-Ajax-Browser-Auth"))) { return(res => { responseGen.Accept(res); res.addHeader(HttpHeaders.WWW_AUTHENTICATE, "None"); }); } else { return(res => { responseGen.Accept(res); res.addHeader(HttpHeaders.WWW_AUTHENTICATE, "Basic realm=\"Neo4j\""); }); } }
internal TwoPhaseNodeForRelationshipLocking(ThrowingConsumer <long, KernelException> relIdAction, Org.Neo4j.Kernel.impl.locking.Locks_Client locks, LockTracer lockTracer) { this._relIdAction = relIdAction; this._locks = locks; this._lockTracer = lockTracer; }