Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #5141] update eventmesh-admin-server module #5143

Merged
merged 6 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions eventmesh-admin-server/bin/stop-admin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/bash
#
# Licensed to Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Apache Software Foundation (ASF) licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# Detect operating system
OS=$(uname)

EVENTMESH_ADMIN_HOME=`cd $(dirname $0)/.. && pwd`

export EVENTMESH_ADMIN_HOME

function get_pid {
local ppid=""
if [ -f ${EVENTMESH_ADMIN_HOME}/bin/pid-admin.file ]; then
ppid=$(cat ${EVENTMESH_ADMIN_HOME}/bin/pid-admin.file)
# If the process does not exist, it indicates that the previous process terminated abnormally.
if [ ! -d /proc/$ppid ]; then
# Remove the residual file and return an error status.
rm ${EVENTMESH_ADMIN_HOME}/bin/pid-admin.file
echo -e "ERROR\t EventMesh admin process had already terminated unexpectedly before, please check log output."
ppid=""
fi
else
if [[ $OS =~ Msys ]]; then
# There is a Bug on Msys that may not be able to kill the identified process
ppid=`jps -v | grep -i "org.apache.eventmesh.admin.server.ExampleAdminServer" | grep java | grep -v grep | awk -F ' ' {'print $1'}`
elif [[ $OS =~ Darwin ]]; then
# Known problem: grep Java may not be able to accurately identify Java processes
ppid=$(/bin/ps -o user,pid,command | grep "java" | grep -i "org.apache.eventmesh.admin.server.ExampleAdminServer" | grep -Ev "^root" |awk -F ' ' {'print $2'})
else
# It is required to identify the process as accurately as possible on Linux
ppid=$(ps -C java -o user,pid,command --cols 99999 | grep -w $EVENTMESH_ADMIN_HOME | grep -i "org.apache.eventmesh.admin.server.ExampleAdminServer" | grep -Ev "^root" |awk -F ' ' {'print $2'})
fi
fi
echo "$ppid";
}

pid=$(get_pid)
if [[ $pid == "ERROR"* ]]; then
echo -e "${pid}"
exit 9
fi
if [ -z "$pid" ];then
echo -e "ERROR\t No EventMesh admin server running."
exit 9
fi

kill ${pid}
echo "Send shutdown request to EventMesh admin(${pid}) OK"

[[ $OS =~ Msys ]] && PS_PARAM=" -W "
stop_timeout=60
for no in $(seq 1 $stop_timeout); do
if ps $PS_PARAM -p "$pid" 2>&1 > /dev/null; then
if [ $no -lt $stop_timeout ]; then
echo "[$no] server shutting down ..."
sleep 1
continue
fi

echo "shutdown server timeout, kill process: $pid"
kill -9 $pid; sleep 1; break;
echo "`date +'%Y-%m-%-d %H:%M:%S'` , pid : [$pid] , error message : abnormal shutdown which can not be closed within 60s" > ../logs/shutdown.error
else
echo "shutdown server ok!"; break;
fi
done

if [ -f "pid-admin.file" ]; then
rm pid-admin.file
fi


24 changes: 20 additions & 4 deletions eventmesh-admin-server/conf/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ spring:
username: //db_username
password: //db_password
driver-class-name: com.mysql.cj.jdbc.Driver
initialSize: 1
minIdle: 1
maxActive: 20
maxWait: 10000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: false
maxPoolPreparedStatementPerConnectionSize: 20
filters: stat
connectionProperties: "druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000"
# secret keys
sysPubKey:
appPrivKey:

