Exemplo n.º 1
0
        public void Stop()
        {
            List <Task> waiters = new List <Task>();

            foreach (var pg in processes.Values)
            {
                waiters.Add(pg.manager.KillRunningProcessesAsync(exitCode == 0, exitString));
            }

            lock (this)
            {
                UpdateStatus(Constants.ServiceState.Stopped, status.epoch + 1, 1);
            }

            if (server != null)
            {
                server.Stop();
            }

            server = null;

            Task.WaitAll(waiters.ToArray());

            if (dfsClient != null)
            {
                dfsClient.Dispose();
                dfsClient = null;
            }
        }
Exemplo n.º 2
0
 public DirectoryStreamReader(DfsClient client, Uri directoryPath)
 {
     this.client         = client;
     this.directoryFiles = client.ExpandFileOrDirectory(directoryPath).GetEnumerator();
     this.currentStream  = null;
 }
Exemplo n.º 3
0
        public bool Initialize(string configName, Uri jobDirectoryUri, ILogger l)
        {
            logger = l;

            jobGuid = Guid.NewGuid();

            logger.Log("PersistentProcessManager initializing for job " + jobGuid.ToString());

            if (jobDirectoryUri != null)
            {
                if (jobDirectoryUri.Scheme == "azureblob")
                {
                    try
                    {
                        dfsClient = new Azure.AzureDfsClient(jobDirectoryUri);
                        dfsClient.EnsureDirectory(jobDirectoryUri, false);
                    }
                    catch (Exception e)
                    {
                        logger.Log("Failed to make Azure DFS client for " + jobDirectoryUri.AbsoluteUri + ": " + e.ToString());
                    }
                }
                else if (jobDirectoryUri.Scheme == "hdfs")
                {
                    try
                    {
                        dfsClient = new Hdfs.HdfsClient(Environment.UserName);
                        dfsClient.EnsureDirectory(jobDirectoryUri, false);
                    }
                    catch (Exception e)
                    {
                        logger.Log("Failed to make HDFS client for " + jobDirectoryUri.AbsoluteUri + ": " + e.ToString());
                    }
                }
            }

            exitCode   = 0;
            exitString = "Successful execution";

            try
            {
                processes = new Dictionary <string, ProcessGroup>();

                Logger.Log("Loading XML config " + configName);
                var configDoc = XDocument.Load(configName);
                var outer     = configDoc.Descendants("PeloponneseServer").Single();

                portNumber = int.Parse(outer.Descendants("Port").Single().Value);
                httpPrefix = outer.Descendants("Prefix").Single().Value;

                var process = outer.Descendants("ProcessGroup");
                foreach (var pg in process)
                {
                    InitializeProcessGroup(pg);
                }

                status  = new Status(Constants.ServiceState.Running, 0, 0, new byte[0]);
                waiters = new Dictionary <string, StatusWaiter>();

                return(true);
            }
            catch (Exception e)
            {
                Logger.Log("Failed to read config " + e.ToString());
            }

            return(false);
        }