Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,15 @@ protected void serviceInit(Configuration configuration) throws Exception {
this.rpcServer = createRpcServer();
addService(this.rpcServer);
this.setRpcServerAddress(rpcServer.getRpcAddress());
} else {
InetSocketAddress confRpcAddress = conf.getSocketAddr(
RBFConfigKeys.DFS_ROUTER_RPC_BIND_HOST_KEY,
RBFConfigKeys.DFS_ROUTER_RPC_ADDRESS_KEY,
RBFConfigKeys.DFS_ROUTER_RPC_ADDRESS_DEFAULT,
RBFConfigKeys.DFS_ROUTER_RPC_PORT_DEFAULT);

String hostname = InetAddress.getLocalHost().getHostName();
setRouterId(hostname + ":" + confRpcAddress.getPort());
}

if (conf.getBoolean(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,16 @@ public void testSwitchRouter() throws IOException {
private void assertRouterHeartbeater(boolean expectedRouterHeartbeat,
boolean expectedNNHeartbeat) throws IOException {
final Router router = new Router();
Configuration baseCfg = new RouterConfigBuilder(conf).rpc().build();
Comment thread
goiri marked this conversation as resolved.
Configuration baseCfg = new RouterConfigBuilder(conf).rpc(false).build();
baseCfg.setBoolean(RBFConfigKeys.DFS_ROUTER_HEARTBEAT_ENABLE,
expectedRouterHeartbeat);
baseCfg.setBoolean(RBFConfigKeys.DFS_ROUTER_NAMENODE_HEARTBEAT_ENABLE,
expectedNNHeartbeat);
router.init(baseCfg);

// RouterId can not be null , used by RouterHeartbeatService.updateStateStore()
assertNotNull(router.getRouterId());

RouterHeartbeatService routerHeartbeatService =
router.getRouterHeartbeatService();
if (expectedRouterHeartbeat) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public class TestRouterHeartbeatService {
@Before
public void setup() throws Exception {
router = new Router();
router.setRouterId(routerId);
Configuration conf = new Configuration();
conf.setInt(RBFConfigKeys.DFS_ROUTER_CACHE_TIME_TO_LIVE_MS, 1);
Configuration routerConfig =
Expand All @@ -76,6 +75,8 @@ public void setup() throws Exception {
curatorFramework.start();
routerConfig.set(CommonConfigurationKeys.ZK_ADDRESS, connectStr);
router.init(routerConfig);
// set custom routerid after router.init()
router.setRouterId(routerId);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldnt init already trigger this with the new code change?
Or we need to force the specific routerId?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If set the specific routerid,we use the specific routerid; otherwise we use the routerid generated by Router.serviceInit.

router.start();


Expand Down