예제 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void write(org.neo4j.io.fs.StoreChannel channel, long time, long identifier, long version, long lastCommittedTxId, long indexVersion) throws java.io.IOException
        private void Write(StoreChannel channel, long time, long identifier, long version, long lastCommittedTxId, long indexVersion)
        {
            _buf.clear();
            _buf.putLong(time).putLong(identifier).putLong(version).putLong(lastCommittedTxId).putLong(indexVersion);
            _buf.flip();

            channel.WriteAll(_buf, 0);
            channel.Force(true);
        }
예제 #2
0
        /// <summary>
        /// Create/reserve an empty failure file for the given indexId.
        ///
        /// This will overwrite any pre-existing failure file.
        /// </summary>
        /// <exception cref="IOException"> if the failure file could not be created </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public synchronized void reserveForIndex() throws java.io.IOException
        public virtual void ReserveForIndex()
        {
            lock (this)
            {
                _fs.mkdirs(_folderLayout.IndexFolder);
                File failureFile = failureFile();
                using (StoreChannel channel = _fs.create(failureFile))
                {
                    channel.WriteAll(ByteBuffer.wrap(new sbyte[MAX_FAILURE_SIZE]));
                    channel.Force(true);
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Store failure in failure file for index with the given id
        /// </summary>
        /// <param name="failure"> message describing the failure that needs to be stored </param>
        /// <exception cref="IOException"> if the failure could not be stored </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public synchronized void storeIndexFailure(String failure) throws java.io.IOException
        public virtual void StoreIndexFailure(string failure)
        {
            lock (this)
            {
                File failureFile = failureFile();
                using (StoreChannel channel = _fs.open(failureFile, OpenMode.READ_WRITE))
                {
                    sbyte[] existingData = new sbyte[( int )channel.size()];
                    channel.ReadAll(ByteBuffer.wrap(existingData));
                    channel.Position(LengthOf(existingData));

                    sbyte[] data = UTF8.encode(failure);
                    channel.WriteAll(ByteBuffer.wrap(data, 0, Math.Min(data.Length, MAX_FAILURE_SIZE)));

                    channel.Force(true);
                    channel.close();
                }
            }
        }
예제 #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: static void saveFulltextIndexSettings(FulltextIndexDescriptor descriptor, java.io.File indexFolder, org.neo4j.io.fs.FileSystemAbstraction fs) throws java.io.IOException
        internal static void SaveFulltextIndexSettings(FulltextIndexDescriptor descriptor, File indexFolder, FileSystemAbstraction fs)
        {
            File       indexConfigFile = new File(indexFolder, INDEX_CONFIG_FILE);
            Properties settings        = new Properties();

            settings.setProperty(INDEX_CONFIG_EVENTUALLY_CONSISTENT, Convert.ToString(descriptor.EventuallyConsistent));
            settings.setProperty(INDEX_CONFIG_ANALYZER, descriptor.AnalyzerName());
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            settings.setProperty(INDEX_CONFIG_PROPERTY_NAMES, descriptor.PropertyNames().collect(Collectors.joining(", ", "[", "]")));
            settings.setProperty("_propertyIds", Arrays.ToString(descriptor.Properties()));
            settings.setProperty("_name", descriptor.Name());
            settings.setProperty("_schema_entityType", descriptor.Schema().entityType().name());
            settings.setProperty("_schema_entityTokenIds", Arrays.ToString(descriptor.Schema().EntityTokenIds));
            using (StoreChannel channel = fs.Create(indexConfigFile), Writer writer = fs.OpenAsWriter(indexConfigFile, StandardCharsets.UTF_8, false))
            {
                settings.store(writer, "Auto-generated file. Do not modify!");
                writer.flush();
                channel.Force(true);
            }
        }
예제 #5
0
        private void Write(File file)
        {
            StoreChannel channel = null;

            try
            {
                channel = _fileSystem.open(file, OpenMode.READ_WRITE);
                channel.WriteAll(ByteBuffer.wrap(_magic));
                IoPrimitiveUtils.writeInt(channel, Buffer(4), VERSION);
                WriteMap(channel, _nodeConfig);
                WriteMap(channel, _relConfig);
                channel.Force(false);
            }
            catch (IOException e)
            {
                throw new Exception(e);
            }
            finally
            {
                Close(channel);
            }
        }
예제 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldNotLoseDataForcedBeforeFileSystemCrashes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldNotLoseDataForcedBeforeFileSystemCrashes()
        {
            using (EphemeralFileSystemAbstraction fs = new EphemeralFileSystemAbstraction())
            {
                // given
                int numberOfBytesForced = 8;

                File aFile = new File("yo");

                StoreChannel channel = fs.Open(aFile, OpenMode.READ_WRITE);
                WriteLong(channel, 1111);

                // when
                channel.Force(true);
                WriteLong(channel, 2222);
                fs.Crash();

                // then
                StoreChannel readChannel = fs.Open(aFile, OpenMode.READ);
                assertEquals(numberOfBytesForced, readChannel.size());

                assertEquals(1111, ReadLong(readChannel).Long);
            }
        }
예제 #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void force(boolean metaData) throws java.io.IOException
        public override void Force(bool metaData)
        {
            @delegate.Force(metaData);
        }