ClusterForwardProvider 接口 demo 插件。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.5 KiB

package com.fr.plugin.cluster.req.demo.handler;
import com.fr.decision.fun.impl.BaseHttpHandler;
import com.fr.json.JSONObject;
import com.fr.plugin.cluster.req.demo.ReqDemoManager;
import com.fr.plugin.cluster.req.demo.URIConstants;
import com.fr.plugin.cluster.req.demo.entity.Task;
import com.fr.third.springframework.web.bind.annotation.RequestMethod;
import com.fr.web.core.cluster.ClusterStatusHelper;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
*/
public class SearchAction extends BaseHttpHandler {
@Override
public RequestMethod getMethod() {
return RequestMethod.GET;
}
@Override
public String getPath() {
return URIConstants.SEARCH;
}
@Override
public boolean isPublic() {
return true;
}
@Override
public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception {
JSONObject json = new JSONObject();
String id = WebUtils.getHTTPRequestParameter(req, "id");
json.put("id", id);
boolean isCluster = ClusterStatusHelper.isClusterEnv();
json.put("isCluster", isCluster);
if (isCluster) {
String clusterNodeId = ClusterStatusHelper.getCurrentNodeId();
json.put("clusterId", clusterNodeId);
Task task = ReqDemoManager.getTask(id);
if (task != null) {
json.put("taskName", task.getName());
}
}
WebUtils.printAsJSON(res, json);
}
}