Compare commits

..

1 Commits

Author SHA1 Message Date
Norman Maurer
411e786a6f Add default methods to EventExecutor / EventExecutorGroup / EventLoop / EventLoopGroup
Motivation:

We can remove some classes and duplication if we add default methods

Modifications:

- Add default methods to EventExecutor / EventExecutorGroup / EventLoop / EventLoopGroup
- Remove code duplication
- Remove AbstractEventExecutorGroup as it is not needed anymore

Result:

Cleanup and removal of code-duplication. Also makes it easier for people to implement their custom executors / groups
2021-09-02 20:12:56 +02:00
2974 changed files with 371963 additions and 3557 deletions

1
.github/CONTRIBUTING.md vendored Normal file
View File

@ -0,0 +1 @@
Please review the [guidelines for contributing](https://netty.io/wiki/developer-guide.html) for this repository.

13
.github/ISSUE_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,13 @@
### Expected behavior
### Actual behavior
### Steps to reproduce
### Minimal yet complete reproducer code (or URL to code)
### Netty version
### JVM version (e.g. `java -version`)
### OS version (e.g. `uname -a`)

14
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,14 @@
Motivation:
Explain here the context, and why you're making that change.
What is the problem you're trying to solve.
Modification:
Describe the modifications you've done.
Result:
Fixes #<GitHub issue number>.
If there is no issue then describe the changes introduced by this PR.

33
.github/scripts/build_affected_only.sh vendored Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
# ----------------------------------------------------------------------------
# Copyright 2021 The Netty Project
#
# The Netty Project licenses this file to you under the Apache License,
# version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at:
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
set -e
if [ "$#" -lt 2 ]; then
echo "Expected branch and maven arguments"
exit 1
fi
MODULES=$(git diff --name-only "$1" | cut -d '/' -f 1 | sort -u | sed -n -e 'H;${x;s/\n/,/g;s/^,//;p;}')
MAVEN_ARGUMENTS=${*:2}
if [ -z "$MODULES" ]; then
echo "No changes detected, skipping build"
exit 0
fi
echo "Changes detected, start the build"
echo "./mvnw -pl $MODULES -amd $MAVEN_ARGUMENTS"
./mvnw -pl "$MODULES" -amd "${@:2}"

30
.github/scripts/check_build_result.sh vendored Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
# ----------------------------------------------------------------------------
# Copyright 2021 The Netty Project
#
# The Netty Project licenses this file to you under the Apache License,
# version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at:
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
set -e
if [ "$#" -ne 1 ]; then
echo "Expected build log as argument"
exit 1
fi
if grep -q 'BUILD FAILURE' $1 ; then
echo "Build failure detected, please inspect build log"
exit 1
else
echo "Build successful"
exit 0
fi

31
.github/scripts/check_leak.sh vendored Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
# ----------------------------------------------------------------------------
# Copyright 2021 The Netty Project
#
# The Netty Project licenses this file to you under the Apache License,
# version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at:
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
set -e
if [ "$#" -ne 1 ]; then
echo "Expected build log as argument"
exit 1
fi
if grep -q 'LEAK:' $1 ; then
echo "Leak detected, please inspect build log"
exit 1
else
echo "No Leak detected"
exit 0
fi

35
.github/scripts/merge_local_staging.sh vendored Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
# ----------------------------------------------------------------------------
# Copyright 2021 The Netty Project
#
# The Netty Project licenses this file to you under the Apache License,
# version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at:
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
set -e
if [ "$#" -lt 2 ]; then
echo "Expected target directory and at least one local staging directory"
exit 1
fi
TARGET=$1
for ((i=2; i<=$#; i++))
do
DIR="${!i}"
SUB_DIR=$(ls -d "${DIR}"/* | awk -F / '{print $NF}')
if [ ! -d "${TARGET}/${SUB_DIR}" ]
then
mkdir -p "${TARGET}/${SUB_DIR}"
fi
cat "${DIR}"/"${SUB_DIR}"/.index >> "${TARGET}/${SUB_DIR}"/.index
cp -r "${DIR}"/"${SUB_DIR}"/* "${TARGET}/${SUB_DIR}"/
done

28
.github/scripts/release_checkout_tag.sh vendored Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
# ----------------------------------------------------------------------------
# Copyright 2021 The Netty Project
#
# The Netty Project licenses this file to you under the Apache License,
# version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at:
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
set -e
if [ "$#" -ne 1 ]; then
echo "Expected release.properties file"
exit 1
fi
TAG=$(grep scm.tag= "$1" | cut -d'=' -f2)
echo "Checkout tag $TAG"
git checkout "$TAG"
exit 0

29
.github/scripts/release_rollback.sh vendored Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
# ----------------------------------------------------------------------------
# Copyright 2021 The Netty Project
#
# The Netty Project licenses this file to you under the Apache License,
# version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at:
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
set -e
if [ "$#" -ne 3 ]; then
echo "Expected release.properties file, repository name and branch"
exit 1
fi
TAG=$(grep scm.tag= "$1" | cut -d'=' -f2)
git remote set-url origin git@github.com:"$2".git
git fetch
git checkout "$3"
./mvnw -B --file pom.xml release:rollback
git push origin :"$TAG"

79
.github/workflows/ci-build.yml vendored Normal file
View File

@ -0,0 +1,79 @@
# ----------------------------------------------------------------------------
# Copyright 2021 The Netty Project
#
# The Netty Project licenses this file to you under the Apache License,
# version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at:
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
name: Build project
on:
push:
branches: [ "main"]
schedule:
- cron: '30 1 * * 1' # At 01:30 on Monday, every Monday.
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryhandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=240
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- setup: linux-x86_64-java11
docker-compose-build: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.111.yaml build"
docker-compose-run: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.111.yaml run build"
name: ${{ matrix.setup }}
steps:
- uses: actions/checkout@v2
# Cache .m2/repository
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ matrix.setup }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-${{ matrix.setup }}-
${{ runner.os }}-maven-
# Enable caching of Docker layers
- uses: satackey/action-docker-layer-caching@v0.0.11
continue-on-error: true
with:
key: build-docker-cache-${{ matrix.setup }}-{hash}
restore-keys: |
build-docker-cache-${{ matrix.setup }}-
build-docker-cache-
- name: Build docker image
run: docker-compose ${{ matrix.docker-compose-build }}
- name: Build project without leak detection
run: docker-compose ${{ matrix.docker-compose-run }} | tee build.output
- name: Checking for test failures
run: ./.github/scripts/check_build_result.sh build.output
- uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
name: target
path: |
**/target/surefire-reports/
**/hs_err*.log

143
.github/workflows/ci-deploy.yml vendored Normal file
View File

@ -0,0 +1,143 @@
# ----------------------------------------------------------------------------
# Copyright 2021 The Netty Project
#
# The Netty Project licenses this file to you under the Apache License,
# version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at:
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
name: Deploy project
on:
push:
branches: [ "main" ]
schedule:
- cron: '30 1 * * 1' # At 01:30 on Monday, every Monday.
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryhandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=240
jobs:
stage-snapshot:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- setup: linux-x86_64-java11
docker-compose-build: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.111.yaml build"
docker-compose-run: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.111.yaml run stage-snapshot"
- setup: linux-aarch64
docker-compose-build: "-f docker/docker-compose.centos-7.yaml build"
docker-compose-run: "-f docker/docker-compose.centos-7.yaml run cross-compile-aarch64-stage-snapshot"
name: stage-snapshot-${{ matrix.setup }}
steps:
- uses: actions/checkout@v2
# Cache .m2/repository
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ matrix.setup }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-${{ matrix.setup }}-
${{ runner.os }}-maven-
# Enable caching of Docker layers
- uses: satackey/action-docker-layer-caching@v0.0.11
env:
docker-cache-name: staging-${{ matrix.setup }}-cache-docker
continue-on-error: true
with:
key: ${{ runner.os }}-staging-${{ env.docker-cache-name }}-{hash}
restore-keys: |
${{ runner.os }}-staging-${{ env.docker-cache-name }}-
- name: Create local staging directory
run: mkdir -p ~/local-staging
- name: Build docker image
run: docker-compose ${{ matrix.docker-compose-build }}
- name: Stage snapshots to local staging directory
run: docker-compose ${{ matrix.docker-compose-run }}
- name: Upload local staging directory
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.setup }}-local-staging
path: ~/local-staging
if-no-files-found: error
deploy-staged-snapshots:
runs-on: ubuntu-18.04
# Wait until we have staged everything
needs: stage-snapshot
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: '11'
# Cache .m2/repository
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-deploy-staged-snapshots-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-deploy-staged-snapshots-
${{ runner.os }}-maven-
# Setup some env to re-use later.
- name: Prepare enviroment variables
run: |
echo "LOCAL_STAGING_DIR=$HOME/local-staging" >> $GITHUB_ENV
# Hardcode the staging artifacts that need to be downloaded.
# These must match the matrix setups. There is currently no way to pull this out of the config.
- name: Download linux-aarch64 staging directory
uses: actions/download-artifact@v2
with:
name: linux-aarch64-local-staging
path: ~/linux-aarch64-local-staging
- name: Download linux-x86_64-java11 staging directory
uses: actions/download-artifact@v2
with:
name: linux-x86_64-java11-local-staging
path: ~/linux-x86_64-java11-local-staging
- name: Merge staging repositories
run: |
mkdir -p ~/local-staging/deferred
cat ~/linux-aarch64-local-staging/deferred/.index >> ~/local-staging/deferred/.index
cp -r ~/linux-aarch64-local-staging/deferred/* ~/local-staging/deferred/
cat ~/linux-x86_64-java11-local-staging/deferred/.index >> ~/local-staging/deferred/.index
cp -r ~/linux-x86_64-java11-local-staging/deferred/* ~/local-staging/deferred/
- uses: s4u/maven-settings-action@v2.2.0
with:
servers: |
[{
"id": "sonatype-nexus-snapshots",
"username": "${{ secrets.SONATYPE_USERNAME }}",
"password": "${{ secrets.SONATYPE_PASSWORD }}"
}]
- name: Deploy local staged artifacts
run: ./mvnw -B --file pom.xml org.sonatype.plugins:nexus-staging-maven-plugin:deploy-staged -DaltStagingDirectory=$LOCAL_STAGING_DIR

54
.github/workflows/ci-pr-reports.yml vendored Normal file
View File

@ -0,0 +1,54 @@
# ----------------------------------------------------------------------------
# Copyright 2021 The Netty Project
#
# The Netty Project licenses this file to you under the Apache License,
# version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at:
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
name: PR Reports
on:
workflow_run:
workflows: [ "Build PR" ]
types:
- completed
env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryhandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=240
jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ignore-if-missing: [false]
include:
- setup: linux-x86_64-java11
- setup: linux-x86_64-java16
- setup: linux-x86_64-java11-boringssl
- setup: windows-x86_64-java11-boringssl
continue-on-error: ${{ matrix.ignore-if-missing }}
steps:
- name: Download Artifacts
uses: dawidd6/action-download-artifact@v2.14.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: ${{ github.event.workflow_run.workflow_id }}
workflow_conclusion: completed
commit: ${{ github.event.workflow_run.head_commit.id }}
# File location set in ci-pr.yml and must be coordinated.
name: test-results-${{ matrix.setup }}
- name: Publish Test Report
uses: scacap/action-surefire-report@v1.0.13
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
report_paths: '**/target/surefire-reports/TEST-*.xml'
commit: ${{ github.event.workflow_run.head_commit.id }}
check_name: ${{ matrix.setup }} test reports

206
.github/workflows/ci-pr.yml vendored Normal file
View File

@ -0,0 +1,206 @@
# ----------------------------------------------------------------------------
# Copyright 2021 The Netty Project
#
# The Netty Project licenses this file to you under the Apache License,
# version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at:
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
name: Build PR
on:
pull_request:
branches: [ "main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryhandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=240
jobs:
verify-pr:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: '11'
# Cache .m2/repository
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-verify-pr-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-verify-pr-
${{ runner.os }}-maven-
- name: Verify with Maven
run: ./mvnw -B -ntp --file pom.xml verify -DskipTests=true
build-pr-windows:
runs-on: windows-2016
name: windows-x86_64-java11-boringssl
needs: verify-pr
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
# Cache .m2/repository
# Caching of maven dependencies
- uses: actions/cache@v2
with:
path: ~/.m2/repository
key: pr-windows-x86_64-maven-cache-${{ hashFiles('**/pom.xml') }}
restore-keys: |
pr-windows-x86_64-maven-cache-
- name: Build project
run: ./mvnw.cmd -B -ntp --file pom.xml clean package -Pboringssl -DskipHttp2Testsuite=true -DskipAutobahnTestsuite=true
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: test-results-windows-x86_64-java11-boringssl
path: '**/target/surefire-reports/TEST-*.xml'
- uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
name: build-pr-windows-target
path: |
**/target/surefire-reports/
**/hs_err*.log
build-pr-aarch64:
name: linux-aarch64-verify-native
# The host should always be Linux
runs-on: ubuntu-20.04
needs: verify-pr
steps:
- uses: actions/checkout@v2
# Cache .m2/repository
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-build-pr-aarch64-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-build-pr-aarch64-
${{ runner.os }}-maven-
- uses: uraimo/run-on-arch-action@v2.0.9
name: Run commands
id: runcmd
with:
arch: aarch64
distro: ubuntu20.04
# Not required, but speeds up builds by storing container images in
# a GitHub package registry.
githubToken: ${{ github.token }}
# Mount the .m2/repository
dockerRunArgs: |
--volume "/home/runner/.m2/repository/:/root/.m2/repository"
# Install dependencies
install: |
apt-get update -q -y
apt-get install -q -y openjdk-11-jdk autoconf automake libtool make tar maven git
# Compile native code and the modules it depend on and run NativeLoadingTest. This is enough to ensure
# we can load the native module on aarch64
#
# Use tcnative.classifier that is empty as we don't support using the shared lib version on ubuntu.
run: |
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-arm64 ./mvnw -B -ntp -pl testsuite-native -am clean package -DskipTests=true -Dcheckstyle.skip=true -DskipNativeTestsuite=false -Dtcnative.classifier=
build-pr:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- setup: linux-x86_64-java11
docker-compose-build: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.111.yaml build"
docker-compose-run: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.111.yaml run build-leak"
- setup: linux-x86_64-java11-graal
docker-compose-build: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.graalvm111.yaml build"
docker-compose-run: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.graalvm111.yaml run build-leak"
- setup: linux-x86_64-java16
docker-compose-build: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.116.yaml build"
docker-compose-run: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.116.yaml run build-leak"
- setup: linux-x86_64-java17
docker-compose-build: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.117.yaml build"
docker-compose-run: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.117.yaml run build-leak"
- setup: linux-x86_64-java11-boringssl
docker-compose-build: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.111.yaml build"
docker-compose-run: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.111.yaml run build-leak-boringssl-static"
- setup: linux-x86_64-java11-unsafe-buffer
docker-compose-build: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.111.yaml build"
docker-compose-run: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.111.yaml run build-unsafe-buffer"
name: ${{ matrix.setup }} build
needs: verify-pr
steps:
- uses: actions/checkout@v2
# Cache .m2/repository
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ matrix.setup }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-${{ matrix.setup }}-
${{ runner.os }}-maven-
# Enable caching of Docker layers
- uses: satackey/action-docker-layer-caching@v0.0.11
continue-on-error: true
with:
key: build-docker-cache-${{ matrix.setup }}-{hash}
restore-keys: |
build-docker-cache-${{ matrix.setup }}-
build-docker-cache-
- name: Build docker image
run: docker-compose ${{ matrix.docker-compose-build }}
- name: Build project with leak detection
run: docker-compose ${{ matrix.docker-compose-run }} | tee build-leak.output
- name: Checking for test failures
run: ./.github/scripts/check_build_result.sh build-leak.output
- name: Checking for detected leak
run: ./.github/scripts/check_leak.sh build-leak.output
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: test-results-${{ matrix.setup }}
path: '**/target/surefire-reports/TEST-*.xml'
- uses: actions/upload-artifact@v2
if: ${{ failure() }}
with:
name: build-${{ matrix.setup }}-target
path: |
**/target/surefire-reports/
**/hs_err*.log

249
.github/workflows/ci-release.yml vendored Normal file
View File

@ -0,0 +1,249 @@
# ----------------------------------------------------------------------------
# Copyright 2021 The Netty Project
#
# The Netty Project licenses this file to you under the Apache License,
# version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at:
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
name: Release
on:
# Releases can only be triggered via the action tab
workflow_dispatch:
env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryhandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=240
jobs:
prepare-release:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
ref: main
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: '11'
- name: Setup git configuration
run: |
git config --global user.email "netty-project-bot@users.noreply.github.com"
git config --global user.name "Netty Project Bot"
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY_PEM }}
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
# Cache .m2/repository
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-prepare-release-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-prepare-release-
${{ runner.os }}-maven-
- name: Prepare release with Maven
run: |
./mvnw -B -ntp --file pom.xml release:prepare -DpreparationGoals=clean -DskipTests=true
./mvnw -B -ntp clean
- name: Checkout tag
run: ./.github/scripts/release_checkout_tag.sh release.properties
- name: Upload workspace
uses: actions/upload-artifact@v2
with:
name: prepare-release-workspace
path: ${{ github.workspace }}/**
stage-release-linux:
runs-on: ubuntu-latest
needs: prepare-release
strategy:
matrix:
include:
- setup: linux-x86_64-java11
docker-compose-build: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.11.yaml build"
docker-compose-run: "-f docker/docker-compose.yaml -f docker/docker-compose.centos-6.11.yaml run stage-release"
- setup: linux-aarch64
docker-compose-build: "-f docker/docker-compose.centos-7.yaml build"
docker-compose-run: "-f docker/docker-compose.centos-7.yaml run cross-compile-aarch64-stage-release"
name: stage-release-${{ matrix.setup }}
steps:
- name: Download release-workspace
uses: actions/download-artifact@v2
with:
name: prepare-release-workspace
path: ./prepare-release-workspace/
- name: Adjust mvnw permissions
run: chmod 755 ./prepare-release-workspace/mvnw
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: '11'
- name: Setup git configuration
run: |
git config --global user.email "netty-project-bot@users.noreply.github.com"
git config --global user.name "Netty Project Bot"
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY_PEM }}
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
# Enable caching of Docker layers
- uses: satackey/action-docker-layer-caching@v0.0.11
continue-on-error: true
with:
key: ${{ runner.os }}-staging-docker-cache-${{ matrix.setup }}-{hash}
restore-keys: |
${{ runner.os }}-staging-docker-cache-${{ matrix.setup }}-
${{ runner.os }}-staging-docker-cache-
- uses: s4u/maven-settings-action@v2.2.0
with:
servers: |
[{
"id": "sonatype-nexus-staging",
"username": "${{ secrets.SONATYPE_USERNAME }}",
"password": "${{ secrets.SONATYPE_PASSWORD }}"
}]
# Cache .m2/repository
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ matrix.setup }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-${{ matrix.setup }}-
${{ runner.os }}-maven-
- name: Create local staging directory
run: mkdir -p ~/local-staging
- name: Build docker image
working-directory: ./prepare-release-workspace/
run: docker-compose ${{ matrix.docker-compose-build }}
- name: Stage release to local staging directory
working-directory: ./prepare-release-workspace/
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_KEYNAME: ${{ secrets.GPG_KEYNAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: docker-compose ${{ matrix.docker-compose-run }}
- name: Upload local staging directory
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.setup }}-local-staging
path: ~/local-staging
if-no-files-found: error
- name: Rollback release on failure
working-directory: ./prepare-release-workspace/
if: ${{ failure() }}
# Rollback the release in case of an failure
run: bash ./.github/scripts/release_rollback.sh release.properties netty/netty main
deploy-staged-release:
runs-on: ubuntu-18.04
# Wait until we have staged everything
needs: stage-release-linux
steps:
- name: Download release-workspace
uses: actions/download-artifact@v2
with:
name: prepare-release-workspace
path: ./prepare-release-workspace/
- name: Adjust mvnw permissions
run: chmod 755 ./prepare-release-workspace/mvnw
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: '11'
- name: Setup git configuration
run: |
git config --global user.email "netty-project-bot@users.noreply.github.com"
git config --global user.name "Netty Project Bot"
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY_PEM }}
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
# Hardcode the staging artifacts that need to be downloaded.
# These must match the matrix setups. There is currently no way to pull this out of the config.
- name: Download linux-aarch64 staging directory
uses: actions/download-artifact@v2
with:
name: linux-aarch64-local-staging
path: ~/linux-aarch64-local-staging
- name: Download linux-x86_64-java11 staging directory
uses: actions/download-artifact@v2
with:
name: linux-x86_64-java11-local-staging
path: ~/linux-x86_64-java11-local-staging
# This step takes care of merging all the previous staged repositories in a way that will allow us to deploy
# all together with one maven command.
- name: Merge staging repositories
working-directory: ./prepare-release-workspace/
run: bash ./.github/scripts/merge_local_staging.sh /home/runner/local-staging/staging ~/linux-aarch64-local-staging/staging ~/linux-x86_64-java11-local-staging/staging
- uses: s4u/maven-settings-action@v2.2.0
with:
servers: |
[{
"id": "sonatype-nexus-staging",
"username": "${{ secrets.SONATYPE_USERNAME }}",
"password": "${{ secrets.SONATYPE_PASSWORD }}"
}]
# Cache .m2/repository
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-deploy-staged-release-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-deploy-staged-release-
${{ runner.os }}-maven-
- name: Deploy local staged artifacts
working-directory: ./prepare-release-workspace/
# If we don't want to close the repository we can add -DskipStagingRepositoryClose=true
run: ./mvnw -B -ntp --file pom.xml org.sonatype.plugins:nexus-staging-maven-plugin:deploy-staged -DnexusUrl=https://oss.sonatype.org -DserverId=sonatype-nexus-staging -DaltStagingDirectory=/home/runner/local-staging -DskipStagingRepositoryClose=true
- name: Rollback release on failure
working-directory: ./prepare-release-workspace/
if: ${{ failure() }}
# Rollback the release in case of an failure
run: bash ./.github/scripts/release_rollback.sh release.properties netty/netty main

102
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@ -0,0 +1,102 @@
# ----------------------------------------------------------------------------
# Copyright 2021 The Netty Project
#
# The Netty Project licenses this file to you under the Apache License,
# version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at:
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
name: "CodeQL"
on:
push:
branches: ["4.1", main]
pull_request:
# The branches below must be a subset of the branches above
branches: ["4.1", main]
schedule:
- cron: '0 13 * * 3'
env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryhandler.count=5 -Dmaven.wagon.httpconnectionManager.ttlSeconds=240
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['java', 'cpp' ]
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# Cache .m2/repository
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ matrix.language }} ${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-${{ matrix.language }}
${{ runner.os }}-maven-
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
# - name: Autobuild
# uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
- uses: actions/setup-java@v1
with:
java-version: '11' # The JDK version to make available on the path.
- name: Compile project
run: ./mvnw -B -ntp clean package -DskipTests=true
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

BIN
.mvn/wrapper/maven-wrapper.jar vendored Normal file

Binary file not shown.

1
.mvn/wrapper/maven-wrapper.properties vendored Normal file
View File

@ -0,0 +1 @@
distributionUrl=https://downloads.apache.org/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.zip

View File

@ -33,32 +33,32 @@ Netty can be used in modular JDK9+ applications as a collection of automatic mod
reverse-DNS style, and are derived from subproject names rather than root packages due to historical reasons. They
are listed below:
* `io.net5.all`
* `io.net5.buffer`
* `io.net5.codec`
* `io.net5.codec.dns`
* `io.net5.codec.haproxy`
* `io.net5.codec.http`
* `io.net5.codec.http2`
* `io.net5.codec.memcache`
* `io.net5.codec.mqtt`
* `io.net5.codec.redis`
* `io.net5.codec.smtp`
* `io.net5.codec.socks`
* `io.net5.codec.stomp`
* `io.net5.codec.xml`
* `io.net5.common`
* `io.net5.handler`
* `io.net5.handler.proxy`
* `io.net5.resolver`
* `io.net5.resolver.dns`
* `io.net5.transport`
* `io.net5.transport.epoll` (`native` omitted - reserved keyword in Java)
* `io.net5.transport.kqueue` (`native` omitted - reserved keyword in Java)
* `io.net5.transport.unix.common` (`native` omitted - reserved keyword in Java)
* `io.net5.transport.rxtx`
* `io.net5.transport.sctp`
* `io.net5.transport.udt`
* `io.netty.all`
* `io.netty.buffer`
* `io.netty.codec`
* `io.netty.codec.dns`
* `io.netty.codec.haproxy`
* `io.netty.codec.http`
* `io.netty.codec.http2`
* `io.netty.codec.memcache`
* `io.netty.codec.mqtt`
* `io.netty.codec.redis`
* `io.netty.codec.smtp`
* `io.netty.codec.socks`
* `io.netty.codec.stomp`
* `io.netty.codec.xml`
* `io.netty.common`
* `io.netty.handler`
* `io.netty.handler.proxy`
* `io.netty.resolver`
* `io.netty.resolver.dns`
* `io.netty.transport`
* `io.netty.transport.epoll` (`native` omitted - reserved keyword in Java)
* `io.netty.transport.kqueue` (`native` omitted - reserved keyword in Java)
* `io.netty.transport.unix.common` (`native` omitted - reserved keyword in Java)
* `io.netty.transport.rxtx`
* `io.netty.transport.sctp`
* `io.netty.transport.udt`

631
all/pom.xml Normal file
View File

@ -0,0 +1,631 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2012 The Netty Project
~
~ The Netty Project licenses this file to you under the Apache License,
~ version 2.0 (the "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at:
~
~ https://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
~ License for the specific language governing permissions and limitations
~ under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.netty</groupId>
<artifactId>netty-parent</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</parent>
<artifactId>netty-all</artifactId>
<packaging>jar</packaging>
<name>Netty/All-in-One</name>
<properties>
<generatedSourceDir>${project.build.directory}/src</generatedSourceDir>
<dependencyVersionsDir>${project.build.directory}/versions</dependencyVersionsDir>
<japicmp.skip>true</japicmp.skip>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<profiles>
<!-- If the uber profile is used it will automatically fetch the missing native jar from maven and add it to the all jar as well. -->
<profile>
<id>uber-staging</id>
<repositories>
<repository>
<id>staged-releases</id>
<name>Staged Releases</name>
<url>https://oss.sonatype.org/service/local/repositories/${stagingRepositoryId}/content/</url>
</repository>
</repositories>
<dependencies>
<!-- Depend on all our native jars -->
<!-- As this is executed on either macOS or Linux we directly need to specify the classifier -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<classifier>linux-x86_64</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<classifier>linux-aarch_64</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
<classifier>osx-x86_64</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-resolver-dns-native-macos</artifactId>
<classifier>osx-x86_64</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>
</profile>
<profile>
<id>uber-snapshot</id>
<dependencies>
<!-- Depend on all our native jars -->
<!-- As this is executed on either macOS or Linux we directly need to specify the classifier -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<classifier>linux-x86_64</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<classifier>linux-aarch_64</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
<classifier>osx-x86_64</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-resolver-dns-native-macos</artifactId>
<classifier>osx-x86_64</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>
</profile>
<!-- The linux profile will only include the native jar for epol to the all jar.
If you want to also include the native jar for kqueue use -Puber.
-->
<profile>
<id>linux</id>
<activation>
<os>
<family>linux</family>
</os>
</activation>
<dependencies>
<!-- All release modules -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<version>${project.version}</version>
<classifier>${jni.classifier}</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<!-- Just include the classes for the other platform so these are at least present in the netty-all artifact -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-resolver-dns-native-macos</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>
</profile>
<!-- The mac, openbsd and freebsd profile will only include the native jar for epol to the all jar.
If you want to also include the native jar for kqueue use -Puber.
-->
<profile>
<id>mac</id>
<activation>
<os>
<family>mac</family>
</os>
</activation>
<dependencies>
<!-- All release modules -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
<version>${project.version}</version>
<classifier>${jni.classifier}</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-resolver-dns-native-macos</artifactId>
<version>${project.version}</version>
<classifier>${jni.classifier}</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<!-- Just include the classes for the other platform so these are at least present in the netty-all artifact -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>
</profile>
<profile>
<id>freebsd</id>
<activation>
<os>
<family>unix</family>
<name>freebsd</name>
</os>
</activation>
<dependencies>
<!-- All release modules -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
<version>${project.version}</version>
<classifier>${jni.classifier}</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-resolver-dns-native-macos</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<!-- Just include the classes for the other platform so these are at least present in the netty-all artifact -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>
</profile>
<profile>
<id>openbsd</id>
<activation>
<os>
<family>unix</family>
<name>openbsd</name>
</os>
</activation>
<dependencies>
<!-- All release modules -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
<version>${project.version}</version>
<classifier>${jni.classifier}</classifier>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-resolver-dns-native-macos</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<!-- Just include the classes for the other platform so these are at least present in the netty-all artifact -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>
</profile>
</profiles>
<dependencies>
<!-- All release modules -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-buffer</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-codec</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-codec-dns</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-codec-haproxy</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-codec-http</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-codec-http2</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-codec-memcache</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-codec-mqtt</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-codec-redis</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-codec-smtp</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-codec-socks</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-codec-stomp</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-codec-xml</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-common</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-handler</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-handler-proxy</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-resolver</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-resolver-dns</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-transport-sctp</artifactId>
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<executions>
<execution>
<id>clean-first</id>
<phase>generate-resources</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<!-- Populate the properties whose key is groupId:artifactId:type
and whose value is the path to the artifact -->
<execution>
<id>locate-dependencies</id>
<phase>initialize</phase>
<goals>
<goal>properties</goal>
</goals>
</execution>
<!-- Unpack all source files -->
<execution>
<id>unpack-sources</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<classifier>sources</classifier>
<includes>io/netty/**</includes>
<includeScope>runtime</includeScope>
<includeGroupIds>${project.groupId}</includeGroupIds>
<outputDirectory>${generatedSourceDir}</outputDirectory>
</configuration>
</execution>
<!-- Unpack all class files -->
<execution>
<id>unpack-jars</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<excludes>io/netty/internal/tcnative/**,io/netty/example/**,META-INF/native/libnetty_tcnative*,META-INF/native/include/**,META-INF/native/**/*.a</excludes>
<includes>io/netty/**,META-INF/native/**,META-INF/native-image/**</includes>
<includeScope>runtime</includeScope>
<includeGroupIds>${project.groupId}</includeGroupIds>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<!-- Instead of generating a new version property file, merge others' version property files into one. -->
<execution>
<id>write-version-properties</id>
<phase>none</phase>
</execution>
<execution>
<id>merge-version-properties</id>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<propertyselector property="versions" match="^(${project.groupId}:(?!netty-example)[^:]+:jar(?::[^:]+)?)$" select="\1" />
<for list="${versions}" param="x">
<sequential>
<unzip src="${@{x}}" dest="${dependencyVersionsDir}">
<patternset>
<include name="META-INF/${project.groupId}.versions.properties" />
</patternset>
</unzip>
<concat destfile="${project.build.outputDirectory}/META-INF/${project.groupId}.versions.properties" append="true">
<path path="${dependencyVersionsDir}/META-INF/${project.groupId}.versions.properties" />
</concat>
</sequential>
</for>
<delete dir="${dependencyVersionsDir}" quiet="true" />
</target>
</configuration>
</execution>
<!-- Clean everything once finished so that IDE doesn't find the unpacked files. -->
<execution>
<id>clean-source-directory</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<delete dir="${generatedSourceDir}" quiet="true" />
<delete dir="${dependencyVersionsDir}" quiet="true" />
<delete dir="${project.build.outputDirectory}" quiet="true" />
</target>
</configuration>
</execution>
</executions>
</plugin>
<!-- Include the directory where the source files were unpacked -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>prepare-package</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${generatedSourceDir}</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<!-- Disable OSGi bundle manifest generation -->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<executions>
<execution>
<id>generate-manifest</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<!-- Override the default JAR configuration -->
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>default-jar</id>
<phase>none</phase>
</execution>
<execution>
<id>all-in-one-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Automatic-Module-Name>io.netty.all</Automatic-Module-Name>
</manifestEntries>
<index>true</index>
</archive>
</configuration>
</execution>
</executions>
</plugin>
<!-- Disable animal sniffer -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<executions>
<execution>
<id>default</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<!-- Disable checkstyle -->
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>check-style</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<!-- Disable all plugin executions configured by jar packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>default-resources</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testResources</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>default-test</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2017, 2012 The Netty Project
~ Copyright 2017 The Netty Project
~
~ The Netty Project licenses this file to you under the Apache License,
~ version 2.0 (the "License"); you may not use this file except in compliance
@ -16,15 +16,14 @@
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<distributionManagement>
<repository>
<id>mchv-snapshot</id>
<name>MCHV Apache Snapshot Maven Packages Distribution</name>
<url>https://mvn.mchv.eu/repository/mchv-snapshot</url>
</repository>
</distributionManagement>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
<relativePath />
</parent>
<groupId>io.net5</groupId>
<groupId>io.netty</groupId>
<artifactId>netty-bom</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
<packaging>pom</packaging>
@ -64,27 +63,240 @@
</developer>
</developers>
<properties>
<!-- Keep in sync with ../pom.xml -->
</properties>
<dependencyManagement>
<dependencies>
<!-- All release modules -->
<dependency>
<groupId>io.net5</groupId>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.net5</groupId>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-dns</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-haproxy</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http2</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-memcache</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-mqtt</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-redis</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-smtp</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-socks</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-stomp</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-xml</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.net5</groupId>
<groupId>io.netty</groupId>
<artifactId>netty-dev-tools</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler-proxy</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver-dns</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-sctp</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-example</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver-dns-native-macos</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver-dns-native-macos</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
<classifier>osx-x86_64</classifier>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
<classifier>linux-aarch_64</classifier>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
<classifier>linux-x86_64</classifier>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-unix-common</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
<classifier>osx-x86_64</classifier>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
<classifier>linux-aarch_64</classifier>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
<classifier>linux-x86_64</classifier>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
<classifier>osx-x86_64</classifier>
</dependency>
<!-- Add netty-tcnative* as well as users need to ensure they use the correct version -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative</artifactId>
<version>${tcnative.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative</artifactId>
<version>${tcnative.version}</version>
<classifier>linux-x86_64</classifier>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative</artifactId>
<version>${tcnative.version}</version>
<classifier>linux-aarch_64</classifier>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative</artifactId>
<version>${tcnative.version}</version>
<classifier>osx-x86_64</classifier>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>${tcnative.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>${tcnative.version}</version>
<classifier>linux-x86_64</classifier>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>${tcnative.version}</version>
<classifier>linux-aarch_64</classifier>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>${tcnative.version}</version>
<classifier>osx_64</classifier>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>${tcnative.version}</version>
<classifier>windows_64</classifier>
</dependency>
</dependencies>
</dependencyManagement>
</project>
</project>

View File

@ -18,7 +18,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.net5</groupId>
<groupId>io.netty</groupId>
<artifactId>netty-parent</artifactId>
<version>5.0.0.Final-SNAPSHOT</version>
</parent>
@ -29,7 +29,7 @@
<name>Netty/Buffer</name>
<properties>
<javaModuleName>io.net5.buffer</javaModuleName>
<javaModuleName>io.netty.buffer</javaModuleName>
</properties>
<dependencies>

View File

@ -1,290 +0,0 @@
/*
* Copyright 2021 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer.api;
/**
* The {@code CompositeBuffer} is a concrete {@link Buffer} implementation that make a number of other buffers appear
* as one. A composite buffer behaves the same as a normal, non-composite buffer in every way, so you normally don't
* need to handle them specially.
* <p>
* A composite buffer is constructed using one of the {@code compose} methods:
* <ul>
* <li>
* {@link #compose(BufferAllocator, Send[])} creates a composite buffer from the buffers that are sent to it via
* the passed in send objects. Since {@link Send#receive()} transfers ownership, the resulting composite buffer
* will have ownership, because it is guaranteed that there are no other references to its constituent buffers.
* </li>
* <li>
* {@link #compose(BufferAllocator)} creates an empty, zero capacity, composite buffer. Such empty buffers may
* change their {@linkplain #readOnly() read-only} states when they gain their first component.
* </li>
* </ul>
* Composite buffers can later be extended with internally allocated components, with {@link #ensureWritable(int)},
* or with externally allocated buffers, using {@link #extendWith(Send)}.
*
* <h3>Constituent buffer requirements</h3>
*
* The buffers that are being composed to form the composite buffer, need to live up to a number of requirements.
* Basically, if we imagine that the constituent buffers have their memory regions concatenated together, then the
* result needs to make sense.
* <p>
* The read and write offsets of the constituent buffers must be arranged such that there are no "gaps" when viewed
* as a single connected chunk of memory.
* Specifically, there can be at most one buffer whose write offset is neither zero nor at capacity,
* and all buffers prior to it must have their write offsets at capacity, and all buffers after it must have a
* write-offset of zero.
* Likewise, there can be at most one buffer whose read offset is neither zero nor at capacity,
* and all buffers prior to it must have their read offsets at capacity, and all buffers after it must have a read
* offset of zero.
* Furthermore, the sum of the read offsets must be less than or equal to the sum of the write-offsets.
* <p>
* Reads and writes to the composite buffer that modifies the read or write offsets, will also modify the relevant
* offsets in the constituent buffers.
* <p>
* It is not a requirement that the buffers have the same size.
* <p>
* It is not a requirement that the buffers are allocated by this allocator, but if
* {@link Buffer#ensureWritable(int)} is called on the composed buffer, and the composed buffer needs to be
* expanded, then this allocator instance will be used for allocation the extra memory.
*
* <h3>Ownership and Send</h3>
*
* {@linkplain Resource#send() Sending} a composite buffer implies sending all of its constituent buffers.
* For sending to be possible, both the composite buffer itself, and all of its constituent buffers, must be in a
* state that permits them being sent. This should be the case by default, as it shouldn't be possible to create
* composite buffers that can't be sent.
*/
public interface CompositeBuffer extends Buffer {
/**
* Compose the given sequence of sends of buffers and present them as a single buffer.
* <p>
* When a composite buffer is closed, all of its constituent component buffers are closed as well.
* <p>
* See the class documentation for more information on what is required of the given buffers for composition to be
* allowed.
*
* @param allocator The allocator for the composite buffer. This allocator will be used e.g. to service
* {@link #ensureWritable(int)} calls.
* @param sends The sent buffers to compose into a single buffer view.
* @return A buffer composed of, and backed by, the given buffers.
* @throws IllegalStateException if one of the sends have already been received. The remaining buffers and sends
* will be closed and discarded, respectively.
*/
@SafeVarargs
static CompositeBuffer compose(BufferAllocator allocator, Send<Buffer>... sends) {
return DefaultCompositeBuffer.compose(allocator, sends);
}
/**
* Create an empty composite buffer, that has no components. The buffer can be extended with components using either
* {@link #ensureWritable(int)} or {@link #extendWith(Send)}.
*
* @param allocator The allocator for the composite buffer. This allocator will be used e.g. to service
* {@link #ensureWritable(int)} calls.
* @return A composite buffer that has no components, and has a capacity of zero.
*/
static CompositeBuffer compose(BufferAllocator allocator) {
return DefaultCompositeBuffer.compose(allocator);
}
/**
* Check if the given buffer is a {@linkplain #compose(BufferAllocator, Send...) composite} buffer or not.
* @param composite The buffer to check.
* @return {@code true} if the given buffer was created with {@link #compose(BufferAllocator, Send...)},
* {@code false} otherwise.
*/
static boolean isComposite(Buffer composite) {
return composite instanceof CompositeBuffer;
}
/**
* Extend this composite buffer with the given extension buffer.
* This works as if the extension had originally been included at the end of the list of constituent buffers when
* the composite buffer was created.
* The extension buffer is added to the end of this composite buffer, which is modified in-place.
*
* @see #compose(BufferAllocator, Send...)
* @param extension The buffer to extend the composite buffer with.
* @return This composite buffer instance.
*/
CompositeBuffer extendWith(Send<Buffer> extension);
/**
* Split this buffer at a component boundary that is less than or equal to the given offset.
* <p>
* This method behaves the same as {@link #split(int)}, except no components are split.
*
* @param splitOffset The maximum split offset. The real split offset will be at a component boundary that is less
* than or equal to this offset.
* @return A new buffer with independent and exclusive ownership over the bytes from the beginning to a component
* boundary less than or equal to the given offset of this buffer.
*/
CompositeBuffer splitComponentsFloor(int splitOffset);
/**
* Split this buffer at a component boundary that is greater than or equal to the given offset.
* <p>
* This method behaves the same as {@link #split(int)}, except no components are split.
*
* @param splitOffset The minimum split offset. The real split offset will be at a component boundary that is
* greater than or equal to this offset.
* @return A new buffer with independent and exclusive ownership over the bytes from the beginning to a component
* boundary greater than or equal to the given offset of this buffer.
*/
CompositeBuffer splitComponentsCeil(int splitOffset);
/**
* Break a composite buffer into its constituent components.
* <p>
* This "consumes" the composite buffer, leaving the composite buffer instance as if it had been closed.
* The buffers in the returned array are not closed, and become owned by the caller.
*
* @return An array of the constituent buffer components.
*/
Buffer[] decomposeBuffer();
@Override
CompositeBuffer readerOffset(int offset);
@Override
CompositeBuffer writerOffset(int offset);
@Override
CompositeBuffer fill(byte value);
@Override
CompositeBuffer makeReadOnly();
@Override
default CompositeBuffer writeBytes(Buffer source) {
return (CompositeBuffer) Buffer.super.writeBytes(source);
}
@Override
default CompositeBuffer writeBytes(byte[] source) {
return (CompositeBuffer) Buffer.super.writeBytes(source);
}
@Override
default CompositeBuffer writeBytes(byte[] source, int srcPos, int length) {
return (CompositeBuffer) Buffer.super.writeBytes(source, srcPos, length);
}
@Override
default CompositeBuffer resetOffsets() {
return (CompositeBuffer) Buffer.super.resetOffsets();
}
@Override
default CompositeBuffer ensureWritable(int size) {
return (CompositeBuffer) Buffer.super.ensureWritable(size);
}
@Override
CompositeBuffer ensureWritable(int size, int minimumGrowth, boolean allowCompaction);
@Override
default CompositeBuffer copy() {
return (CompositeBuffer) Buffer.super.copy();
}
@Override
CompositeBuffer copy(int offset, int length);
@Override
default CompositeBuffer split() {
return (CompositeBuffer) Buffer.super.split();
}
@Override
CompositeBuffer split(int splitOffset);
@Override
CompositeBuffer compact();
@Override
CompositeBuffer writeByte(byte value);
@Override
CompositeBuffer setByte(int woff, byte value);
@Override
CompositeBuffer writeUnsignedByte(int value);
@Override
CompositeBuffer setUnsignedByte(int woff, int value);
@Override
CompositeBuffer writeChar(char value);
@Override
CompositeBuffer setChar(int woff, char value);
@Override
CompositeBuffer writeShort(short value);
@Override
CompositeBuffer setShort(int woff, short value);
@Override
CompositeBuffer writeUnsignedShort(int value);
@Override
CompositeBuffer setUnsignedShort(int woff, int value);
@Override
CompositeBuffer writeMedium(int value);
@Override
CompositeBuffer setMedium(int woff, int value);
@Override
CompositeBuffer writeUnsignedMedium(int value);
@Override
CompositeBuffer setUnsignedMedium(int woff, int value);
@Override
CompositeBuffer writeInt(int value);
@Override
CompositeBuffer setInt(int woff, int value);
@Override
CompositeBuffer writeUnsignedInt(long value);
@Override
CompositeBuffer setUnsignedInt(int woff, long value);
@Override
CompositeBuffer writeFloat(float value);
@Override
CompositeBuffer setFloat(int woff, float value);
@Override
CompositeBuffer writeLong(long value);
@Override
CompositeBuffer setLong(int woff, long value);
@Override
CompositeBuffer writeDouble(double value);
@Override
CompositeBuffer setDouble(int woff, double value);
}

