Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Microsoft.WindowsAzure.Management.HDInsight;
- using Microsoft.Hadoop.Client;
- using System.IO;
- using System.Threading;
- using System.Security.Cryptography.X509Certificates;
- using Microsoft.Hadoop.WebHCat.Protocol;
- using Newtonsoft.Json.Linq;
- namespace SubmitMapReduceJob
- {
- public class SubmitMapReduceJob
- {
- static void Main(string[] args)
- {
- string clusterUrl = "http://someURL:50010"; /* Cluster URL */
- string mrMapper = "WordCountMapper.exe"; /* WordCount Mapper */
- string mrReducer = "WordCountReducer.exe"; /* WordCount Reducer */
- string mrMapperFile = "/WordCount/Apps/WordCountMapper.exe"; /* HDfs path */
- string mrReducerFile = "/WordCount/Apps/WordCountReducer.exe"; /*HDfs path*/
- string mrInput = "/WordCount/Input"; /* HDfs path */
- string mrOutput = "/WordCount/Output"; /* HDfs path */
- string mrStatusOutput = "/WordCount/MRStatusOutput"; /* HDfs path */
- var files = new List<string>() { "/WordCount/Apps/WordCountMapper.exe", "/WordCount/Apps/WordCountReducer.exe" };
- /* Create job object that captures details of the job. */
- var myJobDefinition = new StreamingMapReduceJobCreateParameters()
- {
- Mapper = mrMapper,
- Reducer = mrReducer,
- Input = mrInput,
- Output = mrOutput,
- StatusFolder = mrStatusOutput,
- JobName = "test"
- };
- /* Add files */
- myJobDefinition.Files.Add(mrMapperFile); /* Add mapper */
- myJobDefinition.Files.Add(mrReducerFile); /* Add reducer */
- var creds = new BasicAuthCredential(); /* Basic Authentication Connection */
- creds.UserName = "hadoop"; /* hadoop cluster User Name */
- creds.Password = "India@123"; /* hadoop Cluster Password */
- creds.Server = new Uri(clusterUrl); /* Connection URL */
- var jobClient = JobSubmissionClientFactory.Connect(creds); /* Cluster Connection */
- // Run the MapReduce job
- Console.WriteLine("----- Submit the Hadoop streaming job ...");
- JobCreationResults mrJobResults = jobClient.CreateStreamingJob(myJobDefinition);
- // Wait for the job to complete
- Console.WriteLine("----- Wait for the Hadoop streaming job to complete ...");
- WaitForJobCompletion(mrJobResults, jobClient); /* Wait for the job to complete */
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement