Database Reference
In-Depth Information
Listing 5-10. DoHiveOperations() method
public static void DoHiveOperations()
{
HiveJobCreateParameters hiveJobDefinition = new HiveJobCreateParameters()
{
JobName = "Show tables job",
StatusFolder = "/TableListFolder",
Query = "show tables;"
};
var store = new X509Store();
store.Open(OpenFlags.ReadOnly);
var cert = store.Certificates.Cast<X509Certificate2>().First(item
=> item.Thumbprint == Constants.thumbprint);
var creds = new JobSubmissionCertificateCredential(
Constants.subscriptionId, cert, Constants.clusterName);
var jobClient = JobSubmissionClientFactory.Connect(creds);
JobCreationResults jobResults = jobClient.CreateHiveJob(hiveJobDefinition);
Console.Write("Executing Hive Job.");
// Wait for the job to complete
WaitForJobCompletion(jobResults, jobClient);
// Print the Hive job output
System.IO.Stream stream = jobClient.GetJobOutput(jobResults.JobId);
System.IO.StreamReader reader = new System.IO.StreamReader(stream);
Console.Write("Done..List of Tables are:\n");
Console.WriteLine(reader.ReadToEnd());
}
Once this is done, you are ready to submit the Hive job to your cluster.
Running the Hive Job
The final step is to add a call to the DoHiveOperations() method in the Main() function. The Main() method should
now look similar to the following:
static void Main(string[] args)
{
//ListClusters();
//CreateCluster();
//DeleteCluster();
//DoCustomMapReduce();
//DoMapReduce();
DoHiveOperations();
Console.Write("Press any key to exit");
Console.ReadKey();
}
 
Search WWH ::




Custom Search