View File

@ -1,83 +0,0 @@
/*
* Copyright 2021 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License, version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at:
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package io.net5.buffer.api;
import io.net5.util.internal.PlatformDependent;
import io.net5.util.internal.SystemPropertyUtil;
import io.net5.util.internal.logging.InternalLogger;
import io.net5.util.internal.logging.InternalLoggerFactory;
import java.util.Locale;
import java.util.function.Supplier;
import static io.net5.buffer.api.BufferAllocator.offHeapPooled;
import static io.net5.buffer.api.BufferAllocator.offHeapUnpooled;
import static io.net5.buffer.api.BufferAllocator.onHeapPooled;
import static io.net5.buffer.api.BufferAllocator.onHeapUnpooled;
import static io.net5.util.internal.ObjectUtil.checkNotNullWithIAE;
import static io.net5.util.internal.PlatformDependent.directBufferPreferred;
import static java.lang.Runtime.getRuntime;
/**
* A {@link BufferAllocator} which is {@link #close() disposed} when the {@link Runtime} is shutdown.
*/
public final class DefaultGlobalBufferAllocator implements BufferAllocator {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(DefaultGlobalBufferAllocator.class);
public static final BufferAllocator DEFAUL_GLOBAL_BUFFER_ALLOCATOR;
static {
String allocType = SystemPropertyUtil.get(
"io.net5.allocator.type", PlatformDependent.isAndroid() ? "unpooled" : "pooled");
allocType = allocType.toLowerCase(Locale.US).trim();
BufferAllocator alloc;
if ("unpooled".equals(allocType)) {
alloc = directBufferPreferred() ? offHeapUnpooled() : onHeapUnpooled();
logger.debug("-Dio.net5.allocator.type: {}", allocType);
} else if ("pooled".equals(allocType)) {
alloc = directBufferPreferred() ? offHeapPooled() : onHeapPooled();
logger.debug("-Dio.net5.allocator.type: {}", allocType);
} else {
alloc = directBufferPreferred() ? offHeapPooled() : onHeapPooled();
logger.debug("-Dio.net5.allocator.type: pooled (unknown: {})", allocType);
}
DEFAUL_GLOBAL_BUFFER_ALLOCATOR = new DefaultGlobalBufferAllocator(alloc);
}
private final BufferAllocator delegate;
private DefaultGlobalBufferAllocator(BufferAllocator delegate) {
this.delegate = checkNotNullWithIAE(delegate, "delegate");
getRuntime().addShutdownHook(new Thread(this.delegate::close));
}
@Override
public Buffer allocate(int size) {
return delegate.allocate(size);
}
@Override
public Supplier<Buffer> constBufferSupplier(byte[] bytes) {
return delegate.constBufferSupplier(bytes);
}
/**
* @throws UnsupportedOperationException Close is not supported as this is a shared allocator.
*/
@Override
public void close() {
throw new UnsupportedOperationException("Global buffer allocator can not be closed explicitly.");
}
}

