@Override public String getRegisterNodeUrl() { return (this.registerNodeUrl != null) ? this.registerNodeUrl : delegate.getRegisterNodeUrl(); }
public static void invokeRegisterNode(KeycloakDeployment deployment, String host) throws HttpFailure, IOException { String registerNodeUrl = deployment.getRegisterNodeUrl(); invokeClientManagementRequest(deployment, host, registerNodeUrl); }
public void tryRegister(final KeycloakDeployment resolvedDeployment) { if (resolvedDeployment.isRegisterNodeAtStartup()) { final String registrationUri = resolvedDeployment.getRegisterNodeUrl(); if (needRefreshRegistration(registrationUri, resolvedDeployment)) { Runnable runnable = new Runnable() { @Override public void run() { // Need to check it again in case that executor triggered by other thread already finished computation in the meantime if (needRefreshRegistration(registrationUri, resolvedDeployment)) { sendRegistrationEvent(resolvedDeployment); } } }; executor.execute(runnable); } } }
protected void sendRegistrationEvent(KeycloakDeployment deployment) { // This method is invoked from single-thread executor, so no synchronization is needed // However, it could happen that the same deployment was submitted more than once to that executor // Hence we need to recheck that the registration is really needed final String registrationUri = deployment.getRegisterNodeUrl(); if (! needRefreshRegistration(registrationUri, deployment)) { return; } if (Thread.currentThread().isInterrupted()) { return; } log.debug("Sending registration event right now"); String host = HostUtils.getHostName(); try { ServerRequest.invokeRegisterNode(deployment, host); NodeRegistrationContext regContext = new NodeRegistrationContext(Time.currentTime(), deployment); nodeRegistrations.put(deployment.getRegisterNodeUrl(), regContext); log.debugf("Node '%s' successfully registered in Keycloak", host); } catch (ServerRequest.HttpFailure failure) { log.error("failed to register node to keycloak"); log.error("status from server: " + failure.getStatus()); if (failure.getError() != null) { log.error(" " + failure.getError()); } } catch (IOException e) { log.error("failed to register node to keycloak", e); } }