Ejemplo n.º 1
0
        public void DropSessionObject(Schema.CatalogObject objectValue)
        {
            ServerSession session = Sessions.GetSession(objectValue.SessionID);

            lock (session.SessionObjects)
            {
                int objectIndex = session.SessionObjects.IndexOf(objectValue.SessionObjectName);
                if ((objectIndex >= 0) && (((Schema.SessionObject)session.SessionObjects[objectIndex]).GlobalName == objectValue.Name))
                {
                    session.SessionObjects.RemoveAt(objectIndex);
                }
            }
        }
Ejemplo n.º 2
0
        protected bool _firstRun;         // Indicates whether or not this is the first time this server has run on the configured store

        /*
         *      Catalog Startup ->
         *              Catalog startup occurs in 5 phases
         *                      Bootstrap ->
         *                              Creates the SystemUser and CatalogDevice, then connects the SystemSession and opens a device session with the catalog device
         *                      Core ->
         *                              Creates the core catalog objects required to compile D4 statements. These objects are programmatically created by the
         *                              server and include the Admin user, User role, Temp device, ApplicationTransaction device and the Server-level rights.
         *                      Base ->
         *                              These are the basic objects required to facilitate caching and D4 compilation. These objects are created by running
         *                              the DataTypes.d4 script, and include the majority of the system data types. All the objects created up to this phase
         *                              constitute the base objects that will always be present in any given instance of a Dataphor Server, and are used as
         *                              the default set of cached objects.
         *                      System ->
         *                              The system objects are all the remaining objects in the System library, and are created by running the SystemCatalog.d4
         *                              script. These objects are only created on a first-time run for a given catalog store.
         *                      Load ->
         *                              The load phase finishes preparing the server to compile and run D4 statements by restoring server state.
         */
        private void InitializeCatalog()
        {
            LogMessage("Initializing Catalog...");

            // Create the Catalog device
            // Note that this must be the first object created to avoid the ID being different on subsequent loads
            Schema.Object.SetNextObjectID(0);
            _catalogDevice = CreateCatalogDevice();

            // Create the system user
            _systemUser = new Schema.User(SystemUserID, "System User", String.Empty);

            // Create the system library
            _systemLibrary       = new Schema.LoadedLibrary(SystemLibraryName);
            _systemLibrary.Owner = _systemUser;
            LoadSystemAssemblies();
            _catalog.LoadedLibraries.Add(_systemLibrary);

            // Load available libraries
            LoadAvailableLibraries();

            // Connect the System Session
            if (_systemSession != null)
            {
                _systemSession.Dispose();
                _systemProcess = null;
            }
            _systemSession = (ServerSession)InternalConnect(SystemSessionID, new SessionInfo(_systemUser.ID, _systemUser.Password, SystemLibraryName));
            _systemSession.SessionInfo.UsePlanCache = false;
            _systemProcess = (ServerProcess)((IServerSession)_systemSession).StartProcess(new ProcessInfo(_systemSession.SessionInfo));
            _systemProcess.SuppressWarnings = true;

            // Register the Catalog device
            _catalogDevice.Owner           = _systemUser;
            _catalogDevice.Library         = _systemLibrary;
            _catalogDevice.ClassDefinition = new ClassDefinition("System.CatalogDevice");
            _catalogDevice.Start(_systemProcess);
            _catalogDevice.Register(_systemProcess);

            _firstRun = DetermineFirstRun();

            // If this is a repository or there are no objects in the catalog, register, else resolve
            InternalInitializeCatalog();

            // Bind the native type references to the system data types
            BindNativeTypes();

            LogMessage("Catalog Initialized.");
        }
Ejemplo n.º 3
0
 public void DropSessionOperator(Schema.Operator operatorValue)
 {
     if (!Catalog.OperatorMaps.ContainsName(operatorValue.OperatorName))
     {
         ServerSession session = Sessions.GetSession(operatorValue.SessionID);
         lock (session.SessionOperators)
         {
             int operatorIndex = session.SessionOperators.IndexOf(operatorValue.SessionObjectName);
             if ((operatorIndex >= 0) && (((Schema.SessionObject)session.SessionOperators[operatorIndex]).GlobalName == operatorValue.OperatorName))
             {
                 session.SessionOperators.RemoveAt(operatorIndex);
             }
         }
     }
 }
Ejemplo n.º 4
0
        private void InternalStop()
        {
            try
            {
                try
                {
                    try
                    {
                        try
                        {
                            if (_planCache != null)
                            {
                                _planCache.Clear(_systemProcess);
                                _planCache = null;
                            }
                        }
                        finally
                        {
                            StopDevices();
                        }
                    }
                    finally
                    {
                        CloseSessions();
                    }
                }
                finally
                {
                    _systemSession = null;
                    _systemProcess = null;

                    if (_streamManager != null)
                    {
                        _streamManager.Dispose();
                        _streamManager = null;
                    }
                }
            }
            finally
            {
                UninitializeAvailableLibraries();
            }
        }
Ejemplo n.º 5
0
        private ServerSession InternalConnect(int sessionID, SessionInfo sessionInfo)
        {
            Schema.User   user    = ValidateLogin(sessionID, sessionInfo);
            ServerSession session = new ServerSession(this, sessionID, sessionInfo, user);

            try
            {
                Schema.LoadedLibrary currentLibrary = null;
                if (sessionInfo.DefaultLibraryName != String.Empty)
                {
                    if (_systemProcess == null)
                    {
                        currentLibrary = _catalog.LoadedLibraries[sessionInfo.DefaultLibraryName];
                    }
                    else
                    {
                        currentLibrary = _systemProcess.CatalogDeviceSession.ResolveLoadedLibrary(sessionInfo.DefaultLibraryName, false);
                    }
                }

                if (currentLibrary == null)
                {
                    currentLibrary = _catalog.LoadedLibraries[GeneralLibraryName];
                }

                session.CurrentLibrary = currentLibrary;

                _sessions.Add(session);
                return(session);
            }
            catch
            {
                session.Dispose();
                throw;
            }
        }
Ejemplo n.º 6
0
 private void InternalDisconnect(ServerSession session)
 {
     session.Dispose();
 }