Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
StatusManageService
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈文可
StatusManageService
Commits
6e383b95
Commit
6e383b95
authored
May 22, 2025
by
cwk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
定位服务和田浩瀚服务接入
parent
43111fd2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
265 additions
and
2 deletions
+265
-2
src/main/java/com/hpcner/statusmanageservice/serv/deploy/DeployService.java
...hpcner/statusmanageservice/serv/deploy/DeployService.java
+1
-1
src/main/java/com/hpcner/statusmanageservice/serv/other/LocalizationService.java
...r/statusmanageservice/serv/other/LocalizationService.java
+107
-0
src/main/java/com/hpcner/statusmanageservice/serv/recog/RecogThhService.java
...pcner/statusmanageservice/serv/recog/RecogThhService.java
+151
-0
src/main/resources/application.yaml
src/main/resources/application.yaml
+6
-1
No files found.
src/main/java/com/hpcner/statusmanageservice/serv/deploy/DeployService.java
View file @
6e383b95
...
@@ -73,7 +73,7 @@ public class DeployService extends BaseService {
...
@@ -73,7 +73,7 @@ public class DeployService extends BaseService {
return
false
;
return
false
;
}
else
{
}
else
{
if
(
jsonObject
.
get
(
"code"
).
asInt
()!=
ResponseConstant
.
RES_OK
){
if
(
jsonObject
.
get
(
"code"
).
asInt
()!=
ResponseConstant
.
RES_OK
){
log
.
info
(
"Error st
art
ing deploy: {}"
,
jsonObject
.
get
(
"msg"
).
asText
());
log
.
info
(
"Error st
opp
ing deploy: {}"
,
jsonObject
.
get
(
"msg"
).
asText
());
return
false
;
return
false
;
}
}
}
}
...
...
src/main/java/com/hpcner/statusmanageservice/serv/other/LocalizationService.java
0 → 100644
View file @
6e383b95
package
com.hpcner.statusmanageservice.serv.other
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.hpcner.statusmanageservice.bean.entity.ServiceInfo
;
import
com.hpcner.statusmanageservice.constant.ResponseConstant
;
import
com.hpcner.statusmanageservice.serv.BaseService
;
import
com.hpcner.statusmanageservice.service.database.ServiceInfoService
;
import
com.hpcner.statusmanageservice.utils.ApplicationContextUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.http.*
;
import
org.springframework.http.client.SimpleClientHttpRequestFactory
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.RestTemplate
;
import
java.util.Map
;
@Component
(
"other_localization"
)
@Slf4j
public
class
LocalizationService
extends
BaseService
{
//这是本地服务的位置
public
static
final
String
BASE_URL
=
"http://Localization-Service"
;
@Override
public
boolean
start
(
String
json
)
throws
JsonProcessingException
{
RestTemplate
restTemplate
=
ApplicationContextUtil
.
getBean
(
RestTemplate
.
class
);
String
url
=
BASE_URL
+
"/start"
;
ResponseEntity
<
String
>
result
=
restTemplate
.
postForEntity
(
url
,
null
,
String
.
class
);
if
(
result
.
getStatusCode
().
equals
(
HttpStatus
.
OK
)){
String
retBody
=
result
.
getBody
();
log
.
info
(
"Localization Service start result: {}"
,
retBody
);
ObjectMapper
mapper
=
new
ObjectMapper
();
JsonNode
jsonObject
=
mapper
.
readTree
(
retBody
);
if
(!
jsonObject
.
has
(
"code"
)){
log
.
info
(
"Error parse Localization Service result: {}"
,
retBody
);
return
false
;
}
else
{
if
(
jsonObject
.
get
(
"code"
).
asInt
()!=
ResponseConstant
.
RES_OK
){
log
.
info
(
"Error starting Localization Service: {}"
,
jsonObject
.
get
(
"message"
).
asText
());
return
false
;
}
}
ServiceInfoService
serviceInfoService
=
ApplicationContextUtil
.
getBean
(
ServiceInfoService
.
class
);
ServiceInfo
serviceInfo
=
new
ServiceInfo
();
serviceInfo
.
setServiceId
(
getId
());
serviceInfo
.
setServiceState
(
true
);
serviceInfoService
.
UpsertServiceInfoByServiceId
(
serviceInfo
);
return
true
;
}
else
{
return
false
;
}
}
@Override
public
boolean
stop
()
throws
JsonProcessingException
{
RestTemplate
restTemplate
=
ApplicationContextUtil
.
getBean
(
RestTemplate
.
class
);
String
url
=
BASE_URL
+
"/stop"
;
ResponseEntity
<
String
>
result
=
restTemplate
.
postForEntity
(
url
,
null
,
String
.
class
);
if
(
result
.
getStatusCode
().
equals
(
HttpStatus
.
OK
)){
String
retBody
=
result
.
getBody
();
log
.
info
(
"Localization Service start result: {}"
,
retBody
);
ObjectMapper
mapper
=
new
ObjectMapper
();
JsonNode
jsonObject
=
mapper
.
readTree
(
retBody
);
if
(!
jsonObject
.
has
(
"code"
)){
log
.
info
(
"Error parse Localization Service result: {}"
,
retBody
);
return
false
;
}
else
{
if
(
jsonObject
.
get
(
"code"
).
asInt
()!=
ResponseConstant
.
RES_OK
){
log
.
info
(
"Error stopping Localization Service: {}"
,
jsonObject
.
get
(
"message"
).
asText
());
return
false
;
}
}
ServiceInfoService
serviceInfoService
=
ApplicationContextUtil
.
getBean
(
ServiceInfoService
.
class
);
ServiceInfo
serviceInfo
=
new
ServiceInfo
();
serviceInfo
.
setServiceId
(
getId
());
serviceInfo
.
setServiceState
(
false
);
serviceInfoService
.
UpsertServiceInfoByServiceId
(
serviceInfo
);
return
true
;
}
else
{
return
false
;
}
}
@Override
public
boolean
restart
(
String
json
)
throws
JsonProcessingException
{
if
(!
stop
()){
return
false
;
}
if
(
start
(
json
)){
return
true
;
}
else
{
return
false
;
}
}
}
src/main/java/com/hpcner/statusmanageservice/serv/recog/RecogThhService.java
0 → 100644
View file @
6e383b95
package
com.hpcner.statusmanageservice.serv.recog
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.hpcner.statusmanageservice.bean.entity.ServiceInfo
;
import
com.hpcner.statusmanageservice.serv.BaseService
;
import
com.hpcner.statusmanageservice.service.database.ServiceInfoService
;
import
com.hpcner.statusmanageservice.utils.ApplicationContextUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.http.*
;
import
org.springframework.http.client.SimpleClientHttpRequestFactory
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.RestTemplate
;
import
java.util.concurrent.atomic.AtomicBoolean
;
@Component
(
"recog-thh"
)
@Slf4j
public
class
RecogThhService
extends
BaseService
{
//curl -X GET http://localhost:8000/e2e_status
// {"status":"success","services":{"service1":"stopped","service2":"stopped"}}
//curl -X GET http://localhost:8000/e2e_status
//{"status":"success","services":{"service1":"running","service2":"running"}}(base)
// curl -X POST http://localhost:8000/e2e_start
//{"status":"completed","details":{"service1":"started","service2":"started"}}(base) [cwk@iZ2ze2pfzefpro00cn0ybhZ StatusManageService]$ curl -X POST http://localhost:8000/e2e_start
//{"status":"completed","details":{"service1":"already running","service2":"already running"}}
// curl -X POST http://localhost:8000/e2e_stop
//curl -X POST http://localhost:8000/e2e_stop
//{"status":"completed","details":{"service1":"stopped","service2":"stopped"}}(base) [cwk@iZ2ze2pfzefpro00cn0ybhZ StatusManageService]$ curl -X POST http://localhost:8000/e2e_stop
//{"status":"completed","details":{"service1":"already stopped","service2":"already stopped"}}
public
static
final
String
BASE_URL
=
"http://localhost:8000"
;
@Override
public
boolean
start
(
String
json
)
{
//curl -X POST "http://localhost:8081/models?url=retinanet.mar&initial_workers=3"
try
{
ObjectMapper
mapper
=
new
ObjectMapper
();
String
url
=
String
.
format
(
"%s/e2e_start"
,
BASE_URL
);
log
.
info
(
"Start recog thh {}"
,
url
);
RestTemplate
restTemplate
=
new
RestTemplate
(
new
SimpleClientHttpRequestFactory
());
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
postForEntity
(
url
,
null
,
String
.
class
);
if
(!
responseEntity
.
getStatusCode
().
equals
(
HttpStatus
.
OK
)){
return
false
;
}
JsonNode
resultObject
=
mapper
.
readTree
(
responseEntity
.
getBody
());
if
(
resultObject
==
null
)
{
log
.
info
(
"Error parse recog thh result: {}"
,
responseEntity
.
getBody
());
return
false
;
}
if
(!
resultObject
.
has
(
"details"
))
{
log
.
info
(
"Error starting recog thh: {}"
,
responseEntity
.
getBody
());
return
false
;
}
AtomicBoolean
started
=
new
AtomicBoolean
(
false
);
resultObject
.
get
(
"details"
).
fields
().
forEachRemaining
(
entry
->
{
String
serviceName
=
entry
.
getKey
();
String
serviceStatus
=
entry
.
getValue
().
asText
();
if
(
serviceStatus
.
contains
(
"already"
))
{
log
.
info
(
"Service {} is already running"
,
serviceName
);
started
.
set
(
true
);
}
});
if
(
started
.
get
()){
return
false
;
}
ServiceInfoService
serviceInfoService
=
ApplicationContextUtil
.
getBean
(
ServiceInfoService
.
class
);
ServiceInfo
serviceInfo
=
new
ServiceInfo
();
serviceInfo
.
setServiceId
(
getId
());
serviceInfo
.
setServiceState
(
true
);
serviceInfoService
.
UpsertServiceInfoByServiceId
(
serviceInfo
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"Exception in start recog zgs"
,
e
);
return
false
;
}
}
@Override
public
boolean
stop
()
{
try
{
ObjectMapper
mapper
=
new
ObjectMapper
();
String
url
=
String
.
format
(
"%s/e2e_stop"
,
BASE_URL
);
log
.
info
(
"Stop recog thh {}"
,
url
);
RestTemplate
restTemplate
=
new
RestTemplate
(
new
SimpleClientHttpRequestFactory
());
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
postForEntity
(
url
,
null
,
String
.
class
);
if
(!
responseEntity
.
getStatusCode
().
equals
(
HttpStatus
.
OK
)){
return
false
;
}
JsonNode
resultObject
=
mapper
.
readTree
(
responseEntity
.
getBody
());
if
(
resultObject
==
null
)
{
log
.
info
(
"Error parse recog thh result: {}"
,
responseEntity
.
getBody
());
return
false
;
}
if
(!
resultObject
.
has
(
"details"
))
{
log
.
info
(
"Error Stopping recog thh: {}"
,
responseEntity
.
getBody
());
return
false
;
}
AtomicBoolean
started
=
new
AtomicBoolean
(
false
);
resultObject
.
get
(
"details"
).
fields
().
forEachRemaining
(
entry
->
{
String
serviceName
=
entry
.
getKey
();
String
serviceStatus
=
entry
.
getValue
().
asText
();
if
(
serviceStatus
.
contains
(
"already"
))
{
log
.
info
(
"Service {} is already stopped"
,
serviceName
);
started
.
set
(
true
);
}
});
if
(
started
.
get
()){
return
false
;
}
ServiceInfoService
serviceInfoService
=
ApplicationContextUtil
.
getBean
(
ServiceInfoService
.
class
);
ServiceInfo
serviceInfo
=
new
ServiceInfo
();
serviceInfo
.
setServiceId
(
getId
());
serviceInfo
.
setServiceState
(
false
);
serviceInfoService
.
UpsertServiceInfoByServiceId
(
serviceInfo
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"Exception in stop recog zgs"
,
e
);
return
false
;
}
}
@Override
public
boolean
restart
(
String
json
)
{
if
(!
stop
()){
return
false
;
}
if
(
start
(
json
)){
return
true
;
}
else
{
return
false
;
}
}
}
src/main/resources/application.yaml
View file @
6e383b95
...
@@ -51,6 +51,8 @@ service-config:
...
@@ -51,6 +51,8 @@ service-config:
-
id
:
recog-zgs
-
id
:
recog-zgs
name
:
张高帅算法
name
:
张高帅算法
#json: "{ \"url\":\"String\",\"initial_workers\":\"Integer\" }"
#json: "{ \"url\":\"String\",\"initial_workers\":\"Integer\" }"
-
id
:
recog-thh
name
:
田浩瀚算法
deploy-lists
:
deploy-lists
:
-
id
:
deploy_zhangyuhao
-
id
:
deploy_zhangyuhao
...
@@ -70,4 +72,7 @@ service-config:
...
@@ -70,4 +72,7 @@ service-config:
name
:
通导态势图算法
name
:
通导态势图算法
#json: ""
#json: ""
-
id
:
other_simulator
-
id
:
other_simulator
name
:
模拟器服务
name
:
模拟器服务
\ No newline at end of file
-
id
:
other_localization
name
:
定位算法
\ No newline at end of file
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