Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
TDLCloud
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
WitCloud
TDLCloud
Commits
61ad2edc
Commit
61ad2edc
authored
Nov 05, 2019
by
zhuangzhuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.增加查询当前线程数量的接口
parent
2592af72
Pipeline
#93
passed with stage
in 0 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
189 additions
and
1 deletion
+189
-1
build.gradle
build.gradle
+2
-1
IRestResponse.java
src/main/java/com/example/tdl/domain/dto/IRestResponse.java
+12
-0
RestResponse.java
src/main/java/com/example/tdl/domain/dto/RestResponse.java
+47
-0
Result.java
src/main/java/com/example/tdl/domain/dto/Result.java
+94
-0
ServiceController.java
src/main/java/com/example/tdl/web/ServiceController.java
+34
-0
No files found.
build.gradle
View file @
61ad2edc
...
...
@@ -49,7 +49,8 @@ dependencies {
compile
(
'com.aliyun.oss:aliyun-sdk-oss:2.5.0'
)
compile
(
'org.apache.poi:poi:3.9'
)
compile
files
(
'libs/javacsv-2.0.jar'
)
compile
(
'com.github.miwurster:spring-data-influxdb:1.6'
)
compile
(
'com.github.miwurster:spring-data-influxdb:1.6'
)
compile
(
'org.jetbrains:annotations:17.0.0'
)
compile
(
'org.springframework.boot:spring-boot-starter-mail'
)
}
...
...
src/main/java/com/example/tdl/domain/dto/IRestResponse.java
0 → 100644
View file @
61ad2edc
package
com
.
example
.
tdl
.
domain
.
dto
;
import
org.springframework.http.ResponseEntity
;
public
interface
IRestResponse
{
/**
* Get response entity
* @return response entity of string
*/
ResponseEntity
<
String
>
getResponseEntity
();
}
src/main/java/com/example/tdl/domain/dto/RestResponse.java
0 → 100644
View file @
61ad2edc
package
com
.
example
.
tdl
.
domain
.
dto
;
import
com.google.gson.Gson
;
import
org.jetbrains.annotations.Contract
;
import
org.jetbrains.annotations.NotNull
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
public
class
RestResponse
implements
IRestResponse
{
public
String
status
;
public
Object
message
;
@Contract
(
pure
=
true
)
public
RestResponse
(
String
status
,
String
message
)
{
this
.
status
=
status
;
this
.
message
=
message
;
}
@Contract
(
pure
=
true
)
public
RestResponse
(
String
status
,
Object
message
)
{
this
.
status
=
status
;
this
.
message
=
message
;
}
@Contract
(
pure
=
true
)
public
RestResponse
(
@NotNull
Result
result
)
{
if
(
result
.
code
.
equals
(
Result
.
OK
))
{
this
.
status
=
Result
.
STATUS_OK
;
}
else
{
this
.
status
=
Result
.
STATUS_ERROR
;
}
this
.
message
=
result
.
message
;
}
@Override
public
String
toString
()
{
return
new
Gson
().
toJson
(
this
);
}
@Override
public
ResponseEntity
<
String
>
getResponseEntity
()
{
return
new
ResponseEntity
<>(
this
.
toString
(),
HttpStatus
.
OK
);
}
}
src/main/java/com/example/tdl/domain/dto/Result.java
0 → 100644
View file @
61ad2edc
package
com
.
example
.
tdl
.
domain
.
dto
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
Result
{
public
Integer
code
;
public
String
message
;
/* OK */
public
final
static
Integer
OK
=
0x0001
;
public
final
static
Integer
SUCCESS
=
0x0002
;
/* Success messages */
public
static
final
String
STATUS_OK
=
"OK"
;
public
static
final
String
STATUS_SUCCESS
=
"Success"
;
public
static
final
String
DEVICE_CONTROLLED
=
"Device control successfully"
;
public
static
final
String
DEVICE_CONFIGURED
=
"Device configure successfully"
;
/* Error*/
public
final
static
Integer
ERROR
=
0xFFFF
;
/* Error Codes */
public
final
static
Integer
ERR_TOPIC_SUBSCRIBE
=
0x0101
;
public
final
static
Integer
ERR_TOPIC_UNSUBSCRIBE
=
0x0102
;
public
final
static
Integer
ERR_DEVICE_MOUNT
=
0x0103
;
public
final
static
Integer
ERR_DEVICE_UNMOUNT
=
0x0104
;
public
final
static
Integer
ERR_NO_SENSOR_IN_GATEWAY
=
0x0105
;
public
final
static
Integer
ERR_NO_SUCH_DEVICE
=
0x0106
;
public
final
static
Integer
ERR_PARSE_DEVICE_CONFIG
=
0x0107
;
public
final
static
Integer
ERR_TOPIC_PUBLISH
=
0x0108
;
public
final
static
Integer
ERR_INVALID_TOPIC
=
0x0109
;
public
final
static
Integer
ERR_DEVICE_OCCUPIED
=
0x010A
;
public
final
static
Integer
ERR_DEVICE_TIMEOUT
=
0x010B
;
/* Task Error Codes */
public
final
static
Integer
ERR_TASK_TIMEOUT
=
0x0110
;
public
final
static
Integer
ERR_SEM_ACQUIRE
=
0x0111
;
/* Error messages */
public
static
final
String
STATUS_ERROR
=
"Error"
;
public
static
final
String
JSON_INVALID
=
"Json is invalid"
;
public
static
final
String
CTRL_MSG_INVALID
=
"Control message is invalid"
;
private
final
static
Map
<
Integer
,
String
>
resultMap
=
new
HashMap
<
Integer
,
String
>()
{
{
/* OK */
put
(
OK
,
STATUS_OK
);
put
(
SUCCESS
,
STATUS_SUCCESS
);
/* Error */
put
(
ERROR
,
STATUS_ERROR
);
/* Error Codes */
put
(
ERR_TOPIC_SUBSCRIBE
,
"Topic subscribe error!"
);
put
(
ERR_TOPIC_UNSUBSCRIBE
,
"Topic unsubscribe error!"
);
put
(
ERR_TOPIC_PUBLISH
,
"Topic publish error!"
);
put
(
ERR_DEVICE_MOUNT
,
"Device mount error!"
);
put
(
ERR_DEVICE_UNMOUNT
,
"Device unmount error!"
);
put
(
ERR_NO_SENSOR_IN_GATEWAY
,
"No such sensor in the gateway!"
);
put
(
ERR_NO_SUCH_DEVICE
,
"No such device mounted!"
);
put
(
ERR_PARSE_DEVICE_CONFIG
,
"Parse device config error!"
);
put
(
ERR_INVALID_TOPIC
,
"Invalid topic name!"
);
put
(
ERR_DEVICE_OCCUPIED
,
"Device is being occupied!"
);
put
(
ERR_DEVICE_TIMEOUT
,
"Device response timeout!"
);
/* Task Error Codes */
put
(
ERR_TASK_TIMEOUT
,
"Task run timeout!"
);
put
(
ERR_SEM_ACQUIRE
,
"Semaphore acquire error!"
);
}
};
public
Result
(
Integer
code
)
{
if
(
resultMap
.
containsKey
(
code
))
{
this
.
code
=
code
;
this
.
message
=
resultMap
.
get
(
code
);
}
else
{
this
.
code
=
ERROR
;
this
.
message
=
resultMap
.
get
(
ERROR
);
}
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
instanceof
Result
)
{
return
this
.
code
.
equals
(((
Result
)
obj
).
code
);
}
else
{
return
super
.
equals
(
obj
);
}
}
public
boolean
equals
(
Integer
code
)
{
return
this
.
code
.
equals
(
code
);
}
}
src/main/java/com/example/tdl/web/ServiceController.java
0 → 100644
View file @
61ad2edc
package
com
.
example
.
tdl
.
web
;
import
com.example.tdl.domain.dto.RestResponse
;
import
com.example.tdl.domain.dto.Result
;
import
com.google.gson.JsonObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/service"
)
public
class
ServiceController
{
@Autowired
private
ThreadPoolTaskExecutor
taskExecutor
;
@GetMapping
(
value
=
"/getThreadPool"
)
public
ResponseEntity
<
String
>
getThreadPool
()
{
try
{
JsonObject
jsonObject
=
new
JsonObject
();
jsonObject
.
addProperty
(
"poolSize"
,
taskExecutor
.
getPoolSize
());
jsonObject
.
addProperty
(
"activeThreads"
,
taskExecutor
.
getActiveCount
());
return
new
RestResponse
(
Result
.
STATUS_OK
,
jsonObject
.
toString
())
.
getResponseEntity
();
}
catch
(
Exception
e
)
{
return
new
RestResponse
(
Result
.
STATUS_ERROR
,
"Exception: "
+
e
.
getMessage
())
.
getResponseEntity
();
}
}
}
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