예제 #1
0
        public IRebuilderPerfCounter Rebuild()
        {
            try
            {
                lock (coordinator.LockObject)
                {
                    if (coordinator.PortalIsRebuilding)
                    {
                        coordinator.SetPortalIsRebuilding();
                        return(rebuilder.PerformanceCounter);
                    }
                }

                rebuilder.Rebuild();

                lock (coordinator.LockObject)
                {
                    coordinator.SetPortalIsNotRebuilding();
                }

                return(rebuilder.PerformanceCounter);
            }
            catch (Exception ex)
            {
                coordinator.SetPortalIsNotRebuilding();
                WorkerRoleWebPortal.Instance.WorkerRole.Tracer.Notify(ex.Message);
                throw;
            }
            finally
            {
                rebuilder = null;
            }
        }
예제 #2
0
        public static ReadModelRebuilderWebPortal <T> CreateNew(IReadModelRebuilder <T> rebuilderInstance, IPortalTaskCoordinator coordinator)
        {
            try
            {
                lock (coordinator.LockObject)
                {
                    if (rebuilder != null)
                    {
                        throw new InvalidOperationException("Can not create new instance of ReadModelRebuilderWebPortal<T>. You should only start one instance!");
                    }

                    if (coordinator.PortalIsRebuilding)
                    {
                        throw new InvalidOperationException("Can not create new instance of ReadModelRebuilderWebPortal<T>. Is already rebuilding");
                    }

                    instance = new ReadModelRebuilderWebPortal <T>();



                    ReadModelRebuilderWebPortal <T> .coordinator = coordinator;
                    ReadModelRebuilderWebPortal <T> .coordinator.SetPortalIsNotRebuilding();

                    rebuilder = rebuilderInstance;
                }

                return(instance);
            }
            catch (Exception ex)
            {
                WorkerRoleWebPortal.Instance.WorkerRole.Tracer.Notify(ex.Message);
                throw;
            }
        }