|
package com.uplooking.bigdata.rpc; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ipc.RPC;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
/**
* RPC客户端程序
*/
public> public static void main(String[] args) throws IOException {
// 构建InetSocketAddress对象
InetSocketAddress address = new InetSocketAddress(InetAddress.getByName("localhost"), 4893);
// 通过RPC.getProxy方法获得代理对象
/**
* @param protocol 接口的类型对象
* @param clientVersion 版本号
* @param addr 服务端地址
* @param conf 配置信息
*/
IHelloService helloServiceProxy = RPC.getProxy(IHelloService.class, IHelloService.versionID, address, new Configuration());
String result = helloServiceProxy.sayHi("小秋田");
System.out.println(result);
}
}
|
|
|