Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
browser-backend
Project
Project
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
Administrator
browser-backend
Commits
8da9ffec
Commit
8da9ffec
authored
Dec 09, 2024
by
jinliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove unnecessary delete logic
parent
40fc1409
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
18 deletions
+19
-18
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+14
-13
ShopServiceImpl.java
.../browserbackend/browser/service/Impl/ShopServiceImpl.java
+4
-4
BrowserTask.java
...va/com/edgec/browserbackend/browser/task/BrowserTask.java
+1
-1
No files found.
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
8da9ffec
...
...
@@ -468,8 +468,8 @@ public class IpResourceServiceImpl implements IpResourceService {
public
IpOperationResultDto
deleteExpiredIp
(
String
username
,
IpResourceRequestDto
ipResourceRequestDto
)
{
Account
account
=
accountRepository
.
findByName
(
username
).
orElseThrow
(()
->
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
));
String
URL
=
(
profiles
.
equals
(
"dev"
)
||
profiles
.
equals
(
"staging"
))
?
TESTURL
:
CLOUDAMURL
;
RestTemplate
restTemplate
=
new
RestTemplate
();
//
String URL = (profiles.equals("dev") || profiles.equals("staging")) ? TESTURL : CLOUDAMURL;
//
RestTemplate restTemplate = new RestTemplate();
HttpHeaders
headers
=
buildGetHeader
();
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
HttpEntity
<
Map
<
String
,
String
>>
httpEntity
=
new
HttpEntity
<>(
params
,
headers
);
...
...
@@ -487,8 +487,9 @@ public class IpResourceServiceImpl implements IpResourceService {
return
;
}
try
{
// 现在全部都是包月的机器,然后也没有给用户保留7天,所以不需要再执行这个删除逻辑了
/* try {
// 调用 uri删除远程的 IP资源
ResponseEntity<String> result = restTemplate.exchange(URL + "/intelligroup/ipresources?accountId=browser&ip={ip}", HttpMethod.DELETE, httpEntity, String.class, ipAddr);
DeleteIpResultDto deleteIpResultDto = JSON.parseObject(result.getBody(), DeleteIpResultDto.class);
...
...
@@ -501,7 +502,7 @@ public class IpResourceServiceImpl implements IpResourceService {
} catch (Exception e) {
logger.error("fail to delete ip", e);
ipOperationResultDto.getFailList().add(ipAddr);
}
}
*/
try
{
// ip资源为未绑定,则直接删除
...
...
@@ -534,7 +535,8 @@ public class IpResourceServiceImpl implements IpResourceService {
if
(
ipResource
.
getStatus
()
==
6
)
{
ipResourceRepository
.
delete
(
ipResource
);
}
else
if
(
StringUtils
.
isNotBlank
(
ipResource
.
getAddr
())
&&
ipResource
.
getIpType
()
==
IpType
.
VENDOR
)
{
try
{
// 现在全部都是包月的机器,然后也没有给用户保留7天,所以不需要再执行这个删除逻辑了
/* try {
ResponseEntity<String> result = restTemplate.exchange(URL + "/intelligroup/ipresources?accountId=browser&ip={ip}",
HttpMethod.DELETE, httpEntity, String.class, ipResource.getAddr());
DeleteIpResultDto deleteIpResultDto = JSON.parseObject(result.getBody(), DeleteIpResultDto.class);
...
...
@@ -544,10 +546,9 @@ public class IpResourceServiceImpl implements IpResourceService {
}
} catch (Exception t) {
logger.error("ip " + ipResource.getAddr() + " 删除失败", t);
}
}
*/
}
ipResource
.
setDeleted
(
true
);
ipResource
.
setShopIds
(
null
);
ipResourceRepository
.
save
(
ipResource
);
...
...
@@ -736,14 +737,14 @@ public class IpResourceServiceImpl implements IpResourceService {
if
(
x
.
getLockTimestamp
()
>=
Instant
.
now
().
minusSeconds
(
1
*
60
).
toEpochMilli
()
&&
x
.
getIpType
()
==
IpType
.
VENDOR
&&
(
x
.
getStatus
()
==
0
||
x
.
getStatus
()
==
2
))
{
x
.
setStatus
(
3
);
// 1.2 ip资源在未来
七
天内到期,且 ip 资源的状态不是 3(正在分配)、5(已失效)、6(未分配),则将 ip 资源设置为 2(即将过期)
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
x
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
// 1.2 ip资源在未来
3
天内到期,且 ip 资源的状态不是 3(正在分配)、5(已失效)、6(未分配),则将 ip 资源设置为 2(即将过期)
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
3
).
toEpochMilli
()
&&
x
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
if
(
x
.
getStatus
()
!=
5
&&
x
.
getStatus
()
!=
3
&&
x
.
getStatus
()
!=
6
&&
x
.
getStatus
()
!=
9
)
{
ipResourceRepository
.
updateStatus
(
x
.
getId
(),
2
);
}
// 1.3 ip资源在
七
天前到期,且 ip 资源的状态不是 3(正在分配)、6(未分配),则删除 ip 资源
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
x
.
getStatus
()
!=
3
&&
x
.
getStatus
()
!=
6
&&
x
.
getStatus
()
!=
9
)
{
// 1.3 ip资源在
1
天前到期,且 ip 资源的状态不是 3(正在分配)、6(未分配),则删除 ip 资源
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
).
toEpochMilli
()
&&
x
.
getStatus
()
!=
3
&&
x
.
getStatus
()
!=
6
&&
x
.
getStatus
()
!=
9
)
{
if
(
x
.
getIpType
()
==
IpType
.
VENDOR
)
{
IpResourceRequestDto
ipResourceRequestDto
=
new
IpResourceRequestDto
();
ipResourceRequestDto
.
setAddr
(
Arrays
.
asList
(
x
.
getAddr
()));
...
...
@@ -919,7 +920,7 @@ public class IpResourceServiceImpl implements IpResourceService {
if
(
StringUtils
.
isNotBlank
(
ipResource
.
getAddr
()))
{
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
ipResource
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
ipResourceRepository
.
updateStatus
(
ipResource
.
getId
(),
2
);
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
())
{
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
).
toEpochMilli
())
{
deleteExpiredIp
(
username
,
ipResourceRequestDto
);
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
toEpochMilli
())
{
ipResourceRepository
.
updateStatus
(
ipResource
.
getId
(),
1
);
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/ShopServiceImpl.java
View file @
8da9ffec
...
...
@@ -591,16 +591,16 @@ public class ShopServiceImpl implements ShopService {
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
x
.
getShopId
(),
false
);
// 如果 ip资源非空 且 addr 也非空
if
(
ipResource
!=
null
&&
!
StringUtils
.
isEmpty
(
ipResource
.
getAddr
()))
{
// 1. ip资源在未来
七
天内到期 且 ip 资源的状态不是 3(正在分配)、5(已失效)、6(未分配),则将 ip 资源设置为 2(即将过期)
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
ipResource
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
// 1. ip资源在未来
3
天内到期 且 ip 资源的状态不是 3(正在分配)、5(已失效)、6(未分配),则将 ip 资源设置为 2(即将过期)
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
3
).
toEpochMilli
()
&&
ipResource
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
if
(
ipResource
.
getStatus
()
!=
5
&&
ipResource
.
getStatus
()
!=
3
&&
ipResource
.
getStatus
()
!=
6
&&
ipResource
.
getStatus
()
!=
9
)
{
ipResource
.
setStatus
(
2
);
//ipResourceRepository.save(ipResource);
pageIpResourceListToSave
.
add
(
ipResource
);
}
// 2. ip资源在
七
天前到期,且 ip 资源的状态不是 3(正在分配)、6(未分配),则删除 ip 资源
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
ipResource
.
getStatus
()
!=
3
&&
ipResource
.
getStatus
()
!=
6
&&
ipResource
.
getStatus
()
!=
9
)
{
// 2. ip资源在
1
天前到期,且 ip 资源的状态不是 3(正在分配)、6(未分配),则删除 ip 资源
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
).
toEpochMilli
()
&&
ipResource
.
getStatus
()
!=
3
&&
ipResource
.
getStatus
()
!=
6
&&
ipResource
.
getStatus
()
!=
9
)
{
IpResourceRequestDto
ipResourceRequestDto1
=
new
IpResourceRequestDto
();
if
(
ipResource
.
getIpType
()
==
IpType
.
VENDOR
)
{
ipResourceRequestDto1
.
setAddr
(
Arrays
.
asList
(
ipResource
.
getAddr
()));
...
...
src/main/java/com/edgec/browserbackend/browser/task/BrowserTask.java
View file @
8da9ffec
...
...
@@ -1120,7 +1120,7 @@ public class BrowserTask {
String
logs
=
"【deleteOverdueIps】 "
;
List
<
IpResource
>
list
=
ipResourceRepository
.
findByValidTimeLessThanAndIsDeleted
(
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
(),
false
);
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
3
).
toEpochMilli
(),
false
);
log
.
error
(
"Scheduled {}, list size : {}"
,
logs
,
list
.
size
());
list
.
forEach
(
this
::
deleteOverdueIp
);
...
...
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