Esempio n. 1
0
        public void Roundtrip()
        {
            Console.WriteLine("Starting...");
            var client = new MemoryClient();
            var passed = false;
            var pager  = new PagedClient(client, "test");

            using (var s = new CancellationTokenSource(TimeSpan.FromSeconds(10))) {
                var unpackedMessage = new UnpackedMessage(GetBytes(Constants.MaxKeySize),
                                                          GetBytes(Constants.MaxValueSize * 5 + 1));
                Console.WriteLine("Pub...");
                pager.Publish(new[] { unpackedMessage }).Wait(s.Token);
                Console.WriteLine("Waiting...");

                pager.ChaseEventsForever(s.Token, (id, subscription) => {
                    CollectionAssert.AreEqual(unpackedMessage.Value, id.Value);
                    CollectionAssert.AreEqual(unpackedMessage.Key, id.Key);
                    passed = true;
                    Console.WriteLine("Got it" + id);
                    s.Cancel();
                });
            }

            if (!passed)
            {
                Assert.Fail("Failed");
            }
        }
Esempio n. 2
0
        //Construct a new MemoryManager with the given MemoryClient and memory size
        public MemoryManager(MemoryClient memoryClient, short memorySize)
        {
            //TODO: Implement me

            //Set the MemoryManager's memorySize
            this.memorySize = memorySize;
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var ms = new MemoryClient("q666");

            Console.WriteLine(((A)ms.Read("q")).a);


            var mss = new MemoryServices("zzzz");

            mss.Write("z", "我是测试");

            Console.ReadLine();
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            var ms = new MemoryServices("q666");

            ms.Write("q", new A {
                a = 6666
            });


            var ml = new MeoryListen("zzzz");

            ml.Register("z", () =>
            {
                var msc = new MemoryClient("zzzz");
                Console.WriteLine(msc.Read("z"));
            });
            Console.Read();
        }
Esempio n. 5
0
        //Begin the Master node
        public void run()
        {
            Console.Out.WriteLine("[MasterManager] Starting a new HypeVM instance...");
            Console.Beep();//TODO: what


            //Read the configuration file
            //TODO: Implement file reading
            TextReader textReader = new TextReader(configFilePath);

            //TODO: Implement the reading of lines
            textReader.getNextLine();

            //TODO: Test configuration put in place whilst I work on the TextReader module
            string memoryServerIP   = "127.0.0.1";
            int    memoryServerPort = 3001;

            string registerServerIP   = "127.0.0.1";
            int    registerServerPort = 3002;

            //Set the memory size to the maximum possible size for the HypeVM
            short memorySize = 32767;

            //Setup the relevant servers
            Console.Out.WriteLine("[MasterManager] Setting up servers...");

            //Setup the MemoryClient
            //TODO: Implement me
            MemoryClient memoryClient = new MemoryClient(memoryServerIP, memoryServerPort, memorySize);

            //Setup anything that needs to be setup for the MemoryClient and then begin its Thread
            memoryClient.start();

            //Setup the RegisterClient
            //TODO: Implement me
            RegisterClient registerClient = new RegisterClient(registerServerIP, registerServerPort);

            //Setup anything that needs to be setup for the RegisterClient and then begin its Thread
            registerClient.start();


            //Setup the managers
            Console.Out.WriteLine("[MasterManager] Setting up managers...");

            //Setup the MemoryManager
            //TODO: Implement me
            MemoryManager memoryManager = new MemoryManager(memoryClient, memorySize);


            //Setup the RegisterManager
            //TODO: Implement me
            RegisterManager registerManager = new RegisterManager(registerClient);

            //Setup the DeviceManager
            //TODO: Implement me
            //DeviceManager deviceMamnager = null;


            Console.Out.WriteLine("[MasterManager] Setting up virtual machine...");

            //Create the virtual machine
            VM virtualMachine = new VM(memoryManager, registerManager, null);

            //Load the init image into the machine's memory and set the respective registers
            virtualMachine.bootMachine("init.img"); //TODO: change me

            //Start the virtual machine
            virtualMachine.beginRun();


            //Virtual machine has ended
            Console.Out.WriteLine("[MasterManager] VM run completed.");
        }