General

How do I use it?

Goodwill-access is synced to Maven Central. Simply add the dependency to your pom.xml:

    <dependency>
        <groupId>com.ning</groupId>
        <artifactId>metrics.goodwill-access</artifactId>
        <version>0.0.6</version>
    </dependency>

The library offers both bulk fetch and lookup methods. Here is a complete working example:

    private final GoodwillAccessor goodwillAccessor = new GoodwillAccessor(host, port);

    public Collection<String> getAllSchemataNames()
    {
        Collection<String> result = new ArrayList<String>();

        try {
            List<GoodwillSchema> goodwillSchemata = goodwillAccessor.getSchemata().get();
            for (GoodwillSchema goodwillSchema : goodwillSchemata) {
                result.add(goodwillSchema.getName());
            }
        }
        catch (InterruptedException e) {
            throw new RuntimeException("Was interrupted while getting the list of schemata", e);
        }
        catch (ExecutionException e) {
            throw new RuntimeException("Problem getting the list of schemata", e);
        }

        return result;
    }

    public GoodwillSchema getSchema(String type)
    {
        try {
            return goodwillAccessor.getSchema(type).get();
        }
        catch (InterruptedException e) {
            throw new RuntimeException(String.format("Was interrupted while getting schema: %s", type), e);
        }
        catch (ExecutionException e) {
            throw new RuntimeException(String.format("Problem getting schema: %s", type), e);
        }
    }

Note that Goodwill-access uses the Async HTTP client, so each method returns a Future on the requested object. This allows you fine tuning for performance demanding environments.