Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datax-cloud
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄营
datax-cloud
Commits
2d3e43ac
Commit
2d3e43ac
authored
Nov 12, 2019
by
yw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目初始化
parent
0a2093cb
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
88 additions
and
50 deletions
+88
-50
application-dev.yml
datax-config/src/main/resources/config/application-dev.yml
+5
-3
datax-gateway-dev.yml
datax-config/src/main/resources/config/datax-gateway-dev.yml
+5
-5
RouterFunctionConfiguration.java
.../cn/datax/gateway/config/RouterFunctionConfiguration.java
+29
-0
FallbackController.java
.../java/cn/datax/gateway/controller/FallbackController.java
+0
-21
DataGatewayRequestFilter.java
...ava/cn/datax/gateway/filter/DataGatewayRequestFilter.java
+1
-1
HystrixFallbackHandler.java
...java/cn/datax/gateway/handler/HystrixFallbackHandler.java
+36
-0
EmailServiceFeignFallbackFactory.java
...l/api/feign/factory/EmailServiceFeignFallbackFactory.java
+1
-3
EmailServiceFeignFallbackImpl.java
...ail/api/feign/fallback/EmailServiceFeignFallbackImpl.java
+4
-6
UserServiceFeignFallbackFactory.java
...em/api/feign/factory/UserServiceFeignFallbackFactory.java
+1
-3
UserServiceFeignFallbackImpl.java
...stem/api/feign/fallback/UserServiceFeignFallbackImpl.java
+4
-6
UserServiceImpl.java
...cn/datax/service/system/service/impl/UserServiceImpl.java
+2
-2
No files found.
datax-config/src/main/resources/config/application-dev.yml
View file @
2d3e43ac
...
...
@@ -36,8 +36,8 @@ feign:
client
:
config
:
default
:
connectTimeout
:
10
000
readTimeout
:
10
000
connectTimeout
:
5
000
readTimeout
:
5
000
compression
:
request
:
enabled
:
true
...
...
@@ -49,10 +49,12 @@ hystrix:
command
:
default
:
execution
:
timeout
:
enabled
:
true
isolation
:
strategy
:
SEMAPHORE
thread
:
timeoutInMilliseconds
:
60000
timeoutInMilliseconds
:
5000
#断路器超时时间,默认1000ms
shareSecurityContext
:
true
#请求处理的超时时间
...
...
datax-config/src/main/resources/config/datax-gateway-dev.yml
View file @
2d3e43ac
...
...
@@ -10,8 +10,8 @@ spring:
allowCredentials
:
true
discovery
:
locator
:
lowerCaseServiceId
:
true
enabled
:
true
lower-case-service-id
:
true
default-filters
:
-
StripPrefix=1
routes
:
...
...
@@ -24,7 +24,7 @@ spring:
-
name
:
Hystrix
args
:
name
:
authFallback
fallbackUri
:
forward:/fallback
/datax-auth
fallbackUri
:
forward:/fallback
# 系统配置中心
-
id
:
datax-service-system
uri
:
lb://datax-service-system
...
...
@@ -34,7 +34,7 @@ spring:
-
name
:
Hystrix
args
:
name
:
systemFallback
fallbackUri
:
forward:/fallback
/datax-service-system
fallbackUri
:
forward:/fallback
# 邮件中心
-
id
:
datax-service-email
uri
:
lb://datax-service-email
...
...
@@ -44,7 +44,7 @@ spring:
-
name
:
Hystrix
args
:
name
:
emailFallback
fallbackUri
:
forward:/fallback
/datax-service-email
fallbackUri
:
forward:/fallback
# 邮件中心
-
id
:
datax-service-file
uri
:
lb://datax-service-file
...
...
@@ -54,7 +54,7 @@ spring:
-
name
:
Hystrix
args
:
name
:
fileFallback
fallbackUri
:
forward:/fallback
/datax-service-file
fallbackUri
:
forward:/fallback
# 即时通讯消息中心
-
id
:
datax-websocket-server
uri
:
ws://localhost:9876
...
...
datax-gateway/src/main/java/cn/datax/gateway/config/RouterFunctionConfiguration.java
0 → 100644
View file @
2d3e43ac
package
cn
.
datax
.
gateway
.
config
;
import
cn.datax.gateway.handler.HystrixFallbackHandler
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.http.MediaType
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.reactive.function.server.RequestPredicates
;
import
org.springframework.web.reactive.function.server.RouterFunction
;
import
org.springframework.web.reactive.function.server.RouterFunctions
;
/**
* 路由配置信息 特殊请求直接在此处理,不进行路由转发
*/
@Slf4j
@Component
@AllArgsConstructor
public
class
RouterFunctionConfiguration
{
private
final
HystrixFallbackHandler
hystrixFallbackHandler
;
@Bean
public
RouterFunction
routerFunction
()
{
return
RouterFunctions
.
route
(
RequestPredicates
.
path
(
"/fallback"
)
.
and
(
RequestPredicates
.
accept
(
MediaType
.
TEXT_PLAIN
)),
hystrixFallbackHandler
);
}
}
datax-gateway/src/main/java/cn/datax/gateway/controller/FallbackController.java
deleted
100644 → 0
View file @
0a2093cb
package
cn
.
datax
.
gateway
.
controller
;
import
cn.datax.common.core.R
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.RestController
;
import
reactor.core.publisher.Mono
;
@RestController
public
class
FallbackController
{
@RequestMapping
(
"fallback/{name}"
)
@ResponseStatus
(
HttpStatus
.
INTERNAL_SERVER_ERROR
)
public
Mono
<
R
>
systemFallback
(
@PathVariable
String
name
)
{
String
response
=
String
.
format
(
"访问%s超时或者服务不可用"
,
name
);
return
Mono
.
just
(
R
.
error
(
response
));
}
}
datax-gateway/src/main/java/cn/datax/gateway/filter/DataGatewayRequestFilter.java
View file @
2d3e43ac
...
...
@@ -32,7 +32,7 @@ public class DataGatewayRequestFilter implements GlobalFilter {
printLog
(
exchange
);
byte
[]
token
=
Base64Utils
.
encode
((
DataConstant
.
GATEWAY_TOKEN_VALUE
).
getBytes
());
String
headerValues
=
new
String
(
token
)
;
String
[]
headerValues
=
{
new
String
(
token
)}
;
ServerHttpRequest
build
=
request
.
mutate
().
header
(
DataConstant
.
GATEWAY_TOKEN_HEADER
,
headerValues
).
build
();
ServerWebExchange
newExchange
=
exchange
.
mutate
().
request
(
build
).
build
();
return
chain
.
filter
(
newExchange
);
...
...
datax-gateway/src/main/java/cn/datax/gateway/handler/HystrixFallbackHandler.java
0 → 100644
View file @
2d3e43ac
package
cn
.
datax
.
gateway
.
handler
;
import
cn.datax.common.core.R
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.reactive.function.BodyInserters
;
import
org.springframework.web.reactive.function.server.HandlerFunction
;
import
org.springframework.web.reactive.function.server.ServerRequest
;
import
org.springframework.web.reactive.function.server.ServerResponse
;
import
reactor.core.publisher.Mono
;
import
java.util.Optional
;
import
static
org
.
springframework
.
cloud
.
gateway
.
support
.
ServerWebExchangeUtils
.
GATEWAY_ORIGINAL_REQUEST_URL_ATTR
;
/**
* Hystrix 降级处理 网关请求错误重定向到fallback 再到这里
*/
@Slf4j
@Component
public
class
HystrixFallbackHandler
implements
HandlerFunction
<
ServerResponse
>
{
@Override
public
Mono
<
ServerResponse
>
handle
(
ServerRequest
serverRequest
)
{
//得到原始的请求的url
Optional
<
Object
>
originalUris
=
serverRequest
.
attribute
(
GATEWAY_ORIGINAL_REQUEST_URL_ATTR
);
//如果这个urls里面有东西
originalUris
.
ifPresent
(
originalUri
->
log
.
error
(
"网关执行请求:{}失败,hystrix服务降级处理"
,
originalUri
));
//返回空的response
return
ServerResponse
.
status
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
value
())
.
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
)
.
body
(
BodyInserters
.
fromObject
(
R
.
error
(
"服务超时或者服务不可用,请稍后重试"
)));
}
}
datax-modules/email-service-parent/email-service-api/src/main/java/cn/datax/service/email/api/feign/factory/EmailServiceFeignFallbackFactory.java
View file @
2d3e43ac
...
...
@@ -10,9 +10,7 @@ public class EmailServiceFeignFallbackFactory implements FallbackFactory<EmailSe
@Override
public
EmailServiceFeign
create
(
Throwable
throwable
)
{
EmailServiceFeignFallbackImpl
emailServiceFeignFallbackImpl
=
new
EmailServiceFeignFallbackImpl
();
emailServiceFeignFallbackImpl
.
setCause
(
throwable
);
return
emailServiceFeignFallbackImpl
;
return
new
EmailServiceFeignFallbackImpl
(
throwable
);
}
}
datax-modules/email-service-parent/email-service-api/src/main/java/cn/datax/service/email/api/feign/fallback/EmailServiceFeignFallbackImpl.java
View file @
2d3e43ac
...
...
@@ -3,20 +3,18 @@ package cn.datax.service.email.api.feign.fallback;
import
cn.datax.common.core.R
;
import
cn.datax.service.email.api.entity.EmailEntity
;
import
cn.datax.service.email.api.feign.EmailServiceFeign
;
import
lombok.
Sette
r
;
import
lombok.
AllArgsConstructo
r
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
@Slf4j
@
Component
@
AllArgsConstructor
public
class
EmailServiceFeignFallbackImpl
implements
EmailServiceFeign
{
@Setter
private
Throwable
cause
;
private
final
Throwable
cause
;
@Override
public
R
sendMail
(
EmailEntity
mail
)
{
log
.
error
(
"feign
发送邮件失败"
,
cause
);
log
.
error
(
"feign
调用邮件出错,信息:{}"
,
cause
.
getLocalizedMessage
()
);
return
null
;
}
}
datax-modules/system-service-parent/system-service-api/src/main/java/cn/datax/service/system/api/feign/factory/UserServiceFeignFallbackFactory.java
View file @
2d3e43ac
...
...
@@ -10,8 +10,6 @@ public class UserServiceFeignFallbackFactory implements FallbackFactory<UserServ
@Override
public
UserServiceFeign
create
(
Throwable
throwable
)
{
UserServiceFeignFallbackImpl
userServiceFeignFallbackImpl
=
new
UserServiceFeignFallbackImpl
();
userServiceFeignFallbackImpl
.
setCause
(
throwable
);
return
userServiceFeignFallbackImpl
;
return
new
UserServiceFeignFallbackImpl
(
throwable
);
}
}
datax-modules/system-service-parent/system-service-api/src/main/java/cn/datax/service/system/api/feign/fallback/UserServiceFeignFallbackImpl.java
View file @
2d3e43ac
...
...
@@ -2,20 +2,18 @@ package cn.datax.service.system.api.feign.fallback;
import
cn.datax.common.core.R
;
import
cn.datax.service.system.api.feign.UserServiceFeign
;
import
lombok.
Sette
r
;
import
lombok.
AllArgsConstructo
r
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
@Slf4j
@
Component
@
AllArgsConstructor
public
class
UserServiceFeignFallbackImpl
implements
UserServiceFeign
{
@Setter
private
Throwable
cause
;
private
final
Throwable
cause
;
@Override
public
R
getUserByUsername
(
String
username
)
{
log
.
error
(
"feign
获取用户信息失败"
,
cause
);
log
.
error
(
"feign
调用用户{}出错,信息:{}"
,
username
,
cause
.
getLocalizedMessage
()
);
return
null
;
}
}
datax-modules/system-service-parent/system-service/src/main/java/cn/datax/service/system/service/impl/UserServiceImpl.java
View file @
2d3e43ac
...
...
@@ -9,8 +9,8 @@ import cn.datax.service.system.api.entity.UserPostEntity;
import
cn.datax.service.system.api.entity.UserRoleEntity
;
import
cn.datax.service.system.dao.UserDao
;
import
cn.datax.service.system.dao.UserDeptDao
;
import
cn.datax.service.system.dao.UserPostDao
;
import
cn.datax.service.system.dao.UserRoleDao
;
import
cn.datax.service.system.dao.UserPostDao
;
import
cn.datax.service.system.mapstruct.UserMapper
;
import
cn.datax.service.system.service.UserService
;
import
cn.datax.common.base.BaseServiceImpl
;
...
...
@@ -132,5 +132,5 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem
String
passwordEncode
=
new
BCryptPasswordEncoder
().
encode
(
userPasswordDto
.
getPassword
());
userDao
.
updateUserPassword
(
passwordEncode
,
userPasswordDto
.
getId
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment