Posts

Showing posts from December 9, 2018

find random country but probability of picking higher population country should be higher [duplicate]

Image
up vote 0 down vote favorite This question already has an answer here: Random number with Probabilities 10 answers I am working on below interview question: If you're given a list of countries and its corresponding population, write a function that will return a random country but the higher the population of the country, the more likely it is to be picked at random. I came up with below logic: Make two traversal on the list. In the first traversal, sum up all the population of every location to get the total population TOTAL_POP. In the second iteration, calculate % of each location's population against TOTAL_POP. For example, if location A has a popoulation 'a'. The percentage of

hdfs datanode can not register to namenode due to L2TP with NAT( not sure )

Image
up vote 0 down vote favorite Hi everyone i v come up with a problem which involves lots of techs and i m not sure i can describe it properly.. first my network topology: lab 1 (datanode1~5) < client - L2TP vpn ( with NAT on ) - server > lab 2 (datanode 6~8 and namenode 1~2) lab 1 datanode IP 192.169.88.x lab 2 datanode IP 192.168.77.x L2TP : lab 1 77.77.77.254 -> 77.77.77.1 lab 2 when i start a datanode in lab1 , in lab 2's namenode, i can see register request came up , but with wrong IP address ( 77.77.77.254 which is VPN client, or NAT IP ) not then exact datanode IP. in my knowledge tunnel tranportation should not be awared by applications , but why hdfs get this IP address . ? BTW , in the same topo, YARN cluster works just fine with all the node active. ( yarn resorcemanager is located in la