本文整理了Java中org.tinygroup.event.Event.getServiceRequest()
方法的一些代码示例,展示了Event.getServiceRequest()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Event.getServiceRequest()
方法的具体详情如下:
包路径:org.tinygroup.event.Event
类名称:Event
方法名:getServiceRequest
暂无
代码示例来源:origin: org.tinygroup/org.tinygroup.cepcorenettysc
public static String getServiceId(Event event){
return event.getServiceRequest().getServiceId();
}
}
代码示例来源:origin: org.tinygroup/event
public static Event createEvent(String serviceId, String nodeName,
Context context) {
Event event = createEvent(serviceId, context);
event.getServiceRequest().setNodeName(nodeName);
return event;
}
代码示例来源:origin: org.tinygroup/org.tinygroup.cepcore
public static boolean isTinySysService(Event event) {
String serviceId = event.getServiceRequest().getServiceId();
return isTinySysService(serviceId);
}
代码示例来源:origin: org.tinygroup/org.tinygroup.cepcore
public void handle(Event e) {
if (servicePattern == null) {
adapter.handle(e);
return;
}
String requestId = e.getServiceRequest().getServiceId();
if (servicePattern.matcher(requestId).matches()) {
adapter.handle(e);
}
}
}
代码示例来源:origin: org.tinygroup/org.tinygroup.cepcoremutiremoteimpl
public static void updateResponse(String eventId, Event event) {
// 如果该eventId已不在列表之中,那么该event也许是之前已被超时清理了
if (!responseMap.containsKey(eventId)) {
String serviceId = event.getServiceRequest().getServiceId();
TinyRequestHasTimeOutException e = new TinyRequestHasTimeOutException(
eventId, serviceId);
logger.errorMessage(e.getMessage());
throw e;
}
BlockingQueue<Event> queue = responseMap.get(eventId);
queue.add(event);
}
代码示例来源:origin: org.tinygroup/org.tinygroup.cepcore
public void handle(Event event) {
ServiceRequest request = event.getServiceRequest();
ServiceInfo info = find(request);
List<Parameter> params = info.getParameters();
if (params != null && !params.isEmpty()) {
Object args[] = new Object[params.size()];
for (int i = 0; i < params.size(); i++) {
args[i] = getArgument(request.getContext(), params.get(i));
}
ParameterValidator.validate(args, info.getParameters(), this
.getClass().getClassLoader());
}
}
代码示例来源:origin: org.tinygroup/org.tinygroup.cepcorebase
public void process(CEPCoreProcessDealer dealer, Event event, CEPCore core, EventProcessor processor) {
Context oldContext = event.getServiceRequest().getContext();
ServiceParamUtil.changeEventContext(event, core, Thread.currentThread().getContextClassLoader());
try {
dealer.process(event, core, processor);
} finally {
ServiceParamUtil.resetEventContext(event, core, oldContext);
}
}
代码示例来源:origin: org.tinygroup/org.tinygroup.cepcorebase
/**
* 异步服务执行线程执行之前
*
* @param event
*/
public static void synBeforeProcess(Event event) {
Context reuqestContext = event
.getServiceRequest().getContext();
//从请求上下文中解析线程上下文
ThreadContextUtil.parseCurrentThreadContext(reuqestContext);
parseLoggerThreadLocal();
}
代码示例来源:origin: org.tinygroup/org.tinygroup.servicewrapper
private <T> T callServiceAndCallBack(String serviceId, Context context)
throws Exception {
Event event = getEvent(serviceId, context);
core.process(event);
ServiceInfo info = core.getServiceInfo(serviceId);
List<Parameter> resultsParam = info.getResults();
if (resultsParam == null || resultsParam.size() == 0) {
return null;
}
return event.getServiceRequest().getContext()
.get(resultsParam.get(0).getName());
}
代码示例来源:origin: org.tinygroup/org.tinygroup.cepcorebase
private void putThreadVariable(Event event) {
ServiceRequest request = event.getServiceRequest();
LoggerFactory.putThreadVariable(LoggerFactory.SERVICE_EVENTID, event.getEventId());
LoggerFactory.putThreadVariable(LoggerFactory.SERVICE_SERVICEID, request.getServiceId());
}
代码示例来源:origin: org.tinygroup/org.tinygroup.cepcorebase
/**
* 异步服务调用的主线程发起之前
*
* @param event
*/
public static void synBeforeCall(Event event) {
// 将 日志线程变量 放入 请求线程变量
ThreadContextUtil.put(ThreadContextUtil.LOGGER_THREADLOCAL_KEY,
LoggerFactory.getThreadVariableMap());
Context reuqestContext = event.getServiceRequest().getContext();
// 将 请求线程变量的clone 放入 请求上下文(context),之所以放clone是因为synBeforeCall/synAfterCall与执行线程是异步的
ThreadContextUtil.putCurrentThreadContextIntoContext(reuqestContext);
}
代码示例来源:origin: org.tinygroup/org.tinygroup.cepcoremutiremoteimpl
protected void processResult(Object response, ChannelHandlerContext ctx)
throws Exception {
Event event = (Event) response;
String eventId = event.getEventId();
logger.logMessage(LogLevel.INFO, "接收到Event:{0}的请求响应,请求id:{1}", eventId,
event.getServiceRequest().getServiceId());
ResponseManager.updateResponse(eventId, event);
}
代码示例来源:origin: org.tinygroup/org.tinygroup.cepcoremutiremoteimpl
public void channelRead(ChannelHandlerContext ctx, Object msg)
throws Exception {
Event event = (Event) msg;
String serviceId = event.getServiceRequest().getServiceId();
logger.logMessage(LogLevel.INFO, "接收到请求,id:{},type:{}", serviceId,
event.getType());
dealRemoteRequest(event, ctx);
}
代码示例来源:origin: org.tinygroup/org.tinygroup.cepcoremutiremoteimpl
public void dealNodeUnregResponse(Event result) {
logger.logMessage(LogLevel.INFO, "接收到服务中心返回的注销响应");
Context c2 = result.getServiceRequest().getContext();
Map<String, Node> nodeServices = c2.get(NODES_KEY);
logger.logMessage(LogLevel.INFO, "需要注销的其他节点数{}", nodeServices.size());
for (String nodeString : nodeServices.keySet()) {
RemoteEventProcessorConatiner.remove(nodeString, getCore());
}
logger.logMessage(LogLevel.INFO, "处理服务中心返回的注销响应完毕");
}
代码示例来源:origin: org.tinygroup/org.tinygroup.cepcoremutiremoteimpl
public void channelRead(ChannelHandlerContext ctx, Object msg)
throws Exception {
Event event = (Event) msg;
String serviceId = event.getServiceRequest().getServiceId();
logger.logMessage(LogLevel.INFO, "接收到请求,id:{},type:{}", serviceId,
event.getType());
boolean isResponse = (Event.EVENT_TYPE_RESPONSE == event.getType());
if (isResponse) {
processResult(event, ctx); // 处理服务的返回结果
} else {
logger.errorMessage("客户端收到未知请求" + serviceId);
}
}
代码示例来源:origin: org.tinygroup/org.tinygroup.cepcore
public static Context getContext(Event event, ServiceInfo info, ClassLoader loder) {
Context c = new ContextImpl();
Context oldContext = event.getServiceRequest().getContext();
if (info.getParameters() == null) {
return c;
}
for (Parameter p : info.getParameters()) {
Object value = Context2ObjectUtil.getObject(p, oldContext, loder);
if (value != null && !(value instanceof java.io.Serializable)) {
throw new ParamNotSerializableException(event
.getServiceRequest().getServiceId(), p.getName());
}
c.put(p.getName(), value);
}
return c;
}
代码示例来源:origin: org.tinygroup/org.tinygroup.cepcorenettysc
private void unregToSc(EventClient client) {
logger.logMessage(LogLevel.INFO, "开始向服务中心发起注销");
Context c = new ContextImpl();
c.put(NettyCepCoreUtil.NODE_KEY, getNode());
c.put(NettyCepCoreUtil.TYPE_KEY, NettyCepCoreUtil.UNREG_KEY);
Event e = Event.createEvent(NettyCepCoreUtil.AR_TO_SC, c);
Event result = client.sendObject(e);
Context c2 = result.getServiceRequest().getContext();
Map<String, Node> nodeServices = c2
.get(NettyCepCoreUtil.NODES_KEY);
logger.logMessage(LogLevel.INFO, "需要注销的其他节点数{}",nodeServices.size());
for (String nodeString : nodeServices.keySet()) {
NettyEventProcessorConatiner.remove(nodeString, core);
}
logger.logMessage(LogLevel.INFO, "向服务中心注销完成");
}
代码示例来源:origin: org.tinygroup/weblayer
private Object callService(String serviceId, Context context) {
CEPCore core = SpringUtil.getBean(CEPCore.CEP_CORE_BEAN);
Event event = new Event();
ServiceRequest sq = new ServiceRequest();
sq.setServiceId(serviceId);
sq.setContext(context);
event.setServiceRequest(sq);
core.process(event);
ServiceInfo info = core.getServiceInfo(serviceId);
List<Parameter> resultsParam = info.getResults();
if (resultsParam.size() == 0) {
return null;
}
return event.getServiceRequest().getContext()
.get(resultsParam.get(0).getName());
}
代码示例来源:origin: org.tinygroup/org.tinygroup.cepcoremutiremoteimpl
public void dealScUnregNodeToNode(Event event, ChannelHandlerContext ctx) {
logger.logMessage(LogLevel.INFO, "开始处理服务中心发来的其它节点注销请求");
Context c = event.getServiceRequest().getContext();
Node remoteNode = c.get(NODE_KEY);
logger.logMessage(LogLevel.INFO, "开始注销节点:{}", remoteNode.toString());
RemoteEventProcessorConatiner.remove(remoteNode.toString(), getCore());
logger.logMessage(LogLevel.INFO, "注销节点:{}完成", remoteNode.toString());
logger.logMessage(LogLevel.INFO, "处理服务中心发来的其它节点注销请求完成");
}
代码示例来源:origin: org.tinygroup/org.tinygroup.cepcoremutiremoteimpl
public void dealScRegNodeToNode(Event event, ChannelHandlerContext ctx) {
logger.logMessage(LogLevel.INFO, "开始处理服务中心发来的其它节点注册请求");
Context c = event.getServiceRequest().getContext();
Node remoteNode = c.get(NODE_KEY);
List<ServiceInfo> list = c.get(SC_TO_NODE_SERVICE_KEY);
int version = (Integer)c.get(SC_TO_NODE_SERVICE_VERSION_KEY);
logger.logMessage(LogLevel.INFO, "开始注册节点:{},为节点创建服务处理器,服务版本{}",
remoteNode.toString(),version);
RemoteEventProcessorConatiner.add(remoteNode, list, getCore(), version);
logger.logMessage(LogLevel.INFO, "为节点:{}创建服务处理器完成",
remoteNode.toString());
logger.logMessage(LogLevel.INFO, "处理服务中心发来的其它节点注册请求完成");
}
内容来源于网络,如有侵权,请联系作者删除!