Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/07/19 23:20:52 (6 years ago)
Author:
abeham
Message:

Added further projects useful for interfacing with irace

Location:
misc/tools/HeuristicLab.HiveDrain/HiveStatus
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • misc/tools/HeuristicLab.HiveDrain/HiveStatus/App.config

    r15921 r16667  
    1 <?xml version="1.0"?>
     1<?xml version="1.0"?>
    22<configuration>
    33  <configSections>
    44    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    5       <section name="HeuristicLab.Clients.Hive.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
     5      <section name="HeuristicLab.Clients.Hive.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
    66    </sectionGroup>
    77    <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    8       <section name="HeuristicLab.Clients.Common.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
     8      <section name="HeuristicLab.Clients.Common.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
    99    </sectionGroup>
    1010  </configSections>
    11   <connectionStrings>
    12   </connectionStrings>
    13   <system.serviceModel>
    14     <behaviors />
    15     <bindings>
    16       <wsHttpBinding>
    17         <binding name="WSHttpBinding_IHiveService" receiveTimeout="00:20:00" sendTimeout="00:20:00" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
    18           <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    19           <security>
    20             <message clientCredentialType="UserName" />
    21           </security>
    22         </binding>
    23       </wsHttpBinding>
    24       <netTcpBinding>
    25         <binding name="NetBinding_IHiveService" receiveTimeout="00:20:00" sendTimeout="00:20:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
    26           <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    27           <security mode="TransportWithMessageCredential">
    28             <message clientCredentialType="UserName" />
    29           </security>
    30         </binding>
    31       </netTcpBinding>
    32     </bindings>
    33     <client>
    34       <endpoint address="http://services.heuristiclab.com/Hive-3.3/HiveService.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IHiveService" contract="HeuristicLab.Clients.Hive.IHiveService" name="WSHttpBinding_IHiveService">
    35         <identity>
    36           <dns value="services.heuristiclab.com" />
    37         </identity>
    38       </endpoint>
    39       <endpoint address="net.tcp://services.heuristiclab.com/Hive-3.3/HiveService.svc" binding="netTcpBinding" bindingConfiguration="NetBinding_IHiveService" contract="HeuristicLab.Clients.Hive.IHiveService" name="NetBinding_IHiveService">
    40         <identity>
    41           <dns value="services.heuristiclab.com" />
    42         </identity>
    43       </endpoint>
    44     </client>
    45   </system.serviceModel>
    46   <startup>
    47     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    48   </startup>
     11  <userSettings>
     12    <HeuristicLab.Clients.Common.Properties.Settings>
     13      <setting name="UserName" serializeAs="String">
     14        <value>anonymous</value>
     15      </setting>
     16      <setting name="SavePassword" serializeAs="String">
     17        <value>True</value>
     18      </setting>
     19      <setting name="Password" serializeAs="String">
     20        <value>AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAA36TvN4MDBkWUU6yPrzj49gAAAAACAAAAAAADZgAAwAAAABAAAABr3+B3SidbFwV5hCTHGoESAAAAAASAAACgAAAAEAAAAGSI+4CIIV5GmEl09qLBIxIYAAAAkpj3t9H1LBYhpUjjoM6qEc83XlY0xbnuFAAAADY3OscJ1F9ThR3SHB0sLax4TAN8</value>
     21      </setting>
     22    </HeuristicLab.Clients.Common.Properties.Settings>
     23  </userSettings>
    4924  <applicationSettings>
    5025    <HeuristicLab.Clients.Hive.Settings>
     
    8055    </HeuristicLab.Clients.Hive.Settings>
    8156  </applicationSettings>
    82   <userSettings>
    83     <HeuristicLab.Clients.Common.Properties.Settings>
    84       <setting name="UserName" serializeAs="String">
    85         <value>anonymous</value>
    86       </setting>
    87       <setting name="SavePassword" serializeAs="String">
    88         <value>True</value>
    89       </setting>
    90       <setting name="Password" serializeAs="String">
    91         <value>AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAA36TvN4MDBkWUU6yPrzj49gAAAAACAAAAAAADZgAAwAAAABAAAABr3+B3SidbFwV5hCTHGoESAAAAAASAAACgAAAAEAAAAGSI+4CIIV5GmEl09qLBIxIYAAAAkpj3t9H1LBYhpUjjoM6qEc83XlY0xbnuFAAAADY3OscJ1F9ThR3SHB0sLax4TAN8</value>
    92       </setting>
    93     </HeuristicLab.Clients.Common.Properties.Settings>
    94   </userSettings>
     57  <system.serviceModel>
     58    <behaviors/>
     59    <bindings>
     60      <wsHttpBinding>
     61        <binding name="WSHttpBinding_IHiveService" receiveTimeout="00:20:00" sendTimeout="00:20:00" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
     62          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
     63          <security>
     64            <message clientCredentialType="UserName"/>
     65          </security>
     66        </binding>
     67      </wsHttpBinding>
     68      <netTcpBinding>
     69        <binding name="NetBinding_IHiveService" receiveTimeout="00:20:00" sendTimeout="00:20:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
     70          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
     71          <security mode="TransportWithMessageCredential">
     72            <message clientCredentialType="UserName"/>
     73          </security>
     74        </binding>
     75      </netTcpBinding>
     76    </bindings>
     77    <client>
     78      <endpoint address="http://services.heuristiclab.com/Hive-3.4/HiveService.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IHiveService" contract="HeuristicLab.Clients.Hive.IHiveService" name="WSHttpBinding_IHiveService">
     79        <identity>
     80          <dns value="services.heuristiclab.com"/>
     81        </identity>
     82      </endpoint>
     83      <endpoint address="net.tcp://services.heuristiclab.com/Hive-3.4/HiveService.svc" binding="netTcpBinding" bindingConfiguration="NetBinding_IHiveService" contract="HeuristicLab.Clients.Hive.IHiveService" name="NetBinding_IHiveService">
     84        <identity>
     85          <dns value="services.heuristiclab.com"/>
     86        </identity>
     87      </endpoint>
     88    </client>
     89  </system.serviceModel>
     90  <startup>
     91    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
     92  </startup>
    9593</configuration>
  • misc/tools/HeuristicLab.HiveDrain/HiveStatus/HiveStatus.csproj

    r15921 r16667  
    99    <RootNamespace>HiveStatus</RootNamespace>
    1010    <AssemblyName>HiveStatus</AssemblyName>
    11     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     11    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
    1212    <FileAlignment>512</FileAlignment>
     13    <TargetFrameworkProfile />
    1314  </PropertyGroup>
    1415  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     
    1819    <Optimize>false</Optimize>
    1920    <OutputPath>bin\Debug\</OutputPath>
    20     <DefineConstants>DEBUG;TRACE</DefineConstants>
     21    <DefineConstants>TRACE;DEBUG</DefineConstants>
    2122    <ErrorReport>prompt</ErrorReport>
    2223    <WarningLevel>4</WarningLevel>
  • misc/tools/HeuristicLab.HiveDrain/HiveStatus/Options.cs

    r15921 r16667  
    2525namespace HiveStatus {
    2626  internal class Options {
    27     [Option('u', "user", HelpText = "Username")]
     27    [Value(0, HelpText = "Job ID to check status for, if omitted all jobs of the user will be checked.", Required = false)]
     28    public Guid JobId { get; set; }
     29
     30    [Option('u', "user", HelpText = "There are three ways to supply login information, by argument (here), by config file or by being prompted for it.")]
    2831    public string Username { get; set; }
    29     [Option('p', "password", HelpText = "Password")]
     32    [Option('p', "password", HelpText = "There are three ways to supply login information, by argument (here), by config file or by being prompted for it.")]
    3033    public string Password { get; set; }
    31 
    32     [Option('a', "all", HelpText = "Checks status of all jobs.", SetName = "ALL")]
    33     public bool All { get; set; }
    34     [Option('j', "job", HelpText = "Checks status of a certain job", SetName = "SINGLE")]
    35     public Guid JobId { get; set; }
    36     [Option('v', "verbose", HelpText = "More detailed status of a job")]
     34   
     35    [Option('v', "verbose", HelpText = "More detailed/expensive status check")]
    3736    public bool Verbose { get; set; }
    3837  }
  • misc/tools/HeuristicLab.HiveDrain/HiveStatus/Program.cs

    r15921 r16667  
    3131    public const int EXIT_OK = 0;
    3232    public const int EXIT_ERR = 1;
    33     public const int EXIT_WAITING = 2;
    34     public const int EXIT_FAILED = 3;
    35     public const int EXIT_NOTFOUND = 4;
     33    public const int EXIT_FAILED = 2;
     34    public const int EXIT_NOTFOUND = 3;
    3635
    3736    static void Main(string[] args) {
     37      //AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", "HiveStatus.exe.config");
    3838      var result = Parser.Default.ParseArguments<Options>(args)
    3939        .WithParsed(x => {
     
    4545    }
    4646
    47     private static int Run(Options opt) {
    48       if (!string.IsNullOrEmpty(opt.Username)) {
    49         HiveServiceLocator.Instance.Username = opt.Username;
    50         var password = opt.Password;
     47    private static int Run(Options opts) {
     48#if __DRY_RUN__
     49      Console.WriteLine("DONE");
     50      return EXIT_OK;
     51#endif
     52      if (string.IsNullOrEmpty(opts.Username) && HeuristicLab.Clients.Common.Properties.Settings.Default.UserName.ToLower() == "anonymous") {
     53        Console.Write("Username: ");
     54        opts.Username = Console.ReadLine();
     55      }
     56      if (!string.IsNullOrEmpty(opts.Username)) {
     57        HiveServiceLocator.Instance.Username = opts.Username;
     58        var password = opts.Password;
    5159        if (string.IsNullOrEmpty(password)) {
    52           Console.Error.Write("Password for " + opt.Username + ": ");
     60          Console.Error.Write("Password for " + opts.Username + ": ");
    5361          password = ReadPassword();
    5462        }
    5563        HiveServiceLocator.Instance.Password = password;
    5664      }
    57       return CheckStatus(opt);
     65      return CheckStatus(opts);
     66    }
     67
     68    private static int CheckStatus(Options opt) {
     69      if (opt.JobId == default(Guid)) return CheckStatusAll(opt);
     70
     71      var jobId = opt.JobId;
     72
     73      if (opt.Verbose) {
     74
     75        List<LightweightTask> tasks = null;
     76        try {
     77          tasks = HiveServiceLocator.Instance.CallHiveService(x => x.GetLightweightJobTasksWithoutStateLog(jobId));
     78        } catch (System.ServiceModel.Security.SecurityAccessDeniedException) {
     79          Console.WriteLine("?");
     80          return EXIT_NOTFOUND;
     81        }
     82
     83        int completed, failed, running, paused;
     84        GetStats(tasks, out completed, out failed, out running, out paused);
     85        Console.WriteLine(FormatStateInfo(tasks.Count, completed, failed, running, paused));
     86        return failed > 0 ? EXIT_FAILED : EXIT_OK;
     87
     88      } else {
     89
     90        Job job = null;
     91        try {
     92          job = HiveServiceLocator.Instance.CallHiveService(x => x.GetJob(jobId));
     93        } catch (System.ServiceModel.Security.SecurityAccessDeniedException) {
     94          Console.WriteLine("?");
     95          return EXIT_NOTFOUND;
     96        }
     97        Console.WriteLine(FormatStateInfo(job.JobCount, job.FinishedCount, job.CalculatingCount));
     98        return EXIT_OK;
     99      }
     100    }
     101
     102    private static int CheckStatusAll(Options opt) {
     103      List<Job> jobs = null;
     104      try {
     105        jobs = HiveServiceLocator.Instance.CallHiveService(x => x.GetJobs());
     106      } catch (System.ServiceModel.Security.SecurityAccessDeniedException) {
     107        Console.WriteLine("?");
     108        return EXIT_NOTFOUND;
     109      }
     110
     111      if (opt.Verbose) {
     112        List<LightweightTask> tasks = null;
     113        int totFinished, totFailed, totCalculating, totPaused, total;
     114        totFinished = totFailed = totCalculating = totPaused = total = 0;
     115        try {
     116
     117          foreach (var j in jobs) {
     118            tasks = HiveServiceLocator.Instance.CallHiveService(x => x.GetLightweightJobTasksWithoutStateLog(j.Id));
     119
     120            int finished, failed, calculating, paused;
     121            GetStats(tasks, out finished, out failed, out calculating, out paused);
     122            totFinished += finished;
     123            totFailed += failed;
     124            totCalculating += calculating;
     125            totPaused += paused;
     126            total += tasks.Count;
     127
     128            Console.WriteLine(FormatStateInfo(tasks.Count, finished, failed, calculating, paused) + " | " + Truncate(j.Name, 40).PadRight(40) + " | " + j.DateCreated.ToShortDateString());
     129          }
     130        } catch (System.ServiceModel.Security.SecurityAccessDeniedException) {
     131          Console.WriteLine("?");
     132          return EXIT_NOTFOUND;
     133        }
     134        Console.WriteLine();
     135        Console.WriteLine(FormatStateInfo(total, totFinished, totFailed, totCalculating, totPaused) + " | ALL");
     136        return totFailed > 0 ? EXIT_FAILED : EXIT_OK;
     137      } else {
     138        int totFinished, totCalculating, total;
     139        totFinished = totCalculating = total = 0;
     140        foreach (var j in jobs) {
     141          Console.WriteLine(FormatStateInfo(j.JobCount, j.FinishedCount, j.CalculatingCount) + " | " + Truncate(j.Name, 40).PadRight(40) + " | " + j.DateCreated.ToShortDateString());
     142          totFinished += j.FinishedCount;
     143          totCalculating += j.CalculatingCount;
     144          total += j.JobCount;
     145        }
     146        Console.WriteLine();
     147        Console.WriteLine(FormatStateInfo(total, totFinished, totCalculating) + " | ALL");
     148        return EXIT_OK;
     149      }
     150    }
     151
     152    private static void GetStats(List<LightweightTask> tasks, out int completed, out int failed, out int running, out int paused) {
     153      completed = tasks.Count(x => x.State == TaskState.Finished);
     154      failed = tasks.Count(x => x.State == TaskState.Failed || x.State == TaskState.Aborted);
     155      running = tasks.Count(x => x.State == TaskState.Calculating || x.State == TaskState.Transferring
     156|| x.State == TaskState.Waiting);
     157      paused = tasks.Count(x => x.State == TaskState.Paused);
     158    }
     159
     160    private static string FormatStateInfo(int total, int finished, int calculating) {
     161      var state = finished == total ? "DONE" : "CALC";
     162      return string.Join(" ", new object[] { state
     163        , "CALC=" + calculating.ToString().PadRight(4)
     164        , "DONE=" + finished.ToString().PadRight(4) });
     165    }
     166
     167    private static string FormatStateInfo(int total, int finished, int failed, int calculating, int paused) {
     168      var state = finished == total ? "DONE" : failed > 0 ? "FAIL" : calculating > 0 ? "CALC" : paused > 0 ? "PAUS" : "NDEF";
     169      return string.Join(" ", new object[] { state
     170        , "CALC=" + calculating.ToString().PadRight(4)
     171        , "DONE=" + finished.ToString().PadRight(4)
     172        , "FAIL=" + failed.ToString().PadRight(4)
     173        , "PAUS=" + paused.ToString().PadRight(4) });
     174    }
     175
     176    #region Helpers
     177    private static string Truncate(string text, int length) {
     178      if (text.Length <= length) return text;
     179      return text.Substring(0, length - 3) + "...";
    58180    }
    59181
     
    103225      return sb.ToString();
    104226    }
    105 
    106     private static int CheckStatus(Options opt) {
    107       if (opt.All) return CheckStatusAll(opt);
    108 
    109       var jobId = opt.JobId;
    110 
    111       if (opt.Verbose) {
    112 
    113         List<LightweightTask> tasks = null;
    114         try {
    115           tasks = HiveServiceLocator.Instance.CallHiveService(x => x.GetLightweightJobTasksWithoutStateLog(jobId));
    116         } catch (System.ServiceModel.Security.SecurityAccessDeniedException) {
    117           Console.WriteLine("?");
    118           return EXIT_NOTFOUND;
    119         }
    120 
    121         int completed, failed, running, paused;
    122         GetStats(tasks, out completed, out failed, out running, out paused);
    123         Console.WriteLine(FormatStateInfo(tasks.Count, completed, failed, running, paused));
    124         return completed == tasks.Count ? EXIT_OK : failed > 0 ? EXIT_FAILED : EXIT_WAITING;
    125 
    126       } else {
    127 
    128         Job job = null;
    129         try {
    130           job = HiveServiceLocator.Instance.CallHiveService(x => x.GetJob(jobId));
    131         } catch (System.ServiceModel.Security.SecurityAccessDeniedException) {
    132           Console.WriteLine("?");
    133           return EXIT_NOTFOUND;
    134         }
    135         Console.WriteLine(FormatStateInfo(job.JobCount, job.FinishedCount, job.CalculatingCount));
    136         return job.FinishedCount == job.JobCount ? EXIT_OK : EXIT_WAITING;
    137       }
    138     }
    139 
    140     private static int CheckStatusAll(Options opt) {
    141       List<Job> jobs = null;
    142       try {
    143         jobs = HiveServiceLocator.Instance.CallHiveService(x => x.GetJobs());
    144       } catch (System.ServiceModel.Security.SecurityAccessDeniedException) {
    145         Console.WriteLine("?");
    146         return EXIT_NOTFOUND;
    147       }
    148 
    149       if (opt.Verbose) {
    150         List<LightweightTask> tasks = null;
    151         int totFinished, totFailed, totCalculating, totPaused, total;
    152         totFinished = totFailed = totCalculating = totPaused = total = 0;
    153         try {
    154 
    155           foreach (var j in jobs) {
    156             tasks = HiveServiceLocator.Instance.CallHiveService(x => x.GetLightweightJobTasksWithoutStateLog(j.Id));
    157 
    158             int finished, failed, calculating, paused;
    159             GetStats(tasks, out finished, out failed, out calculating, out paused);
    160             totFinished += finished;
    161             totFailed += failed;
    162             totCalculating += calculating;
    163             totPaused += paused;
    164             total += tasks.Count;
    165 
    166             Console.WriteLine(FormatStateInfo(tasks.Count, finished, failed, calculating, paused) + " | " + Truncate(j.Name, 40).PadRight(40) + " | " + j.DateCreated.ToShortDateString());
    167           }
    168         } catch (System.ServiceModel.Security.SecurityAccessDeniedException) {
    169           Console.WriteLine("?");
    170           return EXIT_NOTFOUND;
    171         }
    172         Console.WriteLine();
    173         Console.WriteLine(FormatStateInfo(total, totFinished, totFailed, totCalculating, totPaused) + " | ALL");
    174         return totFinished == total ? EXIT_OK : totFailed > 0 ? EXIT_FAILED : EXIT_WAITING;
    175       } else {
    176         int totFinished, totCalculating, total;
    177         totFinished = totCalculating = total = 0;
    178         foreach (var j in jobs) {
    179           Console.WriteLine(FormatStateInfo(j.JobCount, j.FinishedCount, j.CalculatingCount) + " | " + Truncate(j.Name, 40).PadRight(40) + " | " + j.DateCreated.ToShortDateString());
    180           totFinished += j.FinishedCount;
    181           totCalculating += j.CalculatingCount;
    182           total += j.JobCount;
    183         }
    184         Console.WriteLine();
    185         Console.WriteLine(FormatStateInfo(total, totFinished, totCalculating) + " | ALL");
    186         return totFinished == total ? EXIT_OK : EXIT_WAITING;
    187       }
    188     }
    189 
    190     private static void GetStats(List<LightweightTask> tasks, out int completed, out int failed, out int running, out int paused) {
    191       completed = tasks.Count(x => x.State == TaskState.Finished);
    192       failed = tasks.Count(x => x.State == TaskState.Failed || x.State == TaskState.Aborted);
    193       running = tasks.Count(x => x.State == TaskState.Calculating || x.State == TaskState.Transferring
    194 || x.State == TaskState.Waiting);
    195       paused = tasks.Count(x => x.State == TaskState.Paused);
    196     }
    197 
    198     private static string FormatStateInfo(int total, int finished, int calculating) {
    199       var state = finished == total ? "DONE" : "CALC";
    200       return string.Join(" ", new object[] { state
    201         , "CALC=" + calculating.ToString().PadRight(4)
    202         , "DONE=" + finished.ToString().PadRight(4) });
    203     }
    204 
    205     private static string FormatStateInfo(int total, int finished, int failed, int calculating, int paused) {
    206       var state = finished == total ? "DONE" : failed > 0 ? "FAIL" : calculating > 0 ? "CALC" : paused > 0 ? "PAUS" : "NDEF";
    207       return string.Join(" ", new object[] { state
    208         , "CALC=" + calculating.ToString().PadRight(4)
    209         , "DONE=" + finished.ToString().PadRight(4)
    210         , "FAIL=" + failed.ToString().PadRight(4)
    211         , "PAUS=" + paused.ToString().PadRight(4) });
    212     }
    213 
    214     private static string Truncate(string text, int length) {
    215       if (text.Length <= length) return text;
    216       return text.Substring(0, length - 3) + "...";
    217     }
     227    #endregion
    218228  }
    219229}
Note: See TracChangeset for help on using the changeset viewer.