当前位置: 首页>>代码示例>>C#>>正文


C# IRegionManager.readRegionAddr方法代码示例

本文整理汇总了C#中IRegionManager.readRegionAddr方法的典型用法代码示例。如果您正苦于以下问题:C# IRegionManager.readRegionAddr方法的具体用法?C# IRegionManager.readRegionAddr怎么用?C# IRegionManager.readRegionAddr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRegionManager的用法示例。


在下文中一共展示了IRegionManager.readRegionAddr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: _InitResume

        private void _InitResume(IRegionManager regionmgr)
        {
            this.rootblockstream = regionmgr.readRegionAddr(0).getNewAccessStream();
            root = Util.readStruct<RootBlockHeader>(rootblockstream);
            if (!root.IsValid()) {
                throw new Exception("invalid root block");
            }
            RootBlockLogSegment[] log_segments = new RootBlockLogSegment[root.num_logsegments];
            for (int i=0;i<root.num_logsegments;i++) {
                log_segments[i] = Util.readStruct<RootBlockLogSegment>(rootblockstream);
            }

            // setup the log segment handler
            this.log_handler = new LogSegmentsHandler(this,regionmgr, log_segments);

            foreach (LogCmd cmd in log_handler.recoverLogCmds()) {
                 receiver.handleCommand(cmd.cmd, cmd.cmddata);
            }
        }
开发者ID:jeske,项目名称:StepsDB-alpha,代码行数:19,代码来源:LogWriter.cs

示例2: _InitNewRegion

        // special "init" of a region
        private void _InitNewRegion(IRegionManager regionmgr, out int system_reserved_space)
        {
            // test to see if there is already a root record there
            {
                try {
                    Stream testrootblockstream = regionmgr.readRegionAddr(0).getNewAccessStream();

                    RootBlockHeader nroot = Util.readStruct<RootBlockHeader>(testrootblockstream);
                    long rtblksz = testrootblockstream.Position;
                    if (nroot.IsValid()) {
                        // TODO: we should be careful not to overwrite an existing root record...

                        // throw new Exception("existing root record present! Can't re-init.");
                    }
                    testrootblockstream.Close();
                } catch (RegionExposedFiles.RegionMissingException) {

                }
            }

            // (1) initialize the log segments...
            RootBlockLogSegment[] log_segments = new RootBlockLogSegment[LogWriter.DEFAULT_LOG_SEGMENTS];

            uint nextFreeAddress = RootBlockHeader.ROOTBLOCK_SIZE;
            for (int i=0;i<log_segments.Length;i++) {

                // calculate the segment start and length
                log_segments[i].logsegment_size = LogWriter.DEFAULT_LOG_SEGMENT_SIZE;
                log_segments[i].logsegment_start = nextFreeAddress;

                nextFreeAddress += LogWriter.DEFAULT_LOG_SEGMENT_SIZE;

                // open the segment
                Stream logstream = regionmgr.writeFreshRegionAddr(log_segments[i].logsegment_start, log_segments[i].logsegment_size).getNewAccessStream();

                // write to the end of the log to be sure the file/stream has enough space
                logstream.Seek(log_segments[i].logsegment_size - 1, SeekOrigin.Begin);
                logstream.WriteByte(0x00);
                logstream.Flush();
                logstream.Seek(0, SeekOrigin.Begin);

                LogSegmentsHandler.InitLogSegmentStream(logstream);
                // write the initial "log-end" record at the beginning of the segment

                logstream.Close();
            }

            root.magic = RootBlockHeader.ROOTMAGIC;
            root.root_checksum = 0;
            byte[] root_block_data = root.constructRootBlock(log_segments);

            // open the streams...
            Stream rootblockwritestream = regionmgr.writeFreshRegionAddr(0, (long)RootBlockHeader.ROOTBLOCK_SIZE).getNewAccessStream();

            // this.logstream = logwritestream;
            this.rootblockstream = rootblockwritestream;

            // now write the root record
            rootblockstream.Seek(0, SeekOrigin.Begin);
            rootblockstream.Write(root_block_data,0,root_block_data.Length);
            rootblockstream.Flush();
            rootblockstream.Close(); // must close the stream so resume can operate

            system_reserved_space = (int)nextFreeAddress;
        }
开发者ID:jeske,项目名称:StepsDB-alpha,代码行数:66,代码来源:LogWriter.cs


注:本文中的IRegionManager.readRegionAddr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。