//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: protected void run(org.neo4j.helpers.Args args, java.io.PrintStream out) throws Exception protected internal override void Run( Args args, PrintStream @out ) { DependencyResolver dependencyResolver = _to.get().DependencyResolver; TransactionIdStore txIdStore = dependencyResolver.ResolveDependency( typeof( TransactionIdStore ) ); Config config = dependencyResolver.ResolveDependency( typeof( Config ) ); long fromTx = txIdStore.LastCommittedTransaction.transactionId(); long toTx; if ( args.Orphans().Count == 0 ) { throw new System.ArgumentException( "No tx specified" ); } string whereTo = args.Orphans()[0]; if ( whereTo.Equals( "next" ) ) { toTx = fromTx + 1; } else if ( whereTo.Equals( "last" ) ) { toTx = long.MaxValue; } else { toTx = long.Parse( whereTo ); } long lastApplied = ApplyTransactions( _from, _to.get(), config, fromTx, toTx, @out ); @out.println( "Applied transactions up to and including " + lastApplied ); }
/// <summary> /// You MUST hold a schema write lock before you call this method. /// </summary> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void dropUniquenessConstraintIndex(org.neo4j.storageengine.api.schema.IndexDescriptor descriptor) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException public virtual void DropUniquenessConstraintIndex(IndexDescriptor descriptor) { using (Transaction transaction = _kernelSupplier.get().beginTransaction(@implicit, AUTH_DISABLED), Statement ignore = ((KernelTransaction)transaction).acquireStatement()) { (( KernelTransactionImplementation )transaction).txState().indexDoDrop(descriptor); transaction.Success(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Override public void log(@Nonnull String message) public override void Log(string message) { requireNonNull(message, "message must not be null"); PrintWriter writer; lock ( @lock ) { writer = _writerSupplier.get(); WriteLog(writer, message); } MaybeFlush(writer); }
private TransactionIdStore TransactionIdStore() { // We need to resolve this as late as possible in case the database has been restarted as part of store copy. // This causes TransactionIdStore staleness and we could get a MetaDataStore closed exception. // Ideally we'd fix this with some life cycle wizardry but not going to do that for now. return(_transactionIdStoreSupplier.get()); }
public override Neo4jTransactionalContext NewContext(ClientConnectionInfo clientConnection, InternalTransaction tx, string queryText, MapValue queryParameters) { Statement initialStatement = _statementSupplier.get(); ClientConnectionInfo connectionWithUserName = clientConnection.WithUsername(tx.SecurityContext().subject().username()); ExecutingQuery executingQuery = initialStatement.QueryRegistration().startQueryExecution(connectionWithUserName, queryText, queryParameters); return(_contextCreator.create(tx, initialStatement, executingQuery)); }
internal virtual void TickAndCheck() { KernelTransactionMonitor timeoutMonitor = MonitorSupplier.get(); if ( timeoutMonitor != null ) { _fakeClock.forward( 1, TimeUnit.SECONDS ); timeoutMonitor.Run(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") public RECORD[] newBatchObject(int batchSize) public virtual RECORD[] NewBatchObject(int batchSize) { object array = Array.CreateInstance(_klass, batchSize); for (int i = 0; i < batchSize; i++) { (( Array )array).SetValue(_factory.get(), i); } return(( RECORD[] )array); }
public override void AssertInOpenTransaction() { KernelTransaction transaction = TransactionSupplier.get(); if (transaction.Terminated) { Status terminationReason = transaction.ReasonIfTerminated.orElse(Org.Neo4j.Kernel.Api.Exceptions.Status_Transaction.Terminated); throw new TransactionTerminatedException(terminationReason); } }
public virtual Response <T> PackTransactionStreamResponse <T>(RequestContext context, T response) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long toStartFrom = context.lastAppliedTransaction() + 1; long toStartFrom = context.LastAppliedTransaction() + 1; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long toEndAt = transactionIdStore.getLastCommittedTransactionId(); long toEndAt = _transactionIdStore.LastCommittedTransactionId; TransactionStream transactions = visitor => { // Check so that it's even worth thinking about extracting any transactions at all if (toStartFrom > BASE_TX_ID && toStartFrom <= toEndAt) { ExtractTransactions(toStartFrom, FilterVisitor(visitor, toEndAt)); } }; return(new TransactionStreamResponse <T>(response, StoreId.get(), transactions, Org.Neo4j.com.ResourceReleaser_Fields.NoOp)); }
public override void Start() { lock (this) { _state = TX_PULLING; _timer = _timerService.create(TX_PULLER_TIMER, Group.PULL_UPDATES, timeout => onTimeout()); _timer.set(fixedTimeout(_txPullIntervalMillis, MILLISECONDS)); _dbHealth = _databaseHealthSupplier.get(); _upToDateFuture = new CompletableFuture <bool>(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Override public void bulk(@Nonnull Consumer<Log> consumer) public override void Bulk(Consumer <Log> consumer) { PrintWriter writer; lock ( Lock ) { writer = _writerSupplier.get(); consumer.accept(new FormattedLog(Suppliers.singleton(writer), ZoneId, Lock, _category, _levelRef.get(), false)); } if (AutoFlush) { writer.flush(); } }
public BackupOutcome DoFullBackup(final string sourceHostNameOrIp, final int sourcePort, DatabaseLayout targetLayout, ConsistencyCheck consistencyCheck, Config tuningConfiguration, final long timeout, final bool forensics) { try { using (FileSystemAbstraction fileSystem = _fileSystemSupplier.get()) { return(FullBackup(fileSystem, sourceHostNameOrIp, sourcePort, targetLayout, consistencyCheck, tuningConfiguration, timeout, forensics)); } } catch (IOException e) { throw new Exception(e); } }
private void ZapPage(long?pageId) { try { using (PageCursor cursor = _cursorSupplier.get()) { cursor.Next(pageId.Value); cursor.ZapPage(); } } catch (IOException) { throw new Exception("Could not go to page " + pageId); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") @Override public java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> calculate(TestTarget target, java.util.Set<com.opengamma.strata.calc.Measure> measures, CalculationParameters parameters, com.opengamma.strata.data.scenario.ScenarioMarketData marketData, com.opengamma.strata.basics.ReferenceData refData) //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: public IDictionary <Measure, Result <object> > calculate(TestTarget target, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData marketData, ReferenceData refData) { T obj = supplier.get(); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: if (obj instanceof com.opengamma.strata.collect.result.Result<?>) if (obj is Result <object> ) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: return com.google.common.collect.ImmutableMap.of(com.opengamma.strata.calc.TestingMeasures.PRESENT_VALUE, (com.opengamma.strata.collect.result.Result<?>) obj); return(ImmutableMap.of(TestingMeasures.PRESENT_VALUE, (Result <object>)obj)); } ScenarioArray <object> array = ScenarioArray.of(obj); return(ImmutableMap.of(TestingMeasures.PRESENT_VALUE, Result.success(array))); }
private void ApplyJob() { while (_applierState.keepRunning) { try { ApplyUpTo(_applierState.awaitJob()); } catch (Exception e) { _applierState.panic(); _log.error("Failed to apply", e); _dbHealth.get().panic(e); return; // LET THREAD DIE } } }
private IDictionary <string, string> GetOrCreateIndexConfig(IndexEntityType entityType, string indexName, IDictionary <string, string> suppliedConfig) { IDictionary <string, string> config = FindIndexConfig(entityType.entityClass(), indexName, suppliedConfig, this._config); if (!_indexStore.has(entityType.entityClass(), indexName)) { // Ok, we need to create this config lock (this) { // Were we the first ones to get here? IDictionary <string, string> existing = _indexStore.get(entityType.entityClass(), indexName); if (existing != null) { // No, someone else made it before us, cool AssertConfigMatches(_explicitIndexProvider.getProviderByName(existing[PROVIDER]), indexName, existing, config); return(config); } // We were the first one here, let's create this config try { using (Transaction transaction = _kernel.get().beginTransaction([email protected]_Type.Implicit, AUTH_DISABLED), Statement statement = ((KernelTransaction)transaction).acquireStatement()) { switch (entityType.innerEnumValue) { case Node: transaction.IndexWrite().nodeExplicitIndexCreate(indexName, config); break; case Relationship: transaction.IndexWrite().relationshipExplicitIndexCreate(indexName, config); break; default: throw new System.ArgumentException("Unknown entity type: " + entityType); } transaction.Success(); } } catch (Exception ex) { throw new TransactionFailureException("Index creation failed for " + indexName + ", " + config, ex); } } } return(config); }
protected internal override void DoWork() { GraphDatabaseService db = _dbRef.get(); try { using (Transaction tx = Db.beginTx()) { Node node = Db.createNode(_label); for (int i = 1; i <= 8; i++) { node.SetProperty(Prop(i), "let's add some data here so the transaction logs rotate more often..."); } tx.Success(); } } catch (Exception e) when(e is DatabaseShutdownException || e is TransactionFailureException || e is TransientFailureException) { // whatever let's go on with the workload } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void upgradeIndex(java.nio.file.Path indexPath) throws Throwable public virtual void UpgradeIndex(Path indexPath) { // since lucene use ServiceLocator to load services, context class loader need to be replaced as well ClassLoader contextClassLoader = Thread.CurrentThread.ContextClassLoader; try { if (_mainMethod == null) { _luceneLoader = _jarLoaderSupplier.get(); Type upgrader = _luceneLoader.loadEmbeddedClass(LUCENE_INDEX_UPGRADER_CLASS_NAME); MethodHandles.Lookup lookup = MethodHandles.lookup(); _mainMethod = lookup.findStatic(upgrader, "main", MethodType.methodType(typeof(void), typeof(string[]))); } Thread.CurrentThread.ContextClassLoader = _luceneLoader.JarsClassLoader; _mainMethod.invokeExact(new string[] { indexPath.ToString() }); } finally { Thread.CurrentThread.ContextClassLoader = contextClassLoader; } }
private sbyte[] CreateCommands(string tokenName) { StorageEngine storageEngine = _storageEngineSupplier.get(); ICollection <StorageCommand> commands = new List <StorageCommand>(); TransactionState txState = new TxState(); int tokenId = Math.toIntExact(_idGeneratorFactory.get(_tokenIdType).nextId()); _tokenCreator.createToken(txState, tokenName, tokenId); try { using (StorageReader statement = storageEngine.NewReader()) { storageEngine.CreateCommands(commands, txState, statement, [email protected]_Fields.None, long.MaxValue, NO_DECORATION); } } catch (Exception e) when(e is CreateConstraintFailureException || e is TransactionFailureException || e is ConstraintValidationException) { throw new Exception("Unable to create token '" + tokenName + "'", e); } return(ReplicatedTokenRequestSerializer.CommandBytes(commands)); }
public override void Run() { if (!MoveToRunningState()) { return; } try { _monitor.startedDownloadingSnapshot(); _applicationProcess.pauseApplier(OPERATION_NAME); while (_keepRunning && !_downloader.downloadSnapshot(_addressProvider)) { Thread.Sleep(_timeout.Millis); _timeout.increment(); } } catch (InterruptedException) { Thread.CurrentThread.Interrupt(); _log.warn("Persistent snapshot downloader was interrupted"); } catch (DatabaseShutdownException e) { _log.warn("Store copy aborted due to shut down", e); } catch (Exception e) { _log.error("Unrecoverable error during store copy", e); _dbHealth.get().panic(e); } finally { _applicationProcess.resumeApplier(OPERATION_NAME); _monitor.downloadSnapshotComplete(); _state = State.Completed; } }
public virtual Statement Statement() { EnsureStarted(); return(_statementSupplier.get()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void before() public virtual void Before() { _array = Factory.get(); }
private static void BuildUpExpectedData(IList <InputEntity> nodeData, IList <InputEntity> relationshipData, IDictionary <string, InputEntity> expectedNodes, IDictionary <string, string[]> expectedNodeNames, IDictionary <string, IDictionary <string, System.Action <object> > > expectedNodePropertyVerifiers, IDictionary <string, IDictionary <string, IDictionary <string, AtomicInteger> > > expectedRelationships, IDictionary <string, AtomicLong> nodeCounts, IDictionary <string, IDictionary <string, IDictionary <string, AtomicLong> > > relationshipCounts) { foreach (InputEntity node in nodeData) { expectedNodes[( string )node.Id()] = node; expectedNodeNames[NameOf(node)] = node.Labels(); // Build default verifiers for all the properties that compares the property value using equals assertTrue(!node.HasIntPropertyKeyIds); IDictionary <string, System.Action <object> > propertyVerifiers = new SortedDictionary <string, System.Action <object> >(); for (int i = 0; i < node.PropertyCount(); i++) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final Object expectedValue = node.propertyValue(i); object expectedValue = node.PropertyValue(i); System.Action verify; if (expectedValue is TemporalAmount) { // Since there is no straightforward comparison for TemporalAmount we add it to a reference // point in time and compare the result verify = actualValue => { DateTime referenceTemporal = new DateTime(0, 1, 1, 0, 0); DateTime expected = referenceTemporal.plus(( TemporalAmount )expectedValue); DateTime actual = referenceTemporal.plus(( TemporalAmount )actualValue); assertEquals(expected, actual); }; } else if (expectedValue is Temporal) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.time.LocalDate expectedDate = ((java.time.temporal.Temporal) expectedValue).query(java.time.temporal.TemporalQueries.localDate()); LocalDate expectedDate = (( Temporal )expectedValue).query(TemporalQueries.localDate()); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.time.LocalTime expectedTime = ((java.time.temporal.Temporal) expectedValue).query(java.time.temporal.TemporalQueries.localTime()); LocalTime expectedTime = (( Temporal )expectedValue).query(TemporalQueries.localTime()); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.time.ZoneId expectedZoneId = ((java.time.temporal.Temporal) expectedValue).query(java.time.temporal.TemporalQueries.zone()); ZoneId expectedZoneId = (( Temporal )expectedValue).query(TemporalQueries.zone()); verify = actualValue => { LocalDate actualDate = (( Temporal )actualValue).query(TemporalQueries.localDate()); LocalTime actualTime = (( Temporal )actualValue).query(TemporalQueries.localTime()); ZoneId actualZoneId = (( Temporal )actualValue).query(TemporalQueries.zone()); assertEquals(expectedDate, actualDate); assertEquals(expectedTime, actualTime); if (expectedZoneId == null) { if (actualZoneId != null) { // If the actual value is zoned it should have the default zone assertEquals(_testDefaultTimeZone.get(), actualZoneId); } } else { assertEquals(expectedZoneId, actualZoneId); } }; } else { verify = actualValue => assertEquals(expectedValue, actualValue); } propertyVerifiers[( string )node.PropertyKey(i)] = verify; } // Special verifier for pointA property System.Action verifyPointA = actualValue => { // The y-coordinate should match the node number PointValue v = ( PointValue )actualValue; double actualY = v.Coordinates.get(0).Coordinate.get(1); double expectedY = IndexOf(node); string message = actualValue.ToString() + " does not have y=" + expectedY; assertEquals(message, expectedY, actualY, 0.1); message = actualValue.ToString() + " does not have crs=wgs-84"; assertEquals(message, CoordinateReferenceSystem.WGS84.Name, v.CoordinateReferenceSystem.Name); }; propertyVerifiers["pointA"] = verifyPointA; // Special verifier for pointB property System.Action verifyPointB = actualValue => { // The y-coordinate should match the node number PointValue v = ( PointValue )actualValue; double actualY = v.Coordinates.get(0).Coordinate.get(1); double expectedY = IndexOf(node); string message = actualValue.ToString() + " does not have y=" + expectedY; assertEquals(message, expectedY, actualY, 0.1); message = actualValue.ToString() + " does not have crs=cartesian"; assertEquals(message, CoordinateReferenceSystem.Cartesian.Name, v.CoordinateReferenceSystem.Name); }; propertyVerifiers["pointB"] = verifyPointB; expectedNodePropertyVerifiers[NameOf(node)] = propertyVerifiers; CountNodeLabels(nodeCounts, node.Labels()); } foreach (InputEntity relationship in relationshipData) { // Expected relationship counts per node, type and direction InputEntity startNode = expectedNodes[relationship.StartId()]; InputEntity endNode = expectedNodes[relationship.EndId()]; { expectedRelationships[NameOf(startNode)][NameOf(endNode)][relationship.StringType].incrementAndGet(); } // Expected counts per start/end node label ids // Let's do what CountsState#addRelationship does, roughly relationshipCounts[null][null][null].incrementAndGet(); relationshipCounts[null][relationship.StringType][null].incrementAndGet(); foreach (string startNodeLabelName in asSet(startNode.Labels())) { IDictionary <string, IDictionary <string, AtomicLong> > startLabelCounts = relationshipCounts[startNodeLabelName]; startLabelCounts[null][null].incrementAndGet(); IDictionary <string, AtomicLong> typeCounts = startLabelCounts[relationship.StringType]; typeCounts[null].incrementAndGet(); if (COMPUTE_DOUBLE_SIDED_RELATIONSHIP_COUNTS) { foreach (string endNodeLabelName in asSet(endNode.Labels())) { startLabelCounts[null][endNodeLabelName].incrementAndGet(); typeCounts[endNodeLabelName].incrementAndGet(); } } } foreach (string endNodeLabelName in asSet(endNode.Labels())) { relationshipCounts[null][null][endNodeLabelName].incrementAndGet(); relationshipCounts[null][relationship.StringType][endNodeLabelName].incrementAndGet(); } } }
private IndexReaderFactory IndexReaderFactory() { return(_indexReaderFactory != null ? _indexReaderFactory : (_indexReaderFactory = _indexReaderFactorySupplier.get())); }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: @Override public java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> calculate(TestTarget target, java.util.Set<com.opengamma.strata.calc.Measure> measures, CalculationParameters parameters, com.opengamma.strata.data.scenario.ScenarioMarketData marketData, com.opengamma.strata.basics.ReferenceData refData) public IDictionary <Measure, Result <object> > calculate(TestTarget target, ISet <Measure> measures, CalculationParameters parameters, ScenarioMarketData marketData, ReferenceData refData) { Result <CurrencyScenarioArray> result = Result.success(supplier.get()); return(ImmutableMap.of(TestingMeasures.PRESENT_VALUE, result, TestingMeasures.PRESENT_VALUE_MULTI_CCY, result)); }
private string Time() { return(_dateTimeFormatter.format(_supplier.get())); }