public boolean syncLabels(NewRelicCache cache)
    {
        boolean ret = true;

        if(apiClient == null)
            throw new IllegalArgumentException("null API client");

        // Get the label configuration using the REST API
        if(cache.isApmEnabled() || cache.isSyntheticsEnabled())
        {
            ret = false;

            logger.info("Getting the labels");
            Collection<Label> labels = apiClient.labels().list();
            for(Label label : labels)
            {
                cache.applications().addLabel(label);

                try
                {
                    // Also check to see if this label is associated with any monitors
                    Collection<Monitor> monitors = syntheticsApiClient.monitors().list(label);
                    for(Monitor monitor : monitors)
                       cache.monitors().labels(monitor.getId()).add(label);
                }
                catch(NullPointerException e)
                {
                    logger.severe("Unable to get monitor labels: "+e.getClass().getName()+": "+e.getMessage());
                }
            }

            cache.setUpdatedAt();

            ret = true;
        }

        return ret;
    }
public boolean syncLabels ( NewRelicCache cache ) { boolean ret = true ; if ( apiClient == null ) throw new IllegalArgumentException ( "null API client" ) ; if ( cache . isApmEnabled ( ) || cache . isSyntheticsEnabled ( ) ) { ret = false ; logger . info ( "Getting the labels" ) ; Collection < Label > labels = apiClient . labels ( ) . list ( ) ; for ( Label label : labels ) { cache . applications ( ) . addLabel ( label ) ; try { Collection < Monitor > monitors = syntheticsApiClient . monitors ( ) . list ( label ) ; for ( Monitor monitor : monitors ) cache . monitors ( ) . labels ( monitor . getId ( ) ) . add ( label ) ; } catch ( NullPointerException e ) { logger . severe ( "Unable to get monitor labels: " + e . getClass ( ) . getName ( ) + ": " + e . getMessage ( ) ) ; } } cache . setUpdatedAt ( ) ; ret = true ; } return ret ; }
Synchronise the label configuration with the cache.
@param cache The provider cache
@return <CODE>true</CODE> if the operation was successful