From e88313ca68276867f87938a9f4dc6536673302c8 Mon Sep 17 00:00:00 2001 From: Nathan Schile <96078352+nschile@users.noreply.github.com> Date: Fri, 1 Nov 2024 14:19:00 -0500 Subject: [PATCH 1/8] DEV-29238 Close idle connections after 4 seconds (#91) Allow connections to be idle for up to 4 seconds before not reusing. This strategy is needed because we are seeing connections being closed by the server after 4 seconds, then when we attempt to use, the call fails. --- .../b2/client/webApiHttpClient/HttpClientFactoryImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/httpclient/src/main/java/com/backblaze/b2/client/webApiHttpClient/HttpClientFactoryImpl.java b/httpclient/src/main/java/com/backblaze/b2/client/webApiHttpClient/HttpClientFactoryImpl.java index 141305121..adae523c0 100644 --- a/httpclient/src/main/java/com/backblaze/b2/client/webApiHttpClient/HttpClientFactoryImpl.java +++ b/httpclient/src/main/java/com/backblaze/b2/client/webApiHttpClient/HttpClientFactoryImpl.java @@ -76,6 +76,10 @@ public CloseableHttpClient create() throws B2Exception { .setUserAgent(APACHE_HTTP_CLIENT_USER_AGENT) .setConnectionManager(connectionManager) .setDefaultRequestConfig(requestConfig) + // Allow connections to be idle for up to 4 seconds before not reusing. This strategy is needed + // because we are seeing connections being closed by the server after 4 seconds, then when we attempt + // to use, the call fails. + .setKeepAliveStrategy((httpResponse, httpContext) -> 4000) .build(); } From 38c2419df64f8488e90f002fa785113b1058f15d Mon Sep 17 00:00:00 2001 From: Nick Behrens Date: Mon, 11 Nov 2024 11:28:29 -0600 Subject: [PATCH 2/8] update version for private fork --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index a2beedf6d..53bdc0130 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Copyright 2022, Backblaze Inc. All Rights Reserved. # License https://www.backblaze.com/using_b2_code.html -version=6.4.0-SNAPSHOT +version=6.4.0-PRIVATE group=com.backblaze.b2 From 2bcd7b582ce4e6b505d8c5bd9815a75fe552da4e Mon Sep 17 00:00:00 2001 From: Kyle Wood Date: Tue, 19 Nov 2024 13:29:42 -0600 Subject: [PATCH 3/8] Configure to deploy to Artifactory and cleanup GitHub Actions configs --- .github/workflows/.ci_cd.yml | 37 +++++++++-------------- .github/workflows/deploy.yml | 25 ++++++--------- buildSrc/src/main/kotlin/b2sdk.gradle.kts | 14 ++++++--- 3 files changed, 34 insertions(+), 42 deletions(-) diff --git a/.github/workflows/.ci_cd.yml b/.github/workflows/.ci_cd.yml index 949b22042..20c1bfe98 100644 --- a/.github/workflows/.ci_cd.yml +++ b/.github/workflows/.ci_cd.yml @@ -14,8 +14,6 @@ env: OUTPUT_DIR: $GITHUB_WORKSPACE/build/outputs OUTPUT_ZIP: b2-sdk-build-${GITHUB_RUN_NUMBER}.zip BUILD_NUMBER: ${{ github.run_number }} - # This token was generated under rhryckewicz account - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # These are stored in Bitwarden B2_ACCOUNT_ID: ${{ secrets.B2_ACCOUNT_ID }} B2_UPLOAD_BUCKET: ${{ secrets.B2_UPLOAD_BUCKET }} @@ -25,26 +23,26 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Use jdk8 - uses: actions/setup-java@v2 + - uses: actions/setup-java@v4 with: - distribution: 'adopt' - java-version: '8' - cache: 'gradle' + distribution: 'temurin' + java-version: '11' + + - uses: gradle/actions/wrapper-validation@v4 + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 - - uses: gradle/wrapper-validation-action@v1 - name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_DEFAULT_VERSION }} - name: Install dependencies run: | - mkdir -p ~/.gradle && echo "org.gradle.daemon=false" >> ~/.gradle/gradle.properties # upgrade pip and setuptools so that b2 CLI can be properly installed python -m pip install --upgrade pip setuptools python -m pip install b2 @@ -66,18 +64,13 @@ jobs: - name: Deploy to internal Maven repo if: github.ref == 'refs/heads/master' && github.repository == 'Backblaze/b2-sdk-java-private' - run: $GITHUB_WORKSPACE/gradlew publishMavenPublicationToBzGithubPackagesRepository + run: $GITHUB_WORKSPACE/gradlew publishMavenPublicationToBzArtifactoryRepository publishMavenPublicationToBzGithubPackagesRepository env: + ORG_GRADLE_PROJECT_bzArtifactoryUsername: ${{ secrets.ARTIFACTORY_USERNAME }} + ORG_GRADLE_PROJECT_bzArtifactoryPassword: ${{ secrets.ARTIFACTORY_TOKEN }} ORG_GRADLE_PROJECT_bzGithubPackagesUsername: ${{ secrets.PACKAGES_USERNAME }} ORG_GRADLE_PROJECT_bzGithubPackagesPassword: ${{ secrets.PACKAGES_TOKEN }} - - name: Cleanup Gradle Cache - # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. - # Restoring these files from a GitHub Actions cache might cause problems for future builds. - run: | - rm -f ~/.gradle/caches/modules-2/modules-2.lock - rm -fr ~/.gradle/caches/*/plugin-resolution/ - - name: Upload to b2 if: github.ref == 'refs/heads/master' # upload to b2 (if credentials are provided, as they will be for backblaze's builds, but not pull requests) @@ -86,16 +79,16 @@ jobs: - name: Check GitHub Pages status if: github.ref == 'refs/heads/master' - uses: crazy-max/ghaction-github-status@v2 + uses: crazy-max/ghaction-github-status@v4 with: pages_threshold: major_outage - - name: Deploy + - name: Deploy Javadoc # note that i'm only uploading the javadocs for b2-sdk-core. # that's because i'm lame and building separate javadocs for # each jar and only uploading one set of javadocs. if: github.ref == 'refs/heads/master' && success() - uses: crazy-max/ghaction-github-pages@v2 + uses: crazy-max/ghaction-github-pages@v3 with: target_branch: gh-pages build_dir: core/build/docs/javadoc diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 947e4d73e..49d6dfcea 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,18 +12,19 @@ jobs: if: github.repository == 'Backblaze/b2-sdk-java' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Use jdk8 - uses: actions/setup-java@v2 + - uses: actions/setup-java@v4 with: - distribution: 'adopt' - java-version: '8' - cache: 'gradle' + distribution: 'temurin' + java-version: '11' + + - uses: gradle/actions/wrapper-validation@v4 + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 - - uses: gradle/wrapper-validation-action@v1 - name: Deploy to Maven Central run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository createBundle --no-daemon --stacktrace env: @@ -33,21 +34,15 @@ jobs: ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }} ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} - - name: Cleanup Gradle Cache - # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. - # Restoring these files from a GitHub Actions cache might cause problems for future builds. - run: | - rm -f ~/.gradle/caches/modules-2/modules-2.lock - rm -fr ~/.gradle/caches/*/plugin-resolution/ - - name: Get tag name id: get_tag shell: bash run: | tag_name="$(echo $GITHUB_REF | cut -d / -f 3)" echo ::set-output name=tag::$tag_name + - name: Create GitHub Release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: diff --git a/buildSrc/src/main/kotlin/b2sdk.gradle.kts b/buildSrc/src/main/kotlin/b2sdk.gradle.kts index a53ab6284..0fec9be88 100644 --- a/buildSrc/src/main/kotlin/b2sdk.gradle.kts +++ b/buildSrc/src/main/kotlin/b2sdk.gradle.kts @@ -90,10 +90,10 @@ publishing { groupId = project.group.toString() artifactId = project.name - if (System.getenv("RELEASE_BUILD") != null) { - version = project.version.toString() + version = if (System.getenv("RELEASE_BUILD") != null) { + project.version.toString() } else { - version = when (val buildNum = System.getenv("BUILD_NUMBER")) { + when (val buildNum = System.getenv("BUILD_NUMBER")) { null -> project.version.toString() else -> "${project.version}+$buildNum" } @@ -134,6 +134,10 @@ publishing { } repositories { + maven("https://artifactory.backblaze.com/artifactory/maven-private/") { + name = "bzArtifactory" + credentials(PasswordCredentials::class) + } maven("https://maven.pkg.github.com/Backblaze/repo") { name = "bzGithubPackages" credentials(PasswordCredentials::class) @@ -144,8 +148,8 @@ publishing { val sonatypeUsername = findProperty("sonatypeUsername") val sonatypePassword = findProperty("sonatypePassword") -val gpgSigningKey = System.getenv("GPG_SIGNING_KEY") -val gpgPassphrase = System.getenv("GPG_PASSPHRASE") +val gpgSigningKey: String? = System.getenv("GPG_SIGNING_KEY") +val gpgPassphrase: String? = System.getenv("GPG_PASSPHRASE") if (sonatypeUsername != null && sonatypePassword != null) { signing { From c79b83b36257e3460fd5463e083f6ce24c5a6ad8 Mon Sep 17 00:00:00 2001 From: Venkatesh Sridharan <167803032+vsridharan-bz@users.noreply.github.com> Date: Wed, 18 Dec 2024 14:12:33 -0500 Subject: [PATCH 4/8] Configure github actions to allow releasing from a feature branch --- .github/workflows/{.ci_cd.yml => ci_cd.yml} | 31 +++++++++++---------- 1 file changed, 16 insertions(+), 15 deletions(-) rename .github/workflows/{.ci_cd.yml => ci_cd.yml} (73%) diff --git a/.github/workflows/.ci_cd.yml b/.github/workflows/ci_cd.yml similarity index 73% rename from .github/workflows/.ci_cd.yml rename to .github/workflows/ci_cd.yml index 20c1bfe98..3dd4e5c15 100644 --- a/.github/workflows/.ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -8,9 +8,10 @@ on: pull_request: branches: - master + - api-v2 + - 7.x # TODO: This is temporary and will be removed once we merge this branch to master branch env: - PYTHON_DEFAULT_VERSION: 3.8 OUTPUT_DIR: $GITHUB_WORKSPACE/build/outputs OUTPUT_ZIP: b2-sdk-build-${GITHUB_RUN_NUMBER}.zip BUILD_NUMBER: ${{ github.run_number }} @@ -21,7 +22,7 @@ env: jobs: build: - runs-on: ubuntu-latest + runs-on: self-hosted steps: - uses: actions/checkout@v4 with: @@ -36,16 +37,14 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 - - name: Set up Python ${{ env.PYTHON_DEFAULT_VERSION }} - uses: actions/setup-python@v5 - with: - python-version: ${{ env.PYTHON_DEFAULT_VERSION }} - - - name: Install dependencies + - name: Set up Python run: | + python3.8 -m venv env + source env/bin/activate + echo "VIRTUAL ENV:" $VIRTUAL_ENV # upgrade pip and setuptools so that b2 CLI can be properly installed - python -m pip install --upgrade pip setuptools - python -m pip install b2 + pip install --upgrade pip setuptools + pip install b2 pysqlite3 - name: Build the distribution run: | @@ -63,7 +62,7 @@ jobs: zip -r $GITHUB_WORKSPACE/build/${{ env.OUTPUT_ZIP }} * - name: Deploy to internal Maven repo - if: github.ref == 'refs/heads/master' && github.repository == 'Backblaze/b2-sdk-java-private' + if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/api-v2' || github.ref == 'refs/heads/7.x') && github.repository == 'Backblaze/b2-sdk-java-private' run: $GITHUB_WORKSPACE/gradlew publishMavenPublicationToBzArtifactoryRepository publishMavenPublicationToBzGithubPackagesRepository env: ORG_GRADLE_PROJECT_bzArtifactoryUsername: ${{ secrets.ARTIFACTORY_USERNAME }} @@ -72,10 +71,12 @@ jobs: ORG_GRADLE_PROJECT_bzGithubPackagesPassword: ${{ secrets.PACKAGES_TOKEN }} - name: Upload to b2 - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/api-v2' || github.ref == 'refs/heads/7.x' # upload to b2 (if credentials are provided, as they will be for backblaze's builds, but not pull requests) - # This should be using python 3.4 - run: $GITHUB_WORKSPACE/maybe_upload_build_results ${{ env.OUTPUT_ZIP }} + # This should be using python 3.8 + run: | + source $GITHUB_WORKSPACE/env/bin/activate + $GITHUB_WORKSPACE/maybe_upload_build_results ${{ env.OUTPUT_ZIP }} - name: Check GitHub Pages status if: github.ref == 'refs/heads/master' @@ -87,7 +88,7 @@ jobs: # note that i'm only uploading the javadocs for b2-sdk-core. # that's because i'm lame and building separate javadocs for # each jar and only uploading one set of javadocs. - if: github.ref == 'refs/heads/master' && success() + if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/api-v2' || github.ref == 'refs/heads/7.x') && success() uses: crazy-max/ghaction-github-pages@v3 with: target_branch: gh-pages From 3e7cb83f28ce1d4deb0066601e20f99382a980fc Mon Sep 17 00:00:00 2001 From: Nick Behrens <165070315+nbehrens-bz@users.noreply.github.com> Date: Mon, 24 Mar 2025 09:18:54 -0600 Subject: [PATCH 5/8] Add new BAL capabilities to the private SDK (#106) --- .../com/backblaze/b2/client/structures/B2Capabilities.java | 3 +++ .../backblaze/b2/client/structures/B2ApplicationKeyTest.java | 2 ++ 2 files changed, 5 insertions(+) diff --git a/core/src/main/java/com/backblaze/b2/client/structures/B2Capabilities.java b/core/src/main/java/com/backblaze/b2/client/structures/B2Capabilities.java index ce3575c78..c25a9507c 100644 --- a/core/src/main/java/com/backblaze/b2/client/structures/B2Capabilities.java +++ b/core/src/main/java/com/backblaze/b2/client/structures/B2Capabilities.java @@ -37,6 +37,9 @@ public interface B2Capabilities { String READ_BUCKET_ENCRYPTION = "readBucketEncryption"; String WRITE_BUCKET_ENCRYPTION = "writeBucketEncryption"; + + String READ_BUCKET_LOGGING = "readBucketLogging"; + String WRITE_BUCKET_LOGGING = "writeBucketLogging"; String BYPASS_GOVERNANCE = "bypassGovernance"; String READ_BUCKET_RETENTIONS = "readBucketRetentions"; diff --git a/core/src/test/java/com/backblaze/b2/client/structures/B2ApplicationKeyTest.java b/core/src/test/java/com/backblaze/b2/client/structures/B2ApplicationKeyTest.java index a074b81a9..6b15fc7dd 100644 --- a/core/src/test/java/com/backblaze/b2/client/structures/B2ApplicationKeyTest.java +++ b/core/src/test/java/com/backblaze/b2/client/structures/B2ApplicationKeyTest.java @@ -28,6 +28,8 @@ public void testEquals() { capabilities.add(B2Capabilities.WRITE_BUCKET_RETENTIONS); capabilities.add(B2Capabilities.READ_FILE_RETENTIONS); capabilities.add(B2Capabilities.WRITE_FILE_RETENTIONS); + capabilities.add(B2Capabilities.READ_BUCKET_LOGGING); + capabilities.add(B2Capabilities.WRITE_BUCKET_LOGGING); capabilities.add(B2Capabilities.READ_FILE_LEGAL_HOLDS); capabilities.add(B2Capabilities.WRITE_FILE_LEGAL_HOLDS); capabilities.add(B2Capabilities.READ_BUCKET_REPLICATIONS); From f5c1b539bfe434fa0dbc6242cb1b21a1334f743e Mon Sep 17 00:00:00 2001 From: Nick Behrens Date: Tue, 6 May 2025 10:01:50 -0600 Subject: [PATCH 6/8] Changelog updates for 6.4.0 --- CHANGELOG.md | 4 ++++ gradle.properties | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f8e215be..2bf3c0049 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog ## [Unreleased] - TBD +### Added +* Close idle connections after 4 seconds. +* Add `readBucketLogging` and `writeBucketLogging` capabilities. + ## [6.3.0] - 2024-11-08 ### Added * Fixed `B2StorageClient.deleteAllFilesInBucket` so it uses `fileVersions` instead of `fileNames`. diff --git a/gradle.properties b/gradle.properties index 53bdc0130..a2beedf6d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Copyright 2022, Backblaze Inc. All Rights Reserved. # License https://www.backblaze.com/using_b2_code.html -version=6.4.0-PRIVATE +version=6.4.0-SNAPSHOT group=com.backblaze.b2 From 2c5f5b49b8f66c321e5e82bd8a98b62b3221d413 Mon Sep 17 00:00:00 2001 From: Nick Behrens Date: Tue, 6 May 2025 11:38:09 -0600 Subject: [PATCH 7/8] Add ci_cd to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b63368639..93b6cb07b 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ hs_err_pid* .DS_Store !gradle/wrapper/gradle-wrapper.jar +.github/workflows/ci_cd.yml From 19169e89e90f14b4e142ed1bee2416389a81d824 Mon Sep 17 00:00:00 2001 From: Nick Behrens Date: Tue, 6 May 2025 15:56:29 -0600 Subject: [PATCH 8/8] Remove ci cd file from public repo --- .github/workflows/ci_cd.yml | 97 ------------------------------------- 1 file changed, 97 deletions(-) delete mode 100644 .github/workflows/ci_cd.yml diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml deleted file mode 100644 index 3dd4e5c15..000000000 --- a/.github/workflows/ci_cd.yml +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright 2022, Backblaze Inc. All Rights Reserved. -# License https://www.backblaze.com/using_b2_code.html - -name: b2-sdk-java ci/cd - -on: - push: - pull_request: - branches: - - master - - api-v2 - - 7.x # TODO: This is temporary and will be removed once we merge this branch to master branch - -env: - OUTPUT_DIR: $GITHUB_WORKSPACE/build/outputs - OUTPUT_ZIP: b2-sdk-build-${GITHUB_RUN_NUMBER}.zip - BUILD_NUMBER: ${{ github.run_number }} - # These are stored in Bitwarden - B2_ACCOUNT_ID: ${{ secrets.B2_ACCOUNT_ID }} - B2_UPLOAD_BUCKET: ${{ secrets.B2_UPLOAD_BUCKET }} - B2_APPLICATION_KEY: ${{ secrets.B2_APPLICATION_KEY }} - -jobs: - build: - runs-on: self-hosted - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: '11' - - - uses: gradle/actions/wrapper-validation@v4 - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v4 - - - name: Set up Python - run: | - python3.8 -m venv env - source env/bin/activate - echo "VIRTUAL ENV:" $VIRTUAL_ENV - # upgrade pip and setuptools so that b2 CLI can be properly installed - pip install --upgrade pip setuptools - pip install b2 pysqlite3 - - - name: Build the distribution - run: | - $GITHUB_WORKSPACE/gradlew build - # - # Prepare the outputs - # - - # make the directory - mkdir -p ${{ env.OUTPUT_DIR }} - cp -v */build/libs/b2-sdk-*.{jar,pom,module} ${{ env.OUTPUT_DIR }} - - # zip up the outputs - cd ${{ env.OUTPUT_DIR }} - zip -r $GITHUB_WORKSPACE/build/${{ env.OUTPUT_ZIP }} * - - - name: Deploy to internal Maven repo - if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/api-v2' || github.ref == 'refs/heads/7.x') && github.repository == 'Backblaze/b2-sdk-java-private' - run: $GITHUB_WORKSPACE/gradlew publishMavenPublicationToBzArtifactoryRepository publishMavenPublicationToBzGithubPackagesRepository - env: - ORG_GRADLE_PROJECT_bzArtifactoryUsername: ${{ secrets.ARTIFACTORY_USERNAME }} - ORG_GRADLE_PROJECT_bzArtifactoryPassword: ${{ secrets.ARTIFACTORY_TOKEN }} - ORG_GRADLE_PROJECT_bzGithubPackagesUsername: ${{ secrets.PACKAGES_USERNAME }} - ORG_GRADLE_PROJECT_bzGithubPackagesPassword: ${{ secrets.PACKAGES_TOKEN }} - - - name: Upload to b2 - if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/api-v2' || github.ref == 'refs/heads/7.x' - # upload to b2 (if credentials are provided, as they will be for backblaze's builds, but not pull requests) - # This should be using python 3.8 - run: | - source $GITHUB_WORKSPACE/env/bin/activate - $GITHUB_WORKSPACE/maybe_upload_build_results ${{ env.OUTPUT_ZIP }} - - - name: Check GitHub Pages status - if: github.ref == 'refs/heads/master' - uses: crazy-max/ghaction-github-status@v4 - with: - pages_threshold: major_outage - - - name: Deploy Javadoc - # note that i'm only uploading the javadocs for b2-sdk-core. - # that's because i'm lame and building separate javadocs for - # each jar and only uploading one set of javadocs. - if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/api-v2' || github.ref == 'refs/heads/7.x') && success() - uses: crazy-max/ghaction-github-pages@v3 - with: - target_branch: gh-pages - build_dir: core/build/docs/javadoc - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}