Esempio n. 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void doWrite(StoreWriter writer, ByteBuffer temporaryBuffer, java.io.File file, int recordSize, java.nio.channels.ReadableByteChannel fileChannel, long fileSize, String storeCopyIdentifier, boolean isLogFile) throws java.io.IOException
        private void DoWrite(StoreWriter writer, ByteBuffer temporaryBuffer, File file, int recordSize, ReadableByteChannel fileChannel, long fileSize, string storeCopyIdentifier, bool isLogFile)
        {
            _monitor.startStreamingStoreFile(file, storeCopyIdentifier);
            string path = isLogFile ? file.Name : relativePath(_databaseDirectory, file);

            writer.Write(path, fileChannel, temporaryBuffer, fileSize > 0, recordSize);
            _monitor.finishStreamingStoreFile(file, storeCopyIdentifier);
        }
Esempio n. 2
0
        /// <summary>
        /// Dispose of remote importer.
        /// </summary>
        public void Dispose()
        {
            this.disposed         = true;
            this.metaClientThread = null;
            this.dataClientThread = null;

            this.storeWriter.Dispose();
            this.storeWriter = null;
        }
Esempio n. 3
0
        public override Response <Void> CopyStore(RequestContext requestContext, StoreWriter writer)
        {
            RequestContext context;

            using (StoreWriter storeWriter = writer)
            {
                context = _spi.flushStoresAndStreamStoreFiles(storeWriter);
            }               // close the store writer

            return(_spi.packTransactionStreamResponse(context, null));
        }
Esempio n. 4
0
 private RemoteImporter(Func <string, Importer> importerThunk, TimeInterval replay, bool replayRemoteLatestStart, string host, int port, string name, string path, bool allowSequenceRestart)
 {
     this.importerThunk           = importerThunk;
     this.replayStart             = replay.Left.Ticks;
     this.replayEnd               = replay.Right.Ticks;
     this.replayRemoteLatestStart = replayRemoteLatestStart;
     this.host = host;
     this.port = port;
     this.allowSequenceRestart = allowSequenceRestart;
     this.storeWriter          = new StoreWriter(name, path);
     this.StartMetaClient();
 }
