Search in sources :

Example 1 with BucketRegionExecutor

use of io.datarouter.aws.s3.config.DatarouterAwsS3Executors.BucketRegionExecutor in project datarouter by hotpads.

the class S3WebInspector method buildBucketTable.

private ContainerTag<?> buildBucketTable(String contextPath, ClientId clientId) {
    DatarouterS3Client client = s3ClientManager.getClient(clientId);
    List<S3BucketDto> buckets = client.scanBuckets().parallel(new ParallelScannerContext(bucketRegionExecutor, bucketRegionExecutor.getMaximumPoolSize(), true)).map(bucket -> {
        // RPC
        Region region = client.getBucketRegion(bucket.name());
        return new S3BucketDto(clientId.getName(), bucket.name(), region, bucket.creationDate());
    }).sort(Comparator.comparing(bucket -> bucket.bucketName.toLowerCase())).list();
    var table = new J2HtmlTable<S3BucketDto>().withClasses("sortable table table-sm table-striped my-4 border").withHtmlColumn("Name", bucket -> {
        String href = new URIBuilder().setPath(contextPath + paths.datarouter.clients.awsS3.listObjects.toSlashedString()).addParameter(S3BucketHandler.P_client, bucket.clientName).addParameter(S3BucketHandler.P_bucket, bucket.bucketName).addParameter(S3BucketHandler.P_delimiter, "/").toString();
        return td(a(bucket.bucketName).withHref(href));
    }).withColumn("Region", bucket -> bucket.region).withColumn("Created", bucket -> bucket.creationDate).build(buckets);
    return div(h4("Buckets - " + buckets.size()), table).withClass("container-fluid my-4").withStyle("padding-left: 0px");
}
Also used : Scanner(io.datarouter.scanner.Scanner) DatarouterWebRequestParamsFactory(io.datarouter.web.browse.dto.DatarouterWebRequestParamsFactory) DatarouterS3Client(io.datarouter.aws.s3.DatarouterS3Client) S3BucketHandler(io.datarouter.aws.s3.web.S3BucketHandler) ParallelScannerContext(io.datarouter.scanner.ParallelScannerContext) ClientOptions(io.datarouter.storage.client.ClientOptions) TagCreator.h4(j2html.TagCreator.h4) Inject(javax.inject.Inject) HttpServletRequest(javax.servlet.http.HttpServletRequest) MessageMav(io.datarouter.web.handler.mav.imp.MessageMav) DatarouterWebRequireJsV2(io.datarouter.web.requirejs.DatarouterWebRequireJsV2) Map(java.util.Map) S3Node(io.datarouter.aws.s3.node.S3Node) ClientId(io.datarouter.storage.client.ClientId) DatarouterNodes(io.datarouter.storage.node.DatarouterNodes) Params(io.datarouter.web.handler.params.Params) Region(software.amazon.awssdk.regions.Region) J2HtmlTable(io.datarouter.web.html.j2html.J2HtmlTable) BucketRegionExecutor(io.datarouter.aws.s3.config.DatarouterAwsS3Executors.BucketRegionExecutor) NodeTool(io.datarouter.storage.node.NodeTool) DatarouterClientWebInspector(io.datarouter.web.browse.DatarouterClientWebInspector) URIBuilder(org.apache.http.client.utils.URIBuilder) DatarouterAwsS3Paths(io.datarouter.aws.s3.config.DatarouterAwsS3Paths) Mav(io.datarouter.web.handler.mav.Mav) Instant(java.time.Instant) TagCreator.a(j2html.TagCreator.a) ContainerTag(j2html.tags.ContainerTag) S3ClientType(io.datarouter.aws.s3.S3ClientType) List(java.util.List) TagCreator.td(j2html.TagCreator.td) Bootstrap4PageFactory(io.datarouter.web.html.j2html.bootstrap4.Bootstrap4PageFactory) Comparator(java.util.Comparator) TagCreator.div(j2html.TagCreator.div) DatarouterS3Client(io.datarouter.aws.s3.DatarouterS3Client) ParallelScannerContext(io.datarouter.scanner.ParallelScannerContext) Region(software.amazon.awssdk.regions.Region) URIBuilder(org.apache.http.client.utils.URIBuilder)

Aggregations

DatarouterS3Client (io.datarouter.aws.s3.DatarouterS3Client)1 S3ClientType (io.datarouter.aws.s3.S3ClientType)1 BucketRegionExecutor (io.datarouter.aws.s3.config.DatarouterAwsS3Executors.BucketRegionExecutor)1 DatarouterAwsS3Paths (io.datarouter.aws.s3.config.DatarouterAwsS3Paths)1 S3Node (io.datarouter.aws.s3.node.S3Node)1 S3BucketHandler (io.datarouter.aws.s3.web.S3BucketHandler)1 ParallelScannerContext (io.datarouter.scanner.ParallelScannerContext)1 Scanner (io.datarouter.scanner.Scanner)1 ClientId (io.datarouter.storage.client.ClientId)1 ClientOptions (io.datarouter.storage.client.ClientOptions)1 DatarouterNodes (io.datarouter.storage.node.DatarouterNodes)1 NodeTool (io.datarouter.storage.node.NodeTool)1 DatarouterClientWebInspector (io.datarouter.web.browse.DatarouterClientWebInspector)1 DatarouterWebRequestParamsFactory (io.datarouter.web.browse.dto.DatarouterWebRequestParamsFactory)1 Mav (io.datarouter.web.handler.mav.Mav)1 MessageMav (io.datarouter.web.handler.mav.imp.MessageMav)1 Params (io.datarouter.web.handler.params.Params)1 J2HtmlTable (io.datarouter.web.html.j2html.J2HtmlTable)1 Bootstrap4PageFactory (io.datarouter.web.html.j2html.bootstrap4.Bootstrap4PageFactory)1 DatarouterWebRequireJsV2 (io.datarouter.web.requirejs.DatarouterWebRequireJsV2)1