8000 fix(states): add REFRESHING state to avoid deregistration skew and cancellations by andrewazores · Pull Request #100 · cryostatio/cryostat-agent · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(states): add REFRESHING state to avoid deregistration skew and cancellations #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/io/cryostat/agen 8000 t/Agent.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public static void main(String[] args) {
switch (evt.state) {
case REGISTERED:
case UNREGISTERED:
case REFRESHING:
case REFRESHED:
case PUBLISHED:
log.info("Registration state: {}", evt.state);
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/io/cryostat/agent/Registration.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ void start() {
}
});
break;
case REFRESHING:
break;
case REFRESHED:
break;
case PUBLISHED:
Expand All @@ -203,6 +205,7 @@ void addRegistrationListener(Consumer<RegistrationEvent> listener) {
}

void tryRegister() {
notify(RegistrationEvent.State.REFRESHING);
try {
URI credentialedCallback =
new URIBuilder(callback)
Expand All @@ -219,11 +222,12 @@ void tryRegister() {
this.pluginInfo.isInitialized();
this.pluginInfo.copyFrom(plugin);
log.info("Registered as {}", this.pluginInfo.getId());
notify(
previouslyRegistered
? RegistrationEvent.State.REFRESHED
: RegistrationEvent.State.REGISTERED);
tryUpdate();
if (previouslyRegistered) {
notify(RegistrationEvent.State.REFRESHED);
} else {
notify(RegistrationEvent.State.REGISTERED);
tryUpdate();
}
} else if (t != null) {
this.pluginInfo.clear();
throw new RegistrationException(t);
Expand Down Expand Up @@ -347,6 +351,7 @@ enum State {
REGISTERED,
PUBLISHED,
UNREGISTERED,
REFRESHING,
REFRESHED,
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/cryostat/agent/WebServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public void handle(HttpExchange exchange) throws IOException {
switch (mtd) {
case "POST":
synchronized (WebServer.this.credentials) {
executor.execute(registration.get()::deregister);
executor.execute(registration.get()::tryRegister);
exchange.sendResponseHeaders(HttpStatus.SC_NO_CONTENT, -1);
exchange.close();
}
Expand Down
0