use of com.amazonaws.services.logs.model.ResourceNotFoundException in project cloudbreak by hortonworks.
the class CloudwatchRecordWorker method describeLogStreams.
@VisibleForTesting
DescribeLogStreamsResult describeLogStreams() {
DescribeLogStreamsRequest describeLogStreams = new DescribeLogStreamsRequest();
describeLogStreams.setLogGroupName(logGroup);
describeLogStreams.setLogStreamNamePrefix(logStream);
try {
DescribeLogStreamsResult describeLogStreamsResult = getAwsLogsClient().describeLogStreams(describeLogStreams);
if (!describeLogStreamsResult.getLogStreams().isEmpty()) {
return describeLogStreamsResult;
} else {
CreateLogStreamRequest createLogStreamRequest = new CreateLogStreamRequest();
createLogStreamRequest.setLogGroupName(logGroup);
createLogStreamRequest.setLogStreamName(logStream);
getAwsLogsClient().createLogStream(createLogStreamRequest);
return getAwsLogsClient().describeLogStreams(describeLogStreams);
}
} catch (ResourceNotFoundException re) {
LOGGER.error("Error during describing AWS CloudWatch log streams: log group '{}' not found", logGroup, re);
throw re;
}
}
use of com.amazonaws.services.logs.model.ResourceNotFoundException in project ranger by apache.
the class AmazonCloudWatchAuditDestination method pushLogEvents.
private String pushLogEvents(PutLogEventsRequest req, boolean retryingOnInvalidSeqToken, AWSLogs client) {
String sequenceToken;
try {
PutLogEventsResult re = client.putLogEvents(req);
sequenceToken = re.getNextSequenceToken();
} catch (ResourceNotFoundException ex) {
if (!retryingOnInvalidSeqToken) {
createLogStream();
return pushLogEvents(req, true, client);
}
throw ex;
} catch (InvalidSequenceTokenException ex) {
if (retryingOnInvalidSeqToken) {
LOG.error("Unexpected invalid sequence token. Possible race condition occurred");
throw ex;
}
// LogStream may exist before first push attempt, re-obtain the sequence token
if (LOG.isDebugEnabled()) {
LOG.debug("Invalid sequence token. Plugin possibly restarted. Updating the sequence token and retrying");
}
sequenceToken = ex.getExpectedSequenceToken();
req.setSequenceToken(sequenceToken);
return pushLogEvents(req, true, client);
}
return sequenceToken;
}
use of com.amazonaws.services.logs.model.ResourceNotFoundException in project aws-sdk-android by aws-amplify.
the class ResourceNotFoundExceptionUnmarshaller method unmarshall.
@Override
public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception {
ResourceNotFoundException e = (ResourceNotFoundException) super.unmarshall(error);
e.setErrorCode("ResourceNotFoundException");
return e;
}
Aggregations