private void NewTransaction() { if (_tx != null) { _tx.success(); _tx.close(); } _tx = _graph.beginTx(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotRollbackParentIfSuccessCalled() public virtual void ShouldNotRollbackParentIfSuccessCalled() { // When _placeboTx.success(); _placeboTx.close(); // Then verify(_kernelTransaction, never()).failure(); }
public override Void DoWork(HighlyAvailableGraphDatabase state) { if (_successful) { _tx.success(); } _tx.close(); return(null); }
public override void NotifyStatusChanged(object instance, LifecycleStatus from, LifecycleStatus to) { if ((LifecycleStatus.STOPPED == to) && (instance is RecordStorageEngine)) { Transaction.success(); Transaction.close(); TransactionClosedConflict = true; } }
private void Commit() { try { _tx.success(); } finally { _tx.close(); } }
public override void OnRepresentationWritten() { HttpResponseContext response = _httpContext.Response; int statusCode = response.Status; if (statusCode >= 200 && statusCode < 300) { _transaction.success(); } }
public virtual void FinishTx(bool success) { if (_tx != null) { if (success) { _tx.success(); } _tx.close(); _tx = null; } }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: private static org.neo4j.kernel.impl.util.Listener<org.neo4j.graphdb.GraphDatabaseService> uniquenessConstraint(final org.neo4j.graphdb.Label label, final String propertyKey) private static Listener <GraphDatabaseService> UniquenessConstraint(Label label, string propertyKey) { return(db => { using (Transaction tx = Db.beginTx()) { Db.schema().constraintFor(label).assertPropertyIsUnique(propertyKey).create(); tx.success(); } }); }
public virtual void Success() { try { if (_tx != null) { _tx.success(); _tx.close(); } } finally { _tx = null; } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldWriteOutThePropertyRecordBeforeReferencingItFromANodeRecord() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldWriteOutThePropertyRecordBeforeReferencingItFromANodeRecord() { Race race = new Race(); long[] latestNodeId = new long[1]; AtomicLong writes = new AtomicLong(); AtomicLong reads = new AtomicLong(); long endTime = currentTimeMillis() + SECONDS.toMillis(2); race.WithEndCondition(() => (writes.get() > 100 && reads.get() > 10_000) || currentTimeMillis() > endTime); race.AddContestant(() => { using (Transaction tx = Db.beginTx()) { Node node = Db.createNode(); latestNodeId[0] = node.Id; node.setProperty("largeProperty", LONG_STRING_VALUE); tx.success(); } writes.incrementAndGet(); }); race.AddContestant(() => { try { using (Transaction tx = Db.GraphDatabaseAPI.beginTx()) { Node node = Db.GraphDatabaseAPI.getNodeById(latestNodeId[0]); foreach (string propertyKey in node.PropertyKeys) { node.getProperty(propertyKey); } tx.success(); } } catch (NotFoundException e) { if (Exceptions.contains(e, typeof(InvalidRecordException))) { throw e; } } reads.incrementAndGet(); }); race.Go(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldWriteOutTheDynamicChainBeforeUpdatingThePropertyRecord() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldWriteOutTheDynamicChainBeforeUpdatingThePropertyRecord() { Race race = new Race(); long[] latestNodeId = new long[1]; AtomicLong writes = new AtomicLong(); AtomicLong reads = new AtomicLong(); long endTime = currentTimeMillis() + SECONDS.toMillis(2); race.WithEndCondition(() => (writes.get() > 100 && reads.get() > 10_000) || currentTimeMillis() > endTime); race.AddContestant(() => { using (Transaction tx = Db.beginTx()) { Node node = Db.createNode(); latestNodeId[0] = node.Id; node.setProperty("largeProperty", LONG_STRING_VALUE); tx.success(); } writes.incrementAndGet(); }); race.AddContestant(() => { try { using (Transaction tx = Db.GraphDatabaseAPI.beginTx()) { Node node = Db.GraphDatabaseAPI.getNodeById(latestNodeId[0]); foreach (string propertyKey in node.PropertyKeys) { node.getProperty(propertyKey); } tx.success(); } } catch (NotFoundException) { // This will catch nodes not found (expected) and also PropertyRecords not found (shouldn't happen // but handled in shouldWriteOutThePropertyRecordBeforeReferencingItFromANodeRecord) } reads.incrementAndGet(); }); race.Go(); }
//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 static org.neo4j.test.OtherThreadExecutor.WorkerCommand<Void, bool> createNode(final org.neo4j.graphdb.GraphDatabaseService db, final String label, final String propertyKey, final Object propertyValue) public static OtherThreadExecutor.WorkerCommand <Void, bool> CreateNode(GraphDatabaseService db, string label, string propertyKey, object propertyValue) { return(nothing => { try { using (Transaction tx = Db.beginTx()) { Db.createNode(label(label)).setProperty(propertyKey, propertyValue); tx.success(); return true; } } catch (ConstraintViolationException) { return false; } }); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void validateIndexedNodePropertiesInLucene() internal virtual void ValidateIndexedNodePropertiesInLucene() { setUp(default_schema_provider.name(), GraphDatabaseSettings.SchemaIndex.NATIVE10.providerName()); Label label = Label.label("indexedNodePropertiesTestLabel"); string propertyName = "indexedNodePropertyName"; CreateIndex(label, propertyName); using (Transaction ignored = _database.beginTx()) { _database.schema().awaitIndexesOnline(5, TimeUnit.MINUTES); } System.ArgumentException argumentException = assertThrows(typeof(System.ArgumentException), () => { using (Transaction transaction = _database.beginTx()) { Node node = _database.createNode(label); node.setProperty(propertyName, StringUtils.repeat("a", IndexWriter.MAX_TERM_LENGTH + 1)); transaction.success(); } }); assertThat(argumentException.Message, equalTo("Property value size is too large for index. Please see index documentation for limitations.")); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void validateIndexedNodePropertiesInNativeBtree() internal virtual void ValidateIndexedNodePropertiesInNativeBtree() { setUp(); Label label = Label.label("indexedNodePropertiesTestLabel"); string propertyName = "indexedNodePropertyName"; CreateIndex(label, propertyName); using (Transaction ignored = _database.beginTx()) { _database.schema().awaitIndexesOnline(5, TimeUnit.MINUTES); } System.ArgumentException argumentException = assertThrows(typeof(System.ArgumentException), () => { using (Transaction transaction = _database.beginTx()) { Node node = _database.createNode(label); node.setProperty(propertyName, StringUtils.repeat("a", keyValueSizeCapFromPageSize(PAGE_SIZE) + 1)); transaction.success(); } }); assertThat(argumentException.Message, containsString("is too large to index into this particular index. Please see index documentation for limitations.")); }
private void CloseTx() { _tx.success(); _tx.close(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotAllowConcurrentViolationOfConstraint() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotAllowConcurrentViolationOfConstraint() { // Given GraphDatabaseAPI graphDb = Db.GraphDatabaseAPI; System.Func <KernelTransaction> ktxSupplier = () => graphDb.DependencyResolver.resolveDependency(typeof(ThreadToStatementContextBridge)).getKernelTransactionBoundToThisThread(true); Label label = label("Foo"); string propertyKey = "bar"; string conflictingValue = "baz"; // a constraint using (Transaction tx = graphDb.BeginTx()) { graphDb.Schema().constraintFor(label).assertPropertyIsUnique(propertyKey).create(); tx.Success(); } // When using (Transaction tx = graphDb.BeginTx()) { KernelTransaction ktx = ktxSupplier(); int labelId = ktx.TokenRead().nodeLabel(label.Name()); int propertyKeyId = ktx.TokenRead().propertyKey(propertyKey); IndexDescriptor index = TestIndexDescriptorFactory.uniqueForLabel(labelId, propertyKeyId); Read read = ktx.DataRead(); using (NodeValueIndexCursor cursor = ktx.Cursors().allocateNodeValueIndexCursor()) { read.NodeIndexSeek(ktx.SchemaRead().index(labelId, propertyKeyId), cursor, IndexOrder.NONE, false, IndexQuery.exact(index.Schema().PropertyId, "The value is irrelevant, we just want to perform some sort of lookup against this " + "index")); } // then let another thread come in and create a node Threads.execute(Db => { using (Transaction transaction = Db.beginTx()) { Db.createNode(label).setProperty(propertyKey, conflictingValue); transaction.success(); } return(null); }, graphDb).get(); // before we create a node with the same property ourselves - using the same statement that we have // already used for lookup against that very same index long node = ktx.DataWrite().nodeCreate(); ktx.DataWrite().nodeAddLabel(node, labelId); try { ktx.DataWrite().nodeSetProperty(node, propertyKeyId, Values.of(conflictingValue)); fail("exception expected"); } // Then catch (UniquePropertyValueValidationException e) { assertEquals(ConstraintDescriptorFactory.uniqueForLabel(labelId, propertyKeyId), e.Constraint()); IndexEntryConflictException conflict = Iterators.single(e.Conflicts().GetEnumerator()); assertEquals(Values.stringValue(conflictingValue), conflict.SinglePropertyValue); } tx.Success(); } }