首页 > 代码库 > Hadoop HDFS编程 API入门系列之RPC版本2(九)
Hadoop HDFS编程 API入门系列之RPC版本2(九)
不多说,直接上代码。
代码
package zhouls.bigdata.myWholeHadoop.RPC.rpc2;
public class LoginServiceImpl implements LoginServiceInterface {
@Override
public String login(String username, String password) {
return username + " logged in successfully!";
}
}
package zhouls.bigdata.myWholeHadoop.RPC.rpc2;
public interface LoginServiceInterface {
public static final long versionID=1L;
public String login(String username,String password);
}
package zhouls.bigdata.myWholeHadoop.RPC.rpc2;
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 Starter {
public static void main(String[] args) throws HadoopIllegalArgumentException, IOException {
Builder builder = new RPC.Builder(new Configuration());
builder.setBindAddress("HadoopMaster").setPort(10000).setProtocol(LoginServiceInterface.class).setInstance(new LoginServiceImpl());
Server server = builder.build();
server.start();
}
}
Hadoop HDFS编程 API入门系列之RPC版本2(九)