Exemplo n.º 1
0
        public static void saveFileInDfs(Common.File file, int numOfReplcas)
        {
            var chunks  = splitFileIntoChunks(file);
            var workers = WorkersUtil.getClientsToActiveWorkers();

            if (workers.Count < numOfReplcas)
            {
                throw new ArgumentException("You can not create more replicas than workers!");
            }

            int workerId = 0;

            foreach (var chunk in chunks)
            {
                for (int i = 0; i < numOfReplcas; i++)
                {
                    var worker = workers [workerId++ % workers.Count];
                    log.InfoFormat("Saving {0} chunk of {1} in {2}", chunk.chunkId, chunk.fileName, worker.BaseUri);

                    var request = new Worker.SaveChunk();
                    request.chunk = chunk;
                    worker.Put(request);
                }
            }
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            WorkersUtil.loadWorkersFromConfig();

            var listeningOn = args.Length == 0 ? "http://*:8080/" : args [0];
            var appHost     = new MasterHost().Init().Start(listeningOn);

            Console.WriteLine("Master Created at {0}, listening on {1}",
                              DateTime.Now, listeningOn);

            Console.ReadKey();
        }