Skip to content

Commit

Permalink
Merge pull request #1 from morningman/doris-ui
Browse files Browse the repository at this point in the history
[CodeRefactor] Clean up some code
  • Loading branch information
hf200012 authored Jul 11, 2020
2 parents 851b24f + df3f0b0 commit 659db56
Show file tree
Hide file tree
Showing 52 changed files with 637 additions and 425 deletions.
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ cd ${DORIS_HOME}/docs
./build_help_zip.sh
cd ${DORIS_HOME}

which npm
# Clean and build Frontend
if [ ${BUILD_FE} -eq 1 ] ; then
echo "Build Frontend UI"
Expand All @@ -200,15 +201,14 @@ mkdir -p ${DORIS_OUTPUT}
#Copy Frontend and Backend
if [ ${BUILD_FE} -eq 1 ]; then
install -d ${DORIS_OUTPUT}/fe/bin ${DORIS_OUTPUT}/fe/conf \
${DORIS_OUTPUT}/fe/webroot/ ${DORIS_OUTPUT}/fe/lib/
${DORIS_OUTPUT}/fe/lib/

cp -r -p ${DORIS_HOME}/bin/*_fe.sh ${DORIS_OUTPUT}/fe/bin/
cp -r -p ${DORIS_HOME}/conf/fe.conf ${DORIS_OUTPUT}/fe/conf/
rm -rf ${DORIS_OUTPUT}/fe/lib/*
cp -r -p ${DORIS_HOME}/fe/target/lib/* ${DORIS_OUTPUT}/fe/lib/
cp -r -p ${DORIS_HOME}/fe/target/palo-fe.jar ${DORIS_OUTPUT}/fe/lib/
cp -r -p ${DORIS_HOME}/docs/build/help-resource.zip ${DORIS_OUTPUT}/fe/lib/
cp -r -p ${DORIS_HOME}/webroot/* ${DORIS_OUTPUT}/fe/webroot/
cp -p ${DORIS_HOME}/fe/src/main/resources/application.yml ${DORIS_OUTPUT}/fe/conf
fi
if [ ${BUILD_BE} -eq 1 ]; then
Expand Down
24 changes: 19 additions & 5 deletions fe/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ under the License.
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>

Expand All @@ -144,23 +152,24 @@ under the License.
<groupId>org.apache.logging.log4j</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.5.0</version>
</dependency>

<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>5.5.0</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.47</version>
</dependency>

<!-- https://mvnrepository.com/artifact/cglib/cglib -->
<dependency>
Expand Down Expand Up @@ -627,6 +636,11 @@ under the License.
<version>2.4.5</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
3 changes: 1 addition & 2 deletions fe/src/main/java/org/apache/doris/PaloFe.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,10 @@ public static void start(String dorisHomeDir, String pidDir, String[] args) {
QeService qeService = new QeService(Config.query_port, Config.mysql_service_nio_enabled, ExecuteEnv.getInstance().getScheduler());
FeServer feServer = new FeServer(Config.rpc_port);
HttpServer httpServer = new HttpServer();
httpServer.setup();

feServer.start();
// httpServer.start();
qeService.start();
httpServer.start();

ThreadPoolManager.registerAllThreadPoolMetric();

Expand Down
19 changes: 18 additions & 1 deletion fe/src/main/java/org/apache/doris/http/HttpAuthManager.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
// 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.doris.http;

import com.google.common.base.Strings;
import org.apache.doris.analysis.UserIdentity;

import com.google.common.base.Strings;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;

Expand Down
19 changes: 18 additions & 1 deletion fe/src/main/java/org/apache/doris/http/HttpServer.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
// 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.doris.http;

import org.springframework.boot.SpringApplication;
Expand All @@ -17,7 +34,7 @@ protected SpringApplicationBuilder configure(SpringApplicationBuilder applicatio
return application.sources(HttpServer.class);
}

public void setup(){
public void start() {
SpringApplication.run(HttpServer.class);
}
}
22 changes: 18 additions & 4 deletions fe/src/main/java/org/apache/doris/http/config/WebConfigurer.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
// 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.doris.http.config;

import org.apache.doris.http.interceptor.AuthInterceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;


@Configuration
public class WebConfigurer implements WebMvcConfigurer {
Expand All @@ -30,7 +46,5 @@ public void addCorsMappings(CorsRegistry registry) {
.maxAge(3600);

}


}

Original file line number Diff line number Diff line change
@@ -1,37 +1,51 @@
package org.apache.doris.http.controller;

// 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.doris.http.controller;

import java.util.*;

import org.apache.doris.catalog.Catalog;
import org.apache.doris.http.entity.HttpStatus;
import org.apache.doris.http.entity.ResponseEntity;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import org.apache.doris.catalog.Catalog;
import org.apache.doris.system.Backend;

import com.google.common.collect.ImmutableMap;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/rest/v1")
public class BackendController {

private static final Logger LOG = LogManager.getLogger(BackendController.class);


@RequestMapping(path = "/backend",method = RequestMethod.GET)
public Object backend(){
ImmutableMap<Long, Backend> backendMap = Catalog.getCurrentSystemInfo().getIdToBackend();
Map<String,Backend> result = new HashMap<>();
for(long key : backendMap.keySet()){
result.put(Long.toString(key),backendMap.get(key));
}
ResponseEntity entity = ResponseEntity.status(HttpStatus.OK).build(result);
ResponseEntity<Map> entity = ResponseEntity.status(HttpStatus.OK).build(result);
return entity;
}
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,51 @@
// 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.doris.http.controller;

import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import org.apache.doris.analysis.CompoundPredicate;
import org.apache.doris.analysis.UserIdentity;
import org.apache.doris.catalog.Catalog;
import org.apache.doris.cluster.ClusterNamespace;
import org.apache.doris.http.HttpAuthManager;
import org.apache.doris.http.HttpAuthManager.SessionValue;
import org.apache.doris.http.exception.UnauthorizedException;
import org.apache.doris.mysql.privilege.PaloPrivilege;
import org.apache.doris.mysql.privilege.PrivBitSet;
import org.apache.doris.mysql.privilege.PrivPredicate;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.system.SystemInfoService;
import org.apache.doris.http.HttpAuthManager.SessionValue;

import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class BaseController {

private static final Logger LOG = LogManager.getLogger(BaseController.class);
Expand Down Expand Up @@ -122,7 +141,6 @@ public String getCookieValue(HttpServletRequest request, String cookieName, Http
return null;
}


public void updateCookieAge(HttpServletRequest request, String cookieName, int age,HttpServletResponse response) {
Cookie[] cookies = request.getCookies();
for(Cookie cookie :cookies){
Expand All @@ -146,7 +164,6 @@ public boolean needAdmin() {
return true;
}


public static class ActionAuthorizationInfo {
public String fullUserName;
public String remoteIp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@
import org.apache.doris.persist.Storage;
import org.apache.doris.system.Frontend;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.*;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/rest/v1")
public class HaController {
Expand All @@ -48,7 +52,7 @@ public Object ha(){
appendDbNames(result);
appendFe(result);
appendRemovedFe(result);
ResponseEntity entity = ResponseEntity.status(HttpStatus.OK).build(result);
ResponseEntity<Map> entity = ResponseEntity.status(HttpStatus.OK).build(result);
return entity;
}

Expand Down
Loading

0 comments on commit 659db56

Please sign in to comment.