5th June Batch

Name of Innovation

5th June Batch

June 7, 2017 Uncategorized 0

public class HelloWorld {

public static void main(String[] args) {

System.out.println(“Hello World!”);

}

}

 

 

 

 

curl -u admin:admin -X delete "http://192.168.0.12:8161/api/message/&clientId=consumerA"


import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.util.Tool;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.util.ToolRunner;

public class HdfsWriter extends Configured implements Tool {
 
 public static final String FS_PARAM_NAME = "fs.defaultFS";
 
 public int run(String[] args) throws Exception {
 
 if (args.length < 2) {
 System.err.println("HdfsWriter [local input path] [hdfs output path]");
 return 1;
 }
 
 String localInputPath = args[0];
 Path outputPath = new Path(args[1]);

Configuration conf = getConf();
 conf.addResource(new Path("/home/amar/hadoop-2.6.0/etc/hadoop/hdfs-site.xml"));
 conf.addResource(new Path("/home/amar/hadoop-2.6.0/etc/hadoop/core-site.xml"));

System.out.println("configured filesystem = " + conf.get(FS_PARAM_NAME));
 FileSystem fs = FileSystem.get(conf);
 if (fs.exists(outputPath)) {
 System.err.println("output path exists");
 return 1;
 }
 
 OutputStream os = fs.create(outputPath);
 InputStream is = new BufferedInputStream(new FileInputStream(localInputPath));
 IOUtils.copyBytes(is, os, conf);
 return 0;
 }
 
 public static void main( String[] args ) throws Exception {
 int returnCode = ToolRunner.run(new HdfsWriter(), args);
 System.exit(returnCode);
 }
}

 

Input list 


Amar,M,15000
Arpitha,F,20000
Tejas,M,13000
Shaurya,M,19000
Rakshitha,F,18000
Prudhvi,M,23000
Srikhar,M,17000
Shreya,F,25000


Write the code and execute it on your laptop –

1. Using mapreduce, get the max temperature from the following input list –

233

245

123

2445

123

12

15

2. Using MapReduce from the following inout list – find the sum and average of the salaries genderwise.

Amar,M,15000

Arpitha,F,20000

Tejas,M,13000

Shaurya,M,19000

Rakshitha,F,18000

Prudhvi,M,23000

Srikhar,M,17000

Shreya,F,25000

Please attempt that at home and make sure that you do the coding as well – the difficulties we will see in tomorrow’s class.

 

#!/bin/bash
source ~/sourceme
mkdir -p ~/amar
rm ~/amar/in/woir/http/*.class
rm ~/amar/in/woir/http1/*.class
javac -d /home/amar/amar HelloWorld.java WOIR.java
java -cp /home/amar/amar:. in.woir.http.HelloWorld





package in.woir.http;
public class WOIR {
 private String batch;
 private String training_name ;
 public String getBatch(){
 return batch;
 }
 public String getTraining(){
 return training_name;
 }
 public String setTraining( String name){
 training_name = name ;
 }
 public String setBatch( String name){
 batch = name ;
 }
}

package in.woir.http;
import in.woir.http.*;
public class HelloWorld {

 public static void main(String[] args) {
 System.out.println("Hello, World");
 WOIR w = new WOIR();
 }

}



 

——————————————

 

public class HelloWorld {

public static void main(String[] args) {
// Prints “Hello, World” to the terminal window.
System.out.println(“Hello, World” + args[0]);
}

}
public class WOIR {
public void printme( ){
System.out.println(“Hello, World From WOIR”);
}
}