mybatis-plus:
mapper-locations: classpath:mapper/*.xml
configuration:
Expand All @@ -35,8 +53,6 @@ event-mesh:
# grpc server port
port: 8081
adminServerList:
R1:
- http://localhost:8082
R2:
- http://localhost:8082
R1: http://localhost:8082;http://localhost:8082
R2: http://localhost:8092;http://localhost:8092
region: R1
33 changes: 33 additions & 0 deletions eventmesh-admin-server/conf/eventmesh.sql
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,39 @@ CREATE TABLE IF NOT EXISTS `event_mesh_verify` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

-- eventmesh.event_mesh_weredis_position definition
CREATE TABLE `event_mesh_weredis_position` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`jobID` varchar(50) COLLATE utf8_bin NOT NULL DEFAULT '',
`address` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`clusterName` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`partitionName` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`masterReplid` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`host` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`replOffset` bigint(20) NOT NULL DEFAULT '-1',
`createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `jobID` (`jobID`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=DYNAMIC;


CREATE TABLE `event_mesh_monitor` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`taskID` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`jobID` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`address` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`transportType` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`connectorStage` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`totalReqNum` bigint DEFAULT NULL,
`totalTimeCost` bigint DEFAULT NULL,
`maxTimeCost` bigint DEFAULT NULL,
`avgTimeCost` bigint DEFAULT NULL,
`tps` double DEFAULT NULL,
`createTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
Expand Down
68 changes: 0 additions & 68 deletions eventmesh-admin-server/conf/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,74 +28,6 @@
<AppenderRef ref="console"/>
</AsyncRoot>

<AsyncLogger name="retry" level="info" additivity="false" includeLocation="true">
<AppenderRef ref="retryAppender"/>
</AsyncLogger>

<AsyncLogger name="httpMonitor" level="debug" additivity="false" includeLocation="true">
<AppenderRef ref="console"/>
</AsyncLogger>

<AsyncLogger name="tcpMonitor" level="debug" additivity="false" includeLocation="true">
<AppenderRef ref="console"/>
</AsyncLogger>

<AsyncLogger name="appMonitor" level="debug" additivity="false" includeLocation="true">
<AppenderRef ref="console"/>
</AsyncLogger>

<AsyncLogger name="cmd" level="debug" additivity="false" includeLocation="true">
<AppenderRef ref="console"/>
</AsyncLogger>

<AsyncLogger name="message" level="debug" additivity="false" includeLocation="true">
<AppenderRef ref="console"/>
</AsyncLogger>

<AsyncLogger name="batchMessage" level="debug" additivity="false" includeLocation="true">
<AppenderRef ref="console"/>
</AsyncLogger>

<AsyncLogger name="http" level="debug" additivity="false" includeLocation="true">
<AppenderRef ref="console"/>
</AsyncLogger>

<AsyncLogger name="metaStorage" level="debug" additivity="false" includeLocation="true">
<AppenderRef ref="console"/>
</AsyncLogger>

<AsyncLogger name="acl" level="debug" additivity="false" includeLocation="true">
<AppenderRef ref="console"/>
</AsyncLogger>

<AsyncLogger name="org.apache.eventmesh.runtime" level="debug" additivity="false" includeLocation="true">
<AppenderRef ref="console"/>
</AsyncLogger>

<AsyncLogger name="org.apache.rocketmq" level="INFO" additivity="false" includeLocation="true">
<AppenderRef ref="console"/>
</AsyncLogger>

<AsyncLogger name="RocketmqClient" level="INFO" additivity="false" includeLocation="true">
<AppenderRef ref="console"/>
</AsyncLogger>

<AsyncLogger name="RocketmqRemoting" level="INFO" additivity="false" includeLocation="true">
<AppenderRef ref="console"/>
</AsyncLogger>

<AsyncLogger name="RocketmqCommon" level="debug" additivity="false" includeLocation="true">
<AppenderRef ref="console"/>
</AsyncLogger>

<AsyncLogger name="sessionLogger" level="debug" additivity="false" includeLocation="true">
<AppenderRef ref="console"/>
</AsyncLogger>

<AsyncLogger name="subscribeLogger" level="info" additivity="false" includeLocation="true">
<AppenderRef ref="console"/>
</AsyncLogger>

<AsyncLogger name="com.alipay.sofa.jraft" level="info" additivity="false" includeLocation="true">
<AppenderRef ref="console"/>
</AsyncLogger>
Expand Down
46 changes: 46 additions & 0 deletions eventmesh-admin-server/conf/mapper/EventMeshMonitorMapper.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->

<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.apache.eventmesh.admin.server.web.db.mapper.EventMeshMonitorMapper">

<resultMap id="BaseResultMap" type="org.apache.eventmesh.admin.server.web.db.entity.EventMeshMonitor">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="taskID" column="taskID" jdbcType="VARCHAR"/>
<result property="jobID" column="jobID" jdbcType="VARCHAR"/>
<result property="address" column="address" jdbcType="VARCHAR"/>
<result property="transportType" column="transportType" jdbcType="VARCHAR"/>
<result property="connectorStage" column="connectorStage" jdbcType="VARCHAR"/>
<result property="totalReqNum" column="totalReqNum" jdbcType="BIGINT"/>
<result property="totalTimeCost" column="totalTimeCost" jdbcType="BIGINT"/>
<result property="maxTimeCost" column="maxTimeCost" jdbcType="BIGINT"/>
<result property="avgTimeCost" column="avgTimeCost" jdbcType="BIGINT"/>
<result property="tps" column="tps" jdbcType="DOUBLE"/>
<result property="createTime" column="createTime" jdbcType="TIMESTAMP"/>
</resultMap>

<sql id="Base_Column_List">
id,taskID,jobID,address,transportType,connectorStage,
totalReqNum,totalTimeCost,maxTimeCost,avgTimeCost,
tps,createTime
</sql>
</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.apache.eventmesh.admin.server;

import java.util.List;
import java.util.Map;

import org.springframework.boot.context.properties.ConfigurationProperties;
Expand All @@ -35,6 +34,6 @@ public class AdminServerProperties {
private String configurationPath;
private String configurationFile;
private String serviceName;
private Map<String, List<String>> adminServerList;
private Map<String, String> adminServerList;
private String region;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,22 @@

package org.apache.eventmesh.admin.server;

import org.apache.eventmesh.admin.server.constatns.AdminServerConstants;
import org.apache.eventmesh.admin.server.constants.AdminServerConstants;
import org.apache.eventmesh.common.config.ConfigService;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

@SpringBootApplication(scanBasePackages = "org.apache.eventmesh.admin.server")
import lombok.extern.slf4j.Slf4j;

@Slf4j
@SpringBootApplication(scanBasePackages = "org.apache.eventmesh.admin.server", exclude = {DataSourceAutoConfiguration.class})
public class ExampleAdminServer {

public static void main(String[] args) throws Exception {
ConfigService.getInstance().setConfigPath(AdminServerConstants.EVENTMESH_CONF_HOME).setRootConfig(AdminServerConstants.EVENTMESH_CONF_FILE);
SpringApplication.run(ExampleAdminServer.class);
log.info("wedts-admin start success.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.eventmesh.admin.server.constatns;
package org.apache.eventmesh.admin.server.constants;

public class AdminServerConstants {
public static final String CONF_ENV = "configurationPath";
Expand Down
Loading
Loading