locked
Change WorkDirectory with Job Submission Filter RRS feed

  • Question

  • Dear all,

    Currently I am trying to use Job Submission Filter to change the WorkDirectory of a job, but I have not been able to make it to work successfully.

    The reason why I am doing this is because I want force each job to use the correct (internal hostname) work directory path.

    For example,

    "\\FileServer\\share" is the path that users use to access the file server from a client machine.

    "\\LocalFS\\share" is the path (private network) used inside the cluster.

    So, if a job's work directory contains "\\FileServer\", I want to convert it to "\\LocalFS\" by using job submission filter.

    I have posted the C# code below.

    I have used File.Copy to copy the xml file to make sure the change has been made, and it seems like the path in the xml file had been modified successfully,

    but the path in the job remains unchanged.

    Changing job priority worked with out problem.

    Could someone tell me if I am doing something wrong, or maybe changing WorkDirectory is not supported?

     XmlDocument xml = new XmlDocument();  
     XmlAttributeCollection attributes, attributes2;
      
     xml.Load(args[0]);
            XmlNamespaceManager nsMgr = new XmlNamespaceManager(xml.NameTable);
            nsMgr.AddNamespace("hpc", "http://schemas.microsoft.com/HPCS2008R2/scheduler/");
    
            XmlNode job = null;
            XmlNode job2 = null;
            
            job = xml.SelectSingleNode("/hpc:Job",nsMgr);        
    
            foreach (XmlNode temp in job.ChildNodes)
              if (temp.Name == "Tasks")
              {
                job2 = temp.ChildNodes[0];
                break;
              }
    
            attributes = job.Attributes;
            attributes2 = job2.Attributes;
    
            attributes["Priority"].Value = JobPriority.Highest.ToString();
    
            File.Copy(args[0], "D:\\temp\\org.xml", true);
            attributes2["WorkDirectory"].Value = "\\\\Machine1\\Share"; //Forceing WorkDirectory to \\Machine1\\Share just for testing.
            xml.Save(args[0]);
            File.Copy(args[0], "D:\\temp\\moded.xml", true);
            
            return 1;
    
    

    By the way, is there a easier way to access the attributes of "Tasks" other than using foreach loop?

            foreach (XmlNode temp in job.ChildNodes)
              if (temp.Name == "Tasks")
              {
                job2 = temp.ChildNodes[0];
                break;
              }
    

    Thank you.

    Friday, November 12, 2010 7:59 AM

Answers

  • After a little more research the current submission filter design only allow you to change job properties, not task properties.
    Wednesday, January 12, 2011 12:26 AM

All replies

  • Hi,

      As during the stage of executing of Submission/Activation filter, the job's tasks are in "Submitted/Queued" state which means they're not allowed to be modified. Details please see (http://technet.microsoft.com/en-us/library/dd346640(WS.10).aspx)

      From my understanding, you're forcing user to use some format of workdir. So you can block the submission with error message to user to change to the right working dir (Your submission filter's Error output will be shown in the job's "Error Message" property. As a simple testimony, I write below batch file and set as submission filter.

    -------------------------------------------

    echo Please change your task's workdir from xxx to ooo and submit again >&2

    exit /b -1

    -------------------------------------------

    Then each time I try submit job from job console I'll get error dialog saying "Failed to pass job submission filter. Error: Please change your task's workdir from xxx to ooo and submit again"

    Hope this helps.


    Qiufang Shi
    Thursday, January 6, 2011 6:30 AM
  • After a little more research the current submission filter design only allow you to change job properties, not task properties.
    Wednesday, January 12, 2011 12:26 AM