Esempio n. 5
0
        public override Response <Void> FullBackup(StoreWriter writer, bool forensics)
        {
            string backupIdentifier = BackupIdentifier;

            try
            {
                using (StoreWriter storeWriter = writer)
                {
                    _logger.log("%s: Full backup started...", backupIdentifier);
                    RequestContext copyStartContext      = _storeCopyServer.flushStoresAndStreamStoreFiles(FULL_BACKUP_CHECKPOINT_TRIGGER, storeWriter, forensics);
                    ResponsePacker responsePacker        = new StoreCopyResponsePacker(_logicalTransactionStore, _transactionIdStore, _logFileInformation, _storeId, copyStartContext.LastAppliedTransaction() + 1, _storeCopyServer.monitor());
                    long           optionalTransactionId = copyStartContext.LastAppliedTransaction();
                    return(responsePacker.PackTransactionStreamResponse(anonymous(optionalTransactionId), null));
                }
            }
            finally
            {
                _logger.log("%s: Full backup finished.", backupIdentifier);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Exporter"/> class.
        /// </summary>
        /// <param name="pipeline">The pipeline that owns this instance.</param>
        /// <param name="name">The name of the application that generated the persisted files, or the root name of the files</param>
        /// <param name="path">The directory in which the main persisted file resides or will reside, or null to create a volatile data store</param>
        /// <param name="createSubdirectory">If true, a numbered sub-directory is created for this store</param>
        /// <param name="serializers">
        /// A collection of known serializers, or null to infer it from the data being written to the store.
        /// The known serializer set can be accessed and modified afterwards via the <see cref="Serializers"/> property.
        /// </param>
        internal Exporter(Pipeline pipeline, string name, string path, bool createSubdirectory = true, KnownSerializers serializers = null)
        {
            this.pipeline    = pipeline;
            this.serializers = serializers ?? new KnownSerializers();
            this.writer      = new StoreWriter(name, path, createSubdirectory);

            // write the version info
            this.writer.WriteToCatalog(this.serializers.RuntimeVersion);

            // copy the schemas present so far and also make sure the catalog captures schemas added in the future
            this.serializers.SchemaAdded += (o, e) => this.writer.WriteToCatalog(e);
            foreach (var schema in this.serializers.Schemas)
            {
                this.writer.WriteToCatalog(schema);
            }

            this.merger      = new Merger <Message <BufferReader>, string>(pipeline);
            this.writerInput = pipeline.CreateReceiver <Message <BufferReader> >(this, (m, e) => this.writer.Write(m.Data, m.Envelope), nameof(this.writerInput));
            this.merger.Select(this.ThrottledMessages).PipeTo(this.writerInput, DeliveryPolicy.Unlimited);
        }
Esempio n. 7
0
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: public org.neo4j.com.Response<?> copyStore(StoreWriter writer)
            public override Response <object> CopyStore(StoreWriter writer)
            {
                NeoStoreDataSource neoStoreDataSource = Original.DependencyResolver.resolveDependency(typeof(NeoStoreDataSource));

                TransactionIdStore transactionIdStore = Original.DependencyResolver.resolveDependency(typeof(TransactionIdStore));

                LogicalTransactionStore logicalTransactionStore = Original.DependencyResolver.resolveDependency(typeof(LogicalTransactionStore));

                CheckPointer checkPointer = Original.DependencyResolver.resolveDependency(typeof(CheckPointer));

                RequestContext requestContext = (new StoreCopyServer(neoStoreDataSource, checkPointer, Fs, OriginalDir, (new Monitors()).newMonitor(typeof(StoreCopyServer.Monitor)))).flushStoresAndStreamStoreFiles("test", writer, IncludeLogs);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.storageengine.api.StoreId storeId = original.getDependencyResolver().resolveDependency(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine.class).getStoreId();
                StoreId storeId = Original.DependencyResolver.resolveDependency(typeof(RecordStorageEngine)).StoreId;

                ResponsePacker responsePacker = new ResponsePacker(logicalTransactionStore, transactionIdStore, () => storeId);

                Response = spy(responsePacker.PackTransactionStreamResponse(requestContext, null));
                return(Response);
            }
Esempio n. 8
0
        /// <summary>
        /// 创建索引档
        /// </summary>
        /// <param name="id">文档ID号</param>
        /// <param name="author">作者</param>
        /// <param name="cat">文章类别(大类ID)</param>
        /// <param name="title">文章标题</param>
        /// <param name="body">文章正文</param>
        /// <param name="tag">标签</param>
        /// <param name="path">文档路径</param>
        /// <returns></returns>
        public static Lucene.Net.Documents.Document CreateDocument(string id, string author, string cat, string title, string body, string tag, string path)
        {
            Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();

            doc.Add(new Field("id", id, Field.Store.YES, Field.Index.UN_TOKENIZED, Field.TermVector.NO));
            doc.Add(new Field("author", author, Field.Store.NO, Field.Index.UN_TOKENIZED, Field.TermVector.NO));
            doc.Add(new Field("cat", cat, Field.Store.NO, Field.Index.UN_TOKENIZED, Field.TermVector.NO));
            doc.Add(new Field("title", title, Field.Store.NO, Field.Index.TOKENIZED, Field.TermVector.NO));
            doc.Add(new Field("body", body, Field.Store.NO, Field.Index.TOKENIZED, Field.TermVector.WITH_OFFSETS));
            doc.Add(new Field("tag", tag, Field.Store.NO, Field.Index.TOKENIZED, Field.TermVector.NO));
            doc.Add(new Field("path", path, Field.Store.NO, Field.Index.TOKENIZED, Field.TermVector.NO));
            doc.Add(new Field("date", DateField.DateToString(DateTime.Now), Field.Store.YES, Field.Index.NO, Field.TermVector.NO));

            //设置权重,越靠后的文章权重越大,在搜索结果中的位置靠前的机会就越大
            float boost = Single.Parse(DateTime.Now.ToString("0.yyyyMMddhh"));

            doc.SetBoost(boost);

            //确定保存文档压缩包的路径
            string fpath = Directorys.StoreDirectory + Math.Ceiling(Double.Parse(id) / 10000D).ToString("f0");

            if (!System.IO.Directory.Exists(fpath))
            {
                System.IO.Directory.CreateDirectory(fpath);
            }

            //将文档以gzip方式保存到相应位置
            StoreWriter store = new StoreWriter(fpath + @"\" + id + ".gz");

            store.WriteLine(author);
            store.WriteLine(cat);
            store.WriteLine(tag);
            store.WriteLine(title);
            store.WriteLine(path);
            store.WriteLine(body);
            store.Close();

            return(doc);
        }
Esempio n. 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Exporter"/> class.
        /// </summary>
        /// <param name="pipeline">The pipeline that owns this instance.</param>
        /// <param name="name">The name of the application that generated the persisted files, or the root name of the files.</param>
        /// <param name="path">The directory in which the main persisted file resides or will reside, or null to create a volatile data store.</param>
        /// <param name="createSubdirectory">If true, a numbered sub-directory is created for this store.</param>
        /// <param name="serializers">
        /// A collection of known serializers, or null to infer it from the data being written to the store.
        /// The known serializer set can be accessed and modified afterwards via the <see cref="Serializers"/> property.
        /// </param>
        internal Exporter(Pipeline pipeline, string name, string path, bool createSubdirectory = true, KnownSerializers serializers = null)
            : base(pipeline)
        {
            this.pipeline    = pipeline;
            this.serializers = serializers ?? new KnownSerializers();
            this.writer      = new StoreWriter(name, path, createSubdirectory);

            // write the version info
            this.writer.WriteToCatalog(this.serializers.RuntimeVersion);

            // copy the schemas present so far and also make sure the catalog captures schemas added in the future
            this.serializers.SchemaAdded += (o, e) => this.writer.WriteToCatalog(e);
            foreach (var schema in this.serializers.Schemas.Values)
            {
                this.writer.WriteToCatalog(schema);
            }

            this.merger = new Merger <Message <BufferReader>, string>(this, (_, m) =>
            {
                this.Throttle.WaitOne();
                this.writer.Write(m.Data.Data, m.Data.Envelope);
            });
        }
Esempio n. 10
0
 public override RequestContext FlushStoresAndStreamStoreFiles(StoreWriter writer)
 {
     throw new System.NotSupportedException();
 }
Esempio n. 11
0
//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 org.neo4j.com.Response<Void> fullBackup(org.neo4j.com.storecopy.StoreWriter storeWriter, final boolean forensics)
        public override Response <Void> FullBackup(StoreWriter storeWriter, bool forensics)
        {
            return(SendRequest(BackupRequestType.FullBackup, RequestContext.EMPTY, buffer => buffer.writeByte(forensics ? ( sbyte )1 : ( sbyte )0), new Protocol.FileStreamsDeserializer310(storeWriter)));
        }
Esempio n. 12
0
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: public org.neo4j.com.Response<?> copyStore(org.neo4j.com.storecopy.StoreWriter writer)
            public Response <object> copyStore(StoreWriter writer)
            {
                return(_masterClient.copyStore(new RequestContext(0, _outerInstance.config.get(ClusterSettings.server_id).toIntegerIndex(), 0, BASE_TX_ID, 0), writer));
            }
Esempio n. 13
0
        /// <summary>
        /// Trigger store flush (checkpoint) and write <seealso cref="NeoStoreDataSource.listStoreFiles(bool) store files"/> to the
        /// given <seealso cref="StoreWriter"/>.
        /// </summary>
        /// <param name="triggerName"> name of the component asks for store files. </param>
        /// <param name="writer"> store writer to write files to. </param>
        /// <param name="includeLogs"> <code>true</code> if transaction logs should be copied, <code>false</code> otherwise. </param>
        /// <returns> a <seealso cref="RequestContext"/> specifying at which point the store copy started. </returns>
        public virtual RequestContext FlushStoresAndStreamStoreFiles(string triggerName, StoreWriter writer, bool includeLogs)
        {
            try
            {
                string storeCopyIdentifier = Thread.CurrentThread.Name;
                ThrowingAction <IOException> checkPointAction = () =>
                {
                    _monitor.startTryCheckPoint(storeCopyIdentifier);
                    _checkPointer.tryCheckPoint(new SimpleTriggerInfo(triggerName));
                    _monitor.finishTryCheckPoint(storeCopyIdentifier);
                };

                // Copy the store files
                long lastAppliedTransaction;
                StoreCopyCheckPointMutex mutex = _dataSource.StoreCopyCheckPointMutex;
                try
                {
                    using (Resource @lock = mutex.StoreCopy(checkPointAction), ResourceIterator <StoreFileMetadata> files = _dataSource.listStoreFiles(includeLogs))
                    {
                        lastAppliedTransaction = _checkPointer.lastCheckPointedTransactionId();
                        _monitor.startStreamingStoreFiles(storeCopyIdentifier);
                        ByteBuffer temporaryBuffer = ByteBuffer.allocateDirect(( int )ByteUnit.mebiBytes(1));
                        while (Files.MoveNext())
                        {
                            StoreFileMetadata meta = Files.Current;
                            File file       = meta.File();
                            bool isLogFile  = meta.LogFile;
                            int  recordSize = meta.RecordSize();

                            using (ReadableByteChannel fileChannel = _fileSystem.open(file, OpenMode.READ))
                            {
                                long fileSize = _fileSystem.getFileSize(file);
                                DoWrite(writer, temporaryBuffer, file, recordSize, fileChannel, fileSize, storeCopyIdentifier, isLogFile);
                            }
                        }
                    }
                }
                finally
                {
                    _monitor.finishStreamingStoreFiles(storeCopyIdentifier);
                }

                return(anonymous(lastAppliedTransaction));
            }
            catch (IOException e)
            {
                throw new ServerFailureException(e);
            }
        }
Esempio n. 14
0
 public FileStreamsDeserializer310(StoreWriter writer)
 {
     this.Writer = writer;
 }