|
8 | 8 | import com.uid2.operator.monitoring.OperatorMetrics; |
9 | 9 | import com.uid2.operator.monitoring.StatsCollectorVerticle; |
10 | 10 | import com.uid2.operator.service.SecureLinkValidatorService; |
| 11 | +import com.uid2.operator.vertx.OperatorShutdownHandler; |
11 | 12 | import com.uid2.operator.store.CloudSyncOptOutStore; |
12 | 13 | import com.uid2.operator.store.OptOutCloudStorage; |
13 | | -import com.uid2.operator.vertx.OperatorDisableHandler; |
14 | 14 | import com.uid2.operator.vertx.UIDOperatorVerticle; |
15 | 15 | import com.uid2.shared.ApplicationVersion; |
16 | 16 | import com.uid2.shared.Utils; |
|
42 | 42 | import io.vertx.micrometer.backends.BackendRegistries; |
43 | 43 | import org.slf4j.Logger; |
44 | 44 | import org.slf4j.LoggerFactory; |
| 45 | +import software.amazon.awssdk.utils.Pair; |
45 | 46 |
|
46 | 47 | import javax.management.*; |
47 | 48 | import java.lang.management.ManagementFactory; |
@@ -69,11 +70,11 @@ public class Main { |
69 | 70 | private final RotatingClientSideKeypairStore clientSideKeypairProvider; |
70 | 71 | private final RotatingSaltProvider saltProvider; |
71 | 72 | private final CloudSyncOptOutStore optOutStore; |
| 73 | + private OperatorShutdownHandler shutdownHandler = null; |
72 | 74 | private final OperatorMetrics metrics; |
73 | 75 | private final boolean clientSideTokenGenerate; |
74 | 76 | private final boolean validateServiceLinks; |
75 | 77 | private IStatsCollectorQueue _statsCollectorQueue; |
76 | | - private OperatorDisableHandler disableHandler = null; |
77 | 78 | private RotatingServiceStore serviceProvider; |
78 | 79 | private RotatingServiceLinkStore serviceLinkProvider; |
79 | 80 |
|
@@ -101,10 +102,9 @@ public Main(Vertx vertx, JsonObject config) throws Exception { |
101 | 102 |
|
102 | 103 | DownloadCloudStorage fsStores; |
103 | 104 | if (coreAttestUrl != null) { |
104 | | - Duration disableWaitTime = Duration.ofHours(this.config.getInteger(Const.Config.FailureShutdownWaitHoursProp, 120)); |
105 | | - this.disableHandler = new OperatorDisableHandler(disableWaitTime, Clock.systemUTC()); |
| 105 | + this.shutdownHandler = new OperatorShutdownHandler(Duration.ofHours(12), Clock.systemUTC()); |
106 | 106 |
|
107 | | - var clients = createUidClients(this.vertx, coreAttestUrl, operatorKey, this.disableHandler::handleResponseStatus); |
| 107 | + var clients = createUidClients(this.vertx, coreAttestUrl, operatorKey, this.shutdownHandler::handleResponse); |
108 | 108 | UidCoreClient coreClient = clients.getKey(); |
109 | 109 | UidOptOutClient optOutClient = clients.getValue(); |
110 | 110 | fsStores = coreClient; |
@@ -252,8 +252,6 @@ private ICloudStorage wrapCloudStorageForOptOut(ICloudStorage cloudStorage) { |
252 | 252 | private void run() throws Exception { |
253 | 253 | Supplier<Verticle> operatorVerticleSupplier = () -> { |
254 | 254 | UIDOperatorVerticle verticle = new UIDOperatorVerticle(config, this.clientSideTokenGenerate, siteProvider, clientKeyProvider, clientSideKeypairProvider, getKeyManager(), saltProvider, optOutStore, Clock.systemUTC(), _statsCollectorQueue, new SecureLinkValidatorService(this.serviceLinkProvider, this.serviceProvider)); |
255 | | - if (this.disableHandler != null) |
256 | | - verticle.setDisableHandler(this.disableHandler); |
257 | 255 | return verticle; |
258 | 256 | }; |
259 | 257 |
|
@@ -453,15 +451,15 @@ public DistributionStatisticConfig configure(Meter.Id id, DistributionStatisticC |
453 | 451 | .register(globalRegistry); |
454 | 452 | } |
455 | 453 |
|
456 | | - private Map.Entry<UidCoreClient, UidOptOutClient> createUidClients(Vertx vertx, String attestationUrl, String clientApiToken, Handler<Integer> responseWatcher) throws Exception { |
| 454 | + private Map.Entry<UidCoreClient, UidOptOutClient> createUidClients(Vertx vertx, String attestationUrl, String clientApiToken, Handler<Pair<Integer, String>> responseWatcher) throws Exception { |
457 | 455 | AttestationTokenRetriever attestationTokenRetriever = getAttestationTokenRetriever(vertx, attestationUrl, clientApiToken, responseWatcher); |
458 | 456 | Boolean enforceHttps = this.config.getBoolean("enforce_https", true); |
459 | 457 | UidCoreClient coreClient = new UidCoreClient(clientApiToken, CloudUtils.defaultProxy, enforceHttps, attestationTokenRetriever); |
460 | 458 | UidOptOutClient optOutClient = new UidOptOutClient(clientApiToken, CloudUtils.defaultProxy, enforceHttps, attestationTokenRetriever); |
461 | 459 | return new AbstractMap.SimpleEntry<>(coreClient, optOutClient); |
462 | 460 | } |
463 | 461 |
|
464 | | - private AttestationTokenRetriever getAttestationTokenRetriever(Vertx vertx, String attestationUrl, String clientApiToken, Handler<Integer> responseWatcher) throws Exception { |
| 462 | + private AttestationTokenRetriever getAttestationTokenRetriever(Vertx vertx, String attestationUrl, String clientApiToken, Handler<Pair<Integer, String>> responseWatcher) throws Exception { |
465 | 463 | String enclavePlatform = this.config.getString("enclave_platform"); |
466 | 464 | if (Strings.isNullOrEmpty(enclavePlatform)) { |
467 | 465 | return new AttestationTokenRetriever(vertx, attestationUrl, clientApiToken, this.appVersion, new NoAttestationProvider(), responseWatcher, CloudUtils.defaultProxy); |
|
0 commit comments