Exemplo n.º 1
0
        // Public methods

        /// <summary>
        /// Basically the Site DTO passed as paramenter has all the information about the broker site.
        /// </summary>
        /// <param name="o"> Site DTO </param>
        public override void Init(Object o)
        {
            SiteDTO site = o as SiteDTO;

            Console.Write(site);
            IsRoot           = site.IsRoot;
            SiteName         = site.Name;
            this.remoteProxy = new BrokerSiteFrontEnd(site.Brokers, SiteName);
            if (!IsRoot)
            {
                parentSiteBroker = new BrokerSiteFrontEnd(site.Parent.Brokers, site.Parent.Name);
                parentName       = site.Parent.Name;
            }
            else
            {
                parentName = null;
            }
            foreach (BrokerPairDTO dto in site.Brokers)
            {
                brothers.Add(Activator.GetObject(typeof(IBroker), dto.Url) as IBroker);
            }
            foreach (SiteDTO.SiteBrokers dto in site.Childs)
            {
                childSites.Add(dto.Name, new BrokerSiteFrontEnd(dto.Brokers, dto.Name));
            }
            logServer = Activator.GetObject(typeof(IPuppetMasterLog), pmLogServerUrl) as IPuppetMasterLog;
            Console.WriteLine("Broker up and running.......");
        }
 public PublisherLogic(string name, string pmLogServerUrl)
 {
     this.sequenceNumber = 0;
     this.name           = name;
     pool      = new CommonTypes.ThreadPool(10);
     logServer = Activator.GetObject(typeof(IPuppetMasterLog), pmLogServerUrl)
                 as IPuppetMasterLog;
 }
Exemplo n.º 3
0
 public PublisherLogic(string name, string pmLogServerUrl)
 {
     this.sequenceNumber = 0;
     this.name = name;
     pool = new CommonTypes.ThreadPool(10);
     logServer = Activator.GetObject(typeof(IPuppetMasterLog), pmLogServerUrl)
         as IPuppetMasterLog;
 }
Exemplo n.º 4
0
 public SubscriberLogic(ISubscriber myProxy,string orderingPolicy, string name,
     string pmLogServerUrl, string loggingLevel)
 {
     pool = new CommonTypes.ThreadPool(1);
     this.myProxy = myProxy;
     this.name = name;
     this.loggingLevel = loggingLevel;
     this.ordering = orderingPolicy;
     this.freezer = new List<Event>();
     if (orderingPolicy.Equals("FIFO"))
     {
         this.repeated = new DetectRepeatedFIFO();
     }
     else if (orderingPolicy.Equals("NO") || orderingPolicy.Equals("TOTAL"))
     {
         this.repeated = new DetectRepeatedMessageNO();
     }
     logServer = Activator.GetObject(typeof(IPuppetMasterLog), pmLogServerUrl)
         as IPuppetMasterLog;
 }
 public SubscriberLogic(ISubscriber myProxy, string orderingPolicy, string name,
                        string pmLogServerUrl, string loggingLevel)
 {
     pool              = new CommonTypes.ThreadPool(1);
     this.myProxy      = myProxy;
     this.name         = name;
     this.loggingLevel = loggingLevel;
     this.ordering     = orderingPolicy;
     this.freezer      = new List <Event>();
     if (orderingPolicy.Equals("FIFO"))
     {
         this.repeated = new DetectRepeatedFIFO();
     }
     else if (orderingPolicy.Equals("NO") || orderingPolicy.Equals("TOTAL"))
     {
         this.repeated = new DetectRepeatedMessageNO();
     }
     logServer = Activator.GetObject(typeof(IPuppetMasterLog), pmLogServerUrl)
                 as IPuppetMasterLog;
 }
Exemplo n.º 6
0
        public ReplicaObject(string PuppetMasterUrl, string routing, string semantics,
                             string logLevel, Operation operation, List <string> output, string replicaAddress, string operationName,
                             List <string> allAdresses)
        {
            tupleQueue           = new Queue();
            this.PuppetMasterUrl = PuppetMasterUrl;
            this.logLevel        = logLevel.Equals("full");
            this.operation       = operation;
            this.replicaAddress  = replicaAddress;
            this.operationName   = operationName;
            allReplicasURL       = allAdresses;
            failedPings          = new Dictionary <string, int>();
            replicasState        = new Dictionary <string, int>();

            foreach (string s in allReplicasURL)
            {
                if (!s.Equals(replicaAddress))
                {
                    failedPings.Add(s, 0);
                    replicasState.Add(s, OK);
                }
            }

            string routingLower = routing.ToLower();

            char[]   delimiters = { '(', ')' };
            string[] splitted   = routingLower.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

            once        = semantics.Equals("exactly-once");
            atLeastOnce = semantics.Equals("at-least-once");

            if (once || atLeastOnce)
            {
                failureDetectorThread   = new Thread(() => failureDetector());//TODO check if it is use in jus exacly once or some else;
                notAssignedTuplesThread = new Thread(() => notAssignedTuples());
                notAssignedTuplesThread.Start();
            }


            if (splitted[0].Equals("primary"))
            {
                router = new PrimaryRouter(output, semantics);
            }
            else if (splitted[0].Equals("random"))
            {
                router = new RandomRouter(output, semantics);
            }
            else
            {
                router = new HashRouter(output, semantics, int.Parse(splitted[1]));
            }

            // Starts the structure needed for replication
            foreach (string addr in allReplicasURL)
            {
                if (!addr.Equals(replicaAddress))
                {
                    processingOnOther.Add(addr, new Dictionary <string, OtherReplicaTuple>());
                }
            }

            // Assuming that the service is in: tcp://<PuppetMasterIP>:10001/log
            string testpuppetAddress = PuppetMasterUrl + "/log";

            try
            {
                log = (IPuppetMasterLog)Activator.GetObject(typeof(IPuppetMasterLog),
                                                            testpuppetAddress);
            }
            catch (Exception e)
            {
                Console.WriteLine("first e: " + e);
            }
        }
Exemplo n.º 7
0
 // Public methods
 /// <summary>
 /// Basically the Site DTO passed as paramenter has all the information about the broker site.
 /// </summary>
 /// <param name="o"> Site DTO </param>
 public override void Init(Object o)
 {
     SiteDTO site = o as SiteDTO;
     Console.Write(site);
     IsRoot = site.IsRoot;
     SiteName = site.Name;
     this.remoteProxy = new BrokerSiteFrontEnd(site.Brokers, SiteName);
     if (!IsRoot)
     {
         parentSiteBroker = new BrokerSiteFrontEnd(site.Parent.Brokers, site.Parent.Name);
         parentName = site.Parent.Name;
     }
     else
     {
         parentName = null;
     }
     foreach(BrokerPairDTO dto in site.Brokers)
     {
         brothers.Add(Activator.GetObject(typeof(IBroker), dto.Url) as IBroker);
     }
     foreach(SiteDTO.SiteBrokers dto in site.Childs)
     {
         childSites.Add(dto.Name, new BrokerSiteFrontEnd(dto.Brokers, dto.Name));
     }
     logServer = Activator.GetObject(typeof(IPuppetMasterLog), pmLogServerUrl) as IPuppetMasterLog;
     Console.WriteLine("Broker up and running.......");
 }