· 7 years ago · Oct 23, 2018, 02:08 PM
1Ex. No: 1
2
3Date:
4
5
6AIM:
7
8
9
10
11
12STUDY OF ALL COMPUTING TECHNOLOGY
13
14
15
16To study the different computing technologies like Distributed Computing, Ubiquitous computing, Cluster computing and Mobile computing.
17
18Client server computing:
19
20Client/Server computing is a computing model in which client and server computers communicate with each other over a network. In client/server computing, a server takes requests from client computers and shares its resources, applications and/or data with one or more client computers on the network, and a client is a computing device that initiates contact with a server in order to make use of a shareable resource.
21
22
23
24
25
26
27
28
29
30
31Peer to Peer Computing:
32
33Peer-to-peer (P2P) is a decentralized communications model in which each party has the same capabilities and either party can initiate a communication session. Unlike the client/server model, in which the client makes a service request and the server fulfills the request, the P2P network model allows each node to function as both a client and server.
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57Centralized Computing:
58
59Centralized computing is computing done at a central location, using terminals that are attached to a central computer. The computer itself may control all the peripherals directly (if they are physically connected to the central computer), or they may be attached via a terminal server. Alternatively, if the terminals have the capability, they
60
61
62may be able to connect to the central computer over the network. The terminals may be text terminals or thin clients.
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77Parallel Computing:
78
79Parallel computing is a type of computing architecture in which several processors execute or process an application or computation simultaneously. Parallel computing helps in performing large computations by dividing the workload between more than one processor, all of which work through the computation at the same time. Most supercomputers employ parallel computing principles to operate.Parallel computing is also known as parallel processing.
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100Distributed Computing:
101
102Distributed computing is a computing concept that, in its most general sense, refers to multiple computer systems working on a single problem. In distributed computing, a single problem is divided into many parts, and each part is solved by different computers. As long as the computers are networked, they can communicate with each other to solve the problem. If done properly, the computers perform like a single entity.
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120Grid Computing:
121
122Grid computing is a processor architecture that combines computer resources from various domains to reach a main objective. In grid computing, the computers on the network can work on a task together, thus functioning as a supercomputer.
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139Utility Computing:
140
141Utility computing is the process of providing computing service through an on-demand, pay-per-use billing method. Utility computing is a computing business model in which the provider owns, operates and manages the computing infrastructure and resources, and the subscriber‟s accesses it as and when required on a rental or metered basis.
142
143Pervasive Computing (or) ubiquitous computing:
144
145Pervasive computing is an emerging trend associated with embedding microprocessors in day-to-day objects, allowing them to communicate information. It is also known as ubiquitous computing. The terms ubiquitous and pervasive signify "existing everywhere." Pervasive computing systems are totally connected and consistently available. It is also known as ubiquitous computing.
146
147Cluster Computing:
148
149Cluster Computing addresses the latest results in these fields that support High Performance Distributed Computing (HPDC). In HPDC environments, parallel and/or distributed computing techniques are applied to the solution of computationally intensive applications across networks of computers. The journal represents an important source of information for the growing number of researchers, developers and users of HPDC environments.
150
151Fog Computing:
152
153Fog computing or fog networking, also known as fogging, it is an architecture that uses edge devices to carry out a substantial amount of computation, storage, communication locally and routed over the internet backbone, and most definitively has input and output
154
155
156from the physical world known as transduction. Fog computing consists of Edge nodes directly performing physical input and output often to achieve sensor input, display output, or full closed loop process control, and may also use smaller Edge Clouds often called as Cloudlets at the Edge or nearer to the Edge than centralized Clouds residing in very large data centres. The processing power in advanced Edge Clouds like those that control autonomous vehicles can be considerable compared to more traditional Edge personal devices such as mobile phones and personal computers.
157
158Edge Computing:
159
160"Edge computing" is used as a kind of catch-all for various networking technologies including peer-to-peer networking or ad hoc networking, as well as various types of cloud setups and other distributed systems. One other predominant type of edge networking is mobile edge networking or computing, an architecture that utilizes the edge of the cellular network for operations.
161
162Cloud Computing:
163
164Cloud computing is a general term for the delivery of hosted services over the internet. Cloud computing enables companies to consume a compute resource, such as a virtual machine , storage or an application, as a utility -- just like electricity -- rather than having to build and maintain computing infrastructures in house.
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181Ambient Computing:
182
183Ambient computing is the backdrop of sensors, devices, intelligence, and agents that can put the Internet of Things to work. The Internet of Things (IoT) is maturing from its awkward adolescent phase.
184
185Internet Of Things (IOT):
186
187The Internet of Things (IoT) is the network of physical devices, vehicles, home appliances, and other items embedded with electronics, software, sensors, actuators, and connectivity which enables these things to connect and exchange data, creating opportunities for more direct integration of the physical world into computer-based systems, resulting in efficiency improvements, economic benefits, and reduced human exertions. The number of IoT devices increased 31% year-over-year to 8.4 billion in 2017 and it is estimated that there will be 30 billion devices by 2020. The global market value of IoT is projected to reach $7.1 trillion by 2020.
188
189IoT involves extending internet connectivity beyond standard devices, such as desktops, laptops, smart phones and tablets, to any range of traditionally dumb or non-internet-enabled physical devices and everyday objects. Embedded with technology, these devices can communicate and interact over the internet, and they can be remotely monitored and controlled.
190
191Data Analytics:
192
193Data analysis is a process of inspecting, cleansing, transforming, and modeling data with the goal of discovering useful information, informing conclusions, and supporting decision-making. Data analysis has multiple facets and approaches,
194
195encompassing diverse techniques under a variety of names, while being used in different business, science, and social science domains.
196
197Data Mining:
198
199Data mining is the process of discovering patterns in large data sets involving methods at the intersection of machine learning, statistics, and database systems
200
201Data Warehouse:
202
203In computing, a data warehouse (DW or DWH), also known as an enterprise data warehouse (EDW), is a system used for reporting and data analysis, and is considered a core component of business intelligence. DWs are central repositories of integrated data from one or more disparate sources. They store current and historical data in one single place that are used for creating analytical reports for workers throughout the enterprise.
204
205Web Services and Service Architecture:
206
207A service-oriented architecture is essentially a collection of services. These services communicate with each other. The communication can involve either simple data passing or it could involve two or more services coordinating some activity. Some means of connecting services to each other is needed.
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230Service-oriented architectures are not a new thing. The first service-oriented architecture for many people in the past was with the use DCOM or Object Request Brokers (ORBs) based on the CORBA specification. For more on DCOM and CORBA, see Prior Service-Oriented Architectures
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288RESULT:
289
290Thus the study experiment for different computing technologies was learned successfully.
291
292
293Ex. No: 2
294
295Date:
296
297
298AIM:
299
300
301STUDY OF GRID & CLOUD COMPUTING
302
303
304To study about grid and cloud computing.
305
306.Grid Computing:
307
308Grid computing is the collection of computer resources from multiple places to reach a common goal. The grid can be thought of as a distributed system with non-interactive workloads that involve a large number of files. Grid computing is distinguished from conventional high-performance computing systems such as cluster computing in that grid computers have each node set to perform a different task/application.
309
310Grid computers also tend to be more heterogeneous and geographically dispersed (thus not physically coupled) than cluster computers. Although a single grid can be dedicated to a particular application, commonly a grid is used for a variety of purposes. Grids are often constructed with general-purpose grid middleware software libraries.
311
312
313
314
315
316
317
318
319
320
321
322
323
324Grid Architecture Layer:
325
326Grid computing is a distributed architecture of large numbers of computers connected to solve a complex problem. In the grid computing model, servers or personal computers run independent tasks and are loosely linked by the Internet or low-speed networks. Computers may connect directly or via scheduling systems.
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348OGSA&OGSI Architecture:
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367Cloud Computing:
368
369Cloud computing is an information technology (IT) paradigm that enables ubiquitous access to shared pools of configurable system resources and higher-level services that can be rapidly provisioned with minimal management effort, often over the Internet. Cloud computing relies on sharing of resources to achieve coherence and economies of scale, similar to a public utility.
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384Types of Cloud Computing:
385
386Based on a cloud location, we can classify cloud as:
387
388public,
389
390private,
391
392hybrid
393
394community cloud
395
396Public cloud:
397
398
399
400The public cloud is defined as computing services offered by third-party providers over the public Internet, making them available to anyone who wants to use or purchase them. They may be free or sold on-demand, allowing customers to pay only per usage for the CPU cycles, storage or bandwidth they consume.
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417PRIVATE CLOUD:
418
419
420A private cloud is a cloud computing hardware and software platform that is dedicated to your organization. Private clouds hosted at Cybercon data center provides you the freedom to choose: network routers and switches, firewalls, server hardware, storage systems, and cloud computing software. Our solutions are designed and built to give you the power to construct and manage clouds across your internal data centers and Cybercon data centre on terms that you control. This means that you can keep a handle on compliance, security, and costs. And you can let your business needs drive your IT strategy, instead of having IT limit your options.
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437HYBRID CLOUD:
438
439
440Hybrid cloud is a cloud computing environment that uses a mix of on-premises, private cloud and third-party, public cloud services with orchestration between the two platforms. By allowing workloads to move between private and public clouds as computing needs and costs change, hybrid cloud gives businesses greater flexibility and more data deployment options.
441
442
443COMMUNITY CLOUD:
444
445
446A community cloud is a cloud service model that provides a cloud computing solution to a limited number of individuals or organizations that is governed, managed and secured commonly by all the participating organizations or a third party managed service
447
448provider.
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468Based on a service that the cloud is offering,
469
470
471
472IaaS (Infrastructure-as-a-Service)
473
474PaaS (Platform-as-a-Service)
475
476SaaS (Software-as-a-Service)
477
478or, Storage, Database, Information, Process, Application, Integration, Security, Management, Testing-as-a-service
479
480Infrastructure as a service:
481
482Infrastructure as a service (IaaS) refers to online services that provide high-level APIs used to dereference various low-level details of underlying network infrastructure like physical computing resources, location, data partitioning, scaling, security, backup etc. A hypervisor, such as Xen, Oracle VirtualBox, Oracle VM, KVM, VMware ESX/ESXi, or Hyper-V, LXD, runs the virtual machines as guests..
483
484
485
486
487Platform-as-a-Service:
488
489Platform as a Service (PaaS) or application platform as a Service (aPaaS) or platform base service is a category of cloud computing services that provides a platform allowing customers to develop, run, and manage applications without the complexity of building and maintaining the infrastructure typically associated with developing and launching an app. PaaS can be delivered in three ways:
490
491• As a public cloud service from a provider, where the consumer controls software deployment with minimal configuration options, and the provider provides the networks, servers, storage, operating_system (OS), middleware (e.g. Java
492
493runtime, .NET runtime, integration, etc.), database and other services to host the consumer's application.
494
495• As a private service (software or appliance) behind a firewall.
496
497• As software deployed on a public infrastructure as a service.
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518Software-as-a-Service:
519
520Software as a service (SaaS /sæs/) is a software licensing and delivery model in which software is licensed on a subscription basis and is centrally hosted. It is sometimes referred to as "on-demand software", and was formerly referred to as "software plus services" by Microsoft. SaaS is typically accessed by users using a thin client via a web browser. SaaS has become a common delivery model for many business applications, including office software, messaging software, payroll processing software, DBMS software, management
521
522software, CAD_software,_development_software, gamification, virtualization, accounting,
523
524Collaboration, customer_relationship_management (CRM).
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539Merits:
540
541• Flexibility
542• Efficiency
543• Strategic value
544• Cost savings
545• Manageability
546
547Demerits:
548• Downtime
549• Security
550• Vendor Lock-In
551• Limited Control
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576Result:
577
578Thus the study experiment for grid and cloud computing was learned successfully.
579
580
581Ex. No: 3
582
583Date:
584
585
586AIM:
587
588
589EXECUTION OF LINUX COMMANDS IN UBUNTU
590
591
592To study the linux commands and execute the linux commands in Ubuntu.
593
594LINUX COMMANDS:
595
596Linux is one of popular version of UNIX operating System. It is open source as its source code is freely available. It is free to use. Linux was designed considering UNIX compatibility. Its functionality list is quite similar to that of UNIX.
597
598Components of Linux System:
599Linux Operating System has primarily three components
600
601• Kernel − Kernel is the core part of Linux. It is responsible for all major activities of this operating system. It consists of various modules and it interacts directly with the underlying hardware. Kernel provides the required abstraction to hide low level hardware details to system or application programs.
602
603• System Library − System libraries are special functions or programs using which application programs or system utilities accesses Kernel's features. These libraries implement most of the functionalities of the operating system and do not requires kernel module's code access rights.
604
605• System Utility − System Utility programs are responsible to do specialized, individual level tasks.
606
607Kernel Mode vs User Mode:
608
609Kernel component code executes in a special privileged mode called kernel mode with full access to all resources of the computer. This code represents a single process, executes in single address space and do not require any context switch and hence is very efficient and fast. Kernel runs each processes and provides system services to processes, provides protected access to hardware to processes.
610
611Basic Commands:
6121. Date Command:
613This command is used to display the current data and time.
614
615Syntax:
616$date
617
6182. Calender Command:
619
620This command is used to display the calendar of the year or the particular month of calendar year.
621
622Syntax:
623a. $cal <year>
624
625b. $cal <month> <year>
626
627Here the first syntax gives the entire calendar for given year & the second Syntax gives the calendar of reserved month of that year.
628
6293. Echo Command:
630This command is used to print the arguments on the screen.
631
632Syntax:
633$echo <text>
634
6354. Banner Command:
636
637It is used to display the text in „#‟ symbol .It displays the text in the form of a banner.
638
639Syntax :
640$banner <arguments>
641
6425.’who’ Command:
643It is used to display who are the users connected to our computer currently.
644
645Syntax:
646$who
647
6486.’who am i’ Command:
649Display the details of the current working directory.
650
651Syntax:
652$who am i
653
6547.’tty’ Command:
655It will display the terminal name.
656
657Syntax:
658$tty
659
6608.’CLEAR’ Command:
661It is used to clear the screen.
662
663Syntax:
664$clear
665
6669.’MAN’ Command:
667
668It helps us to know about the particular command and its options & working. It is like „help‟ command in windows.
669
670Syntax:
671$man <command name>
672
67310. LIST Command:
674It is used to list all the contents in the current working directory.
675
676Syntax:
677$ ls – options <arguments>
678
679If the command does not contain any argument means it is working in the Current directory.
680
681Options:
682a– used to list all the files including the hidden files.
683
684c– list all the files columnwise.
685d- list all the directories.
686m- list the files separated by commas.
687p- list files include „/‟ to all the directories.
688r- list the files in reverse alphabetical order.
689f- list the files based on the list modification date.
690x-list in column wise sorted order.
691
692DIRECTORY RELATED COMMANDS:
6931. Present Working Directory Command:
694To print the complete path of the current working directory.
695
696Syntax:
697$pwd
698
6992. MKDIR Command:
700To create or make a new directory in a current directory.
701
702Syntax:
703$mkdir <directory name>
704
7053. CD Command:
706To change or move the directory to the mentioned directory .
707Syntax: $cd <directory name>.
708
7094. RMDIR Command:
710To remove a directory in the current directory & not the current directory itself.
711
712Syntax:
713$rmdir <directory name>
714
715FILE RELATED COMMANDS:
7161. CREATE A FILE:
717To create a new file in the current directory we use CAT command.
718
719Syntax:
720$cat > filename.
721
7222. DISPLAY A FILE:
723To display the content of file mentioned we use CAT command without „>‟ operator.
724
725Syntax:
726$cat filename.
727
7283. COPYING CONTENTS:
729
730To copy the content of one file with another. If file doesnot exist, a new file is created and if the file exists with some data then it is overwritten.
731
732Syntax :
733$ cat <source filename> >> <destination filename>
734
7354. SORTING A FILE:
736To sort the contents in alphabetical order in reverse order.
737
738Syntax:
739$sort <filename >
740
741Option: $ sort –r <filename>
742
7435. COPYING CONTENTS FROM ONE FILE TO ANOTHER:
744To copy the contents from source to destination file so that both contents are same.
745Syntax: $cp <source filename> <destination filename>
746$cp <source filename path > <destination filename path>
747
7486. MOVE Command:
749
750To completely move the contents from source file to destination file and to remove the source file.
751
752Syntax:
753$ mv <source filename> <destination filename>
754
7557. REMOVE Command:
756To permanently remove the file we use this command.
757
758Syntax:
759$rm <filename>
760
7618. WORD Command:
762To list the content count of no of lines, words, characters.
763
764Syntax:
765$wc<filename>
766
767Options:
768-c – to display no of characters.
769
770-l – to display only the lines.
771-w – to display the no of words.
772
7739. LINE PRINTER:
774To print the line through the printer, we use lp command.
775
776Syntax: $lp <filename>
777
77810. PAGE Command:
779
780This command is used to display the contents of the file page wise & next page can be viewed by pressing the enter key.
781
782Syntax:
783$pg <filename>
784
78511. FILTERS AND PIPES
786HEAD: It is used to display the top ten lines of file.
787Syntax: $head<filename>
788
789TAIL: This command is used to display the last ten lines of file.
790Syntax: $tail<filename>
791
792PAGE: This command shows the page by page a screenfull of information is displayed after which the page command displays a prompt and passes for the user to strike the enter key to continue scrolling.
793
794Syntax: $ls –a\p
795
796MORE: It also displays the file page by page .To continue scrolling with more command, press the space bar key.
797
798Syntax: $more<filename>
799GREP: This command is used to search and print the specified patterns from the file.
800Syntax: $grep [option] pattern <filename>
801SORT: This command is used to sort the datas in some order.
802Syntax: $sort<filename>
803
804PIPE: It is a mechanism by which the output of one command can be channeled into the input of another command.
805
806Syntax: $who | wc-l
807TR: The tr filter is used to translate one set of characters from the standard inputs to another.
808Syntax: $tr “[a-z]†“[A-Z]â€
809
810COMMUNICATION THROUGH UNIX COMMANDS
811Command: MESG
812
813Description: The message command is used to give permission to other users to send
814message to your terminal.
815Syntax: $mesg y
816Command: WRITE
817
818Description: This command is used to communicate with other users, who are logged in at the same time.
819
820Syntax: $write <user name>
821Command: WALL
822Description: This command sends message to all users those who are logged in
823using the unix server.
824Syntax: $wall <message>
825
826Command: MAIL
827
828Description: It refers to textual information, that can be transferred from one user to another
829
830Syntax: $mail <user name>
831Command: REPLY
832Description: It is used to send reply to specified user.
833Syntax: $reply<user name>
834
835vi EDITOR COMMANDS
836
837The vi editor is a visual editor used to create and edit text, files, documents and programs. It displays the content of files on the screen and allows a user to add, delete or change part of text. There are three modes available in the vi editor, they are
838
8391. Command mode
8402. Input (or) insert mode.
841The vi editor is invoked by giving the following commands in UNIX prompt.
842Syntax: $vi <filename> (or)$vi
843
844Options :
8451.vi +n <filename> - this would point at the nth line (cursor pos).
846
8472.vi –n <filename> - This command is to make the file to read only to change from one mode to another press escape key.
848
849INSERTING AND REPLACING COMMANDS:
850
851To move editor from command node to edit mode, you have to press the <ESC> key. For inserting and replacing the following commands are used.
852
8531. ESC a Command:
854
855This command is used to move the edit mode and start to append after the current character.
856
857Syntax : <ESC> a
858
8592. ESC A COMMAND :
860
861This command is also used to append the file , but this command append at the end of current line.
862
863Syntax: <ESC> A
864
8653. ESC i Command:
866This command is used to insert the text before the current cursor position.
867
868Syntax: <ESC> i
869
8704. ESC I Command:
871This command is used to insert at the beginning of the current line.
872
873Syntax: <ESC> I
874
8755. ESC o Command:
876
877This command is insert a blank line below the current line & allow insertion of contents.
878
879
880Syntax:
881
882
883<ESC> o
884
885
8866. ESC O Command:
887
888This command is used to insert a blank line above & allow insertion of contents.
889
890
891Syntax :
892
893
894<ESC> O
895
896
8977. ESC r Command :
898
899This command is to replace the particular character with the given characters.
900
901
902Syntax:
903
904
905<ESC> rx
906
907
908Where x is the new character.
909
910
9118. ESC R Command:
912This command is used to replace the particular text with a given text.
913
914Syntax: <ESC> R text
915
9169. <ESC> s Command:
917This command replaces a single character with a group of character.
918
919Syntax: <ESC> s
920
92110.<ESC> S Command :
922This command is used to replace a current line with group of characters.
923
924Syntax : <ESC> S
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986RESULT:
987
988Thus the execution of linux commands in ubuntu environment was executed successfully.
989
990
991Ex. No: 4
992
993Date:
994
995
996AIM:
997
998
999Installation of C compiler in the virtual machine
1000
1001
1002
1003To install a C compiler in the virtual machine and execute some sample program in cloud environment.
1004
1005PROCEDURE:
1006
1007STEP 1: Click oracle VM Virtual Box (opened)
1008STEP 2: Click File [Oracle Virtual Box Manager]
1009STEP 3: Click Import Appliance
1010
1011Appliance to Import
1012
1013
1014Click browser (go to D: or E :)
1015
1016
1017
1018
1019STEP 4: In D: or E:, Click Hadoop & open nebula folder
1020STEP 5: In that, click ubuntu-grid (open)
1021STEP 6: Click next
1022STEP 7: Click import
1023STEP 8:
1024
1025Import virtual disk image
1026(It will take time to import)
1027
1028
1029
1030
1031STEP 9: Click ubuntu *(click start)
1032STEP 10: Click ok
1033STEP 11:
1034
1035File machine view input devices help
1036User name:
1037
1038Dinesh
1039
1040Password:
1041
104299425
1043
1044
1045STEP 12:
1046
1047Click here and type
1048terminal
1049Or
1050Directly click terminal
1051
1052
1053STEP 13: To open a new file..Syntax: $vi filename.c
1054
1055
1056
1057STEP 14:
1058
1059~
1060~
1061Go to insert mode
1062
1063Click esc+i
1064
1065STEP 15: After typing C program press esc+:wq(to save & quit)
1066STEP 16: cc Filename.c (to compile)
1067STEP 17:./a.out(to run)
1068
1069Program 1: Switch case
1070#include<stdio.h>
1071
1072void main()
1073{
1074int a,b,ch;
1075int c;
1076printf("Enter two numbers\n");
1077scanf("%d%d",&a,&b);
1078do
1079{
1080printf("\nEnter your choice\n");
1081scanf("%d",&ch);
1082switch(ch)
1083{
1084case 1:
1085printf("Addition is %d",a+b);
1086break;
1087case 2:
1088
1089printf("Subtraction is %d",a-b);
1090break;
1091case 3:
1092printf("Multiplication is %d",a*b);
1093break;
1094case 4:
1095printf ("Division is %d", a/b);
1096break;
1097default:
1098
1099printf ("Enter valid choice");
1100break;
1101}
1102printf("Do you want to continue y/n");
1103scanf("%d",&c);
1104}while(c==0);
1105}
1106
1107OUTPUT:
1108
1109Enter two numbers
11103
11112
1112Enter your choice
11131
1114Addition is 5
1115Do you want to continue 0/1
11160
1117Enter your choice
11185
1119Enter valid choice
1120Do you want to continue 0/1
11211
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148PROGRAM2 : Armstrong Number
1149#include<stdio.h>
1150void main()
1151{
1152int n,a=0,r=0,rf=0;
1153printf("Enter the number\n");
1154scanf("%d",&n);
1155a=n;
1156while(n!=0)
1157{
1158
1159r=n%10;
1160rf+=r*r*r;
1161n=n/10;
1162}
1163if(rf==a)
1164printf("entered number is armstrong number");
1165else
1166printf("entered number is not an armstrong number");
1167
1168}
1169
1170OUTPUT:
1171Enter the number
1172
1173153
1174
1175entered number is armstrong number
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201program 3: Factorial
1202#include<stdio.h>
1203void main()
1204{
1205int n,f=1,i;
1206printf("Enter the number\n");
1207scanf("%d",&n);
1208for(i=1;i<=n;i++)
1209f=f*i;
1210printf("factorial of %d is %d",n,f);}
1211
1212OUTPUT:
1213Enter the number:4
1214
1215factorial of 4 is 24
1216
1217
1218
1219
1220
1221
1222
1223
1224Program 4: Addition of two numbers
1225include<stdio.h>
1226void main()
1227{
1228int a,b,c;
1229printf("enter two numbers");
1230scanf("%d%d",&a,&b);
1231c=a+b;
1232printf("Sum of a and b is %d",c);
1233}
1234
1235OUTPUT:
1236Enter two numbers
1237
123823
123927
1240Sum of a and b is 50
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266Program 5: Palindrome
1267#include<stdio.h>
1268void main()
1269
1270{
1271printf("Enter the number");
1272
1273int n,a=0,r=0,rf=0;
1274scanf("%d",&n);
1275a=n;
1276while(n!=0)
1277{
1278
1279r=n%10;
1280rf=rf*10+r;
1281n=n/10;
1282}
1283if(rf==a)
1284printf("Entered number is palindrome");
1285else
1286
1287printf("Entred number is not palindrome");
1288}
1289
1290OUTPUT:
1291Enter the number
1292
129333
1294Entered number is palindrome
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320Program 6: Multiplication Table
1321#include<stdio.h>
1322void main()
1323
1324{
1325int m,n,i;
1326printf("Enter which table you want");
1327scanf("%d",&m);
1328printf("Enter the range of the table");
1329scanf("%d",&n);
1330
1331for(i=1;i<=n;i++)
1332printf("%d x %d = %d \n",i,m,i*m);
1333}
1334
1335OUTPUT:
1336Enter which table you want
1337
13382
1339Enter the range of the table
13403
13411 x 2 = 2
1342
13432 x 2 = 4
13443 x 2 = 6
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401RESULT:
1402
1403Thus C compiler is installed in virtual machine and some sample programs are executed and verified in cloud environment
1404
1405
1406
1407Ex. No: 5 RUNNING VM’S OF DIFFERENT CONFIGURATION
1408 IN OPEN NEBULA
1409Date:
1410
1411
1412AIM:
1413
1414To find procedure to run the virtual machine of different configuration and to check how many virtual machines can be utilized at particular time.
1415
1416PROCEDURE:
1417Install Open nebula sandbox:
14181. Open Virtual box
14192. File ïƒ import Appliance
1420
14213. Browse OpenNebula-Sandbox-5.0.ova file
1422
14234. Then go to setting, select Usb and choose USB 1.1
1424
14255. Then Start the Open Nebula
1426
14276. Login using username: root, password:opennebula
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452Procedure to run the virtual machine of different configuration and to check how many virtual machines can be utilized at particular time:
14531. Open Browser, type localhost:9869
1454
14552. Login using username: oneadmin, password: opennebula
1456
14573. Click on instances, select VMs then follow the steps to create Virtaul machine
1458
1459a. Expand the + symbol
1460
1461b. Select user oneadmin
1462
1463c. Then enter the VM name,no.of instance, cpu.
1464
1465d. Then click on create button.
1466
1467e. Repeat the steps the C,D for creating more than one VMs.
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525RESULT:
1526
1527Thus to find procedure to run the virtual machine of different configuration and to check how many virtual machines can be utilized at particular time using open nebula is done and verified.
1528
1529
1530Ex. No: 6
1531
1532Date:
1533
1534
1535AIM:
1536
1537
1538PROCEDURE TO ATTACH VIRTUAL BLOCK TO THE VM
1539
1540
1541
1542To find procedure to attach virtual block to the virtual machine and to check whether it holds the data even after the release of the virtual machine.
1543
1544PROCEDURE:
1545Method 1:
15461. Open the virtual box
1547
15482. Power off the VM which you want to add virtual box
1549
15503. Then right click on that VM,select setting
1551
15524. Then click on storage,find controller IDE .
1553
15545. In the top right find add hard disk icon, the pop up window display
1555
15566. On that window select create new disk, and then click next and next then finish.
1557
15587. Then find attributes icon ,hard disk as IDE secondary slave.
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588Method 2:
15891. Open Browser, type localhost:9869
1590
15912. Login using username: oneadmin, password: opennebula
1592
15933. Click on instances, select VMs then follow the steps to add virtual block
1594
1595a. Select any one VM from the list and power off the VM
1596
1597b. Then click on that VM ,find the storage tab then click on that
1598
1599c. Then find the attach disk button
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616d. Click on that button ,the new pop window display
1617
1618e. On that window select either image or volatile disk
1619
1620f. Click on attach button.
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676PREPARATION 30
1677
1678PERFORMANCE 30
1679
1680RECORD 40
1681
1682TOTAL 100
1683
1684
1685
1686
1687
1688RESULT:
1689
1690Thus to find procedure to attach virtual block to the virtual machine and to check whether it holds the data even after the release of the virtual machine is executed and verified.
1691
1692Ex. No: 7
1693
1694Date:
1695
1696
1697AIM:
1698
1699
1700THE VIRTUAL MACHINE MIGRATION
1701
1702
1703
1704Learning the procedure to migrate the virtual machine from one host to another, perform the virtual machine migration and show the virtual machine migration based on certain condition from one node to the other.
1705
1706PROCEDURE:
17071. Open Browser, type localhost:9869
1708
17092. Login using username: oneadmin, password: opennebula
1710
17113. Then follow the steps to migrate VMs
1712
1713a. Click on infrastructure
1714
1715b. Select clusters and enter the cluster name
1716
1717c. Then select host tab, and select all host
1718
1719d. Then select Vnets tab, and select all vnet
1720
1721e. Then select data stores tab, and select all data stores
1722
1723f. And then choose host under infrastructure tab
1724
1725g. Click on + symbol to add new host, name the host then click on create.
1726
17274. on instances, select VMs to migrate then follow the steps
1728
1729a. Click on 8th icon ,the drop down list display
1730
1731b. Select migrate on that ,the popup window display
1732
1733c. On that select the target host to migrate then click on migrates.
1734
1735Before migration
1736Host: naveenkumar
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759Host:one-sandbox
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791After Migration:
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822Host:one-sandbox
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844Host:naveenkumar
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878RESULT:
1879
1880The procedure of creating the host with an existing image file and migrating the virtual machine is practiced and recorded through this experiment.
1881
1882Ex. No: 8
1883DEVELOP A NEW WEB SERVICE FOR CALCULATOR
1884Date:
1885
1886
1887
1888AIM:
1889To develop a web service program for a calculator.
1890
1891PROCEDURE:
1892Step1. Open netbeans and go to New
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920Step 2. Choose Java Web and select Web application and give next.
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947Step 3. Enter the project name and give next and Select the Server either tomcat or glas
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966Step 4. Give next and select finish
1967
1968Step 5. Right click the WebApplication (Projec Name) and Select New, and choose Java Class
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989Step 6. Type the following code
1990import javax.jws.WebMethod;
1991
1992import javax.jws.WebParam;
1993
1994import javax.jws.WebService;
1995
1996@WebService(serviceName="MathService", targetNamespace = "http://my.org/ns/")
1997public class MathService {
1998@WebMethod(operationName = "hello"
1999
2000public String hello(@WebParam(name="name")String txt){ return "Hello"+txt+"!"; }
2001
2002@WebMethod(operationName = "addSer"
2003
2004public String addSer(@WebParam(name="value1")int v1, @WebParam(name = "value2")int v2){
2005
2006return "Answer:" +(v1+v2)+"!";
2007}
2008@WebMethod(operationName = "subSer")
2009
2010public String subSer(@WebParam(name="value1")int v1, @WebParam(name = "value2")int v2){
2011
2012return "Answer:" +(v1-v2)+"!";
2013}
2014
2015@WebMethod(operationName = "mulSer")
2016
2017public String mulSer(@WebParam(name="value1")int v1, @WebParam(name = "value2")int v2){
2018
2019return "Answer:" +(v1*v2)+"!";
2020}
2021
2022@WebMethod(operationName = "divSer")
2023
2024public String divSer(@WebParam(name="value1")int v1, @WebParam(name = "value2")int v2){float res= 0; try
2025
2026{res = ((float)v1)/((float) v2); return "Answer:" +res+"!"; }
2027
2028catch(ArithmeticException e){
2029
2030System.out.println("Can't be divided by
2031
2032Zero"+e); return "Answer:"
2033
2034+e.getMessage().toString()+"!!!";
2035
2036}
2037
2038}
2039}
2040Step 7. Run Project by pressing F6 key or Run button.
2041Step 8. Check Web browser
2042
2043for the following name is available else give it http://localhost:8080/Web pplication2/Math ervice?Tester MathService?Tester ---> represents the java class name
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063Output Screen:
2064
2065Give some value in the fields and check the out put by pressing enter key.
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089Finally select the WSDL link
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135RESULT:
2136Thus the program on calculator for web services is executed successfully.
2137
2138Ex. No: 9 TO DEVELOP A NEW WEB SERVICE FOR FIND A NUMBER IS
2139
2140Date: PALINDROME OR NOT
2141
2142
2143
2144AIM:
2145To develop a web service program for a find a number is palindrome or not..
2146
2147
2148
2149PROCEDURE:
2150
2151Step1. Open net beans and go to New
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181Step 2. Choose Java Web and select Web application and give next.
2182
2183
2184
2185
2186Step 3. Enter the project name and give next and Select the Server either tomcat or gl
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209Step 4. Give next and select finish
2210
2211
2212
2213Step 5. Right click the WebApplication (Projec Name) and Select New, and choose Java Class
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239Step 6. Type the following code
2240
2241
2242import javax.jws.WebMethod;
2243import javax.jws.WebParam;
2244import javax.jws.WebService;
2245@WebService(serviceName="MathService", targetNamespace = "http://my.org/ns/")
2246public class MathService {
2247@WebMethod(operationName = "Palindrome")
2248public String Palindrome(@WebParam(name="value1")int v1, (@WebParam(name="value2")int v2, (@WebParam(name="value3")int v3, (@WebParam(name="value4")int v4){
2249
2250 v3=v1;
2251 while(v1>0)
2252{
2253 v4=v1%10;
2254 v2=(v2*10)+v4;
2255 v1=v1/10;
2256 }
2257 if(temp==sum){
2258 return "palindrome number";
2259}
2260 else {
2261 return "not palindrome";
2262 }
2263}
2264
2265Step 7. Run Project by pressing F6 key or Run button.
2266
2267Step 8. Check Web browser
2268
2269for the following name is available else give it http://localhost:8080/WebApplication2/MathService?Tester
2270MathService?Tester ---> represents the java class name
2271
2272Output Screen:
2273
2274Give some value in the fields and check the out put by pressing enter key.
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295 RESULT:
2296 Thus the program for a find a number is palindrome or not for webservices is executed Succesfully.
2297.
2298
2299
2300
2301
2302
2303
2304Ex. No: 10
2305IMPLEMENTATION OF OGSA USING WINDOWS
2306Date:
2307
2308
2309
2310AIM:
2311To develop a new OGSA- Compliant web service using windows.
2312
2313PROCEDURE:
2314
2315I . Setup the Development Environment
2316
23171.1. First you need to set up the development environment. Following things are needed if you want to create Web Services using Axis2 and Eclipse IDE.
2318
2319
2320Some Eclipse versions have compatibility issues with Axis2. This tutorial is tested with Apache Axis2 1.5.2, Eclipse Helios and Apache Tomcat 6.
2321
23221) Apache Axis2 Binary Distribution - Download
23232) Apache Axis2 WAR Distribution - Download
23243) Apache Tomcat - Download
23254) Eclipse IDE – Download
23265) Java installed in your Computer – Download
2327
23281.2. Then you have to set the environment variables for Java and Tomcat. There following variables should be added.
23291 JAVA_HOME :- Set the value to jdk directory (e.g. C:\Program Files\Java\jdk1.6.0_21)
2330
23312 TOMCAT_HOME :- Set the value to top level directory of your Tomcat install (e.g. D:\programs\apache-tom
2332
23333 6.0.29)
2334
2335PATH :- Set the value to bin directory of your jdk (e.g. C:\Program Files\Java\jdk1.6.0_21\bin)
2336
23371.3. Now you have to add runtime environment to eclipse. There go to Windows –-> Preferences and Select the Server --> Runtime Environments.
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360There select Apache Tomcat v6.0 and in the next window browse your Apache installation directory and click finish.
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
23911.4. Then click on the Web Service –-> Axis2 Preferences and browse the top level directory of Apache Axis2 Binary Distribution.
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416II. Creating the Web Service Using Bottom-Up Approach
2417
24182.1 First create a new Dynamic Web Project (File --> New –-> Other…) and choose Web --> Dynamic Web Project.
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
24472.2 Set Apache Tomcat as the Target Runtime and click Modify to install Axis2 Web Services project facet.
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
24732.3 Select Axis2 Web Services
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
25012.4 Click OK and then Next. There you can choose folders and click Finish when you are done.
2502
2503
2504III. Create Web Service Class
2505
2506Now you can create a Java class that you would want to expose as a Web Service. I‟m going to create new class called FirstWebService and create public method called addTwoNumbers which takes two integers as input and return the addition of them.
2507
25083.1 Right Click on MyFirstWebService in Project Explorer and select New –-> Class and give
2509
2510
2511suitable package name and class name. I have given com.sencide as package name and FirstWebService as class name.
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534package com.sencide;
2535public class FirstWebService {
2536
2537public int addTwoNumbers(int firstNumber, int secondNumber){ return firstNumber + secondNumber; }
2538
2539}
25403.2 Then, select File --> New –-> Other and choose Web Service.
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
25713.3 Select the FirstWebService class as service implementation and to make sure that the
2572
2573
2574Configuration is setup correctly click on Server runtime.
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
25983.4 There set the Web Service runtime as Axis2 (Default one is Axis) and click Ok.
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
26253.5 Click Next and make sure Generate a default service.xml file is selected.
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
26533.6 Click Next and Start the Server and after server is started you can Finish if you do not want to publish the Web service to a test UDDI repository.
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678You can go to http://localhost:8888/MyFirstWebService/services/listServices to see your running service which is deployed by Axis2. You can see the WSDL by clicking the link FirstWebService.
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733RESULT:
2734Thus a new OGSA- Compliant web service is developed and verified using windows .
2735
2736
2737Ex. No: 11 TO DEVELOP A NEW OGSA COMPLAINT WEBSERVICE
2738 (UBUNTU-GRID)
2739Date:
2740
2741
2742AIM:
2743To develop a new OGSA complaint Webservice
2744
2745PROCEDURE:
2746Step 1: Choose New Project from the main menu
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764Step 2: Select POM project from the maven category
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781Step 3: Type MavenOSGiCDIProject as the project name and click finish. When you click finish, the IDE creates the POM project and opens the project in the project window.
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798Step 4: Expand the project files node in the project window and double – click pom.xml to open the file in editor and do the modification in the file and save.
2799In pom.xml file
2800
2801<?xml version="1.0" encoding="UTF-8"?>
2802<project xmlns="http://maven.apache.org/xsd/maven-4.0.0.xsd"
2803xmlns:xsi="http://www.w3.org/2001/XML chema-instance"
2804xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-
28054.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany</groupId>
2806<artifactId>MavenO GiCDIProject</artifactId> <version>1.0-SN PSHOT</version>
2807<packaging>pom</packaging><properties> <project.build.sourceEncoding>UTF-
28088</project.build.sourceEncoding> </properties>
2809<dependencyManagement><dependencies><dependency> <groupId>org.osgi</groupId>
2810<artifactId>org.osgi.core</artifactId>
2811<version>4.2.0</version>
2812<scope>provided</scope>
2813</dependency></dependencies></dependencyManagement>
2814</project>
2815
2816Step 5:Creating OGSi Bundle Projects
2817Choose File -> New Project to open the New Project Wizzard
2818
2819Step 6 : Choose OGSI Bundle from Maven category. Click Next
2820
2821
2822
2823Step 7: Creating MavenHelloService pi as the Project Name for OGSi Bundle
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845The IDE creates the bundle project and opens the project in the Project Window. And check thebuilding pugins at pom.xml under project files.
2846
2847
2848
2849
2850
2851
2852
2853
2854As well as it will create org.osgi.core artifact as default and it can be view at under Dependencies. Step 7: Buid the MavenHello ervice pi Project by
2855
28561. Right Click the MavenHello ervice pi project node in the project window and choose properties.
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
28712. Select the source category in the project project dialog box
28723. Set the Source/Binary Format to 1.6 and confirm that the Encoding is UTF-8 and click ok
2873
2874
2875
28764. Right click the source package node in the project window and choose New -> JavaInterface
28775. Type Hello for the Class Name
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
28986. Select com.mycompany.mavenhelloserviceapi as the Package. Click finish.
2899
29007. Add the following sayHello method to the interface and save the changes. package
2901
2902com.mycompany.mavenhelloserviceapi; public interface Hello {
2903
2904String sayHello(String name);
2905}
2906
2907
2908
29098. Right click the project node in the project window and choose build.
2910
29119. After building the project, open files window and expand the project node such that you can see MavenHelloServiceApi-1.0-SN PSHOT.jar is created in the target folder.
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929Step 8: Creating the MavenHelloServiceImpl Implementation Bundle Here you will create the MavenHelloServiceImpl in the POM Project.
29301. Choose File -> New Project to open the New Project Wizard
29312. Choose OSGi Bundle from the Maven category. Click Next.
29323. Type MavenHelloServiceImpl for the Project Name
2933
29344. Click Browse and select the MavenOSGiCDIProject POM project as the Location. Click Finish.(As earlier step).
2935
29365. Right click the project node in the Projects window and choose Properties.
29376. Select the Sources category in the Project Properties dialog box.
2938
29397. Set the Source/Binary Format to 1.6 and confirm that the Encoding is UTF-8. Click OK.
29408. Right click Source Packages node in the Projects window and choose New -> Java Class.
29419. Type HelloImpl for the Class Name.
294210. Select com.mycompany.mavenhelloserviceimpl as the Package. Click Finish.
2943
294411. Type the following and save your changes
2945
2946package com.mycompany.mavenhelloserviceimpl; public class HelloImpl implements Hello
2947
2948{ public String sayHello(String name){ return "Hello" +name;
2949
2950}}
2951
2952When you implement Hello, the IDE will display an error that you need to resolve by adding the MavenHelloServiceApi project as a dependency.
2953
295412. Right click the Dependencies folder of MavenHelloServiceImpl in the Projects window and choose Add Dependency.
2955
295613. Click the Open Projects tab in the dd Library dialog. 14. Select MavenHello ervice pi O Gi Bundle. Click dd
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
297414. Expand the com.mycompany.mavenhelloserviceimpl package and double click Activator.java and open the file in editor.
2975
2976The IDE automatically creates the Activator.java bundle and its manage the lifecycle of bundle. By default it includes start() and stop().Modify the start() and Stop() methods in the bundle activator class by adding thefollowing lines.
2977
2978package com.mycompany.mavenhelloserviceimpl; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext;
2979
2980public class Activator implements BundleActivator {
2981public void start(BundleContext context) throws Exception {
2982// TODO add activation code here
2983
2984System.out.println("HelloActivator::start");
2985context.registerService(Hello.class.getName(),new
2986HelloImpl(),null);
2987System.out.println("HelloActivator::registration of
2988Hello Service Successfull");
2989}
2990
2991public void stop(BundleContext context) throws Exception {
2992
2993// TODO add deactivation code here context.ungetService(context.getServiceReference(Hello.cl
2994
2995ass.get ame())); System.out.println("HelloActivator stopped");
2996
2997}
2998}
2999
3000
3001
3002
3003
3004Step 9: Bulding and Deploying the OSGi Bundles
3005Here you will build the OSGi bundles and deploy the bundles to GlassFish
3006
30071. Right click the MavenOSGiCDIProject folder in the Projects window and choose Clean and Build.
3008
3009## When you build the project the IDE will create the JAR files in the target folder and aslo install the snapshot JAR in the local repository.
3010
3011## In file window, by expanding the target folder of each of the two bundle projects it will show two JAR archieves(MavenHelloServiceApi-1.0-SNAPSHOT.jar and MavenHElloServiceImpl-1.0-SNAPSHOT.jar.)
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
30302. Start the GlassFish server (if not already started)
30313. Copy the MavenHelloService pi-1.0-SN PSHOT.jar to the /home/linux/glassfish-
30324.1.1/glassfish/domains/domain1/autodeploy/bundles ( GlassFish installed Directory)
3033
30344. You can see output similar to the following in the GlassFish Server log in the output window.
3035
3036
3037
3038Info: Installed /home/linux/glassfish-
3039
30404.1.1/glassfish/domains/domain1/autodeploy/bundles/MavenHelloServiceApi-1.0-SNAPSHOT.jar
3041
3042Info: Started bundle: file:/home/linux/glassfish-
3043
30444.1.1/glassfish/domains/domain1/autodeploy/bundles/MavenHelloServiceApi-1.0-SNAPSHOT.jar Info: Started bundle: file:/home/linux/glassfish-
3045
30464.1.1/glassfish/domains/domain1/autodeploy/bundles/MavenHelloServiceApi-1.0-SNAPSHOT.jar
3047
30485. Repeat the step of copying the MavenHelloServiceImpl-1.0-SNAPSHOT.jar to the/home/linux/glassfish-4.1.1/glassfish/domains/domain1/autodeploy/bundles ( GlassFish installed Directory)
3049
30506. You can see the output athe glassfish server log
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072Info: Installed /home/linux/glassfish
3073
30744.1.1/glassfish/domains/domain1/autodeploy/bundles/MavenHelloServiceImpl-1.0-SNAPSHOT.jarInfo: Hello ctivator::start
3075
3076Info: Hello ctivator::registration of Hello ervice uccessfull Info: Started bundle:
3077file:/home/linux/glassfish-
3078
30794.1.1/glassfish/domains/domain1/autodeploy/bundles/MavenHelloServiceImpl-1.0-SN PSHOT.jar
3080
3081Info: Started bundle: file:/home/linux/glassfish-
3082
30834.1.1/glassfish/domains/domain1/autodeploy/bundles/MavenHelloServiceImpl-1.0-SN PSHOT.jar
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139RESULT:
3140Thus a new OGSA- complaint web service has been executed successfully.
3141
3142Ex. No: 12
3143TO DEVELOP A GRID SERVICE USING APACHE AXIS
3144Date:
3145
3146
3147
3148AIM:
3149To develop a Grid Service using Apache Axis
3150
3151PROCEDURE:
3152Using Apache Axis develop a Grid Service.
31531. Open the terminal
31542. Type cd /opt/axis2/axis2-1.7.3/bin then press enter
31553. Type chmod 500 axis2server.sh
31564. Type ./axis2server.sh
31575. Then open browser on ubuntu type the URL as localhost:8080/axis2/services
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210RESULT:
3211Thus Grid Service using Apache Axis has been executed successfully.
3212
3213
3214Ex. No: 13
3215DEVELOP APPLICATIONS USING JAVA OR C/C++ GRID APIs
3216Date:
3217
3218
3219AIM:
3220To Develop applications using Java or C/C++ Grid APIs
3221
3222PROCEDURE:
3223Develop applications using Java or C/C++ Grid APIs
3224
3225a. Open the terminal
3226
3227b. Type cd /opt/axis2/axis2-1.7.3/bin then press enter
3228
3229c. gedit hello.c
3230
3231d. gcc hello.c
3232
3233e. ./a.out
3234
3235Program 1: Switch case
3236#include<stdio.h>
3237
3238void main()
3239{
3240int a,b,ch;
3241int c;
3242printf("Enter two numbers\n");
3243scanf("%d%d",&a,&b);
3244do
3245{
3246printf("\nEnter your choice\n");
3247scanf("%d",&ch);
3248switch(ch)
3249{
3250case 1:
3251printf("Addition is %d",a+b);
3252break;
3253case 2:
3254printf("Subtraction is %d",a-b);
3255
3256break;
3257case 3:
3258printf("Multiplication is %d",a*b);
3259break;
3260case 4:
3261printf("Division is %d",a/b);
3262break;
3263default:
3264printf("Enter valid choice");
3265break;
3266}
3267
3268
3269printf("Do you want to continue y/n");
3270scanf("%d",&c);
3271}while(c==0);
3272}
3273
3274output:
3275Enter two numbers
3276
32773
32782
3279Enter your choice
32801
3281Addition is 5
3282
3283Do you want to continue 0/1
32840
3285Enter your choice
32865
3287Enter valid choice
3288Do you want to continue 0/1
32891
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318program2 : Armstrong Number
3319
3320#include<stdio.h>
3321void main()
3322{
3323int n,a=0,r=0,rf=0;
3324printf("Enter the number\n");
3325
3326
3327scanf("%d",&n);
3328a=n;
3329while(n!=0)
3330{
3331r=n%10;
3332rf+=r*r*r;
3333n=n/10;
3334}
3335if(rf==a)
3336printf("entered number is armstrong number");
3337else
3338printf("entered number is not an armstrong number");
3339
3340}
3341
3342output:
3343Enter the number
3344
3345153
3346entered number is armstrong number
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390RESULT:
3391
3392Thus applications using Java or C/C++ Grid APIs has been executed successfully.
3393
3394
3395Ex. No: 14 DEVELOP SECURED APPLICATIONS USING BASIC SECURITY
3396
3397Date: MECHANISMS
3398
3399
3400AIM:
3401To develop secured applications using basic security mechanisms available in Globus
3402Toolkit
3403
3404PROCEDURE:
3405
3406Develop secured applications using basic security mechanisms available in Globus Toolkit.
3407
34081. Follow these command to install basic security Installing GRID Essential
3409
3410wget http://www.globus.org/ftppub/gt6/installers/repo/globus-toolkit-repo_latest_all.deb
3411
3412sudo dpkg -i globus-toolkit-repo_latest_all.deb
3413
3414sudo apt-get update
3415
3416sudo apt-get install globus-data-management-client sudo apt-get install globus-gridftp sudo apt-get install globus-gram5
3417
3418sudo apt-get install globus-gsi
3419
3420sudo apt-get install globus-data-management-server
3421
3422sudo apt-get install globus-data-management-client
3423
3424sudo apt-get install globus-data-management-sdk
3425
3426sudo apt-get install globus-resource-management-server
3427
3428sudo apt-get install globus-resource-management-client
3429
3430sudo apt-get install globus-resource-management-sdk
3431
3432sudo apt-get install myproxy
3433
3434sudo apt-get install gsi-openssh
3435
3436sudo apt-get install globus-gridftp globus-gram5 globus-gsi myproxy myproxy-server myproxy-admin
3437
34382. After installing like myproxy,gsi-openssh and Globus GRAM file
3439a. Click the fileïƒ computer
3440b. Then Search Grid security folder
3441
3442c. Then see the gsi.conf, sshftp.( This indicate the basic security mechanisms are configured)
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492RESULT:
3493
3494Thus secured applications using basic security mechanisms available in Globus Toolkit has been executed successfully.
3495
3496
3497Ex. No: 15
3498FIND PROCEDURE TO SETUP THE ONE NODE HADOOP CLUSTER
3499Date:
3500
3501
3502AIM:
3503To Set up the one node Hadoop cluster.
3504
3505PRE-REQUISITE:
35061. Java v1.8 installation
35072. Configuring SSH access. sudo apt-get install vim
3508
3509• Ubuntu Linux 64-bit
3510• JDK 1.8.0_05
3511• Hadoop 2.7.x stable release
3512
3513Note: This exercise depicts about only compatible versions of Hadoop ecosystem tools and software downloaded from the official Apache hadoop website. Preferably use a stable release of the particular tool.
3514
3515PROCEDURE:
35161) Installing Java
3517
3518Hadoop is a framework written in Java for running applications on large clusters of commodity hardware. Hadoop needs Java 6 or above to work. Step 1: Download tar and extract
3519
3520Download Jdk tar.gz file for linux-62 bit, extract it into “/usr/localâ€
3521# cd /opt
3522# sudo tar zxvf /home/user/Downloads/jdk-8u5-linux-x64.tar.g
3523# cd /home/user/Downloads/jdk1.8.0_05
3524
3525• Open the “/etc/profile†file and Add the following line as per the version
3526• Set a environment for Java
3527• Use the root user to save the /etc/proflie or use gedit instead of vi .
3528• The 'profile' file contains commands that ought to be run for login shells
3529# sudo nano /etc/profile
3530#--insert JAVA_HOME JAVA_HOME=/home/user/Downloads/jdk1.8.0_05
3531
3532#--in PATH variable just append at the end of the line PATH=$PATH:$JAVA_HOME/bin
3533
3534#--Append JAVA_HOME at end of the export statement export PATH JAVA_HOME save the file using by pressing “Esc†key followed by :wq!
3535
3536Step 3: Source the /etc/profile
3537# source /etc/profile
3538Step 4: Update the java alternatives
3539
35401. By default OS will have a open jdk. Check by “java -versionâ€. You will be prompt “openJDKâ€
3541
35422. If you also have openjdk installed then you'll need to update the java alternatives:
35433. If your system has more than one version of Java, configure which one your
3544system causes by entering the following command in a terminal window
35454. By default OS will have a open jdk. Check by “java -versionâ€. You will be prompt
3546
3547
3548“JavaHotSpot(TM) 64-Bit Serverâ€
3549
3550# update-alternatives --install "/usr/bin/java" java /home/user/Downloads/jdk1.8.0_05/bin/java"
3551
35521)# update-alternatives --config java --type selection number:
3553
3554# java -version
35552) configure ssh
3556
3557• Hadoop requires SSH access to manage its nodes, i.e. remote machines plus your local machine if you want to use Hadoop on it (which is what we want to do in this exercise). For our single-node setup of Hadoop, we therefore need to configure SSH access to localhost
3558
3559• The need to create a Password-less SSH Key generation based authentication is so that the master node can then login to slave nodes (and the secondary node) to start/stop them easily without any delays for authentication
3560
3561• If you skip this step, then have to provide password
3562
3563Generate an SSH key for the user. Then Enable password-less SSH access to yo sudo apt-get install openssh-server
3564
3565--You will be asked to enter password, root@ubuntu # ssh localhost root@ubuntu# ssh-keygen root@ubuntu# ssh-copy-id -i localhost
3566
3567--After above 2 steps, You will be connected without password, root@ubuntu# ssh localhost
3568
3569root@ubuntu# exit
35703) Hadoop installation
3571• Now Download Hadoop from the official Apache, preferably a stable release
3572version of
3573Hadoop 2.7.x and extract the contents of the Hadoop package to a location of your choice.
3574
3575• For example, choose location as “/opt/â€
3576Step 1: Download the tar.gz file of latest version Hadoop ( hadoop-2.7.x) from the official site .
3577
3578Step 2: Extract (untar) the downloaded file from this commands to /opt/bigdata root@ubuntu# cd /opt
3579
3580root@ubuntu# sudo tar zxvf /home/user/Downloads/hadoop-2.7.0.tar.g root@ubuntucd hadoop-2.7.0/
3581
3582Like java, update Hadop environment variable in /etc/profile
3583# sudo nano /etc/profile
3584#--insert HADOOP_PREFIX HADOOP_PREFIX=/home/user/Downloads/hadoop-2.7.0
3585
3586#--in PATH variable just append at the end of the line PATH=$PATH:$HADOOP_PREFIX/bin
3587
3588#--Append HADOOP_PREFIX at end of the export statement export PATH JAVA_HOME HADOOP_PREFIX
3589
3590save the file using by pressing “Esc†key followed by :wq!
3591Step 3: Source the /etc/profile
3592
3593# source /etc/profile Verify Hadoop installation
3594
3595# cd $HADOOP_PREFIX
3596# bin/hadoop version
35973.1) Modify the Hadoop Configuration Files
3598
3599
3600• In this section, we will configure the directory where Hadoop will store its configuration files, the network ports it listens to, etc. Our setup will use Hadoop Distributed File System,(HDFS), even though we are using only a single local machine.
3601
3602• Add the following properties in the various hadoop configuration files which is available under $HADOOP_PREFIX/etc/hadoop/
3603
3604• core-site.xml, hdfs-site.xml, mapred-site.xml & yarn-site.xml
3605
3606# cd $HADOOP_PREFIX/etc/hadoop
3607# nano hadoop-env.sh
3608Paste following line at beginning of the fill
3609
3610export JAVA_HOME=/usr/local/jdk1.8.0_05 export HADOOP_PREFIX=/opt/hadoop-2.7.0
3611
3612Modify the core-site.xml
3613# cd $HADOOP_PREFIX/etc/hadoop
3614# nano core-site.xml
3615Paste following between <configuration> tags
3616<configuration>
3617<property>
3618<name>fs.defaultFS</name>
3619<value>hdfs://localhost:9000</value>
3620</property>
3621</configuration>
3622Modify the hdfs-site.xml
3623# nano hdfs-site.xml
3624Paste following between <configuration> tags
3625<configuration>
3626<property>
3627<name>dfs.replication</name>
3628<value>1</value>
3629</property>
3630</configuration>
3631YARN configuration - Single Node modify the mapred-site.xml
3632# cp mapred-site.xml.template mapred-site.xml
3633# nano mapred-site.xml
3634Paste following between <configuration> tags
3635<configuration>
3636<property>
3637
3638<name>mapreduce.framework.name</name>
3639<value>yarn</value>
3640</property>
3641</configuration> Modiy yarn-site.xml
3642# nano yarn-site.xml
3643Paste following between <configuration> tags
3644<configuration>
3645<property>
3646<name>yarn.nodemanager.aux-services</name>
3647<value>mapreduce_shuffle</value>
3648
3649
3650</property>
3651</configuration>
3652Formatting the HDFS file-system via the NameNode
3653
3654• The first step to starting up your Hadoop installation is formatting the Hadoop files system which is implemented on top of the local file system of our “cluster†which includes only our local machine. We need to do this the first time you set up a Hadoop cluster.
3655
3656• Do not format a running Hadoop file system as you will lose all the data currently in the cluster (in HDFS)
3657
3658root@ubuntu# cd $HADOOP_PREFIX root@ubuntu# bin/hadoop namenode -format
3659
3660
3661Start NameNode daemon and DataNode daemon: (port 50070)
3662root@ubuntu# sbin/start-dfs.sh
3663To know the running daemons jut type jps or /home/user/Downloads/jdk1.8.0_05/bin/jps
3664
3665Start ResourceManager daemon and NodeManager daemon: (port 8088)
3666
3667root@ubuntu# sbin/start-yarn.sh To stop the running process root@ubuntu# sbin/stop-dfs.sh To know the running daemons jut type jps or /home/user/Downloads/jdk1.8.0_05/bin/jps
3668
3669Start ResourceManager daemon and NodeManager daemon: (port 8088)
3670root@ubuntu# sbin/stop-yarn.sh
3671Make the HDFS directories required to execute MapReduce jobs:
3672$ bin/hdfs dfs -mkdir /user
3673$ bin/hdfs dfs -mkdir /user/mit
3674
3675• Copy the input files into the distributed filesystem: $ bin/hdfs dfs -put <input-path>/* /input
3676• Run some of the examples provided:
3677$ bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.5.1.jar grep
3678/input
3679/output '(CSE)'
3680• Examine the output files:
3681Copy the output files from the distributed filesystem to the local filesystem and examine
3682them:
3683$ bin/hdfs dfs -get output output
3684$ cat output/* or
3685
3686• View the output files on the distributed filesystem: $ bin/hdfs dfs -cat /output/*
3687
3688Output:
3689Hadoop installation:
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714Create the HDFS directories:
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745RESULT:
3746Thus the one node Hadoop cluster is installed successfully.
3747
3748
3749Ex. No: 16
3750MOUNT THE ONE NODE HADOOP CLUSTER USING FUSE
3751Date:
3752
3753
3754AIM:
3755To mount the one node Hadoop cluster using FUSE.
3756
3757PROCEDURE:
3758Download the cdh3 repository from the internet.
3759
3760$ wget http://archive.cloudera.com/one-click-install/maverick/cdh3-repository_1.0_all.deb
3761
3762Add the cdh3 repository to default system repository.
3763
3764$ sudo dpkg -i cdh3-repository_1.0_all.deb
3765Update the package information using the following command.
3766$ sudo apt-get update
3767Install the hadoop-fuse.
3768$ sudo apt-get install hadoop-0.20-fuse
3769
3770Once fuse-dfs is installed, go ahead and mount HDFS using FUSE as follows: $ sudo hadoop-fuse-dfs dfs://<name_node_hostname>:<namenode_port> <mount_point>
3771
3772Once HDFS has been mounted at <mount_point>, you can use most of the traditional filesystem operations (e.g., cp, rm, cat, mv, mkdir, rmdir, more, scp). However, random write operations such as rsync, and permission related operations such as chmod, chown are not supported in FUSE-mounted HDFS.
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825PREPARATION 30
3826
3827PERFORMANCE 30
3828
3829RECORD 40
3830
3831TOTAL 100
3832
3833
3834RESULT:
3835Thus the one node Hadoop cluster is mounted using FUSE successfully.
3836
3837
3838Ex. No: 17WRITE A WORD COUNT PROGRAM TO DEMONSTRATE THE USE OF
3839Date: MAP AND REDUCE TASKS
3840
3841
3842AIM:
3843Word count program to demonstrate the use of Map and Reduce tasks
3844
3845PRE-REQUISITE:
3846â— Java version > 1.6 is installed and configured properly
3847
3848â— Hadoop version 2.x is installed with proper configuration and hadoop daemons are running
3849
3850PROCEDURE:
38511. Analyze the input file content
38522. Develop the code
3853a. Writing a map function
3854b. Writing a reduce function c. Writing the Driver class
38553. Compiling the source
38564. Building the JAR file
38575. Starting the DFS
38586. Creating Input path in HDFS and moving the data into Input path
38597. Executing the program
3860
3861SAMPLE PROGRAM:
3862import java.io.IOException;
3863
3864import java.util.StringTokenizer;
3865import org.apache.hadoop.conf.Configuration;
3866import org.apache.hadoop.fs.Path;
3867import org.apache.hadoop.io.IntWritable;
3868import org.apache.hadoop.io.Text;
3869import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.mapreduce.Mapper;
3870import org.apache.hadoop.mapreduce.Reducer;
3871
3872import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import org.apache.hadoop.util.GenericOptionsParser; public class WordCount{
3873
3874//Step a
3875
3876public static class TokenizerMapper extends Mapper < Object , Text, Text, IntWritable >
3877
3878{
3879//hadoop supported data types
3880private final static IntWritable one = new IntWritable(1);
3881private Text word = new Text();
3882
3883//map method that performs the tokenizer job and framing the initial key value
3884pairs public void map( Object key, Text value, Context context) throws
3885IOException ,
3886InterruptedException
3887{
3888
3889//taking one line at a time and tokenizing the same StringTokenizer itr = new StringTokenizer (value.toString());
3890
3891//iterating through all the words available in that line and forming the key value pair while (itr.hasMoreTokens()){
3892
3893word.set(itr.nextToken());
3894
3895//sending to the context which inturn passes the same to reducer context.write(word, one);
3896
3897}
3898}
3899}
3900
3901//Step b
3902
3903public static class IntSumReducer extends Reducer < Text, IntWritable, Text, IntWritable >{ private IntWritable result = new IntWritable();
3904
3905// Reduce method accepts the Key Value pairs from mappers, do the aggregation based on keys //
3906
3907and produce the final output
3908
3909public void reduce(Text key, Iterable < IntWritable > values, Context context) throws IOException , InterruptedException{
3910
3911int sum = 0;
3912/*iterates through all the values available with a key and
3913
3914add them together and give the final result as the key and sum of its values*/ for (IntWritable val: values){
3915
3916sum += val.get();
3917}
3918result.set(sum); context.write(key, result);
3919}
3920}
3921
3922//Step c
3923
3924public static void main( String [] args) throws Exception{ //creating conf instance for Job Configuration Configuration conf = new Configuration(); //Parsing the command line arguments
3925
3926String [] otherArgs = new GenericOptionsParser(conf,args).getRemainingArgs(); if (otherArgs.length < 2){
3927System .err.println( "Usage: wordcount <in> [<in>...]<out>" ); System
3928.exit(2);
3929}
3930
3931//Create a new Job creating a job object and assigning a job name for identification //purposes
3932
3933Job job = new Job(conf, "word count" );
3934job.setJarByClass(WordCount.class);
3935
3936// Specify various job specific parameters job.setMapperClass(TokenizerMapper.class); job.setCombinerClass(IntSumReducer.class); job.setReducerClass(IntSumReducer.class);
3937
3938//Setting job object with the Data Type of output Key job.setOutputKeyClass(Text.class);
3939
3940//Setting job object with the Data Type of output value job.setOutputValueClass(IntWritable.class);
3941
3942//the hdfs input and output directory to be fetched from the command line for ( int i = 0; i < otherArgs.length 1; ++i){
3943
3944FileInputFormat.addInputPath(job, new Path(otherArgs[i]));
3945}
3946
3947
3948
3949
3950FileOutputFormat.setOutputPath(job, new Path(otherArgs[otherArgs.length 1]));
3951System .exit(job.waitForCompletion( true ) ? 0 : 1);
3952}
3953}
3954STEPS:
3955
39561. Start NameNode daemon and DataNode daemon: (port 50070) $ sbin/start-dfs.sh
3957
39582. Start ResourceManager daemon and NodeManager daemon: (port 8088) $ sbin/start-yarn.sh
3959
39603. Make the HDFS directories required to execute MapReduce jobs:
3961
3962$ bin/hdfs dfs -mkdir /user
3963
39644. Copy the input files into the distributed filesystem: $ bin/hdfs dfs -put <input-path>/* /input Run some of the examples provided:
3965
3966$ bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce- examples-2.7.0.jar wordcount /Cloud/file1.txt /op1
3967
396816/05/28 14:07:04 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032
3969
397016/05/28 14:07:04 INFO input.FileInputFormat: Total input paths to process : 1
397116/05/28 14:07:04 INFO mapreduce.JobSubmitter: number of splits:1
3972
397316/05/28 14:07:05 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1464422714543_0004
3974
397516/05/28 14:07:05 INFO impl.YarnClientImpl: Submitted application application_1464422714543_0004
3976
397716/05/28 14:07:05 INFO mapreduce.Job: The url to track the job: http://PLLAB-
397849:8088/proxy/application_1464422714543_0004/
397916/05/28 14:07:05 INFO mapreduce.Job: Running job: job_1464422714543_0004
398016/05/28 14:07:10 INFO mapreduce.Job: Job job_1464422714543_0004 running in
3981uber mode : false
398216/05/28 14:07:10 INFO mapreduce.Job: map 0% reduce 0%
398316/05/28 14:07:13 INFO mapreduce.Job: map 100% reduce 0%
398416/05/28 14:07:17 INFO mapreduce.Job: map 100% reduce 100%
3985
398616/05/28 14:07:18 INFO mapreduce.Job: Job job_1464422714543_0004 completed
3987successfully
3988
398916/05/28 14:07:18 INFO mapreduce.Job: Counters: 49 File System Counters
3990
3991FILE: Number of bytes read=155
3992
3993FILE: Number of bytes written=229563
3994FILE: Number of read operations=0
3995FILE: Number of large read operations=0
3996FILE: Number of write operations=0
3997HDFS: Number of bytes read=884837
3998HDFS: Number of bytes written=142
3999HDFS: Number of read operations=6
4000
4001
4002HDFS: Number of large read operations=0
4003HDFS: Number of write operations=2
4004Job Counters
4005Launched map tasks=1
4006Launched reduce tasks=1
4007Data-local map tasks=1
4008Total time spent by all maps in occupied slots (ms)=1615
4009Total time spent by all reduces in occupied slots (ms)=1768
4010Total time spent by all map tasks (ms)=1615
4011Total time spent by all reduce tasks (ms)=1768
4012Total vcore-seconds taken by all map tasks=1615
4013Total vcore-seconds taken by all reduce tasks=1768
4014Total megabyte-seconds taken by all map tasks=1653760
4015Total megabyte-seconds taken by all reduce tasks=1810432
4016
4017Map-Reduce Framework
4018Map input records=1
4019Map output records=99348
4020Map output bytes=1282127
4021Map output materialized bytes=155
4022Input split bytes=102
4023Combine input records=99348
4024Combine output records=10
4025Reduce input groups=10
4026Reduce shuffle bytes=155
4027Reduce input records=10
4028Reduce output records=10
4029Spilled Records=20
4030Shuffled Maps =1
4031Failed Shuffles=0
4032Merged Map outputs=1
4033GC time elapsed (ms)=71
4034CPU time spent (ms)=1720
4035Physical memory (bytes) snapshot=454377472
4036Virtual memory (bytes) snapshot=3883495424
4037Total committed heap usage (bytes)=321388544
4038Shuffle Errors
4039BAD_ID=0
4040CONNECTION=0
4041IO_ERROR=0
4042WRONG_LENGTH=0
4043WRONG_MAP=0
4044
4045WRONG_REDUCE=0
4046File Input Format Counters
4047Bytes Read=884735
4048File Output Format Counters
4049Bytes Written=142 user@ubuntu:~/hadoop-2.7.0$
4050
4051In browser type “http://localhost:50070/†Utilities → Browse the file system
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110Result:
4111
4112Thus the Word count program to use Map and reduce tasks is demonstrated successfully.