|
@@ -82,15 +82,8 @@ class BridgeFilter(private val template: SimpMessagingTemplate, val resourceLoad
|
|
val splitPath = req.requestURI.split("/")
|
|
val splitPath = req.requestURI.split("/")
|
|
val client = splitPath[1]
|
|
val client = splitPath[1]
|
|
val toPath = "/" + splitPath.takeLast(splitPath.size - 1).joinToString("/")
|
|
val toPath = "/" + splitPath.takeLast(splitPath.size - 1).joinToString("/")
|
|
- if (
|
|
|
|
- client.startsWith("_")
|
|
|
|
- || client.startsWith("resources")
|
|
|
|
- || client.startsWith("clientStat")
|
|
|
|
- || client.startsWith("actuator")
|
|
|
|
- ) {
|
|
|
|
- chain.doFilter(request, response)
|
|
|
|
- return
|
|
|
|
- } else {
|
|
|
|
|
|
+ val clientNumber = client.toIntOrNull()
|
|
|
|
+ if (clientNumber != null && clientNumber > 0 && clientNumber <= 999) {
|
|
val search = isResourceAvailable(toPath)
|
|
val search = isResourceAvailable(toPath)
|
|
if (search != null && !search.endsWith("assets/bootstrap.js")) {
|
|
if (search != null && !search.endsWith("assets/bootstrap.js")) {
|
|
res.sendRedirect("/resources/$search")
|
|
res.sendRedirect("/resources/$search")
|
|
@@ -137,10 +130,11 @@ class BridgeFilter(private val template: SimpMessagingTemplate, val resourceLoad
|
|
//template.convertAndSend("/topic/request/$client",Singletons.sendQueue[mid]!!.first())
|
|
//template.convertAndSend("/topic/request/$client",Singletons.sendQueue[mid]!!.first())
|
|
|
|
|
|
|
|
|
|
- LogManager.getLogger(this.javaClass).info("part size ${partStr.size}")
|
|
|
|
|
|
+// LogManager.getLogger(this.javaClass).info("part size ${partStr.size}")
|
|
// if (partStr.size > 1) {
|
|
// if (partStr.size > 1) {
|
|
val partialID = UUID.randomUUID().toString()
|
|
val partialID = UUID.randomUUID().toString()
|
|
val st2 = System.nanoTime()
|
|
val st2 = System.nanoTime()
|
|
|
|
+
|
|
partStr.forEachIndexed { idx, it ->
|
|
partStr.forEachIndexed { idx, it ->
|
|
template.convertAndSend(
|
|
template.convertAndSend(
|
|
"/topic/partial/$client",
|
|
"/topic/partial/$client",
|
|
@@ -210,14 +204,22 @@ class BridgeFilter(private val template: SimpMessagingTemplate, val resourceLoad
|
|
ClientHolder.addFailedRequest(client)
|
|
ClientHolder.addFailedRequest(client)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
-
|
|
|
|
-// } else {
|
|
|
|
-//
|
|
|
|
-// response.status = HttpStatus.NOT_FOUND.value()
|
|
|
|
-// response.getWriter().write("Resource not found")
|
|
|
|
-// }
|
|
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ chain.doFilter(request, response)
|
|
|
|
+ return
|
|
}
|
|
}
|
|
|
|
+// if (
|
|
|
|
+// client.startsWith("_")
|
|
|
|
+// || client.startsWith("resources")
|
|
|
|
+// || client.startsWith("clientStat")
|
|
|
|
+// || client.startsWith("actuator")
|
|
|
|
+// ) {
|
|
|
|
+// chain.doFilter(request, response)
|
|
|
|
+// return
|
|
|
|
+// } else {
|
|
|
|
+//
|
|
|
|
+// }
|
|
}
|
|
}
|
|
|
|
|
|
fun isResourceAvailable(path: String, itr: Int = 1): String? {
|
|
fun isResourceAvailable(path: String, itr: Int = 1): String? {
|
|
@@ -237,8 +239,6 @@ class BridgeFilter(private val template: SimpMessagingTemplate, val resourceLoad
|
|
class RequestQue(val id: String, val requestBuilder: RequestBuilder, var responseObj: Resp?)
|
|
class RequestQue(val id: String, val requestBuilder: RequestBuilder, var responseObj: Resp?)
|
|
class PartialData(val id: String, val total: Int, val idx: Int, val data: String, val startTime: Long)
|
|
class PartialData(val id: String, val total: Int, val idx: Int, val data: String, val startTime: Long)
|
|
|
|
|
|
-//class RequestTrigger(val id: String)
|
|
|
|
-
|
|
|
|
class RequestBuilder(
|
|
class RequestBuilder(
|
|
val id: String,
|
|
val id: String,
|
|
val path: String,
|
|
val path: String,
|
|
@@ -252,35 +252,8 @@ class RequestBuilder(
|
|
|
|
|
|
class FilePart(val name: String, val fileName: String, val data: String)
|
|
class FilePart(val name: String, val fileName: String, val data: String)
|
|
|
|
|
|
-//class Message(val id: String, val data: String, val part: Int, val total: Int) : Serializable
|
|
|
|
-
|
|
|
|
-//class MessageHandler(val message: Message, template: SimpMessagingTemplate, val onComplete: () -> Unit) {
|
|
|
|
-// init {
|
|
|
|
-// template.convertAndSend(message)
|
|
|
|
-// Thread({
|
|
|
|
-// while (!sent.get()) {
|
|
|
|
-// Thread.sleep(300)
|
|
|
|
-// if (sent.get()) {
|
|
|
|
-// break
|
|
|
|
-// } else {
|
|
|
|
-// template.convertAndSend(message)
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }, "sendThread").start()
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// fun complate() {
|
|
|
|
-// sent.set(true)
|
|
|
|
-// onComplete()
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// private var sent: AtomicBoolean = AtomicBoolean(false)
|
|
|
|
-//}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
class Resp(val body: ByteArray?, val statusCode: Int, val headers: Map<String, Array<String>>? = null)
|
|
class Resp(val body: ByteArray?, val statusCode: Int, val headers: Map<String, Array<String>>? = null)
|
|
|
|
|
|
-
|
|
|
|
object Singletons {
|
|
object Singletons {
|
|
// val sendQueue: ConcurrentMap<String, MessageHandler> by lazy { ConcurrentHashMap<String, MessageHandler>() }
|
|
// val sendQueue: ConcurrentMap<String, MessageHandler> by lazy { ConcurrentHashMap<String, MessageHandler>() }
|
|
val responseQue: MutableMap<String, Resp> by lazy { mutableMapOf<String, Resp>() }
|
|
val responseQue: MutableMap<String, Resp> by lazy { mutableMapOf<String, Resp>() }
|
|
@@ -300,23 +273,20 @@ class ChunkCollector(private val id: String) {
|
|
private val listSocketChunk = mutableListOf<SocketChunkData>()
|
|
private val listSocketChunk = mutableListOf<SocketChunkData>()
|
|
fun add(dt: SocketChunkData) {
|
|
fun add(dt: SocketChunkData) {
|
|
if (!listSocketChunk.any { it.part == dt.part }) {
|
|
if (!listSocketChunk.any { it.part == dt.part }) {
|
|
-// LogManager.getLogger(this.javaClass).info("add chunk")
|
|
|
|
listSocketChunk.add(dt)
|
|
listSocketChunk.add(dt)
|
|
}
|
|
}
|
|
|
|
|
|
if (dt.part == dt.totalPart - 1) {
|
|
if (dt.part == dt.totalPart - 1) {
|
|
-// LogManager.getLogger(this.javaClass).info("timer completion")
|
|
|
|
val tStart = LocalDateTime.now()
|
|
val tStart = LocalDateTime.now()
|
|
fixedRateTimer("timer-$id", false, 20, 100) {
|
|
fixedRateTimer("timer-$id", false, 20, 100) {
|
|
if (listSocketChunk.size == dt.totalPart) {
|
|
if (listSocketChunk.size == dt.totalPart) {
|
|
-// LogManager.getLogger(this.javaClass).info("chunk complete")
|
|
|
|
val bodyList = listSocketChunk.sortedBy { it.part }.mapNotNull { it.body }
|
|
val bodyList = listSocketChunk.sortedBy { it.part }.mapNotNull { it.body }
|
|
var bd = ByteArray(0)
|
|
var bd = ByteArray(0)
|
|
bodyList.forEach { bd += it }
|
|
bodyList.forEach { bd += it }
|
|
Singletons.responseQue[id] = Resp(
|
|
Singletons.responseQue[id] = Resp(
|
|
bd,
|
|
bd,
|
|
dt.status,
|
|
dt.status,
|
|
- dt.header?.entries?.map { Pair(it.key, it.value.toTypedArray()) }?.toMap()
|
|
|
|
|
|
+ dt.header?.entries?.associate { Pair(it.key, it.value.toTypedArray()) }
|
|
)
|
|
)
|
|
this.cancel()
|
|
this.cancel()
|
|
}
|
|
}
|
|
@@ -325,7 +295,6 @@ class ChunkCollector(private val id: String) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|