Skip to content
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

Introduce JavaClient for GWC Rest endpoints #205

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ahennr
Copy link
Member

@ahennr ahennr commented Dec 17, 2020

Title says it all. Herewith, for example, re-seed of a certain layer can be triggered easily (only in a given bound) in given services that modify the geometry of the cached layer.

Usage:

String username = "admin"; // GeoServer admin user
String password = "<<YOUR_GEOSERVER_PASSWORD>>";
String baseUrl = "http://geoserver.endpoint/geoserver/gwc/rest";

try (
    ShogunGwcManager manager = (ShogunGwcManager) ShogunClientBuilder.builder()
        .password(password)
        .username(username)
        .shogunServiceBaseUrl(baseUrl)
        .managerType(ShogunManagerType.GWC)
        .build()
) {
    Envelope bounds = new Envelope(600000,6000000.0,601000,6001000.0);
    String qualifiedLayerName = "SHOGUN:GEWAESSER";

    GwcSeedRequest gwcSeedRequest = new GwcSeedRequest(
        qualifiedLayerName,
        bounds,
        25832,
        "GRIDSETNAME",
        9,
        9,
        "image/png",
        SeedingType.reseed,
        4
    );

    boolean success = manager.startSeeding(gwcSeedRequest);
    if (success) {
        long t = System.currentTimeMillis();
        long end = t + 60000; // wait 1 minute
        while(System.currentTimeMillis() < end) {
            // check if caching is still running

            System.out.println("\nCurrently running tasks:");
            List<SeedingTaskStatus> currentTasks = manager.getRunningTasksForLayer(qualifiedLayerName);
            currentTasks.forEach(System.out::println);

            // wait 5 sec and check again
            Thread.sleep( 5000 );
        }
    }
}  catch (Exception e) {
    System.err.println(e);
}

@dnlkoch dnlkoch changed the title Draft: Introduce JavaClient for GWC Rest endpoints Introduce JavaClient for GWC Rest endpoints Jul 27, 2021
@dnlkoch dnlkoch marked this pull request as draft July 27, 2021 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant