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

项目:cas-5.1.0    文件:CloudWatchAppender.java   
private String createLogGroupAndLogStreamIfNeeded() {
    LOGGER.debug("Attempting to locate the log group [{}]", logGroupName);
    final DescribeLogGroupsResult describeLogGroupsResult =
            awsLogsClient.describeLogGroups(new DescribeLogGroupsRequest().withLogGroupNamePrefix(logGroupName));
    boolean createLogGroup = true;
    if (describeLogGroupsResult != null && describeLogGroupsResult.getLogGroups() != null && !describeLogGroupsResult.getLogGroups().isEmpty()) {
        createLogGroup = !describeLogGroupsResult.getLogGroups().stream().anyMatch(g -> g.getLogGroupName().equals(logGroupName));
    }
    if (createLogGroup) {
        LOGGER.debug("Creating log group [{}]", logGroupName);
        final CreateLogGroupRequest createLogGroupRequest = new CreateLogGroupRequest(logGroupName);
        awsLogsClient.createLogGroup(createLogGroupRequest);
    }
    String logSequenceToken = null;
    boolean createLogStream = true;
    LOGGER.debug("Attempting to locate the log stream [{}] for group [{}]", logStreamName, logGroupName);
    final DescribeLogStreamsRequest describeLogStreamsRequest = new DescribeLogStreamsRequest(logGroupName).withLogStreamNamePrefix(logStreamName);
    final DescribeLogStreamsResult describeLogStreamsResult = awsLogsClient.describeLogStreams(describeLogStreamsRequest);
    if (describeLogStreamsResult != null && describeLogStreamsResult.getLogStreams() != null && !describeLogStreamsResult.getLogStreams().isEmpty()) {
        for (final LogStream ls : describeLogStreamsResult.getLogStreams()) {
            if (logStreamName.equals(ls.getLogStreamName())) {
                createLogStream = false;
                logSequenceToken = ls.getUploadSequenceToken();
                LOGGER.debug("Found log stream [{}] with sequence token [{}]", logStreamName, logSequenceToken);
                break;
            }
        }
    }

    if (createLogStream) {
        LOGGER.debug("Creating log stream [{}] for group [{}]", logStreamName, logGroupName);
        final CreateLogStreamRequest createLogStreamRequest = new CreateLogStreamRequest(logGroupName, logStreamName);
        awsLogsClient.createLogStream(createLogStreamRequest);
    }
    return logSequenceToken;
}
项目:cloudwatch-logback-appender    文件:CloudWatchAppender.java   
private void verifyLogGroupExists() {
    DescribeLogGroupsRequest request = new DescribeLogGroupsRequest().withLogGroupNamePrefix(logGroup);
    DescribeLogGroupsResult result = awsLogsClient.describeLogGroups(request);
    for (LogGroup group : result.getLogGroups()) {
        if (logGroup.equals(group.getLogGroupName())) {
            return;
        }
    }
    if (createLogDests) {
        callLogClientMethod("createLogGroup", new CreateLogGroupRequest(logGroup));
    } else {
        logWarn("Log-group '" + logGroup + "' doesn't exist and not created", null);
    }
}
项目:minijax    文件:CloudWatchAppender.java   
private void createLogGroup() {
    try {
        awsLogs.createLogGroup(new CreateLogGroupRequest().withLogGroupName(logGroupName));
    } catch (final ResourceAlreadyExistsException e) {
        addStatus(new InfoStatus(e.getMessage(), this));
    }
}