Beispiel #1
0
        public StorageManager(string dllName, string connectionstring, string estateconnectionstring)
        {
            m_log.Info("[DATASTORE]: Attempting to load " + dllName);
            Assembly pluginAssembly = Assembly.LoadFrom(dllName);

            foreach (Type pluginType in pluginAssembly.GetTypes())
            {
                if (pluginType.IsPublic)
                {
                    if (typeof(IRegionDataStore).IsAssignableFrom(pluginType))
                    {
                        IRegionDataStore plug =
                            (IRegionDataStore) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
                        plug.Initialize(connectionstring);

                        m_dataStore = plug;

                        m_log.Info("[DATASTORE]: Added IRegionDataStore Interface");
                    }

                    if (typeof(IEstateDataStore).IsAssignableFrom(pluginType))
                    {
                        IEstateDataStore estPlug =
                            (IEstateDataStore) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
                        estPlug.Initialize(estateconnectionstring);

                        m_estateDataStore = estPlug;
                    }
                }
            }

            //TODO: Add checking and warning to make sure it initialized.
        }
Beispiel #2
0
        public StorageManager(string dllName, string connectionstring, string estateconnectionstring)
        {
            m_log.Info("[DATASTORE]: Attempting to load " + dllName);
            Assembly pluginAssembly = Assembly.LoadFrom(dllName);

            foreach (Type pluginType in pluginAssembly.GetTypes())
            {
                if (pluginType.IsPublic)
                {
                    if (typeof(IRegionDataStore).IsAssignableFrom(pluginType))
                    {
                        IRegionDataStore plug =
                            (IRegionDataStore)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
                        plug.Initialize(connectionstring);

                        m_dataStore = plug;

                        m_log.Info("[DATASTORE]: Added IRegionDataStore Interface");
                    }

                    if (typeof(IEstateDataStore).IsAssignableFrom(pluginType))
                    {
                        IEstateDataStore estPlug =
                            (IEstateDataStore)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
                        estPlug.Initialize(estateconnectionstring);

                        m_estateDataStore = estPlug;
                    }
                }
            }

            //TODO: Add checking and warning to make sure it initialized.
        }
Beispiel #3
0
 public void TriggerOnBackup(IRegionDataStore dstore)
 {
     handlerBackup = OnBackup;
     if (handlerBackup != null)
     {
         handlerBackup(dstore, false);
     }
 }
Beispiel #4
0
 /// <summary>
 /// Process inventory backup
 /// </summary>
 /// <param name="datastore"></param>
 public void ProcessInventoryBackup(IRegionDataStore datastore)
 {
     if (HasInventoryChanged)
     {
         HasInventoryChanged = false;
         List <TaskInventoryItem> items = GetInventoryItems();
         datastore.StorePrimInventory(m_part.UUID, items);
     }
 }
Beispiel #5
0
        /// <summary>
        /// Process inventory backup
        /// </summary>
        /// <param name="datastore"></param>
        public void ProcessInventoryBackup(IRegionDataStore datastore)
        {
            if (HasInventoryChanged)
            {
                lock (Items)
                {
                    datastore.StorePrimInventory(m_part.UUID, Items.Values);
                }

                HasInventoryChanged = false;
            }
        }
        /// <summary>
        /// Processes backup.
        /// </summary>
        /// <param name="datastore"></param>
        public virtual void ProcessBackup(IRegionDataStore datastore, bool forcedBackup)
        {
            if (!m_isBackedUp)
                return;

            // Since this is the top of the section of call stack for backing up a particular scene object, don't let
            // any exception propogate upwards.

            if (IsDeleted || UUID == UUID.Zero)
                return;

            try
            {
                if (!m_scene.ShuttingDown) // if shutting down then there will be nothing to handle the return so leave till next restart
                {
                    ILandObject parcel = m_scene.LandChannel.GetLandObject(
                            m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y);

                    if (parcel != null && parcel.LandData != null &&
                            parcel.LandData.OtherCleanTime != 0)
                    {
                        if (parcel.LandData.OwnerID != OwnerID &&
                                (parcel.LandData.GroupID != GroupID ||
                                parcel.LandData.GroupID == UUID.Zero))
                        {
                            if ((DateTime.UtcNow - RootPart.Rezzed).TotalMinutes >
                                    parcel.LandData.OtherCleanTime)
                            {
                                DetachFromBackup();
                                m_log.InfoFormat("[SCENE]: Returning object {0} due to parcel auto return", RootPart.UUID.ToString());
                                m_scene.AddReturn(OwnerID, Name, AbsolutePosition, "parcel auto return");
                                m_scene.DeRezObject(null, RootPart.LocalId,
                                    RootPart.GroupID, DeRezAction.Return, UUID.Zero);

                                return;
                            }
                        }
                    }
                }

                if (HasGroupChanged)
                {
                    // don't backup while it's selected or you're asking for changes mid stream.
                    if ((isTimeToPersist()) || (forcedBackup))
                    {
                        m_log.DebugFormat(
                            "[SCENE]: Storing {0}, {1} in {2}",
                            Name, UUID, m_scene.RegionInfo.RegionName);

                        SceneObjectGroup backup_group = Copy(OwnerID, GroupID, false);
                        backup_group.RootPart.Velocity = RootPart.Velocity;
                        backup_group.RootPart.Acceleration = RootPart.Acceleration;
                        backup_group.RootPart.AngularVelocity = RootPart.AngularVelocity;
                        backup_group.RootPart.ParticleSystem = RootPart.ParticleSystem;
                        HasGroupChanged = false;

                        datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID);

                        backup_group.ForEachPart(delegate(SceneObjectPart part) 
                        { 
                            part.Inventory.ProcessInventoryBackup(datastore); 
                        });

                        backup_group = null;
                    }
    //                else
    //                {
    //                    m_log.DebugFormat(
    //                        "[SCENE]: Did not update persistence of object {0} {1}, selected = {2}",
    //                        Name, UUID, IsSelected);
    //                }
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat(
                    "[SCENE]: Storing of {0}, {1} in {2} failed with exception {3}\n\t{4}", 
                    Name, UUID, m_scene.RegionInfo.RegionName, e, e.StackTrace);
            }
        }
