In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the example analysis of rpc in hadoop, which is very detailed and has certain reference value. Friends who are interested must finish it!
[root@localhost hadoop-2.4.1] # service network restart starts the network card
UserLoginController on the windos side
Package cn.itcast.bigdata.hadoop.rpc
Import java.io.IOException
Import java.net.InetSocketAddress
Import org.apache.hadoop.conf.Configuration
Import org.apache.hadoop.ipc.RPC
Public class UserLoginController {
Public static void main (String [] args) throws Exception {/ / start the server side first
Configuration conf = new Configuration ()
LoginServiceInterface loginServiceImpl = RPC.getProxy (LoginServiceInterface.class, 1L, new InetSocketAddress ("192.168.88.155", 10000), conf)
String res = loginServiceImpl.login ("angelababy", "123")
System.out.println (res)
}
}
Package cn.itcast.bigdata.hadoop.rpc
Public interface LoginServiceInterface {
Public static final long versionID = 1L
Public String login (String username,String password)
}
Linux-side
Package cn.itcast.bigdata.hadoop.rpc
Public class LoginServiceImpl implements LoginServiceInterface {
@ Override
Public String login (String username, String password) {
Return username + "logged in successfully!"
}
}
Package cn.itcast.bigdata.hadoop.rpc
Public interface LoginServiceInterface {
Public static final long versionID = 1L
Public String login (String username,String password)
}
Package cn.itcast.bigdata.hadoop.rpc
Import java.io.IOException
Import org.apache.hadoop.HadoopIllegalArgumentException
Import org.apache.hadoop.conf.Configuration
Import org.apache.hadoop.ipc.RPC
Import org.apache.hadoop.ipc.RPC.Builder
Import org.apache.hadoop.ipc.RPC.Server
Public class ServerStarter {
Public static void main (String [] args) throws HadoopIllegalArgumentException, IOException {/ / start the server-side
Configuration conf = new Configuration ()
Builder builder = new RPC.Builder (conf)
Builder.setInstance (new LoginServiceImpl ()) .setBindAddress ("192.168.88.155") .setPort (10000) .setProtocol (LoginServiceInterface.class)
Server server = builder.build ()
Server.start ()
}
}
The above is all the content of the article "sample Analysis of rpc in hadoop". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.