org.tinygroup.event.Event.createEvent()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中org.tinygroup.event.Event.createEvent()方法的一些代码示例,展示了Event.createEvent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Event.createEvent()方法的具体详情如下:
包路径:org.tinygroup.event.Event
类名称:Event
方法名:createEvent

Event.createEvent介绍

暂无

代码示例

代码示例来源: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.cepcoremutiremoteimpl

/**
 * 创建节点注册Event
 * 
 * @return
 */
private Event getNodeUnregRequestEvent() {
  Context c = new ContextImpl();
  c.put(NODE_KEY, getNode());
  Event e = Event.createEvent(NODE_UNREG_TO_SC_REQUEST, c);
  return e;
}

代码示例来源:origin: org.tinygroup/org.tinygroup.cepcoremutiremoteimpl

/**
 * 将当前注册的Node节点发送到SC上已有的Node节点列表
 * 
 * @param nodeString
 * @param node
 * @param list
 */
private void scUnregCurrentNodeToNodes(String nodeString, Node currentNode) {
  // 讲注销节点 发送至已有节点列表,在已有节点列表上注销该节点
  logger.logMessage(LogLevel.INFO, "开始将注销请求发送至已有节点列表");
  for (String nodeStringVar : ctxs.keySet()) {
    logger.logMessage(LogLevel.INFO, "向{0}注销{1}", nodeStringVar,
        nodeString);
    // Node node = nodes.get(nodeStringVar);
    Context c2 = new ContextImpl();
    c2.put(NODE_KEY, currentNode);
    Event e = Event.createEvent(SC_UNREG_NODE_TO_NODE_REQUEST, c2);
    ctxs.get(nodeStringVar).writeAndFlush(e);
    logger.logMessage(LogLevel.INFO, "向{0}注销{1}完成", nodeStringVar,
        nodeString);
  }
  logger.logMessage(LogLevel.INFO, "将注销请求发送至已有节点列表完成");
}

代码示例来源:origin: org.tinygroup/org.tinygroup.cepcoremutiremoteimpl

/**
 * 将当前注册的Node节点发送到SC上已有的Node节点列表
 * 
 * @param nodeString
 * @param node
 * @param list
 */
private void scRegCurrentNodeToNodes(String nodeString, Node node,
    List<ServiceInfo> list,int version) {
  logger.logMessage(LogLevel.INFO, "开始将{0}节点注册至已有节点列表", nodeString);
  // 将注册节点信息 发送到 已有节点列表
  for (String string : nodes.keySet()) {
    if(nodeString.equals(string)){
      continue;
    }
    logger.logMessage(LogLevel.INFO, "开始将{0}节点注册至已有节点:{1}", nodeString,
        string);
    Context newContext = new ContextImpl();
    newContext.put(NODE_KEY, node);
    newContext.put(TYPE_KEY, REG_KEY);
    newContext.put(SC_TO_NODE_SERVICE_KEY, list);
    newContext.put(SC_TO_NODE_SERVICE_VERSION_KEY, version);
    Event newEvent = Event.createEvent(SC_REG_NODE_TO_NODE_REQUEST,
        newContext);
    ctxs.get(string).writeAndFlush(newEvent);
    logger.logMessage(LogLevel.INFO, "将{0}节点注册至已有节点:{1}完成", nodeString,
        string);
  }
  logger.logMessage(LogLevel.INFO, "将{0}节点注册至已有节点列表完成", nodeString);
}

代码示例来源: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/org.tinygroup.cepcoremutiremoteimpl

public Event getNodeRegRequestEvent() {
  Context c = new ContextImpl();
  List<ServiceInfo> list = getCore().getServiceInfos();
  if (logger.isEnabled(LogLevel.INFO)) {
    logger.logMessage(LogLevel.INFO, "当前节点服务数{}", list.size());
  }
  int version = getCore()
      .getServiceInfosVersion();
  c.put(NODE_REG_TO_SC_SERVICE_VERSION_KEY, version);
  c.put(NODE_REG_TO_SC_SERVICE_KEY, list);
  c.put(NODE_KEY, getNode());
  Event e = Event.createEvent(NODE_REG_TO_SC_REQUEST, c);
  return e;
}

代码示例来源:origin: org.tinygroup/org.tinygroup.cepcorenettysc

newContext.put(NettyCepCoreUtil.TYPE_KEY, NettyCepCoreUtil.REG_KEY);
newContext.put(NettyCepCoreUtil.SC_TO_AR_SERVICE_KEY, list);
Event newEvent = Event.createEvent(NettyCepCoreUtil.SC_TO_AR,
    newContext);

代码示例来源:origin: org.tinygroup/org.tinygroup.cepcorenettysc

c2.put(NettyCepCoreUtil.NODE_KEY, containNode);
c2.put(NettyCepCoreUtil.TYPE_KEY, NettyCepCoreUtil.UNREG_KEY);
Event e = Event.createEvent(NettyCepCoreUtil.SC_TO_AR, c2);
try {
  NettyCepCoreUtil.sendEvent(client, e);

代码示例来源:origin: org.tinygroup/org.tinygroup.cepcoremutiremoteimpl

/**
 * 创建节点注册Event
 * 
 * @return
 */
public Event getNodeReRegRequestEvent() {
  Context c = new ContextImpl();
  List<ServiceInfo> list = getCore().getServiceInfos();
  if (logger.isEnabled(LogLevel.INFO)) {
    logger.logMessage(LogLevel.INFO, "当前节点服务数{}", list.size());
  }
  int version = getCore()
      .getServiceInfosVersion();
  c.put(NODE_REG_TO_SC_SERVICE_VERSION_KEY, version);
  c.put(NODE_REG_TO_SC_SERVICE_KEY, list);
  c.put(NODE_KEY, getNode());
  Event e = Event.createEvent(NODE_RE_REG_TO_SC_REQUEST, c);
  return e;
}

代码示例来源:origin: org.tinygroup/org.tinygroup.cepcorenettysc

public void regToSc() {
    logger.logMessage(LogLevel.INFO, "开始向服务中心发起注册");
    List<ServiceInfo> list = core.getServiceInfos();
    Context c = new ContextImpl();
    c.put(NettyCepCoreUtil.AR_TO_SC_SERVICE_KEY, list);
    logger.logMessage(LogLevel.INFO, "当前节点服务数{}", list.size());
    c.put(NettyCepCoreUtil.NODE_KEY, node);
    c.put(NettyCepCoreUtil.TYPE_KEY, NettyCepCoreUtil.REG_KEY);
    Event e = Event.createEvent(NettyCepCoreUtil.AR_TO_SC, c);
    Event result = client.getClient().sendObject(e);
    Context c2 = result.getServiceRequest().getContext();
    Map<Node, List<ServiceInfo>> nodeServices = c2
        .get(NettyCepCoreUtil.SC_TO_AR_SERVICE_KEY);
    logger.logMessage(LogLevel.INFO, "接收到服务中心发送的其他节点数{}",
        nodeServices.size());
    for (Node node : nodeServices.keySet()) {
      logger.logMessage(LogLevel.INFO, "为节点:{}创建服务处理器", node.toString());
      NettyEventProcessor ne = new NettyEventProcessor(node,
          nodeServices.get(node));
      NettyEventProcessorConatiner.add(node.toString(), ne, core);
      logger.logMessage(LogLevel.INFO, "为节点:{}创建服务处理器完成", node.toString());
    }
    logger.logMessage(LogLevel.INFO, "向服务中心注册完成");

  }
}

相关文章