Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.WindowsAzure.Management.HDInsight;
  7. using Microsoft.Hadoop.Client;
  8. using System.IO;
  9. using System.Threading;
  10. using System.Security.Cryptography.X509Certificates;
  11. using Microsoft.Hadoop.WebHCat.Protocol;
  12. using Newtonsoft.Json.Linq;
  13.  
  14. namespace SubmitMapReduceJob
  15. {
  16. public class SubmitMapReduceJob
  17. {
  18. static void Main(string[] args)
  19. {
  20.  
  21. string clusterUrl = "http://someURL:50010"; /* Cluster URL */
  22. string mrMapper = "WordCountMapper.exe"; /* WordCount Mapper */
  23. string mrReducer = "WordCountReducer.exe"; /* WordCount Reducer */
  24. string mrMapperFile = "/WordCount/Apps/WordCountMapper.exe"; /* HDfs path */
  25. string mrReducerFile = "/WordCount/Apps/WordCountReducer.exe"; /*HDfs path*/
  26. string mrInput = "/WordCount/Input"; /* HDfs path */
  27. string mrOutput = "/WordCount/Output"; /* HDfs path */
  28. string mrStatusOutput = "/WordCount/MRStatusOutput"; /* HDfs path */
  29.  
  30. var files = new List<string>() { "/WordCount/Apps/WordCountMapper.exe", "/WordCount/Apps/WordCountReducer.exe" };
  31.  
  32.  
  33.  
  34.  
  35. /* Create job object that captures details of the job. */
  36. var myJobDefinition = new StreamingMapReduceJobCreateParameters()
  37. {
  38. Mapper = mrMapper,
  39. Reducer = mrReducer,
  40. Input = mrInput,
  41. Output = mrOutput,
  42. StatusFolder = mrStatusOutput,
  43. JobName = "test"
  44. };
  45.  
  46. /* Add files */
  47. myJobDefinition.Files.Add(mrMapperFile); /* Add mapper */
  48. myJobDefinition.Files.Add(mrReducerFile); /* Add reducer */
  49. var creds = new BasicAuthCredential(); /* Basic Authentication Connection */
  50. creds.UserName = "hadoop"; /* hadoop cluster User Name */
  51. creds.Password = "India@123"; /* hadoop Cluster Password */
  52. creds.Server = new Uri(clusterUrl); /* Connection URL */
  53. var jobClient = JobSubmissionClientFactory.Connect(creds); /* Cluster Connection */
  54. // Run the MapReduce job
  55. Console.WriteLine("----- Submit the Hadoop streaming job ...");
  56. JobCreationResults mrJobResults = jobClient.CreateStreamingJob(myJobDefinition);
  57.  
  58. // Wait for the job to complete
  59. Console.WriteLine("----- Wait for the Hadoop streaming job to complete ...");
  60. WaitForJobCompletion(mrJobResults, jobClient); /* Wait for the job to complete */
  61. }
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement