aaronlinv
3 years ago
committed by
GitHub
16 changed files with 41 additions and 372 deletions
@ -1,56 +0,0 @@
|
||||
<!-- |
||||
~ 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. |
||||
--> |
||||
|
||||
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd"> |
||||
<id>dolphinscheduler-logger-server</id> |
||||
<formats> |
||||
<format>dir</format> |
||||
</formats> |
||||
<includeBaseDirectory>false</includeBaseDirectory> |
||||
<baseDirectory>logger-server</baseDirectory> |
||||
<fileSets> |
||||
<fileSet> |
||||
<directory>${basedir}/src/main/bin</directory> |
||||
<outputDirectory>bin</outputDirectory> |
||||
<fileMode>0755</fileMode> |
||||
<directoryMode>0755</directoryMode> |
||||
</fileSet> |
||||
<fileSet> |
||||
<directory>${basedir}/../script/env</directory> |
||||
<outputDirectory>bin</outputDirectory> |
||||
<includes> |
||||
<include>dolphinscheduler_env.sh</include> |
||||
</includes> |
||||
<fileMode>0755</fileMode> |
||||
<directoryMode>0755</directoryMode> |
||||
</fileSet> |
||||
<fileSet> |
||||
<directory>${basedir}/../../dolphinscheduler-common/src/main/resources</directory> |
||||
<includes> |
||||
<include>**/*.properties</include> |
||||
</includes> |
||||
<outputDirectory>conf</outputDirectory> |
||||
</fileSet> |
||||
</fileSets> |
||||
<dependencySets> |
||||
<dependencySet> |
||||
<outputDirectory>libs</outputDirectory> |
||||
</dependencySet> |
||||
</dependencySets> |
||||
</assembly> |
@ -1,32 +0,0 @@
|
||||
#!/bin/bash |
||||
# |
||||
# 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. |
||||
# |
||||
|
||||
BIN_DIR=$(dirname $0) |
||||
DOLPHINSCHEDULER_HOME=${DOLPHINSCHEDULER_HOME:-$(cd $BIN_DIR/..; pwd)} |
||||
|
||||
source "$BIN_DIR/dolphinscheduler_env.sh" |
||||
|
||||
JAVA_OPTS=${JAVA_OPTS:-"-server -Xms1g -Xmx1g -Xmn512m -XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"} |
||||
|
||||
if [[ "$DOCKER" == "true" ]]; then |
||||
JAVA_OPTS="${JAVA_OPTS} -XX:-UseContainerSupport" |
||||
fi |
||||
|
||||
java $JAVA_OPTS \ |
||||
-cp "$DOLPHINSCHEDULER_HOME/conf":"$DOLPHINSCHEDULER_HOME/libs/*" \ |
||||
org.apache.dolphinscheduler.server.log.LoggerServer |
@ -1,34 +0,0 @@
|
||||
# |
||||
# 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. |
||||
# |
||||
|
||||
FROM openjdk:8-jre-slim-buster |
||||
|
||||
ENV DOCKER true |
||||
ENV TZ Asia/Shanghai |
||||
ENV DOLPHINSCHEDULER_HOME /opt/dolphinscheduler |
||||
|
||||
RUN apt update ; \ |
||||
apt install -y curl ; \ |
||||
rm -rf /var/lib/apt/lists/* |
||||
|
||||
WORKDIR $DOLPHINSCHEDULER_HOME |
||||
|
||||
ADD ./target/logger-server $DOLPHINSCHEDULER_HOME |
||||
|
||||
EXPOSE 50051 |
||||
|
||||
CMD [ "/bin/bash", "./bin/start.sh" ] |
@ -1,88 +0,0 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.server.log; |
||||
|
||||
import org.apache.dolphinscheduler.common.Constants; |
||||
import org.apache.dolphinscheduler.common.utils.PropertyUtils; |
||||
import org.apache.dolphinscheduler.remote.NettyRemotingServer; |
||||
import org.apache.dolphinscheduler.remote.command.CommandType; |
||||
import org.apache.dolphinscheduler.remote.config.NettyServerConfig; |
||||
|
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
/** |
||||
* logger server |
||||
*/ |
||||
public class LoggerServer { |
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(LoggerServer.class); |
||||
|
||||
/** |
||||
* netty server |
||||
*/ |
||||
private final NettyRemotingServer server; |
||||
|
||||
/** |
||||
* netty server config |
||||
*/ |
||||
private final NettyServerConfig serverConfig; |
||||
|
||||
/** |
||||
* loggger request processor |
||||
*/ |
||||
private final LoggerRequestProcessor requestProcessor; |
||||
|
||||
public LoggerServer() { |
||||
this.serverConfig = new NettyServerConfig(); |
||||
this.serverConfig.setListenPort(PropertyUtils.getInt(Constants.RPC_PORT, 50051)); |
||||
this.server = new NettyRemotingServer(serverConfig); |
||||
this.requestProcessor = new LoggerRequestProcessor(); |
||||
this.server.registerProcessor(CommandType.GET_LOG_BYTES_REQUEST, requestProcessor, requestProcessor.getExecutor()); |
||||
this.server.registerProcessor(CommandType.ROLL_VIEW_LOG_REQUEST, requestProcessor, requestProcessor.getExecutor()); |
||||
this.server.registerProcessor(CommandType.VIEW_WHOLE_LOG_REQUEST, requestProcessor, requestProcessor.getExecutor()); |
||||
this.server.registerProcessor(CommandType.REMOVE_TAK_LOG_REQUEST, requestProcessor, requestProcessor.getExecutor()); |
||||
} |
||||
|
||||
/** |
||||
* main launches the server from the command line. |
||||
* @param args arguments |
||||
*/ |
||||
public static void main(String[] args) { |
||||
final LoggerServer server = new LoggerServer(); |
||||
server.start(); |
||||
} |
||||
|
||||
/** |
||||
* server start |
||||
*/ |
||||
public void start() { |
||||
this.server.start(); |
||||
logger.info("logger server started, listening on port : {}", PropertyUtils.getInt(Constants.RPC_PORT, 50051)); |
||||
Runtime.getRuntime().addShutdownHook(new Thread(LoggerServer.this::stop)); |
||||
} |
||||
|
||||
/** |
||||
* stop |
||||
*/ |
||||
public void stop() { |
||||
this.server.close(); |
||||
logger.info("logger server shut down"); |
||||
} |
||||
|
||||
} |
@ -1,81 +0,0 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
|
||||
package org.apache.dolphinscheduler.server.log; |
||||
|
||||
import org.apache.dolphinscheduler.common.Constants; |
||||
import org.apache.dolphinscheduler.common.utils.FileUtils; |
||||
import org.apache.dolphinscheduler.common.utils.PropertyUtils; |
||||
import org.apache.dolphinscheduler.service.log.LogClientService; |
||||
|
||||
import org.apache.commons.lang.StringUtils; |
||||
|
||||
import java.io.File; |
||||
import java.io.IOException; |
||||
import java.nio.charset.Charset; |
||||
|
||||
import org.junit.After; |
||||
import org.junit.Assert; |
||||
import org.junit.Before; |
||||
import org.junit.Test; |
||||
|
||||
public class LoggerServerTest { |
||||
|
||||
private LoggerServer loggerServer; |
||||
|
||||
private LogClientService logClientService; |
||||
|
||||
@Before |
||||
public void startServerAndClient() { |
||||
this.loggerServer = new LoggerServer(); |
||||
this.loggerServer.start(); |
||||
this.logClientService = new LogClientService(); |
||||
} |
||||
|
||||
@Test |
||||
public void testRollViewLog() throws IOException { |
||||
String expectedTmpDemoString = "testRolloViewLog"; |
||||
org.apache.commons.io.FileUtils.writeStringToFile(new File("/tmp/demo.txt"), expectedTmpDemoString, Charset.defaultCharset()); |
||||
|
||||
String resultTmpDemoString = this.logClientService.rollViewLog( |
||||
"localhost", PropertyUtils.getInt(Constants.RPC_PORT, 50051), "/tmp/demo.txt", 0, 1000); |
||||
|
||||
Assert.assertEquals(expectedTmpDemoString, resultTmpDemoString.replaceAll("[\r|\n|\t]", StringUtils.EMPTY)); |
||||
|
||||
FileUtils.deleteFile("/tmp/demo.txt"); |
||||
} |
||||
|
||||
@Test |
||||
public void testRemoveTaskLog() throws IOException { |
||||
String expectedTmpRemoveString = "testRemoveTaskLog"; |
||||
org.apache.commons.io.FileUtils.writeStringToFile(new File("/tmp/remove.txt"), expectedTmpRemoveString, Charset.defaultCharset()); |
||||
|
||||
Boolean b = this.logClientService.removeTaskLog("localhost", PropertyUtils.getInt(Constants.RPC_PORT, 50051),"/tmp/remove.txt"); |
||||
|
||||
Assert.assertTrue(b); |
||||
|
||||
String result = this.logClientService.viewLog("localhost", PropertyUtils.getInt(Constants.RPC_PORT, 50051),"/tmp/demo.txt"); |
||||
|
||||
Assert.assertEquals(StringUtils.EMPTY, result); |
||||
} |
||||
|
||||
@After |
||||
public void stopServerAndClient() { |
||||
this.loggerServer.stop(); |
||||
this.logClientService.close(); |
||||
} |
||||
} |
Loading…
Reference in new issue