View File

@ -13,18 +13,18 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.AsciiString;
import io.net5.util.ByteProcessor;
import io.net5.util.CharsetUtil;
import io.net5.util.IllegalReferenceCountException;
import io.net5.util.ResourceLeakDetector;
import io.net5.util.ResourceLeakDetectorFactory;
import io.net5.util.internal.StringUtil;
import io.net5.util.internal.SystemPropertyUtil;
import io.net5.util.internal.logging.InternalLogger;
import io.net5.util.internal.logging.InternalLoggerFactory;
import io.netty.util.AsciiString;
import io.netty.util.ByteProcessor;
import io.netty.util.CharsetUtil;
import io.netty.util.IllegalReferenceCountException;
import io.netty.util.ResourceLeakDetector;
import io.netty.util.ResourceLeakDetectorFactory;
import io.netty.util.internal.StringUtil;
import io.netty.util.internal.SystemPropertyUtil;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
import java.io.IOException;
import java.io.InputStream;
@ -36,8 +36,8 @@ import java.nio.channels.GatheringByteChannel;
import java.nio.channels.ScatteringByteChannel;
import java.nio.charset.Charset;
import static io.net5.util.internal.MathUtil.isOutOfBounds;
import static io.net5.util.internal.ObjectUtil.checkPositiveOrZero;
import static io.netty.util.internal.MathUtil.isOutOfBounds;
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
import static java.util.Objects.requireNonNull;
/**
@ -45,9 +45,9 @@ import static java.util.Objects.requireNonNull;
*/
public abstract class AbstractByteBuf extends ByteBuf {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(AbstractByteBuf.class);
private static final String PROP_CHECK_ACCESSIBLE = "io.net5.buffer.checkAccessible";
private static final String PROP_CHECK_ACCESSIBLE = "io.netty.buffer.checkAccessible";
static final boolean checkAccessible; // accessed from CompositeByteBuf
private static final String PROP_CHECK_BOUNDS = "io.net5.buffer.checkBounds";
private static final String PROP_CHECK_BOUNDS = "io.netty.buffer.checkBounds";
private static final boolean checkBounds;
static {

View File

@ -14,15 +14,15 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import static io.net5.util.internal.ObjectUtil.checkPositiveOrZero;
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
import io.net5.util.ResourceLeakDetector;
import io.net5.util.ResourceLeakTracker;
import io.net5.util.internal.MathUtil;
import io.net5.util.internal.PlatformDependent;
import io.net5.util.internal.StringUtil;
import io.netty.util.ResourceLeakDetector;
import io.netty.util.ResourceLeakTracker;
import io.netty.util.internal.MathUtil;
import io.netty.util.internal.PlatformDependent;
import io.netty.util.internal.StringUtil;
/**
* Skeletal {@link ByteBufAllocator} implementation to extend.

View File

@ -14,7 +14,7 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import java.nio.ByteBuffer;

View File

@ -14,9 +14,9 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.ObjectPool.Handle;
import io.netty.util.internal.ObjectPool.Handle;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

View File

@ -14,11 +14,11 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import io.net5.util.internal.ReferenceCountUpdater;
import io.netty.util.internal.ReferenceCountUpdater;
/**
* Abstract base class for {@link ByteBuf} implementations that count references.

View File

@ -13,9 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.ByteProcessor;
import io.netty.util.ByteProcessor;
import java.io.IOException;
import java.io.InputStream;
@ -27,7 +27,7 @@ import java.nio.channels.GatheringByteChannel;
import java.nio.channels.ScatteringByteChannel;
import java.nio.charset.Charset;
import static io.net5.util.internal.MathUtil.isOutOfBounds;
import static io.netty.util.internal.MathUtil.isOutOfBounds;
abstract class AbstractUnpooledSlicedByteBuf extends AbstractDerivedByteBuf {
private final ByteBuf buffer;

View File

@ -13,13 +13,13 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.PlatformDependent;
import io.netty.util.internal.PlatformDependent;
import java.nio.ByteOrder;
import static io.net5.util.internal.PlatformDependent.BIG_ENDIAN_NATIVE_ORDER;
import static io.netty.util.internal.PlatformDependent.BIG_ENDIAN_NATIVE_ORDER;
/**
* Special {@link SwappedByteBuf} for {@link ByteBuf}s that is using unsafe.

View File

@ -14,14 +14,14 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.ByteProcessor;
import io.net5.util.ResourceLeakDetector;
import io.net5.util.ResourceLeakTracker;
import io.net5.util.internal.SystemPropertyUtil;
import io.net5.util.internal.logging.InternalLogger;
import io.net5.util.internal.logging.InternalLoggerFactory;
import io.netty.util.ByteProcessor;
import io.netty.util.ResourceLeakDetector;
import io.netty.util.ResourceLeakTracker;
import io.netty.util.internal.SystemPropertyUtil;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
import java.io.IOException;
import java.io.InputStream;
@ -36,7 +36,7 @@ import java.nio.charset.Charset;
final class AdvancedLeakAwareByteBuf extends SimpleLeakAwareByteBuf {
// If set to true we will only record stacktraces for touch(...), release(...) and retain(...) calls.
private static final String PROP_ACQUIRE_AND_RELEASE_ONLY = "io.net5.leakDetection.acquireAndReleaseOnly";
private static final String PROP_ACQUIRE_AND_RELEASE_ONLY = "io.netty.leakDetection.acquireAndReleaseOnly";
private static final boolean ACQUIRE_AND_RELEASE_ONLY;
private static final InternalLogger logger = InternalLoggerFactory.getInstance(AdvancedLeakAwareByteBuf.class);

View File

@ -13,11 +13,11 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.ByteProcessor;
import io.net5.util.ResourceLeakTracker;
import io.netty.util.ByteProcessor;
import io.netty.util.ResourceLeakTracker;
import java.io.IOException;
import java.io.InputStream;
@ -31,7 +31,7 @@ import java.nio.charset.Charset;
import java.util.Iterator;
import java.util.List;
import static io.net5.buffer.AdvancedLeakAwareByteBuf.recordLeakNonRefCountingOperation;
import static io.netty.buffer.AdvancedLeakAwareByteBuf.recordLeakNonRefCountingOperation;
final class AdvancedLeakAwareCompositeByteBuf extends SimpleLeakAwareCompositeByteBuf {

View File

@ -13,10 +13,10 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.ByteProcessor;
import io.net5.util.ReferenceCounted;
import io.netty.util.ByteProcessor;
import io.netty.util.ReferenceCounted;
import java.io.IOException;
import java.io.InputStream;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
/**
* Implementations are responsible to allocate buffers. Implementations of this interface are expected to be

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
public interface ByteBufAllocatorMetric {
/**

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
public interface ByteBufAllocatorMetricProvider {

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
/**
* An interface that can be implemented by any object that know how to turn itself into a {@link ByteBuf}.

View File

@ -13,9 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.ReferenceCounted;
import io.netty.util.ReferenceCounted;
/**
* A packet which is send or receive.

View File

@ -13,13 +13,13 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import static java.util.Objects.requireNonNull;
import static io.net5.util.internal.ObjectUtil.checkPositiveOrZero;
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
import io.net5.util.ReferenceCounted;
import io.net5.util.internal.StringUtil;
import io.netty.util.ReferenceCounted;
import io.netty.util.internal.StringUtil;
import java.io.DataInput;
import java.io.DataInputStream;

View File

@ -13,11 +13,11 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import static java.util.Objects.requireNonNull;
import io.net5.util.CharsetUtil;
import io.netty.util.CharsetUtil;
import java.io.DataOutput;
import java.io.DataOutputStream;

View File

@ -14,9 +14,9 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.ByteProcessor;
import io.netty.util.ByteProcessor;
/**
* @deprecated Use {@link ByteProcessor}.

View File

@ -13,21 +13,21 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.AsciiString;
import io.net5.util.ByteProcessor;
import io.net5.util.CharsetUtil;
import io.net5.util.IllegalReferenceCountException;
import io.net5.util.concurrent.FastThreadLocal;
import io.net5.util.internal.MathUtil;
import io.net5.util.internal.ObjectPool;
import io.net5.util.internal.ObjectPool.Handle;
import io.net5.util.internal.PlatformDependent;
import io.net5.util.internal.StringUtil;
import io.net5.util.internal.SystemPropertyUtil;
import io.net5.util.internal.logging.InternalLogger;
import io.net5.util.internal.logging.InternalLoggerFactory;
import io.netty.util.AsciiString;
import io.netty.util.ByteProcessor;
import io.netty.util.CharsetUtil;
import io.netty.util.IllegalReferenceCountException;
import io.netty.util.concurrent.FastThreadLocal;
import io.netty.util.internal.MathUtil;
import io.netty.util.internal.ObjectPool;
import io.netty.util.internal.ObjectPool.Handle;
import io.netty.util.internal.PlatformDependent;
import io.netty.util.internal.StringUtil;
import io.netty.util.internal.SystemPropertyUtil;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
import java.io.IOException;
import java.io.OutputStream;
@ -43,10 +43,10 @@ import java.nio.charset.CodingErrorAction;
import java.util.Arrays;
import java.util.Locale;
import static io.net5.util.internal.MathUtil.isOutOfBounds;
import static io.net5.util.internal.ObjectUtil.checkPositiveOrZero;
import static io.net5.util.internal.StringUtil.NEWLINE;
import static io.net5.util.internal.StringUtil.isSurrogate;
import static io.netty.util.internal.MathUtil.isOutOfBounds;
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
import static io.netty.util.internal.StringUtil.NEWLINE;
import static io.netty.util.internal.StringUtil.isSurrogate;
import static java.util.Objects.requireNonNull;
/**
@ -74,28 +74,28 @@ public final class ByteBufUtil {
static {
String allocType = SystemPropertyUtil.get(
"io.net5.allocator.type", PlatformDependent.isAndroid() ? "unpooled" : "pooled");
"io.netty.allocator.type", PlatformDependent.isAndroid() ? "unpooled" : "pooled");
allocType = allocType.toLowerCase(Locale.US).trim();
ByteBufAllocator alloc;
if ("unpooled".equals(allocType)) {
alloc = UnpooledByteBufAllocator.DEFAULT;
logger.debug("-Dio.net5.allocator.type: {}", allocType);
logger.debug("-Dio.netty.allocator.type: {}", allocType);
} else if ("pooled".equals(allocType)) {
alloc = PooledByteBufAllocator.DEFAULT;
logger.debug("-Dio.net5.allocator.type: {}", allocType);
logger.debug("-Dio.netty.allocator.type: {}", allocType);
} else {
alloc = PooledByteBufAllocator.DEFAULT;
logger.debug("-Dio.net5.allocator.type: pooled (unknown: {})", allocType);
logger.debug("-Dio.netty.allocator.type: pooled (unknown: {})", allocType);
}
DEFAULT_ALLOCATOR = alloc;
THREAD_LOCAL_BUFFER_SIZE = SystemPropertyUtil.getInt("io.net5.threadLocalDirectBufferSize", 0);
logger.debug("-Dio.net5.threadLocalDirectBufferSize: {}", THREAD_LOCAL_BUFFER_SIZE);
THREAD_LOCAL_BUFFER_SIZE = SystemPropertyUtil.getInt("io.netty.threadLocalDirectBufferSize", 0);
logger.debug("-Dio.netty.threadLocalDirectBufferSize: {}", THREAD_LOCAL_BUFFER_SIZE);
MAX_CHAR_BUFFER_SIZE = SystemPropertyUtil.getInt("io.net5.maxThreadLocalCharBufferSize", 16 * 1024);
logger.debug("-Dio.net5.maxThreadLocalCharBufferSize: {}", MAX_CHAR_BUFFER_SIZE);
MAX_CHAR_BUFFER_SIZE = SystemPropertyUtil.getInt("io.netty.maxThreadLocalCharBufferSize", 16 * 1024);
logger.debug("-Dio.netty.maxThreadLocalCharBufferSize: {}", MAX_CHAR_BUFFER_SIZE);
}
static final int MAX_TL_ARRAY_LEN = 1024;

View File

@ -13,15 +13,15 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import static java.util.Objects.requireNonNull;
import io.net5.util.ByteProcessor;
import io.net5.util.IllegalReferenceCountException;
import io.net5.util.ReferenceCountUtil;
import io.net5.util.internal.EmptyArrays;
import io.net5.util.internal.RecyclableArrayList;
import io.netty.util.ByteProcessor;
import io.netty.util.IllegalReferenceCountException;
import io.netty.util.ReferenceCountUtil;
import io.netty.util.internal.EmptyArrays;
import io.netty.util.internal.RecyclableArrayList;
import java.io.IOException;
import java.io.InputStream;

View File

@ -13,11 +13,11 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import static java.util.Objects.requireNonNull;
import io.net5.util.internal.StringUtil;
import io.netty.util.internal.StringUtil;
/**
* Default implementation of a {@link ByteBufHolder} that holds it's data in a {@link ByteBuf}.

View File

@ -13,9 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.ByteProcessor;
import io.netty.util.ByteProcessor;
import java.io.IOException;
import java.io.InputStream;

View File

@ -14,15 +14,15 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import static io.net5.util.internal.ObjectUtil.checkPositiveOrZero;
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
import static java.util.Objects.requireNonNull;
import io.net5.util.ByteProcessor;
import io.net5.util.internal.EmptyArrays;
import io.net5.util.internal.PlatformDependent;
import io.net5.util.internal.StringUtil;
import io.netty.util.ByteProcessor;
import io.netty.util.internal.EmptyArrays;
import io.netty.util.internal.PlatformDependent;
import io.netty.util.internal.StringUtil;
import java.io.InputStream;
import java.io.OutputStream;

View File

@ -13,10 +13,10 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.EmptyArrays;
import io.net5.util.internal.RecyclableArrayList;
import io.netty.util.internal.EmptyArrays;
import io.netty.util.internal.RecyclableArrayList;
import java.io.IOException;
import java.io.InputStream;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
/**
* Utility class for heap buffers.

View File

@ -14,10 +14,10 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.PlatformDependent;
import io.net5.util.internal.StringUtil;
import io.netty.util.internal.PlatformDependent;
import io.netty.util.internal.StringUtil;
import java.nio.ByteBuffer;
import java.util.ArrayList;
@ -26,7 +26,7 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.LongAdder;
import static io.net5.buffer.PoolChunk.isSubpage;
import static io.netty.buffer.PoolChunk.isSubpage;
import static java.lang.Math.max;
abstract class PoolArena<T> extends SizeClasses implements PoolArenaMetric {
@ -455,22 +455,6 @@ abstract class PoolArena<T> extends SizeClasses implements PoolArenaMetric {
return max(0, val);
}
/**
* Return the number of bytes that are currently pinned to buffer instances, by the arena. The pinned memory is not
* accessible for use by any other allocation, until the buffers using have all been released.
*/
public long numPinnedBytes() {
long val = activeBytesHuge.longValue(); // Huge chunks are exact-sized for the buffers they were allocated to.
synchronized (this) {
for (int i = 0; i < chunkListMetrics.size(); i++) {
for (PoolChunkMetric m: chunkListMetrics.get(i)) {
val += ((PoolChunk<?>) m).pinnedBytes();
}
}
}
return max(0, val);
}
protected abstract PoolChunk<T> newChunk(int pageSize, int maxPageIdx, int pageShifts, int chunkSize);
protected abstract PoolChunk<T> newUnpooledChunk(int capacity);
protected abstract PooledByteBuf<T> newByteBuf(int maxCapacity);

View File

@ -14,7 +14,7 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import java.util.List;

View File

@ -13,10 +13,10 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.LongLongHashMap;
import io.net5.util.internal.LongPriorityQueue;
import io.netty.util.internal.LongLongHashMap;
import io.netty.util.internal.LongPriorityQueue;
import java.nio.ByteBuffer;
import java.util.ArrayDeque;
@ -175,7 +175,6 @@ final class PoolChunk<T> implements PoolChunkMetric {
private final Deque<ByteBuffer> cachedNioBuffers;
int freeBytes;
int pinnedBytes;
PoolChunkList<T> parent;
PoolChunk<T> prev;
@ -343,9 +342,7 @@ final class PoolChunk<T> implements PoolChunkMetric {
handle = splitLargeRun(handle, pages);
}
int pinnedSize = runSize(pageShifts, handle);
freeBytes -= pinnedSize;
pinnedBytes += pinnedSize;
freeBytes -= runSize(pageShifts, handle);
return handle;
}
}
@ -454,8 +451,6 @@ final class PoolChunk<T> implements PoolChunkMetric {
* @param handle handle to free
*/
void free(long handle, int normCapacity, ByteBuffer nioBuffer) {
int runSize = runSize(pageShifts, handle);
pinnedBytes -= runSize;
if (isSubpage(handle)) {
int sizeIdx = arena.size2SizeIdx(normCapacity);
PoolSubpage<T> head = arena.findSubpagePoolHead(sizeIdx);
@ -478,6 +473,8 @@ final class PoolChunk<T> implements PoolChunkMetric {
}
//start free run
int pages = runPages(handle);
synchronized (runsAvail) {
// collapse continuous runs, successfully collapsed runs
// will be removed from runsAvail and runsAvailMap
@ -489,7 +486,7 @@ final class PoolChunk<T> implements PoolChunkMetric {
finalRun &= ~(1L << IS_SUBPAGE_SHIFT);
insertAvailRun(runOffset(finalRun), runPages(finalRun), finalRun);
freeBytes += runSize;
freeBytes += pages << pageShifts;
}
if (nioBuffer != null && cachedNioBuffers != null &&
@ -591,12 +588,6 @@ final class PoolChunk<T> implements PoolChunkMetric {
}
}
public int pinnedBytes() {
synchronized (arena) {
return pinnedBytes;
}
}
@Override
public String toString() {
final int freeBytes;

View File

@ -14,9 +14,9 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.StringUtil;
import io.netty.util.internal.StringUtil;
import java.util.ArrayList;
import java.util.Collections;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
/**
* Metrics for a list of chunks.

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
/**
* Metrics for a chunk.

View File

@ -14,13 +14,13 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import static io.net5.buffer.PoolChunk.RUN_OFFSET_SHIFT;
import static io.net5.buffer.PoolChunk.SIZE_SHIFT;
import static io.net5.buffer.PoolChunk.IS_USED_SHIFT;
import static io.net5.buffer.PoolChunk.IS_SUBPAGE_SHIFT;
import static io.net5.buffer.SizeClasses.LOG2_QUANTUM;
import static io.netty.buffer.PoolChunk.RUN_OFFSET_SHIFT;
import static io.netty.buffer.PoolChunk.SIZE_SHIFT;
import static io.netty.buffer.PoolChunk.IS_USED_SHIFT;
import static io.netty.buffer.PoolChunk.IS_SUBPAGE_SHIFT;
import static io.netty.buffer.SizeClasses.LOG2_QUANTUM;
final class PoolSubpage<T> implements PoolSubpageMetric {

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
/**
* Metrics for a sub-page.

View File

@ -14,18 +14,18 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import static io.net5.util.internal.ObjectUtil.checkPositiveOrZero;
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
import io.net5.buffer.PoolArena.SizeClass;
import io.net5.util.internal.MathUtil;
import io.net5.util.internal.ObjectPool;
import io.net5.util.internal.ObjectPool.Handle;
import io.net5.util.internal.PlatformDependent;
import io.net5.util.internal.logging.InternalLogger;
import io.net5.util.internal.logging.InternalLoggerFactory;
import io.netty.buffer.PoolArena.SizeClass;
import io.netty.util.internal.MathUtil;
import io.netty.util.internal.ObjectPool;
import io.netty.util.internal.ObjectPool.Handle;
import io.netty.util.internal.PlatformDependent;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
import java.nio.ByteBuffer;
import java.util.ArrayList;

View File

@ -14,9 +14,9 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.ObjectPool.Handle;
import io.netty.util.internal.ObjectPool.Handle;
import java.io.IOException;
import java.nio.ByteBuffer;

View File

@ -14,20 +14,20 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import static io.net5.util.internal.ObjectUtil.checkPositiveOrZero;
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
import io.net5.util.NettyRuntime;
import io.net5.util.concurrent.EventExecutor;
import io.net5.util.concurrent.FastThreadLocal;
import io.net5.util.concurrent.FastThreadLocalThread;
import io.net5.util.internal.PlatformDependent;
import io.net5.util.internal.StringUtil;
import io.net5.util.internal.SystemPropertyUtil;
import io.net5.util.internal.ThreadExecutorMap;
import io.net5.util.internal.logging.InternalLogger;
import io.net5.util.internal.logging.InternalLoggerFactory;
import io.netty.util.NettyRuntime;
import io.netty.util.concurrent.EventExecutor;
import io.netty.util.concurrent.FastThreadLocal;
import io.netty.util.concurrent.FastThreadLocalThread;
import io.netty.util.internal.PlatformDependent;
import io.netty.util.internal.StringUtil;
import io.netty.util.internal.SystemPropertyUtil;
import io.netty.util.internal.ThreadExecutorMap;
import io.netty.util.internal.logging.InternalLogger;
import io.netty.util.internal.logging.InternalLoggerFactory;
import java.nio.ByteBuffer;
import java.util.ArrayList;
@ -59,8 +59,8 @@ public class PooledByteBufAllocator extends AbstractByteBufAllocator implements
static {
int defaultAlignment = SystemPropertyUtil.getInt(
"io.net5.allocator.directMemoryCacheAlignment", 0);
int defaultPageSize = SystemPropertyUtil.getInt("io.net5.allocator.pageSize", 8192);
"io.netty.allocator.directMemoryCacheAlignment", 0);
int defaultPageSize = SystemPropertyUtil.getInt("io.netty.allocator.pageSize", 8192);
Throwable pageSizeFallbackCause = null;
try {
validateAndCalculatePageShifts(defaultPageSize, defaultAlignment);
@ -72,7 +72,7 @@ public class PooledByteBufAllocator extends AbstractByteBufAllocator implements
DEFAULT_PAGE_SIZE = defaultPageSize;
DEFAULT_DIRECT_MEMORY_CACHE_ALIGNMENT = defaultAlignment;
int defaultMaxOrder = SystemPropertyUtil.getInt("io.net5.allocator.maxOrder", 11);
int defaultMaxOrder = SystemPropertyUtil.getInt("io.netty.allocator.maxOrder", 11);
Throwable maxOrderFallbackCause = null;
try {
validateAndCalculateChunkSize(DEFAULT_PAGE_SIZE, defaultMaxOrder);
@ -97,62 +97,62 @@ public class PooledByteBufAllocator extends AbstractByteBufAllocator implements
final int defaultChunkSize = DEFAULT_PAGE_SIZE << DEFAULT_MAX_ORDER;
DEFAULT_NUM_HEAP_ARENA = Math.max(0,
SystemPropertyUtil.getInt(
"io.net5.allocator.numHeapArenas",
"io.netty.allocator.numHeapArenas",
(int) Math.min(
defaultMinNumArena,
runtime.maxMemory() / defaultChunkSize / 2 / 3)));
DEFAULT_NUM_DIRECT_ARENA = Math.max(0,
SystemPropertyUtil.getInt(
"io.net5.allocator.numDirectArenas",
"io.netty.allocator.numDirectArenas",
(int) Math.min(
defaultMinNumArena,
PlatformDependent.maxDirectMemory() / defaultChunkSize / 2 / 3)));
// cache sizes
DEFAULT_SMALL_CACHE_SIZE = SystemPropertyUtil.getInt("io.net5.allocator.smallCacheSize", 256);
DEFAULT_NORMAL_CACHE_SIZE = SystemPropertyUtil.getInt("io.net5.allocator.normalCacheSize", 64);
DEFAULT_SMALL_CACHE_SIZE = SystemPropertyUtil.getInt("io.netty.allocator.smallCacheSize", 256);
DEFAULT_NORMAL_CACHE_SIZE = SystemPropertyUtil.getInt("io.netty.allocator.normalCacheSize", 64);
// 32 kb is the default maximum capacity of the cached buffer. Similar to what is explained in
// 'Scalable memory allocation using jemalloc'
DEFAULT_MAX_CACHED_BUFFER_CAPACITY = SystemPropertyUtil.getInt(
"io.net5.allocator.maxCachedBufferCapacity", 32 * 1024);
"io.netty.allocator.maxCachedBufferCapacity", 32 * 1024);
// the number of threshold of allocations when cached entries will be freed up if not frequently used
DEFAULT_CACHE_TRIM_INTERVAL = SystemPropertyUtil.getInt(
"io.net5.allocator.cacheTrimInterval", 8192);
"io.netty.allocator.cacheTrimInterval", 8192);
DEFAULT_CACHE_TRIM_INTERVAL_MILLIS = SystemPropertyUtil.getLong(
"io.net5.allocator.cacheTrimIntervalMillis", 0);
"io.netty.allocator.cacheTrimIntervalMillis", 0);
DEFAULT_USE_CACHE_FOR_ALL_THREADS = SystemPropertyUtil.getBoolean(
"io.net5.allocator.useCacheForAllThreads", false);
"io.netty.allocator.useCacheForAllThreads", false);
// Use 1023 by default as we use an ArrayDeque as backing storage which will then allocate an internal array
// of 1024 elements. Otherwise we would allocate 2048 and only use 1024 which is wasteful.
DEFAULT_MAX_CACHED_BYTEBUFFERS_PER_CHUNK = SystemPropertyUtil.getInt(
"io.net5.allocator.maxCachedByteBuffersPerChunk", 1023);
"io.netty.allocator.maxCachedByteBuffersPerChunk", 1023);
if (logger.isDebugEnabled()) {
logger.debug("-Dio.net5.allocator.numHeapArenas: {}", DEFAULT_NUM_HEAP_ARENA);
logger.debug("-Dio.net5.allocator.numDirectArenas: {}", DEFAULT_NUM_DIRECT_ARENA);
logger.debug("-Dio.netty.allocator.numHeapArenas: {}", DEFAULT_NUM_HEAP_ARENA);
logger.debug("-Dio.netty.allocator.numDirectArenas: {}", DEFAULT_NUM_DIRECT_ARENA);
if (pageSizeFallbackCause == null) {
logger.debug("-Dio.net5.allocator.pageSize: {}", DEFAULT_PAGE_SIZE);
logger.debug("-Dio.netty.allocator.pageSize: {}", DEFAULT_PAGE_SIZE);
} else {
logger.debug("-Dio.net5.allocator.pageSize: {}", DEFAULT_PAGE_SIZE, pageSizeFallbackCause);
logger.debug("-Dio.netty.allocator.pageSize: {}", DEFAULT_PAGE_SIZE, pageSizeFallbackCause);
}
if (maxOrderFallbackCause == null) {
logger.debug("-Dio.net5.allocator.maxOrder: {}", DEFAULT_MAX_ORDER);
logger.debug("-Dio.netty.allocator.maxOrder: {}", DEFAULT_MAX_ORDER);
} else {
logger.debug("-Dio.net5.allocator.maxOrder: {}", DEFAULT_MAX_ORDER, maxOrderFallbackCause);
logger.debug("-Dio.netty.allocator.maxOrder: {}", DEFAULT_MAX_ORDER, maxOrderFallbackCause);
}
logger.debug("-Dio.net5.allocator.chunkSize: {}", DEFAULT_PAGE_SIZE << DEFAULT_MAX_ORDER);
logger.debug("-Dio.net5.allocator.smallCacheSize: {}", DEFAULT_SMALL_CACHE_SIZE);
logger.debug("-Dio.net5.allocator.normalCacheSize: {}", DEFAULT_NORMAL_CACHE_SIZE);
logger.debug("-Dio.net5.allocator.maxCachedBufferCapacity: {}", DEFAULT_MAX_CACHED_BUFFER_CAPACITY);
logger.debug("-Dio.net5.allocator.cacheTrimInterval: {}", DEFAULT_CACHE_TRIM_INTERVAL);
logger.debug("-Dio.net5.allocator.cacheTrimIntervalMillis: {}", DEFAULT_CACHE_TRIM_INTERVAL_MILLIS);
logger.debug("-Dio.net5.allocator.useCacheForAllThreads: {}", DEFAULT_USE_CACHE_FOR_ALL_THREADS);
logger.debug("-Dio.net5.allocator.maxCachedByteBuffersPerChunk: {}",
logger.debug("-Dio.netty.allocator.chunkSize: {}", DEFAULT_PAGE_SIZE << DEFAULT_MAX_ORDER);
logger.debug("-Dio.netty.allocator.smallCacheSize: {}", DEFAULT_SMALL_CACHE_SIZE);
logger.debug("-Dio.netty.allocator.normalCacheSize: {}", DEFAULT_NORMAL_CACHE_SIZE);
logger.debug("-Dio.netty.allocator.maxCachedBufferCapacity: {}", DEFAULT_MAX_CACHED_BUFFER_CAPACITY);
logger.debug("-Dio.netty.allocator.cacheTrimInterval: {}", DEFAULT_CACHE_TRIM_INTERVAL);
logger.debug("-Dio.netty.allocator.cacheTrimIntervalMillis: {}", DEFAULT_CACHE_TRIM_INTERVAL_MILLIS);
logger.debug("-Dio.netty.allocator.useCacheForAllThreads: {}", DEFAULT_USE_CACHE_FOR_ALL_THREADS);
logger.debug("-Dio.netty.allocator.maxCachedByteBuffersPerChunk: {}",
DEFAULT_MAX_CACHED_BYTEBUFFERS_PER_CHUNK);
}
}
@ -384,42 +384,42 @@ public class PooledByteBufAllocator extends AbstractByteBufAllocator implements
}
/**
* Default number of heap arenas - System Property: io.net5.allocator.numHeapArenas - default 2 * cores
* Default number of heap arenas - System Property: io.netty.allocator.numHeapArenas - default 2 * cores
*/
public static int defaultNumHeapArena() {
return DEFAULT_NUM_HEAP_ARENA;
}
/**
* Default number of direct arenas - System Property: io.net5.allocator.numDirectArenas - default 2 * cores
* Default number of direct arenas - System Property: io.netty.allocator.numDirectArenas - default 2 * cores
*/
public static int defaultNumDirectArena() {
return DEFAULT_NUM_DIRECT_ARENA;
}
/**
* Default buffer page size - System Property: io.net5.allocator.pageSize - default 8192
* Default buffer page size - System Property: io.netty.allocator.pageSize - default 8192
*/
public static int defaultPageSize() {
return DEFAULT_PAGE_SIZE;
}
/**
* Default maximum order - System Property: io.net5.allocator.maxOrder - default 11
* Default maximum order - System Property: io.netty.allocator.maxOrder - default 11
*/
public static int defaultMaxOrder() {
return DEFAULT_MAX_ORDER;
}
/**
* Default thread caching behavior - System Property: io.net5.allocator.useCacheForAllThreads - default true
* Default thread caching behavior - System Property: io.netty.allocator.useCacheForAllThreads - default true
*/
public static boolean defaultUseCacheForAllThreads() {
return DEFAULT_USE_CACHE_FOR_ALL_THREADS;
}
/**
* Default prefer direct - System Property: io.net5.noPreferDirect - default false
* Default prefer direct - System Property: io.netty.noPreferDirect - default false
*/
public static boolean defaultPreferDirect() {
return PlatformDependent.directBufferPreferred();
@ -436,14 +436,14 @@ public class PooledByteBufAllocator extends AbstractByteBufAllocator implements
}
/**
* Default small cache size - System Property: io.net5.allocator.smallCacheSize - default 256
* Default small cache size - System Property: io.netty.allocator.smallCacheSize - default 256
*/
public static int defaultSmallCacheSize() {
return DEFAULT_SMALL_CACHE_SIZE;
}
/**
* Default normal cache size - System Property: io.net5.allocator.normalCacheSize - default 64
* Default normal cache size - System Property: io.netty.allocator.normalCacheSize - default 64
*/
public static int defaultNormalCacheSize() {
return DEFAULT_NORMAL_CACHE_SIZE;
@ -658,40 +658,6 @@ public class PooledByteBufAllocator extends AbstractByteBufAllocator implements
return used;
}
/**
* Returns the number of bytes of heap memory that is currently pinned to heap buffers allocated by a
* {@link ByteBufAllocator}, or {@code -1} if unknown.
* A buffer can pin more memory than its {@linkplain ByteBuf#capacity() capacity} might indicate,
* due to implementation details of the allocator.
*/
public final long pinnedHeapMemory() {
return pinnedMemory(heapArenas);
}
/**
* Returns the number of bytes of direct memory that is currently pinned to direct buffers allocated by a
* {@link ByteBufAllocator}, or {@code -1} if unknown.
* A buffer can pin more memory than its {@linkplain ByteBuf#capacity() capacity} might indicate,
* due to implementation details of the allocator.
*/
public final long pinnedDirectMemory() {
return pinnedMemory(directArenas);
}
private static long pinnedMemory(PoolArena<?>[] arenas) {
if (arenas == null) {
return -1;
}
long used = 0;
for (PoolArena<?> arena : arenas) {
used += arena.numPinnedBytes();
if (used < 0) {
return Long.MAX_VALUE;
}
}
return used;
}
final PoolThreadCache threadCache() {
PoolThreadCache cache = threadCache.get();
assert cache != null;

View File

@ -13,9 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.StringUtil;
import io.netty.util.internal.StringUtil;
import java.util.List;

View File

@ -14,10 +14,10 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.ObjectPool;
import io.net5.util.internal.ObjectPool.Handle;
import io.netty.util.internal.ObjectPool;
import io.netty.util.internal.ObjectPool.Handle;
import java.io.IOException;
import java.io.InputStream;

View File

@ -14,11 +14,11 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.ByteProcessor;
import io.net5.util.internal.ObjectPool;
import io.net5.util.internal.ObjectPool.Handle;
import io.netty.util.ByteProcessor;
import io.netty.util.internal.ObjectPool;
import io.netty.util.internal.ObjectPool.Handle;
import java.io.IOException;
import java.io.InputStream;

View File

@ -12,11 +12,11 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.ObjectPool;
import io.net5.util.internal.ObjectPool.Handle;
import io.net5.util.internal.PlatformDependent;
import io.netty.util.internal.ObjectPool;
import io.netty.util.internal.ObjectPool.Handle;
import io.netty.util.internal.PlatformDependent;
import java.io.IOException;
import java.io.InputStream;

View File

@ -14,11 +14,11 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.ByteProcessor;
import io.net5.util.internal.ObjectPool;
import io.net5.util.internal.ObjectPool.Handle;
import io.netty.util.ByteProcessor;
import io.netty.util.internal.ObjectPool;
import io.netty.util.internal.ObjectPool.Handle;
import java.io.IOException;
import java.io.InputStream;
@ -28,7 +28,7 @@ import java.nio.channels.FileChannel;
import java.nio.channels.GatheringByteChannel;
import java.nio.channels.ScatteringByteChannel;
import static io.net5.buffer.AbstractUnpooledSlicedByteBuf.checkSliceOutOfBounds;
import static io.netty.buffer.AbstractUnpooledSlicedByteBuf.checkSliceOutOfBounds;
final class PooledSlicedByteBuf extends AbstractPooledDerivedByteBuf {

View File

@ -14,11 +14,11 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.ObjectPool;
import io.net5.util.internal.ObjectPool.Handle;
import io.net5.util.internal.PlatformDependent;
import io.netty.util.internal.ObjectPool;
import io.netty.util.internal.ObjectPool.Handle;
import io.netty.util.internal.PlatformDependent;
import java.io.IOException;
import java.io.InputStream;

View File

@ -13,11 +13,11 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.ObjectPool;
import io.net5.util.internal.ObjectPool.Handle;
import io.net5.util.internal.PlatformDependent;
import io.netty.util.internal.ObjectPool;
import io.netty.util.internal.ObjectPool.Handle;
import io.netty.util.internal.PlatformDependent;
final class PooledUnsafeHeapByteBuf extends PooledHeapByteBuf {

View File

@ -13,9 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.ByteProcessor;
import io.netty.util.ByteProcessor;
import java.io.IOException;
import java.io.InputStream;

View File

@ -13,9 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.StringUtil;
import io.netty.util.internal.StringUtil;
import java.io.IOException;
import java.io.InputStream;

View File

@ -13,14 +13,14 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import static java.util.Objects.requireNonNull;
import java.nio.ByteBuffer;
import io.net5.util.internal.PlatformDependent;
import io.netty.util.internal.PlatformDependent;
/**

View File

@ -14,12 +14,12 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import static java.util.Objects.requireNonNull;
import io.net5.util.ResourceLeakDetector;
import io.net5.util.ResourceLeakTracker;
import io.netty.util.ResourceLeakDetector;
import io.netty.util.ResourceLeakTracker;
import java.nio.ByteOrder;

View File

@ -13,11 +13,11 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import static java.util.Objects.requireNonNull;
import io.net5.util.ResourceLeakTracker;
import io.netty.util.ResourceLeakTracker;
import java.nio.ByteOrder;

View File

@ -13,9 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import static io.net5.buffer.PoolThreadCache.*;
import static io.netty.buffer.PoolThreadCache.*;
/**
* SizeClasses requires {@code pageShifts} to be defined prior to inclusion,

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
/**
* Expose metrics for an SizeClasses.

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
/**
* A derived buffer which exposes its parent's sub-region only. It is

View File

@ -13,11 +13,11 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import static java.util.Objects.requireNonNull;
import io.net5.util.ByteProcessor;
import io.netty.util.ByteProcessor;
import java.io.IOException;
import java.io.InputStream;

View File

@ -13,13 +13,13 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import static java.util.Objects.requireNonNull;
import io.net5.buffer.CompositeByteBuf.ByteWrapper;
import io.net5.util.CharsetUtil;
import io.net5.util.internal.PlatformDependent;
import io.netty.buffer.CompositeByteBuf.ByteWrapper;
import io.netty.util.CharsetUtil;
import io.netty.util.internal.PlatformDependent;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@ -36,7 +36,7 @@ import java.util.Arrays;
* This classes is intended to be used with Java 5 static import statement:
*
* <pre>
* import static io.net5.buffer.{@link Unpooled}.*;
* import static io.netty.buffer.{@link Unpooled}.*;
*
* {@link ByteBuf} heapBuffer = buffer(128);
* {@link ByteBuf} directBuffer = directBuffer(256);

View File

@ -13,10 +13,10 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.PlatformDependent;
import io.net5.util.internal.StringUtil;
import io.netty.util.internal.PlatformDependent;
import io.netty.util.internal.StringUtil;
import java.nio.ByteBuffer;
import java.util.concurrent.atomic.LongAdder;

View File

@ -13,12 +13,12 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import static io.net5.util.internal.ObjectUtil.checkPositiveOrZero;
import static io.netty.util.internal.ObjectUtil.checkPositiveOrZero;
import static java.util.Objects.requireNonNull;
import io.net5.util.internal.PlatformDependent;
import io.netty.util.internal.PlatformDependent;
import java.io.IOException;
import java.io.InputStream;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
/**
* {@link DuplicatedByteBuf} implementation that can do optimizations because it knows the duplicated buffer

View File

@ -13,12 +13,12 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import static java.util.Objects.requireNonNull;
import io.net5.util.internal.EmptyArrays;
import io.net5.util.internal.PlatformDependent;
import io.netty.util.internal.EmptyArrays;
import io.netty.util.internal.PlatformDependent;
import java.io.IOException;
import java.io.InputStream;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
/**
* A special {@link AbstractUnpooledSlicedByteBuf} that can make optimizations because it knows the sliced buffer is of

View File

@ -13,9 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.PlatformDependent;
import io.netty.util.internal.PlatformDependent;
import java.io.IOException;
import java.io.InputStream;

View File

@ -13,9 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.PlatformDependent;
import io.netty.util.internal.PlatformDependent;
/**
* Big endian Java heap buffer implementation. It is recommended to use

View File

@ -13,9 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.PlatformDependent;
import io.netty.util.internal.PlatformDependent;
import java.nio.ByteBuffer;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import static java.util.Objects.requireNonNull;

View File

@ -13,9 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.PlatformDependent;
import io.netty.util.internal.PlatformDependent;
import java.io.IOException;
import java.io.InputStream;
@ -24,8 +24,8 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
import static io.net5.util.internal.MathUtil.isOutOfBounds;
import static io.net5.util.internal.PlatformDependent.BIG_ENDIAN_NATIVE_ORDER;
import static io.netty.util.internal.MathUtil.isOutOfBounds;
import static io.netty.util.internal.PlatformDependent.BIG_ENDIAN_NATIVE_ORDER;
import static java.util.Objects.requireNonNull;
/**

View File

@ -14,9 +14,9 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.PlatformDependent;
import io.netty.util.internal.PlatformDependent;
/**
* Special {@link SwappedByteBuf} for {@link ByteBuf}s that are backed by a {@code memoryAddress}.

View File

@ -14,9 +14,9 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.PlatformDependent;
import io.netty.util.internal.PlatformDependent;
/**
* Special {@link SwappedByteBuf} for {@link ByteBuf}s that use unsafe to access the byte array.

View File

@ -14,12 +14,12 @@
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import static java.util.Objects.requireNonNull;
import io.net5.util.ByteProcessor;
import io.net5.util.internal.StringUtil;
import io.netty.util.ByteProcessor;
import io.netty.util.internal.StringUtil;
import java.io.IOException;
import java.io.InputStream;

View File

@ -13,9 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.ByteProcessor;
import io.netty.util.ByteProcessor;
import java.io.IOException;
import java.io.InputStream;

View File

@ -13,9 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer;
package io.netty.buffer;
import io.net5.util.internal.PlatformDependent;
import io.netty.util.internal.PlatformDependent;
import java.nio.ByteBuffer;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer.api;
package io.netty.buffer.api;
/**
* An object used by {@linkplain BufferAllocator buffer allocators} to communicate desirable properties of an

View File

@ -13,9 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer.api;
package io.netty.buffer.api;
import io.net5.util.internal.UnstableApi;
import io.netty.util.internal.UnstableApi;
/**
* Methods for accessing and controlling the internals of an allocator.

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer.api;
package io.netty.buffer.api;
import java.nio.ByteBuffer;
@ -172,6 +172,12 @@ public interface Buffer extends Resource<Buffer>, BufferAccessor {
*/
Buffer fill(byte value);
/**
* Gives the native memory address backing this buffer, or return 0 if this buffer has no native memory address.
* @return The native memory address, if any, otherwise 0.
*/
long nativeAddress();
/**
* Makes this buffer read-only. This is irreversible.
* This operation is also idempotent, so calling this method multiple times on the same buffer makes no difference.

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer.api;
package io.netty.buffer.api;
/**
* This interface is just the primitive data accessor methods that {@link Buffer} exposes.

View File

@ -13,9 +13,9 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer.api;
package io.netty.buffer.api;
import io.net5.buffer.api.pool.PooledBufferAllocator;
import io.netty.buffer.api.pool.PooledBufferAllocator;
import java.util.function.Supplier;
@ -25,9 +25,8 @@ import java.util.function.Supplier;
public interface BufferAllocator extends AutoCloseable {
/**
* Produces a {@link BufferAllocator} that allocates unpooled, on-heap buffers.
* On-heap buffers have a {@code byte[]} internally, and their
* {@linkplain ReadableComponent#readableNativeAddress() readable} and
* {@linkplain WritableComponent#writableNativeAddress() writable} native addresses are zero.
* On-heap buffers have a {@code byte[]} internally, and their {@linkplain Buffer#nativeAddress() native address}
* is zero.
* <p>
* The concrete {@link Buffer} implementation is chosen by {@link MemoryManager#instance()}.
*
@ -40,8 +39,7 @@ public interface BufferAllocator extends AutoCloseable {
/**
* Produces a {@link BufferAllocator} that allocates unpooled, off-heap buffers.
* Off-heap buffers a native memory pointer internally, which can be obtained from their
* {@linkplain ReadableComponent#readableNativeAddress() readable} and
* {@linkplain WritableComponent#writableNativeAddress() writable} native address methods.
* {@linkplain Buffer#nativeAddress() native address method.
* <p>
* The concrete {@link Buffer} implementation is chosen by {@link MemoryManager#instance()}.
*
@ -53,9 +51,8 @@ public interface BufferAllocator extends AutoCloseable {
/**
* Produces a pooling {@link BufferAllocator} that allocates and recycles on-heap buffers.
* On-heap buffers have a {@code byte[]} internally, and their
* {@linkplain ReadableComponent#readableNativeAddress() readable} and
* {@linkplain WritableComponent#writableNativeAddress() writable} native addresses are zero.
* On-heap buffers have a {@code byte[]} internally, and their {@linkplain Buffer#nativeAddress() native address}
* is zero.
* <p>
* The concrete {@link Buffer} implementation is chosen by {@link MemoryManager#instance()}.
*
@ -68,8 +65,7 @@ public interface BufferAllocator extends AutoCloseable {
/**
* Produces a pooling {@link BufferAllocator} that allocates and recycles off-heap buffers.
* Off-heap buffers a native memory pointer internally, which can be obtained from their
* {@linkplain ReadableComponent#readableNativeAddress() readable} and
* {@linkplain WritableComponent#writableNativeAddress() writable} native address methods.
* {@linkplain Buffer#nativeAddress() native address method.
* <p>
* The concrete {@link Buffer} implementation is chosen by {@link MemoryManager#instance()}.
*

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer.api;
package io.netty.buffer.api;
/**
* An exception thrown when an operation is attempted on a {@link Buffer} when it has been closed.

View File

@ -13,10 +13,10 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer.api;
package io.netty.buffer.api;
import io.net5.buffer.api.internal.ResourceSupport;
import io.net5.buffer.api.internal.Statics;
import io.netty.buffer.api.internal.ResourceSupport;
import io.netty.buffer.api.internal.Statics;
import java.lang.invoke.VarHandle;
import java.util.Objects;

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer.api;
package io.netty.buffer.api;
/**
* An exception thrown when an operation is attempted on a {@linkplain Buffer#readOnly() read-only} {@link Buffer}.

View File

@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.net5.buffer.api;
package io.netty.buffer.api;
import java.lang.invoke.VarHandle;

Some files were not shown because too many files have changed in this diff Show More