none
ServiceAsClientIdentityProvider does not exist? RRS feed

  • Question

  • I hope this is a simple question, a few things going on here that I am new to.

    Using HPC Pack 2016, with Microsoft.HPC.SDK 5.0.5852-beta1, trying to create an ASP.NET C#/Razor webapp that allows clients to see status of their running jobs, and will eventually want to allow them to submit jobs via this web page.  Using the iScheduler.Connect method with just the clustername, the browser hangs and never responds, and in Visual Studio 2017 it now shows the Connect method as obsolete.  So trying to move to the ConnectServiceAsClient method, but I cannot figure out the ServiceAsClientIdentityProvider piece.  Reading through the following post, but the same or similar code recommended doesn't work as the ServiceAsClientIdentityProvider function "does not exist in the current context".  Building a C# Console App with just the Connect method works great.

    https://social.microsoft.com/Forums/en-US/1c290a38-4135-47d9-8b7d-30c160aaf439/microsoft-hpc-how-to-control-cluster-job-add-cancel-node-onlineoffline-outside-of-domain?forum=windowshpcdevs

    Current code:

    @using Microsoft.Hpc.Scheduler;
    @using Microsoft.Hpc.Scheduler.Properties.
    
    @{
        string HPCClusterName = "localhost";
        string currentUser = User.Identity.Name;
    
        using (var myScheduler = new Scheduler())
        {
            myScheduler.ConnectServiceAsClient(HPCClusterName, currentUser);
        {
    }
    
    

    It doesn't like receiving currentUser as the ServiceAsClientIdentityProvider since currentUser is a string.

    Any help would be VERY much appreciated!
    Thanks!
    -Matt

    Tuesday, April 11, 2017 1:19 PM

Answers

  • Hi Matt,

    You can call IScheduler.ConnectAsync like this:

    IHpcContext context = HpcContext.GetOrAdd("headnodename",CancellationToken.None);
    Scheduler scheduler = new Scheduler();
    await scheduler.ConnectAsync(new SchedulerConnectionContext(context), CancellationToken.None);

    While Schduler.Connect() is marked obsolete, it is still safe to use it. You can wrap a Task.Run() around the connect call like this as a work around of the dead lock:

    Scheduler scheduler = new Scheduler();
    Task.Run(scheduler.Connect("headnodename")).Wait();

    And the dead lock has been fixed in our later version SDK.

    Thanks,

    Zihao

    • Marked as answer by MattManDL Tuesday, April 25, 2017 2:19 PM
    Thursday, April 20, 2017 1:37 AM

All replies

  • Update, I just had to add the Microsoft.HPC namespace, and then the ServiceAsClientIdentityProvider function became available. Also had to move the User.Identity.Name to a function that just returned the username as a string.  So that got me past the errors with ConnectServiceAsClient...

    But now I am having the same issue as with the Connect method.  My browser just spins neverending.  Doesn't timeout, no errors, just spins.  Nothing crazy happening on the HPC HeadNode, where IIS is running, regarding CPU activity or anything.  Just nothing happening!?!

    Has anyone successfully got an ASP.NET page to connect to their HPC Cluster for simple things like just listing available nodes and current jobs?  I would LOVE to get an error or something out of this, but it just sits and spins.

    Updated Code, along with web.config:

    @using Microsoft.Hpc;
    @using Microsoft.Hpc.Scheduler;
    @using Microsoft.Hpc.Scheduler.Properties;
    
    @{
        string HPCClusterName = "localhost";
    
        using (IScheduler myScheduler = new Scheduler())
        {
            ServiceAsClientIdentityProvider myID = new ServiceAsClientIdentityProvider(getWebUserName);
            myScheduler.ConnectServiceAsClient(HPCClusterName, myID);
            //See if we are actually connected to HPC Cluster
            <text> (@myScheduler.GetServerVersion()) </text>
            //foreach (ISchedulerJob job in myScheduler.GetJobList(null, null))
            //{
            //    <text> (@job.Name) - (@job.State) </text>
            //}
        }
    }
    
    @functions{
        public string getWebUserName()
        {
            return User.Identity.Name;
        }
    }
    

    <configuration>
      <system.web>
        <customErrors mode="Off" />
        <compilation targetFramework="4.5.2">
          <assemblies>
            <add assembly="System.Net.Http, Version=4.0.0.0, Culture=neutral/>
            <add assembly="System.Management.Automation, Version=1.0.0.0, Culture=neutral/>
          </assemblies>
        </compilation>
        <httpRuntime targetFramework="4.5.2" />
        <authentication mode="Windows" />
        <identity impersonate="true"/>
      </system.web>
      <appSettings>
        <add key="autoFormsAuthentication" value="false" />
        <add key="enableSimpleMembership" value="false" />
      </appSettings>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Optimization" />
            <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="WebGrease" />
            <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Helpers" />
            <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.WebPages" />
            <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="Newtonsoft.Json" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
      <system.codedom>
        <compilers>
          <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
          <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
        </compilers>
      </system.codedom>
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
      </system.webServer>
    </configuration>
    

    Tuesday, April 11, 2017 1:54 PM
  • Hi,

    Suppose you don't need use ServiceAsClient feature, right, just because iScheduler.Connect hangs,

    two workarounds here:

    1) you can call async method, just iScheduler.ConnectAsync method

    2) Or you can run as the following way: Task.run(()=>iScheduler.Connect());

    We will fix this issue in HPC 2016 Update 1

    Wednesday, April 12, 2017 3:16 AM
  • I appreciate the reply, but am really struggling with either option.  I can't find any documentation that explains the ConnectAsync method, specifically the SchedulerConnectionContext.  The HPC Reference does not include that information.

    Also, reading through the lambda operator example you gave, I am again struggling to get that to work.

    Do you have a more complete code sample for either option?

    Thanks!
    -Matt

    Wednesday, April 19, 2017 4:00 PM
  • Hi Matt,

    You can call IScheduler.ConnectAsync like this:

    IHpcContext context = HpcContext.GetOrAdd("headnodename",CancellationToken.None);
    Scheduler scheduler = new Scheduler();
    await scheduler.ConnectAsync(new SchedulerConnectionContext(context), CancellationToken.None);

    While Schduler.Connect() is marked obsolete, it is still safe to use it. You can wrap a Task.Run() around the connect call like this as a work around of the dead lock:

    Scheduler scheduler = new Scheduler();
    Task.Run(scheduler.Connect("headnodename")).Wait();

    And the dead lock has been fixed in our later version SDK.

    Thanks,

    Zihao

    • Marked as answer by MattManDL Tuesday, April 25, 2017 2:19 PM
    Thursday, April 20, 2017 1:37 AM
  • Zihao, it worked!  Thank you so much.

    I could not get the ConnectAsync to work, still the same behavior of no response in browser.  But the Task.Run worked great!  Very excited to be moving forward with this project finally.

    The code I used was:

    public ISchedulerCollection getHPCJobsCollection()
    {
         Scheduler myScheduler = new Scheduler();
         var t = Task.Run(() => myScheduler.Connect("ClusterName"));
         t.Wait();
         return myScheduler.GetJobList(null, null);
    }
    @{   ISchedulerCollection myJobList;
         myJobList = getHPCJobsCollection();
    }
    <table>
         <tr><th>Name</th><th>Status</th><th>Owner</th><th>Submit Date/Time</th><th>Finish Date/Time</th></tr>
    
         @foreach (ISchedulerJob job in myJobList)
         {
              <tr><td>@job.Name</td><td>@job.State</td><td>@job.Owner</td><td>@job.CreateTime</td><td>@job.EndTime</td></tr>
         }
    </table>
    



    • Edited by MattManDL Tuesday, April 25, 2017 2:23 PM
    Tuesday, April 25, 2017 2:19 PM