Example #1
0
        public void InitServer()
        {
            // Communication Layer
            m_sendReceiveMiddleLayer = new SendReceiveMiddleLayer ();
            m_perfectPointToPointSend = new PerfectPointToPointSend ();

            m_perfectPointToPointSend.Start (m_sendReceiveMiddleLayer, ServerPort);
            m_sendReceiveMiddleLayer.SetPointToPointInterface (m_perfectPointToPointSend);

            // Services Layer
            m_userTableService = new UserTableServiceServer ();
            m_userTableService.SetServer (this);

            m_sendReceiveMiddleLayer.SetLookupCallback (m_userTableService.Lookup);

            m_sequenceNumberService = new SequenceNumberServiceServer ();
            m_sequenceNumberService.SetServer (this);

            m_replicationService = new ReplicationServiceServer ();
            m_replicationService.SetServer (this);

            // Register servers
            m_userTableService.UserConnect ("central-1", ServerList [0]);
            m_userTableService.UserConnect ("central-2", ServerList [1]);
            m_userTableService.UserConnect ("central-3", ServerList [2]);

            m_replicationService.Start ();

            if (m_isPuppetControlled)
            {
                m_puppetSendReceiveMiddleLayer = new SendReceiveMiddleLayer ();
                m_puppetPerfectPointToPointSend = new PerfectPointToPointSend (true);
                m_puppetPerfectPointToPointSend.Start (m_puppetSendReceiveMiddleLayer, ServerPort-100);
                m_puppetSendReceiveMiddleLayer.SetPointToPointInterface (m_puppetPerfectPointToPointSend);
                m_puppetSendReceiveMiddleLayer.SetLookupCallback (m_userTableService.Lookup);

                m_puppetService = new PuppetServerService ();
                m_puppetService.SetServer (this);
                m_puppetService.RegisterAsPuppet ();

                m_puppetService.SendInfoMsgToPuppetMaster ("Ready to serve");
            }

            DebugUncond ("Started. Available commands: \"exit\", \"status\"");
        }
Example #2
0
        public void InitClient()
        {
            // Communication Layer
            m_sendReceiveMiddleLayer = new SendReceiveMiddleLayer();
            if (m_isStressTestClient)
            {
                m_perfectPointToPointSend = new PerfectPointToPointSend (UserName);
            }
            else
            {
                m_perfectPointToPointSend = new PerfectPointToPointSend();
            }

            m_perfectPointToPointSend.Start(m_sendReceiveMiddleLayer, ClientPort);
            m_sendReceiveMiddleLayer.SetPointToPointInterface(m_perfectPointToPointSend);

            DebugInfo ("Started communication services");

            // Services
            //m_groupMulticast = new GroupMulticast ();
            m_calendarService = new CalendarServiceClient ();
            m_calendarService.SetClient (this);
            DebugInfo ("Started calendar service");

            m_lookupService = new LookupServiceClient ();
            m_lookupService.SetClient (this);
            m_sendReceiveMiddleLayer.SetLookupCallback (m_lookupService.Lookup);
            m_sendReceiveMiddleLayer.SetRotateMasterCallback (m_lookupService.RotateMaster);
            DebugInfo ("Started lookup service");

            m_sequenceNumberService = new SequenceNumberServiceClient ();
            m_sequenceNumberService.SetClient (this);
            DebugInfo ("Started numbering service");

            m_connectionServiceClient = new ConnectionServiceClient ();
            m_connectionServiceClient.SetClient (this);
            DebugInfo ("Started connection service");

            if (m_isPuppetControlled) {
                DebugInfo ("Client may be controlled by Puppet Master");
                m_puppetSendReceiveMiddleLayer = new SendReceiveMiddleLayer ();
                m_puppetPerfectPointToPointSend = new PerfectPointToPointSend (true);
                m_puppetPerfectPointToPointSend.Start (m_puppetSendReceiveMiddleLayer, ClientPort+2000);
                m_puppetSendReceiveMiddleLayer.SetPointToPointInterface (m_puppetPerfectPointToPointSend);
                m_puppetSendReceiveMiddleLayer.SetLookupCallback (m_lookupService.Lookup);

                m_puppetService = new PuppetClientService ();
                m_puppetService.SetClient (this);
                m_puppetService.RegisterAsPuppet ();

                // Automatically connect when spawned
                Connect ();

                m_puppetService.SendInfoMsgToPuppetMaster ("Ready to rock \\o/");

                DebugInfo ("Started puppet service");
            }
        }
Example #3
0
 public void SetPointToPointInterface(PerfectPointToPointSend p2p)
 {
     if (p2p != null)
     {
         m_perfectPointToPoint = p2p;
     }
     else
     {
         DebugFatal ("FATAL: SetPointToPointInterface received null p2p pointer");
     }
 }
Example #4
0
        public void InitPuppetMaster()
        {
            // Communication Layer
            m_sendReceiveMiddleLayer = new SendReceiveMiddleLayer ();
            m_perfectPointToPointSend = new PerfectPointToPointSend ();

            m_perfectPointToPointSend.Start (m_sendReceiveMiddleLayer, PuppetPort);
            m_sendReceiveMiddleLayer.SetPointToPointInterface (m_perfectPointToPointSend);

            // Services Layer
            m_puppetMasterService = new PuppetMasterService();
            m_puppetMasterService.SetPuppetMaster (this);

            m_lookupService = new LookupServicePuppet ();
            m_lookupService.SetPuppetMaster (this);
            m_sendReceiveMiddleLayer.SetLookupCallback (m_lookupService.Lookup);

            m_connectionService = new ConnectionServicePuppet();
            m_connectionService.SetPuppetMaster (this);

            DebugInfo ("Started puppet master on {0}", PuppetPort);
            //m_connectionService.Connect ();
            DebugInfo ("Puppet master registered with servers");
        }