You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampark.apache.org by be...@apache.org on 2023/12/10 16:05:44 UTC

(incubator-streampark) branch check_http created (now 209c85d6d)

This is an automated email from the ASF dual-hosted git repository.

benjobs pushed a change to branch check_http
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git


      at 209c85d6d [Improve] http check improvement

This branch includes the following new commits:

     new 209c85d6d [Improve] http check improvement

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(incubator-streampark) 01/01: [Improve] http check improvement

Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

benjobs pushed a commit to branch check_http
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git

commit 209c85d6d1dcdb922125752cfec304834622a9a9
Author: benjobs <be...@gmail.com>
AuthorDate: Mon Dec 11 00:05:33 2023 +0800

    [Improve] http check improvement
---
 .../main/scala/org/apache/streampark/common/util/Utils.scala  | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/streampark-common/src/main/scala/org/apache/streampark/common/util/Utils.scala b/streampark-common/src/main/scala/org/apache/streampark/common/util/Utils.scala
index 5ab002ab2..e5bc05121 100644
--- a/streampark-common/src/main/scala/org/apache/streampark/common/util/Utils.scala
+++ b/streampark-common/src/main/scala/org/apache/streampark/common/util/Utils.scala
@@ -19,7 +19,7 @@ package org.apache.streampark.common.util
 import org.apache.commons.lang3.StringUtils
 
 import java.io._
-import java.net.URL
+import java.net.{HttpURLConnection, URL}
 import java.time.{Duration, LocalDateTime}
 import java.util.{jar, Collection => JavaCollection, Map => JavaMap, Properties, UUID}
 import java.util.concurrent.locks.LockSupport
@@ -156,6 +156,15 @@ object Utils extends Logger {
     }
   }
 
+  def checkHttpURL(urlString: String) = {
+    Try {
+      val url = new URL(urlString)
+      val connection = url.openConnection.asInstanceOf[HttpURLConnection]
+      connection.setRequestMethod("HEAD")
+      connection.getResponseCode == HttpURLConnection.HTTP_OK
+    }.getOrElse(false)
+  }
+
   def printLogo(info: String): Unit = {
     // scalastyle:off println
     println("\n")