Skip to content
This repository was archived by the owner on Feb 5, 2024. It is now read-only.

Commit 8a2ca1c

Browse files
committed
Add client functionality to force keygroupconfig update
1 parent 8ab4c84 commit 8a2ca1c

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

src/main/java/client/KeygroupRequest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ public KeygroupRequest(String address, int port) {
2222
super(address, port, PATH);
2323
}
2424

25+
public KeygroupConfig updateLocalKeygroupConfig(KeygroupID keygroupID) throws UnirestException {
26+
String target = target(keygroupID.getApp(), keygroupID.getTenant(), keygroupID.getGroup(), "update");
27+
logger.info("Running get request targeting " + target);
28+
29+
HttpResponse<String> response =
30+
Unirest.get(target).asString();
31+
32+
return handleObjectResponse(response, KeygroupConfig.class, logger);
33+
}
34+
2535
public boolean createKeygroup(KeygroupConfig keygroupConfig) throws UnirestException {
2636
String target = target();
2737
logger.info("Running post request targeting " + target);

src/main/java/de/hasenburg/fbase/rest/jersey/KeygroupsResource.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package de.hasenburg.fbase.rest.jersey;
22

3+
import java.util.concurrent.ExecutionException;
4+
import java.util.concurrent.TimeUnit;
5+
import java.util.concurrent.TimeoutException;
6+
37
import javax.inject.Inject;
48
import javax.ws.rs.Consumes;
59
import javax.ws.rs.DELETE;
@@ -63,6 +67,33 @@ public class KeygroupsResource {
6367
@Inject
6468
FBase fBase;
6569

70+
@GET
71+
@Path("{app}/{tenant}/{group}/update")
72+
@Produces(MediaType.APPLICATION_JSON)
73+
public Response updateLocal(@PathParam("app") String app, @PathParam("tenant") String tenant,
74+
@PathParam("group") String group) {
75+
76+
KeygroupConfig config = null;
77+
try {
78+
config = fBase.namingServiceSender
79+
.sendKeygroupConfigRead(new KeygroupID(app, tenant, group));
80+
81+
if (config == null) {
82+
return Response.status(404, "Keygroup does not exist").build();
83+
}
84+
85+
fBase.taskmanager.runUpdateKeygroupConfigTask(config, false).get(3, TimeUnit.SECONDS);
86+
} catch (FBaseCommunicationException | FBaseNamingServiceException | InterruptedException
87+
| ExecutionException | TimeoutException e) {
88+
logger.warn(e);
89+
return Response.status(500, e.getMessage()).build();
90+
}
91+
92+
Message m = new Message();
93+
m.setContent(JSONable.toJSON(config));
94+
return Response.ok(JSONable.toJSON(m)).build();
95+
}
96+
6697
@GET
6798
@Path("{app}/{tenant}/{group}")
6899
@Produces(MediaType.APPLICATION_JSON)

0 commit comments

Comments
 (0)