Java 类com.amazonaws.services.logs.model.ResourceNotFoundException 实例源码

项目:log4j-aws-appenders    文件:SNSAppenderIntegrationTest.java   
/**
 *  Loops until an attribute is set, throwing after a timeout.
 */
private String retrieveQueueAttribute(String attributeName)
throws Exception
{

    for (int ii = 0 ; ii < 60 ; ii++)
    {
        try
        {
            GetQueueAttributesRequest attribsRequest = new GetQueueAttributesRequest()
                                                            .withQueueUrl(queueUrl)
                                                            .withAttributeNames(attributeName);
            GetQueueAttributesResult attribsResponse = localSQSclient.getQueueAttributes(attribsRequest);
            Map<String,String> attribs = attribsResponse.getAttributes();
            if (! StringUtil.isEmpty(attribs.get(attributeName)))
                return attribs.get(attributeName);
        }
        catch (ResourceNotFoundException ex)
        {
            // ignored; queue isn't ready
        }
        Thread.sleep(1000);
    }

    throw new IllegalStateException("unable to retrieve attribute: " + attributeName);
}
项目:lambda-monitoring    文件:CloudwatchMetricFilterPublisher.java   
@Override
public boolean removeMetricFilter(MetricFilter metricFilter) {
    log.info(String.format("Removing metric filter [%s] from log group [%s]",
            metricFilter.getMetricName(), metricFilter.getLogGroupName()));

    DeleteMetricFilterRequest request = new DeleteMetricFilterRequest()
            .withLogGroupName(metricFilter.getLogGroupName())
            .withFilterName(metricFilter.getMetricName());

    try {
        client.deleteMetricFilter(request);
        return true;
    } catch (ResourceNotFoundException e) {
        log.warn(String.format("Did not find metric filter [%s] in log group [%s]",
                metricFilter.getMetricName(), metricFilter.getLogGroupName()));
    }

    return false;
}