Skip to content

Commit

Permalink
[tiered storage] Use NAR plugin to package offloaders (apache#2393)
Browse files Browse the repository at this point in the history
 ### Motivation

Offloader typically involves a new storage system, which usually involves dependencies that
might be conflicting with the dependencies of Pulsar. We want to package offloader implementations
as what we did for connectors, so people can decide which offloader to use and only include it.
People would also become easier to write its offloader if needed.

 ### Changes

- Update `tiered-storage/jcloud` to package it using nifi-nar plugin.
- Add bunch of utils in managed-ledger to locate offloader nar packages and load `LedgerOffloaderFactory` from corresponding NAR package.
- Add a new distribution module to package offloaders into one distribution, as what we did for connectors.
- Update pulsar-all image to include offloaders

 ### NOTES

This change doesn't get rid of jcloud-shaded. because jcloud is using `ServiceLoad` and Guice injection. It makes
things very tricky on class loading. Not attempt to address the problem any time soon. We can pin `jcloud-shaded` version
as what we did for `protobuf-shaded` in next release.
  • Loading branch information
sijie authored Aug 29, 2018
1 parent 6aaf613 commit 9c1503b
Show file tree
Hide file tree
Showing 17 changed files with 474 additions and 28 deletions.
3 changes: 3 additions & 0 deletions conf/broker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,9 @@ schemaRegistryStorageClassName=org.apache.pulsar.broker.service.schema.Bookkeepe

### --- Ledger Offloading --- ###

# The directory for all the offloader implementations
offloadersDirectory=./offloaders

# Driver to use to offload old data to long term storage (Possible values: S3, aws-s3, google-cloud-storage)
# When using google-cloud-storage, Make sure both Google Cloud Storage and Google Cloud Storage JSON API are enabled for
# the project (check from Developers Console -> Api&auth -> APIs).
Expand Down
68 changes: 68 additions & 0 deletions distribution/offloaders/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF 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
http://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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.pulsar</groupId>
<artifactId>distribution</artifactId>
<version>2.2.0-incubating-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

<artifactId>pulsar-offloader-distribution</artifactId>
<packaging>pom</packaging>
<name>Pulsar :: Distribution :: Offloader</name>

<dependencies>
<dependency>
<groupId>org.apache.pulsar</groupId>
<artifactId>managed-ledger-original</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>distro-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<attach>true</attach>
<tarLongFileMode>posix</tarLongFileMode>
<finalName>apache-pulsar-offloaders-${project.version}</finalName>
<descriptors>
<descriptor>src/assemble/offloaders.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
10 changes: 10 additions & 0 deletions distribution/offloaders/src/assemble/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

Please refer to http://pulsar.incubator.apache.org/ for access to documentation.

This package contains Pulsar offloader archives. Each archive
contains:

* the offloader code plus all the dependencies

* META-INF/DEPEDENCIES file with licensing information for all transitive
dependencies
54 changes: 54 additions & 0 deletions distribution/offloaders/src/assemble/offloaders.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF 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
http://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.
-->
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>bin</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<files>
<file>
<source>${basedir}/../../DISCLAIMER</source>
<outputDirectory>.</outputDirectory>
<fileMode>644</fileMode>
</file>
<file>
<source>${basedir}/../../LICENSE</source>
<outputDirectory>.</outputDirectory>
<fileMode>644</fileMode>
</file>
<file>
<source>${basedir}/src/assemble/README</source>
<destName>README</destName>
<outputDirectory>.</outputDirectory>
<fileMode>644</fileMode>
</file>

<file>
<source>${basedir}/../../tiered-storage/jcloud/target/tiered-storage-jcloud-${project.version}.nar</source>
<outputDirectory>offloaders</outputDirectory>
<fileMode>644</fileMode>
</file>
</files>
</assembly>
1 change: 1 addition & 0 deletions distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
<modules>
<module>server</module>
<module>io</module>
<module>offloaders</module>
</modules>
</project>
14 changes: 0 additions & 14 deletions distribution/server/src/assemble/LICENSE.bin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ The Apache Software License, Version 2.0
- com.fasterxml.jackson.core-jackson-annotations-2.8.4.jar
- com.fasterxml.jackson.core-jackson-core-2.8.4.jar
- com.fasterxml.jackson.core-jackson-databind-2.8.4.jar
- com.fasterxml.jackson.dataformat-jackson-dataformat-cbor-2.6.7.jar
- com.fasterxml.jackson.dataformat-jackson-dataformat-yaml-2.8.4.jar
- com.fasterxml.jackson.jaxrs-jackson-jaxrs-base-2.8.4.jar
- com.fasterxml.jackson.jaxrs-jackson-jaxrs-json-provider-2.8.4.jar
Expand Down Expand Up @@ -359,7 +358,6 @@ The Apache Software License, Version 2.0
- io.prometheus-simpleclient_hotspot-0.0.23.jar
- io.prometheus-simpleclient_servlet-0.0.23.jar
* Bean Validation API -- javax.validation-validation-api-1.1.0.Final.jar
* Joda Time -- joda-time-joda-time-2.8.1.jar
* Log4J
- log4j-log4j-1.2.17.jar
- org.apache.logging.log4j-log4j-api-2.10.0.jar
Expand Down Expand Up @@ -419,9 +417,6 @@ The Apache Software License, Version 2.0
* OkHttp - com.squareup.okhttp-okhttp-2.5.0.jar
* Okio - com.squareup.okio-okio-1.13.0.jar
* Javassist -- org.javassist-javassist-3.21.0-GA.jar
* Amazon AWS SDK
- com.amazonaws-aws-java-sdk-core-1.11.297.jar
- software.amazon.ion-ion-java-1.0.2.jar
* gRPC
- io.grpc-grpc-all-1.12.0.jar
- io.grpc-grpc-auth-1.12.0.jar
Expand Down Expand Up @@ -455,10 +450,6 @@ The Apache Software License, Version 2.0
- org.xerial.snappy-snappy-java-1.1.1.3.jar
* Objenesis
- org.objenesis-objenesis-2.1.jar
* Java Dependency Injection
- javax.inject-javax.inject-1.jar
* java-xmlbuilder
- com.jamesmurty.utils-java-xmlbuilder-1.1.jar


BSD 3-clause "New" or "Revised" License
Expand Down Expand Up @@ -492,7 +483,6 @@ Protocol Buffers License
CDDL-1.1 -- licenses/LICENSE-CDDL-1.1.txt
* Java Annotations API
- javax.annotation-javax.annotation-api-1.2.jar
- javax.annotation-jsr250-api-1.0.jar
* Java Servlet API -- javax.servlet-javax.servlet-api-3.1.0.jar
* WebSocket Server API -- javax.websocket-javax.websocket-api-1.0.jar
* Java Web Service REST API -- javax.ws.rs-javax.ws.rs-api-2.1.jar
Expand Down Expand Up @@ -524,10 +514,6 @@ Eclipse Public License 1.0 -- licenses/LICENSE-AspectJ.txt
Public Domain
* XZ for Java -- licenses/LICENSE-xz.txt
- org.tukaani-xz-1.5.jar
* iHarder.net Base64
- net.iharder-base64-2.3.8.jar
* AOP Alliance
- aopalliance-aopalliance-1.0.jar

Public Domain (CC0) -- licenses/LICENSE-CC0.txt
* Reactive Streams -- org.reactivestreams-reactive-streams-1.0.0.jar
Expand Down
4 changes: 4 additions & 0 deletions docker/pulsar-all/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
FROM apachepulsar/pulsar:latest

ARG PULSAR_IO_TARBALL
ARG PULSAR_OFFLOADER_TARBALL

ADD ${PULSAR_IO_TARBALL} /
RUN mv /apache-pulsar-io-connectors-*/connectors /pulsar/connectors

ADD ${PULSAR_OFFLOADER_TARBALL} /
RUN mv /apache-pulsar-offloaders-*/offloaders /pulsar/offloaders
21 changes: 21 additions & 0 deletions docker/pulsar-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
<type>tar.gz</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.pulsar</groupId>
<artifactId>pulsar-offloader-distribution</artifactId>
<version>${project.parent.version}</version>
<classifier>bin</classifier>
<type>tar.gz</type>
<scope>provided</scope>
</dependency>
</dependencies>

<profiles>
Expand Down Expand Up @@ -72,6 +80,18 @@
<excludeTransitive>true</excludeTransitive>
</configuration>
</execution>
<execution>
<id>copy-offloader-tarball</id>
<goals>
<goal>copy-dependencies</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<outputDirectory>${project.build.directory}/</outputDirectory>
<includeArtifactIds>pulsar-offloader-distribution</includeArtifactIds>
<excludeTransitive>true</excludeTransitive>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
Expand Down Expand Up @@ -103,6 +123,7 @@
<tag>${project.version}</tag>
<buildArgs>
<PULSAR_IO_TARBALL>target/pulsar-io-distribution-${project.version}-bin.tar.gz</PULSAR_IO_TARBALL>
<PULSAR_OFFLOADER_TARBALL>target/pulsar-offloader-distribution-${project.version}-bin.tar.gz</PULSAR_OFFLOADER_TARBALL>
</buildArgs>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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
*
* http://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 org.apache.bookkeeper.mledger.offload;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
* Definition of an offloader NAR package.
*/
@Data
@NoArgsConstructor
public class OffloaderDefinition {

/**
* The name of the offloader type.
*/
private String name;

/**
* Description to be used for user help.
*/
private String description;

/**
* The class name for the offloader factory implementation.
*/
private String offloaderFactoryClass;

}
Loading

0 comments on commit 9c1503b

Please sign in to comment.