예제 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void appendNullTransactionLogEntryToSetRaftIndexToMinusOne() throws java.io.IOException
        private void AppendNullTransactionLogEntryToSetRaftIndexToMinusOne()
        {
            ReadOnlyTransactionIdStore readOnlyTransactionIdStore = new ReadOnlyTransactionIdStore(_pageCache, _databaseLayout);
            LogFiles logFiles = LogFilesBuilder.activeFilesBuilder(_databaseLayout, _fs, _pageCache).withConfig(_config).withLastCommittedTransactionIdSupplier(() => readOnlyTransactionIdStore.LastClosedTransactionId - 1).build();

            long dummyTransactionId;

            using (Lifespan lifespan = new Lifespan(logFiles))
            {
                FlushableChannel     channel = logFiles.LogFile.Writer;
                TransactionLogWriter writer  = new TransactionLogWriter(new LogEntryWriter(channel));

                long lastCommittedTransactionId      = readOnlyTransactionIdStore.LastCommittedTransactionId;
                PhysicalTransactionRepresentation tx = new PhysicalTransactionRepresentation(Collections.emptyList());
                sbyte[] txHeaderBytes = LogIndexTxHeaderEncoding.encodeLogIndexAsTxHeader(-1);
                tx.SetHeader(txHeaderBytes, -1, -1, -1, lastCommittedTransactionId, -1, -1);

                dummyTransactionId = lastCommittedTransactionId + 1;
                writer.Append(tx, dummyTransactionId);
                channel.PrepareForFlush().flush();
            }

            File neoStoreFile = _databaseLayout.metadataStore();

            MetaDataStore.setRecord(_pageCache, neoStoreFile, LAST_TRANSACTION_ID, dummyTransactionId);
        }
예제 #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void write(Object value, FlushableChannel into) throws IOException
            public override void write(object value, FlushableChannel into)
            {
                ValueType componentType = typeOf(value.GetType().GetElementType());

                into.put(componentType.Id());
                int length = Array.getLength(value);

                into.putInt(length);
                for (int i = 0; i < length; i++)
                {
                    componentType.Write(Array.get(value, i), into);
                }
            }
예제 #3
0
        public override void WriteSessionEnded()
        {
            try
            {
                _channel.put(TYPE_SESSION_END);
            }
            catch (IOException e)
            {
                throw new UncheckedIOException(e);
            }

            _position.add(1);
            if (_position.sum() > _rotationThreshold)
            {
                // Rotate
                @lock.@lock();
                try
                {
                    _channel.prepareForFlush().flush();
                    _channel.Dispose();
                    MoveAwayFile();
                    _position.reset();
                    _channel = InstantiateChannel();
                }
                catch (IOException e)
                {
                    throw new UncheckedIOException(e);
                }
                finally
                {
                    @lock.unlock();
                }

                // Prune
                long time      = currentTimeMillis();
                long threshold = time - _pruneThreshold;
                foreach (File file in _fs.listFiles(_storeDir, (dir, name) => name.StartsWith(file.Name + "-")))
                {
                    if (MillisOf(file) < threshold)
                    {
                        _fs.deleteFile(file);
                    }
                }
            }
        }
예제 #4
0
 internal LabelScanWriteMonitor(FileSystemAbstraction fs, DatabaseLayout databaseLayout, long rotationThreshold, ByteUnit rotationThresholdUnit, long pruneThreshold, TimeUnit pruneThresholdUnit)
 {
     this._fs = fs;
     this._rotationThreshold = rotationThresholdUnit.toBytes(rotationThreshold);
     this._pruneThreshold    = pruneThresholdUnit.toMillis(pruneThreshold);
     this._storeDir          = databaseLayout.DatabaseDirectory();
     this._file = WriteLogBaseFile(databaseLayout);
     try
     {
         if (fs.FileExists(_file))
         {
             MoveAwayFile();
         }
         this._channel = InstantiateChannel();
     }
     catch (IOException e)
     {
         throw new UncheckedIOException(e);
     }
 }
예제 #5
0
 public CommittedTransactionSerializer(FlushableChannel networkFlushableChannel)
 {
     this._writer = new LogEntryWriter(networkFlushableChannel);
 }
 internal CorruptedLogEntryWriter(FlushableChannel channel) : base(channel)
 {
 }
예제 #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void writeLogHeader(org.neo4j.kernel.impl.transaction.log.FlushableChannel channel, long logVersion, long previousCommittedTxId) throws java.io.IOException
        public static void WriteLogHeader(FlushableChannel channel, long logVersion, long previousCommittedTxId)
        {
            channel.PutLong(EncodeLogVersion(logVersion));
            channel.PutLong(previousCommittedTxId);
        }