Skip to content
Snippets Groups Projects
Commit 904ff4cc authored by 潇洒's avatar 潇洒
Browse files

add limit

parent e54247f3
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,8 @@ public class CallbackListenerImpl implements CallbackListener {
UserLoadBalance.weight_large = 6.0 * memory_large / memory_sum;
UserLoadBalance.weight_medium = 6.0 * memory_medium / memory_sum;
UserLoadBalance.weight_small = 6.0 * memory_small / memory_sum;
//System.out.println( UserLoadBalance.weight_large +" "+ UserLoadBalance.weight_medium+" "+ UserLoadBalance.weight_small);
mask = 0x0;
}
}
......
......@@ -20,7 +20,9 @@ public class TestClientFilter implements Filter {
@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
try{
Result result = invoker.invoke(invocation);
return result;
}catch (Exception e){
throw e;
......
......@@ -26,7 +26,7 @@ public class CallbackServiceImpl implements CallbackService {
@Override
public void run() {
if (!listeners.isEmpty()) {
//String messageToPush = generateStatusMessage();
//System.out.println("Server push " +generateStatusMessage() + " Mem="+Runtime.getRuntime().freeMemory());
for (Map.Entry<String, CallbackListener> entry : listeners.entrySet()) {
try {
//entry.getValue().receiveServerMsg(System.getProperty("quota") + " " + new Date().toString());
......@@ -37,7 +37,7 @@ public class CallbackServiceImpl implements CallbackService {
}
}
}
}, 0, 2000);
}, 0, 5000);
}
private Timer timer = new Timer();
......@@ -46,7 +46,6 @@ public class CallbackServiceImpl implements CallbackService {
try {
List<String> cpuLoadList = getProcessCpuLoad().stream().map(Object::toString).collect(Collectors.toList());
String cpuLoadString = String.join(",", cpuLoadList);
System.out.println("Server push " + cpuLoadString);
return "cpu=" + cpuLoadString;
}
catch(Exception ex) {
......
......@@ -20,7 +20,14 @@ public class TestRequestLimiter implements RequestLimiter {
*/
@Override
public boolean tryAcquire(Request request, int activeTaskCount) {
//if (activeTaskCount > 188) return false;
//
if("small".equals(System.getProperty("quota"))){
if (activeTaskCount > 195) return false;
} else if("medium".equals(System.getProperty("quota"))){
if (activeTaskCount > 445) return false;
} else if("large".equals(System.getProperty("quota"))){
if (activeTaskCount > 645) return false;
}
return true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment