Exemplo n.º 1
0
        public static StorageEngineServer CreateServer(IStorageEngine engine, int port = 7182)
        {
            TcpServer server = new TcpServer(port);
            StorageEngineServer engineServer = new StorageEngineServer(engine, server);

            return engineServer;
        }
Exemplo n.º 2
0
        public HeapServer(IHeap heap, TcpServer tcpServer)
        {
            if (heap == null)
                throw new ArgumentNullException("heap");
            if (tcpServer == null)
                throw new ArgumentNullException("tcpServer");

            Heap = heap;
            TcpServer = tcpServer;
        }
Exemplo n.º 3
0
        public StorageEngineServer(IStorageEngine storageEngine, TcpServer tcpServer)
        {
            if (storageEngine == null)
                throw new ArgumentNullException("storageEngine");
            if (tcpServer == null)
                throw new ArgumentNullException("tcpServer");

            StorageEngine = storageEngine;
            TcpServer = tcpServer;

            CommandsIIndexExecute = new Func<XTablePortable, ICommand, ICommand>[CommandCode.MAX];
            CommandsIIndexExecute[CommandCode.REPLACE] = Replace;
            CommandsIIndexExecute[CommandCode.DELETE] = Delete;
            CommandsIIndexExecute[CommandCode.DELETE_RANGE] = DeleteRange;
            CommandsIIndexExecute[CommandCode.INSERT_OR_IGNORE] = InsertOrIgnore;
            CommandsIIndexExecute[CommandCode.CLEAR] = Clear;
            CommandsIIndexExecute[CommandCode.TRY_GET] = TryGet;
            CommandsIIndexExecute[CommandCode.FORWARD] = Forward;
            CommandsIIndexExecute[CommandCode.BACKWARD] = Backward;
            CommandsIIndexExecute[CommandCode.FIND_NEXT] = FindNext;
            CommandsIIndexExecute[CommandCode.FIND_AFTER] = FindAfter;
            CommandsIIndexExecute[CommandCode.FIND_PREV] = FindPrev;
            CommandsIIndexExecute[CommandCode.FIND_BEFORE] = FindBefore;
            CommandsIIndexExecute[CommandCode.FIRST_ROW] = FirstRow;
            CommandsIIndexExecute[CommandCode.LAST_ROW] = LastRow;
            CommandsIIndexExecute[CommandCode.COUNT] = Count;
            CommandsIIndexExecute[CommandCode.XTABLE_DESCRIPTOR_GET] = GetXIndexDescriptor;
            CommandsIIndexExecute[CommandCode.XTABLE_DESCRIPTOR_SET] = SetXIndexDescriptor;

            CommandsStorageEngineExecute = new Func<ICommand, ICommand>[CommandCode.MAX];
            CommandsStorageEngineExecute[CommandCode.STORAGE_ENGINE_COMMIT] = StorageEngineCommit;
            CommandsStorageEngineExecute[CommandCode.STORAGE_ENGINE_GET_ENUMERATOR] = StorageEngineGetEnumerator;
            CommandsStorageEngineExecute[CommandCode.STORAGE_ENGINE_RENAME] = StorageEngineRename;
            CommandsStorageEngineExecute[CommandCode.STORAGE_ENGINE_EXISTS] = StorageEngineExist;
            CommandsStorageEngineExecute[CommandCode.STORAGE_ENGINE_FIND_BY_ID] = StorageEngineFindByID;
            CommandsStorageEngineExecute[CommandCode.STORAGE_ENGINE_FIND_BY_NAME] = StorageEngineFindByNameCommand;
            CommandsStorageEngineExecute[CommandCode.STORAGE_ENGINE_OPEN_XTABLE] = StorageEngineOpenXIndex;
            CommandsStorageEngineExecute[CommandCode.STORAGE_ENGINE_OPEN_XFILE] = StorageEngineOpenXFile;
            CommandsStorageEngineExecute[CommandCode.STORAGE_ENGINE_DELETE] = StorageEngineDelete;
            CommandsStorageEngineExecute[CommandCode.STORAGE_ENGINE_COUNT] = StorageEngineCount;
            CommandsStorageEngineExecute[CommandCode.STORAGE_ENGINE_GET_CACHE_SIZE] = StorageEngineGetCacheSize;
            CommandsStorageEngineExecute[CommandCode.STORAGE_ENGINE_SET_CACHE_SIZE] = StorageEngineSetCacheSize;
            CommandsStorageEngineExecute[CommandCode.HEAP_OBTAIN_NEW_HANDLE] = HeapObtainNewHandle;
            CommandsStorageEngineExecute[CommandCode.HEAP_RELEASE_HANDLE] = HeapReleaseHandle;
            CommandsStorageEngineExecute[CommandCode.HEAP_EXISTS_HANDLE] = HeapExistsHandle;
            CommandsStorageEngineExecute[CommandCode.HEAP_WRITE] = HeapWrite;
            CommandsStorageEngineExecute[CommandCode.HEAP_READ] = HeapRead;
            CommandsStorageEngineExecute[CommandCode.HEAP_COMMIT] = HeapCommit;
            CommandsStorageEngineExecute[CommandCode.HEAP_CLOSE] = HeapClose;
            CommandsStorageEngineExecute[CommandCode.HEAP_GET_TAG] = HeapGetTag;
            CommandsStorageEngineExecute[CommandCode.HEAP_SET_TAG] = HeapSetTag;
            CommandsStorageEngineExecute[CommandCode.HEAP_DATA_SIZE] = HeapDataSize;
            CommandsStorageEngineExecute[CommandCode.HEAP_SIZE] = HeapSize;
        }
Exemplo n.º 4
0
        protected override void OnStart(string[] args)
        {
            string FileName = ConfigurationSettings.AppSettings["FileName"];
            int port = int.Parse(ConfigurationSettings.AppSettings["Port"]);
            int boundedCapacity = int.Parse(ConfigurationSettings.AppSettings["BoundedCapacity"]);
            Service = this;

            StorageEngine = STSdb.FromFile(FileName);
            TcpServer = new TcpServer(port);
            Program.StorageEngineServer = new StorageEngineServer(StorageEngine, TcpServer);
            Program.StorageEngineServer.Start();

            Form = new MainForm();
            Application.Run(Form);
            Program.StorageEngineServer.Stop();
            StorageEngine.Close();
        }