public static StorageEngineServer CreateServer(IStorageEngine engine, int port = 7182) { TcpServer server = new TcpServer(port); StorageEngineServer engineServer = new StorageEngineServer(engine, server); return engineServer; }
public ServerConnection(TcpServer tcpServer, TcpClient tcpClient) { if (tcpServer == null) throw new ArgumentNullException("tcpServer == null"); if (tcpClient == null) throw new ArgumentNullException("tcpClient == null"); TcpServer = tcpServer; TcpClient = tcpClient; }
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; }