先问了简历上 微服务的很多细节,问了 feature flag 系统怎么实现
notes 如下:
enable
dev test production
turn on 10% 50% traffic
canary deployment
define a key
key A:
boolean
10% false
90% true
production
environment
application service make a get to our service
10% return false
90% return true
In UI there is draggable bar for configure
percentage
rolling updates
switch endpoint
a cluster of 10 instances version1
10 %
internal load balancer
reverse proxy
bring up a new cluster of 10 instances version2
we used haproxy in the beginning
but later we discarded haproxy
customized wrote go program to
wrote golang program for proxying
business logic in the golang
static config file for haproxy
dynamic service discovery
registration service
hard coded dns name
service name
zookeeper configuration registration
heart beat if track a instance die
custom dns server
然后问了coding和linux command
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.function.*;
// 8 + 2
// 8 2 +
// tcp udp
// tcp reliable ordering
// udp is
ls
ps aux | grep
top
df -h
ls -l | sort -k 5 -n
public class Solution {
abstract class Operator {
String val;
int count;// how many numbers, root squre -> 1
abstract double apply(List<Double> nums);
}
public static double rpn(List<String> inputs) {
if (inputs == null) {
throw new IllegalArgumentException();
}
Stack<Double> stack = new Stack<>();
for (String s : inputs) {
Operator operator = Operator.valueOf(s);
if (operator == null) {
try {
stack.push(Double.parseDouble(s)); // NumberFormatException
} catch(Exception ex) {
throw new IllegalArgumentException(ex);
}
} else {
int count = opertor.getCount();
if (stack.size() < count) {
throw new IllegalArgumentException("Invalid input");
}
List<Double> nums = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
nums.add(stack.pop());
}
try {
stack.push(operator.apply(nums));
} catch(Exception ex) {///arithematic
throw new IllegalArgumentException();
}
}
}
if (stack.size() != 1) {
throw new IllegalArgumentException();
}
return stack.pop();
}
private static final Map<String, BinaryOperator<Double>> OPERATORS = new HashMap<>();
static {
OPERATORS.put("+", (x, y) -> x + y);
OPERATORS.put("-", (x, y) -> x - y);
OPERATORS.put("/", (x, y) -> x / y);
OPERATORS.put("*", (x, y) -> x * y);
}
public static double rpn(List<String> inputs) {
if (inputs == null) {
throw new IllegalArgumentException();
}
Stack<Double> stack = new Stack<>();
for (String s : inputs) {
BinaryOperator<Double> operator = OPERATORS.get(s);
if (operator == null) {
try {
stack.push(Double.parseDouble(s)); // NumberFormatException
} catch(Exception ex) {
throw new IllegalArgumentException(ex);
}
} else {
if (stack.size() < 2) {
throw new IllegalArgumentException("Invalid input");
}
double y = stack.pop();
double x = stack.pop();
try {
stack.push(operator.apply(x, y));
} catch(Exception ex) {///arithematic
throw new IllegalArgumentException();
}
}
}
if (stack.size() != 1) {
throw new IllegalArgumentException();
}
return stack.pop();
}
public static void main(String args[] ) throws Exception {
//System.out.println(rpn(Arrays.asList("4", "2", "+")));
//System.out.println(rpn(Arrays.asList("4", "2", "-")));
System.out.println(rpn(Arrays.asList("4", "2", "+", "-")));
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
}
}