Esempio n. 1
0
        /// <summary>
        /// Finds which format, if any, succeeded the specified format. Only formats in the same family are considered.
        /// </summary>
        /// <param name="format"> to find successor to. </param>
        /// <returns> the format with the lowest generation > format.generation, or None if no such format is known. </returns>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Nonnull public static java.util.Optional<RecordFormats> findSuccessor(@Nonnull final RecordFormats format)
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        public static Optional <RecordFormats> FindSuccessor(RecordFormats format)
        {
            return(StreamSupport.stream(RecordFormatSelector.AllFormats().spliterator(), false).filter(candidate => FormatFamily.IsSameFamily(format, candidate)).filter(candidate => candidate.generation() > format.Generation()).reduce((a, b) => a.generation() < b.generation() ? a : b));
        }
Esempio n. 2
0
        /// <summary>
        /// Select explicitly configured record format (via given {@code config}) or format from the store. If store does
        /// not exist or has old format (<seealso cref="RecordFormats.generation()"/>) than this method returns
        /// <seealso cref="DEFAULT_FORMAT"/>.
        /// </summary>
        /// <param name="config"> configuration parameters </param>
        /// <param name="databaseLayout"> database directory structure </param>
        /// <param name="fs"> file system used to access store files </param>
        /// <param name="pageCache"> page cache to read store files </param>
        /// <returns> record format from the store (if it can be read) or configured record format or <seealso cref="DEFAULT_FORMAT"/> </returns>
        /// <seealso cref= RecordFormats#generation() </seealso>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Nonnull public static RecordFormats selectNewestFormat(org.neo4j.kernel.configuration.Config config, org.neo4j.io.layout.DatabaseLayout databaseLayout, org.neo4j.io.fs.FileSystemAbstraction fs, org.neo4j.io.pagecache.PageCache pageCache, org.neo4j.logging.LogProvider logProvider)
        public static RecordFormats SelectNewestFormat(Config config, DatabaseLayout databaseLayout, FileSystemAbstraction fs, PageCache pageCache, LogProvider logProvider)
        {
            bool formatConfigured = StringUtils.isNotEmpty(ConfiguredRecordFormat(config));

            if (formatConfigured)
            {
                // format was explicitly configured so select it
                return(SelectForConfig(config, logProvider));
            }
            else
            {
                RecordFormats result = SelectForStore(databaseLayout, fs, pageCache, logProvider);
                if (result == null)
                {
                    // format was not explicitly configured and store does not exist, select default format
                    Info(logProvider, "Selected format '" + _defaultFormat + "' for the new store");
                    result = _defaultFormat;
                }
                else if (FormatFamily.IsHigherFamilyFormat(_defaultFormat, result) || (FormatFamily.IsSameFamily(result, _defaultFormat) && (result.Generation() < _defaultFormat.generation())))
                {
                    // format was not explicitly configured and store has lower format
                    // select default format, upgrade is intended
                    Info(logProvider, "Selected format '" + _defaultFormat + "' for existing store with format '" + result + "'");
                    result = _defaultFormat;
                }
                return(result);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Select record format for the given store (if exists) or from the given configuration. If there is no store and
        /// record format is not configured than <seealso cref="DEFAULT_FORMAT"/> is selected.
        /// </summary>
        /// <param name="config"> configuration parameters </param>
        /// <param name="databaseLayout"> database directory structure </param>
        /// <param name="fs"> file system used to access store files </param>
        /// <param name="pageCache"> page cache to read store files </param>
        /// <returns> record format from the store (if it can be read) or configured record format or <seealso cref="DEFAULT_FORMAT"/> </returns>
        /// <exception cref="IllegalArgumentException"> when configured format is different from the format present in the store </exception>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Nonnull public static RecordFormats selectForStoreOrConfig(org.neo4j.kernel.configuration.Config config, org.neo4j.io.layout.DatabaseLayout databaseLayout, org.neo4j.io.fs.FileSystemAbstraction fs, org.neo4j.io.pagecache.PageCache pageCache, org.neo4j.logging.LogProvider logProvider)
        public static RecordFormats SelectForStoreOrConfig(Config config, DatabaseLayout databaseLayout, FileSystemAbstraction fs, PageCache pageCache, LogProvider logProvider)
        {
            RecordFormats configuredFormat = LoadRecordFormat(ConfiguredRecordFormat(config));
            bool          formatConfigured = configuredFormat != null;

            RecordFormats currentFormat         = SelectForStore(databaseLayout, fs, pageCache, logProvider);
            bool          storeWithFormatExists = currentFormat != null;

            if (formatConfigured && storeWithFormatExists)
            {
                if (currentFormat.FormatFamily.Equals(configuredFormat.FormatFamily) && (currentFormat.Generation() == configuredFormat.Generation()))
                {
                    Info(logProvider, "Configured format matches format in the store. Selected: " + currentFormat);
                    return(currentFormat);
                }
                throw new System.ArgumentException(string.Format("Configured format '{0}' is different from the actual format in the store '{1}'", configuredFormat, currentFormat));
            }

            if (!formatConfigured && storeWithFormatExists)
            {
                Info(logProvider, "Format not configured. Selected format from the store: " + currentFormat);
                return(currentFormat);
            }

            if (formatConfigured)
            {
                Info(logProvider, "Selected configured format: " + configuredFormat);
                return(configuredFormat);
            }

            return(_defaultFormat);
        }
Esempio n. 4
0
        /// <summary>
        /// Check if store and configured formats are compatible. In case if format is not configured or store does not
        /// exist yet - we consider formats as compatible. </summary>
        /// <param name="config"> configuration parameters </param>
        /// <param name="databaseLayout"> database directory structure </param>
        /// <param name="fs"> file system used to access store files </param>
        /// <param name="pageCache"> page cache to read store files </param>
        /// <param name="logProvider"> log provider </param>
        /// <returns> true if configured and actual format is compatible, false otherwise. </returns>
        public static bool IsStoreAndConfigFormatsCompatible(Config config, DatabaseLayout databaseLayout, FileSystemAbstraction fs, PageCache pageCache, LogProvider logProvider)
        {
            RecordFormats configuredFormat = LoadRecordFormat(ConfiguredRecordFormat(config));

            RecordFormats currentFormat = SelectForStore(databaseLayout, fs, pageCache, logProvider);

            return((configuredFormat == null) || (currentFormat == null) || (currentFormat.FormatFamily.Equals(configuredFormat.FormatFamily) && (currentFormat.Generation() == configuredFormat.Generation())));
        }
Esempio n. 5
0
 private bool IsCompatibleFormats(RecordFormats storeFormat)
 {
     return(FormatFamily.isSameFamily(_recordFormats, storeFormat) && _recordFormats.hasCompatibleCapabilities(storeFormat, CapabilityType.FORMAT) && _recordFormats.generation() >= storeFormat.Generation());
 }