Beispiel #7
0
 public void TriggerOnBackup(IRegionDataStore dstore)
 {
     handlerBackup = OnBackup;
     if (handlerBackup != null)
     {
         handlerBackup(dstore, false);
     }
 }
        /// <summary>
        /// Process inventory backup
        /// </summary>
        /// <param name="datastore"></param>
        public void ProcessInventoryBackup(IRegionDataStore datastore)
        {
            if (HasInventoryChanged)
            {
                lock (Items)
                {
                    datastore.StorePrimInventory(m_part.UUID, Items.Values);
                }

                HasInventoryChanged = false;
            }
        }
Beispiel #9
0
 public StorageManager(IRegionDataStore storage)
 {
     m_dataStore = storage;
 }
Beispiel #10
0
 public FakeStorageManager(IRegionDataStore storage) : this()
 {
 }
Beispiel #11
0
 public StorageManager(IRegionDataStore storage)
 {
     m_dataStore = storage;
 }
Beispiel #12
0
 public FakeStorageManager(IRegionDataStore storage) : this()
 {
 }
Beispiel #13
0
        public static void ProcessBulkBackup(IList<SceneObjectGroup> groups, IRegionDataStore datastore, bool forcedBackup)
        {
            List<SceneObjectGroup> groupsThatNeedBackup = new List<SceneObjectGroup>();

            foreach (SceneObjectGroup group in groups)
            {
                if (group.NeedsBackup(forcedBackup))
                {

                    SceneObjectGroup backup_group = CopyObjectForBackup(group);
                    if (backup_group != null)
                    {
                        group.IsPersisted = true;

                        //backup_group.RegionUUID = group.m_scene.RegionInfo.RegionID;
                        groupsThatNeedBackup.Add(backup_group);
                    }
                }
            }

            if (groupsThatNeedBackup.Count > 0)
            {
                m_log.DebugFormat(
                            "[SCENE]: Bulk storing {0} objects",
                            groupsThatNeedBackup.Count);

                datastore.BulkStoreObjects(groupsThatNeedBackup);


                List<KeyValuePair<UUID, IEnumerable<TaskInventoryItem>>> objectInventories
                    = new List<KeyValuePair<UUID, IEnumerable<TaskInventoryItem>>>();

                List<KeyValuePair<UUID, IEnumerable<UUID>>> deletedInventoryItems
                    = new List<KeyValuePair<UUID, IEnumerable<UUID>>>();

                foreach (SceneObjectGroup group in groupsThatNeedBackup)
                {
                    group.ForEachPart(delegate(SceneObjectPart part)
                    {
                        if (part.Inventory.InventoryNeedsBackup())
                        {
                            objectInventories.Add(part.Inventory.CollectInventoryForBackup());
                            deletedInventoryItems.Add(part.Inventory.GetDeletedItemList());
                        }
                    });
                }

                datastore.BulkStoreObjectInventories(objectInventories, deletedInventoryItems);

                m_log.Debug("[SCENE]: Bulk storage completed");
            }
        }
 public void TriggerOnBackup(IRegionDataStore dstore)
 {
     OnBackupDelegate handlerOnAttach = OnBackup;
     if (handlerOnAttach != null)
     {
         foreach (OnBackupDelegate d in handlerOnAttach.GetInvocationList())
         {
             try
             {
                 d(dstore, false);
             }
             catch (Exception e)
             {
                 m_log.ErrorFormat(
                     "[EVENT MANAGER]: Delegate for TriggerOnBackup failed - continuing.  {0} {1}", 
                     e.Message, e.StackTrace);
             }
         }
     }
 }