|
|
@@ -9,7 +9,13 @@ import com.google.gson.JsonElement;
|
|
|
import com.google.gson.JsonObject;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+import java.net.URI;
|
|
|
+import java.net.URISyntaxException;
|
|
|
import java.net.http.HttpClient;
|
|
|
+import java.net.http.HttpRequest;
|
|
|
+import java.net.http.HttpResponse;
|
|
|
+import java.nio.file.Path;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
|
import java.util.Collections;
|
|
|
@@ -59,4 +65,24 @@ public class ConsulService {
|
|
|
}
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
+
|
|
|
+ public void deregister(String service) throws URISyntaxException, IOException, InterruptedException {
|
|
|
+ String url = "http://s75.iquizoo.com:8500/v1/agent/service/deregister/" + service;
|
|
|
+ HttpRequest.Builder builder = HttpRequest.newBuilder(new URI(url)).version(HttpClient.Version.HTTP_1_1);
|
|
|
+
|
|
|
+ HttpRequest httpRequest = builder.PUT(HttpRequest.BodyPublishers.noBody()).build();
|
|
|
+ HttpClient httpClient = HttpClient.newBuilder().build();
|
|
|
+ HttpResponse<String> httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString());
|
|
|
+ int statusCode = httpResponse.statusCode();
|
|
|
+ String body = httpResponse.body();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) throws URISyntaxException, IOException, InterruptedException {
|
|
|
+ ConsulService consulService = new ConsulService();
|
|
|
+ //List<String> list = consulService.getCriticalServices();
|
|
|
+ //System.out.println(list);
|
|
|
+ String service = "FileGrpcService_172_16_45_66_8104";
|
|
|
+ service = "FileService-WebApi_172_16_45_66_8004";
|
|
|
+ consulService.deregister(service);
|
|
|
+ }
|
|
|
}
|