Skip to content

Refactored JCloud Tiered Storage - #2865

Closed
david-streamlio wants to merge 12 commits into
apache:masterfrom
david-streamlio:jcloud-refactor
Closed

david-streamlio wants to merge 12 commits into
apache:masterfrom
david-streamlio:jcloud-refactor

Conversation

@david-streamlio

Copy link
Copy Markdown
Contributor

Motivation

In order to facilitate the support of additional JClouds-supported providers, we first needed to clean up the existing code, as there were a lot of if/then/else constructs throughout the code that were based on the assumption that we either supported AWS S3 or Google Cloud Storage. I didn't want to keep adding else if's to these code blocks for every new provider we add, so I decided to refactor the code to make it a bit cleaner

Modifications

in addition to being home for most of the aforementioned if/then/else blocks, the BlobStoreManagedLedgerOffloader class had multiple responsibilities in addition to providing an implementation for the LedgerOffloader interface. My goal was to simplify this class such that its only responsibility was to implement the LedgerOffloader interface.

The other major change was the addition of the JCloudBlobStoreProvider enum, which implements 3 interfaces that allow for it to handle the provider specific logic for things such as acquiring the credentials, validating the configuration, and creating a provider-specific instance of BlobStore.

Result

After this change, we will be able to easily add support for additional JClouds-supported providers by simply adding new elements to the JCloudBlobStoreProvider Enums since the other logic has been isolated and is not vendor specific.

@sijie
sijie requested review from ivankelly, jiazhai and sijie October 28, 2018 12:51
@sijie sijie added this to the 2.3.0 milestone Oct 28, 2018
Comment thread tiered-storage/jcloud/pom.xml Resolved
@jiazhai

jiazhai commented Oct 29, 2018

Copy link
Copy Markdown
Member

rerun integration tests

@jiazhai

jiazhai commented Oct 29, 2018

Copy link
Copy Markdown
Member

@sijie sijie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good to me. +1

@ivankelly ivankelly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got about 25% through before time ran out. Lots of unrelated changes that should be in a their own cleanup patch, but i guess it's ok this time. Will come back to it later.

import java.io.IOException;
import java.io.InputStream;

/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change, along with several others you have flagged as "unrelated" are actually changes made to conform with the check style rules defined in the pulsar/buildtools/src/main/resources/pulsar/checkstyle.xml file.

Before I commit my changes I run "mvn -Pcontrib-check clean install" , which flags any check style violations.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not saying these changes are wrong. But they're in the wrong PR. This PR is 1500+ lines long. There are substantive code changes in it and stuff that normally could be waved through with a quick glance. But given that there are some real changes, all 1500 lines of change must be looked at carefully.

import java.io.IOException;
import java.io.InputStream;

/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not saying these changes are wrong. But they're in the wrong PR. This PR is 1500+ lines long. There are substantive code changes in it and stuff that normally could be waved through with a quick glance. But given that there are some real changes, all 1500 lines of change must be looked at carefully.

@ivankelly

Copy link
Copy Markdown
Contributor

rerun integration tests

@ivankelly ivankelly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still looks like it's breaking BC in a lot of places, which I guess is why integration are failing.

Comment thread tiered-storage/jcloud/pom.xml Resolved
David Kjerrumgaard added 2 commits December 4, 2018 19:12

@ivankelly ivankelly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better, though you don't need to expose the map, since you can mock the passed in config. Mocking the config would allow you to assign writeBlobStore in the constructor also.

Regarding the integration tests, I don't think they will ever pass with the current change due to the config changes, but am happy to be proven wrong on this. They seems to be generally passing on master.

@david-streamlio

Copy link
Copy Markdown
Contributor Author

After making changes to the integration test property names, the only failures we are seeing in the integration tests are related to Kafka and JDBC

------- Starting test [TestClass name=class org.apache.pulsar.tests.integration.functions.PulsarFunctionsThreadTest].pulsar-test-suite([])-------
20:29:00.055 [TestNG-method=testKafkaSink-1:org.apache.pulsar.tests.integration.topologies.PulsarCluster@241] INFO org.apache.pulsar.tests.integration.topologies.PulsarCluster - Starting external service kafka ...
20:29:00.061 [testcontainers-netty-1-5:com.github.dockerjava.core.async.ResultCallbackTemplate@54] ERROR com.github.dockerjava.core.async.ResultCallbackTemplate - Error during callback
com.github.dockerjava.api.exception.NotFoundException: {"message":"No such image: alpine/socat:latest"}

------- Starting test [TestClass name=class org.apache.pulsar.tests.integration.functions.PulsarFunctionsThreadTest].pulsar-test-suite([])-------
20:28:59.981 [TestNG-method=testJdbcSink-1:org.apache.pulsar.tests.integration.topologies.PulsarCluster@241] INFO org.apache.pulsar.tests.integration.topologies.PulsarCluster - Starting external service jdbc ...
20:28:59.989 [testcontainers-netty-1-1:com.github.dockerjava.core.async.ResultCallbackTemplate@54] ERROR com.github.dockerjava.core.async.ResultCallbackTemplate - Error during callback
com.github.dockerjava.api.exception.NotFoundException: {"message":"No such image: mysql:5.7.22"}

@ivankelly

Copy link
Copy Markdown
Contributor

After making changes to the integration test property

This is a BC break. A configuration which works with 2.1 or 2.2 will not work with this code.

And even if I were willing to accept a BC break like this, endpoint and bucket are far to generic names in the context of the entire broker.conf.

@david-streamlio

Copy link
Copy Markdown
Contributor Author

I can fix the BC issue, but we need to decide on what the future property names will be. My only requests are that we don't use a vendor specific prefix, like "s3Bucket" nor have every permutation of "provider/property", e.g. "GCSBucket", "S3Bucket", "AzureBucket", "rackspace-cloudfiles-us-bucket", "Backblaze-B2-Bucket", etc. As it will make documentation an absolute nightmare.

@ivankelly

Copy link
Copy Markdown
Contributor

There will likely have to be some vendor specific things, as they don't have 100% compatible features. How about something like:

offloader.<vendor>.bucket=
offloader.<vendor>.endpoint=

I don't think this adds a much of a documentation burden. We have a core set that work for everyone, and can be documented once. The vendor specific stuff gets documented in their own section. In broker.conf they only need to be added once.

@ivankelly ivankelly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New conf looks good. Some small comments.

brokerContainer.withEnv("managedLedgerOffloadDriver", "s3");
brokerContainer.withEnv("bucket", "pulsar-integtest");
brokerContainer.withEnv("endpoint", "http://" + S3Container.NAME + ":9090");
brokerContainer.withEnv("s3ManagedLedgerOffloadBucket", "pulsar-integtest");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to test both the BC version and the variants.
Maybe ```
if (i++ % 2) {
// use BC variant
} else {
// use new variant
}


Kinda messy though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This brings up two questions:

  1. Should I just create a second class for the BC tests, e.g. PulsarTieredStorageBCTestSuite?
  2. How are the following properties being propagated to the JCloud provider? I didn't see any place in the code (old or new) that does this, which has me concerned that I might have missed something.

brokerContainer.withEnv("managedLedgerMaxEntriesPerLedger", String.valueOf(ENTRIES_PER_LEDGER));
brokerContainer.withEnv("managedLedgerMinLedgerRolloverTimeMinutes", "0");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PulsarTieredStorageTestSuite is a base class used by TestS3Offload. So adding a new TestSuite class would be kinda messy. I'm happy enough to keep it as it is now. When you add azure, I assume there'll be some tests that use the new values.

These values get passed as environment values to the docker containers which run the tests. The docker containers go through each environment variable, sees if it matches a field in the configuration file (like broker.conf), and if so updates that field.

Comment thread site2/docs/cookbooks-tiered-storage.md Resolved
@ivankelly

Copy link
Copy Markdown
Contributor

rerun integration tests
rerun java8 test

@ivankelly

Copy link
Copy Markdown
Contributor

rerun java8 tests

@ivankelly ivankelly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Can be merged once integration tests pass.

Perhaps @sijie and @jiazhai could give another look.

@sijie

sijie commented Dec 18, 2018

Copy link
Copy Markdown
Member

run java8 tests
run integration tests

1 similar comment
@sijie

sijie commented Dec 27, 2018

Copy link
Copy Markdown
Member

run java8 tests
run integration tests

@sijie

sijie commented Dec 27, 2018

Copy link
Copy Markdown
Member

run integration tests

1 similar comment
@merlimat

merlimat commented Jan 3, 2019

Copy link
Copy Markdown
Contributor

run integration tests

@jiazhai

jiazhai commented Jan 4, 2019 •

Copy link
Copy Markdown
Member

run integration tests

@david-streamlio FYI.
Test Result (1 failure / +1)
org.apache.pulsar.tests.integration.offload.TestS3Offload.tiered-storage-test-suite

org.testcontainers.containers.ContainerLaunchException: Container startup failed
	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:229)
	at org.testcontainers.containers.GenericContainer.start(GenericContainer.java:207)
	at org.apache.pulsar.tests.integration.containers.PulsarContainer.start(PulsarContainer.java:125)
	at java.lang.Iterable.forEach(Iterable.java:75)
	at org.apache.pulsar.tests.integration.topologies.PulsarCluster.startAllBrokers(PulsarCluster.java:488)
	at org.apache.pulsar.tests.integration.topologies.PulsarCluster.start(PulsarCluster.java:210)
	at org.apache.pulsar.tests.integration.suites.PulsarTieredStorageTestSuite.setupCluster(PulsarTieredStorageTestSuite.java:65)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
	at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:59)
	at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:451)
	at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:222)
	at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:401)
	at org.testng.SuiteRunner.run(SuiteRunner.java:364)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1183)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1116)
	at org.testng.TestNG.runSuites(TestNG.java:1028)
	at org.testng.TestNG.run(TestNG.java:996)
	at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:283)
	at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)
	at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:120)
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:379)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:340)
	at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:125)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:413)
Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:83)
	at org.testcontainers.containers.GenericContainer.doStart(GenericContainer.java:222)
	... 31 more
Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:294)
	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:224)
	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:76)
	... 32 more
Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (localhost ports: [48175] should be listening)
	at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:47)
	at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:32)
	at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:556)
	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:273)
	... 34 more

@merlimat merlimat modified the milestones: 2.3.0, 2.4.0 Feb 14, 2019
@sijie sijie removed this from the 2.4.0 milestone Jun 9, 2019
@syedatifakhtar

Copy link
Copy Markdown

Hi, when is this going to be available? This is a much needed change for us!

@sijie

sijie commented Feb 8, 2020

Copy link
Copy Markdown
Member

@david-streamlio do you have time to rebase this pull request? or shall we pick it up? /cc @jiazhai

@david-streamlio

david-streamlio commented Feb 8, 2020 via email

Copy link
Copy Markdown
Contributor Author

@sijie

sijie commented Feb 8, 2020

Copy link
Copy Markdown
Member

@david-streamlio I thought this pull request was approved a while ago by Jia, Ivan and me.

@david-streamlio

david-streamlio commented Feb 8, 2020 via email

Copy link
Copy Markdown
Contributor Author

@syedatifakhtar

Copy link
Copy Markdown

Thanks! We are in dire need of this and Azure blob loader PR-2615. I'm hoping we will move that too once this moves?

@david-streamlio

Copy link
Copy Markdown
Contributor Author

I have opened #6335 as a replacement for this, as it is now based of the 2.6.0 branch.

Should we close this one?

@sijie

sijie commented Feb 16, 2020

Copy link
Copy Markdown
Member

Close this pull request since #6335 is open to replace it.

@sijie sijie closed this Feb 16, 2020
jiazhai pushed a commit that referenced this pull request Oct 19, 2020
Motivation

In order to facilitate the support of additional JClouds-supported providers, we first needed to clean up the existing code, as there were a lot of if/then/else constructs throughout the code that were based on the assumption that we either supported AWS S3 or Google Cloud Storage. I didn't want to keep adding else if's to these code blocks for every new provider we add, so I decided to refactor the code to make it a bit cleaner

Modifications

in addition to being home for most of the aforementioned if/then/else blocks, the BlobStoreManagedLedgerOffloader class had multiple responsibilities in addition to providing an implementation for the LedgerOffloader interface. My goal was to simplify this class such that its only responsibility was to implement the LedgerOffloader interface.

The other major change was the addition of the JCloudBlobStoreProvider enum, which implements 3 interfaces that allow for it to handle the provider specific logic for things such as acquiring the credentials, validating the configuration, and creating a provider-specific instance of BlobStore.

Result

After this change, we will be able to easily add support for additional JClouds-supported providers by simply adding new elements to the JCloudBlobStoreProvider Enums since the other logic has been isolated and is not vendor specific.

See #2865 for more details

* Refactored JCloud Tiered Storage

* Refactored JCloud Tiered Storage

* Added missing import statements

* Refactored JCloud Tiered Storage

* Refactored JCloud Tiered Storage

* Added missing import statements

* Refactored JCloud Tiered Storage

* Refactored JCloud Tiered Storage

* Added missing import statements

* fix test

* add test logs

* fix logs

* fix test

* fix

* fix

* fix broker log

* fix configuration

* fix

* fix

* fix

* fix get BlobStore

* repair test presto query tiered storage data

* fix test

* fix test

* fix test TestPrestoQueryTieredStorage

* fix

* fix

Co-authored-by: Sijie Guo <[email protected]>
Co-authored-by: gaoran10 <[email protected]>
Co-authored-by: xiaolong.ran <[email protected]>
wolfstudy added a commit that referenced this pull request Oct 30, 2020
Motivation

In order to facilitate the support of additional JClouds-supported providers, we first needed to clean up the existing code, as there were a lot of if/then/else constructs throughout the code that were based on the assumption that we either supported AWS S3 or Google Cloud Storage. I didn't want to keep adding else if's to these code blocks for every new provider we add, so I decided to refactor the code to make it a bit cleaner

Modifications

in addition to being home for most of the aforementioned if/then/else blocks, the BlobStoreManagedLedgerOffloader class had multiple responsibilities in addition to providing an implementation for the LedgerOffloader interface. My goal was to simplify this class such that its only responsibility was to implement the LedgerOffloader interface.

The other major change was the addition of the JCloudBlobStoreProvider enum, which implements 3 interfaces that allow for it to handle the provider specific logic for things such as acquiring the credentials, validating the configuration, and creating a provider-specific instance of BlobStore.

Result

After this change, we will be able to easily add support for additional JClouds-supported providers by simply adding new elements to the JCloudBlobStoreProvider Enums since the other logic has been isolated and is not vendor specific.

See #2865 for more details

* Refactored JCloud Tiered Storage

* Refactored JCloud Tiered Storage

* Added missing import statements

* Refactored JCloud Tiered Storage

* Refactored JCloud Tiered Storage

* Added missing import statements

* Refactored JCloud Tiered Storage

* Refactored JCloud Tiered Storage

* Added missing import statements

* fix test

* add test logs

* fix logs

* fix test

* fix

* fix

* fix broker log

* fix configuration

* fix

* fix

* fix

* fix get BlobStore

* repair test presto query tiered storage data

* fix test

* fix test

* fix test TestPrestoQueryTieredStorage

* fix

* fix

Co-authored-by: Sijie Guo <[email protected]>
Co-authored-by: gaoran10 <[email protected]>
Co-authored-by: xiaolong.ran <[email protected]>
(cherry picked from commit d3a5233)
huangdx0726 pushed a commit to huangdx0726/pulsar that referenced this pull request Nov 13, 2020
Motivation

In order to facilitate the support of additional JClouds-supported providers, we first needed to clean up the existing code, as there were a lot of if/then/else constructs throughout the code that were based on the assumption that we either supported AWS S3 or Google Cloud Storage. I didn't want to keep adding else if's to these code blocks for every new provider we add, so I decided to refactor the code to make it a bit cleaner

Modifications

in addition to being home for most of the aforementioned if/then/else blocks, the BlobStoreManagedLedgerOffloader class had multiple responsibilities in addition to providing an implementation for the LedgerOffloader interface. My goal was to simplify this class such that its only responsibility was to implement the LedgerOffloader interface.

The other major change was the addition of the JCloudBlobStoreProvider enum, which implements 3 interfaces that allow for it to handle the provider specific logic for things such as acquiring the credentials, validating the configuration, and creating a provider-specific instance of BlobStore.

Result

After this change, we will be able to easily add support for additional JClouds-supported providers by simply adding new elements to the JCloudBlobStoreProvider Enums since the other logic has been isolated and is not vendor specific.

See apache#2865 for more details

* Refactored JCloud Tiered Storage

* Refactored JCloud Tiered Storage

* Added missing import statements

* Refactored JCloud Tiered Storage

* Refactored JCloud Tiered Storage

* Added missing import statements

* Refactored JCloud Tiered Storage

* Refactored JCloud Tiered Storage

* Added missing import statements

* fix test

* add test logs

* fix logs

* fix test

* fix

* fix

* fix broker log

* fix configuration

* fix

* fix

* fix

* fix get BlobStore

* repair test presto query tiered storage data

* fix test

* fix test

* fix test TestPrestoQueryTieredStorage

* fix

* fix

Co-authored-by: Sijie Guo <[email protected]>
Co-authored-by: gaoran10 <[email protected]>
Co-authored-by: xiaolong.ran <[email protected]>
flowchartsman pushed a commit to flowchartsman/pulsar that referenced this pull request Nov 17, 2020
Motivation

In order to facilitate the support of additional JClouds-supported providers, we first needed to clean up the existing code, as there were a lot of if/then/else constructs throughout the code that were based on the assumption that we either supported AWS S3 or Google Cloud Storage. I didn't want to keep adding else if's to these code blocks for every new provider we add, so I decided to refactor the code to make it a bit cleaner

Modifications

in addition to being home for most of the aforementioned if/then/else blocks, the BlobStoreManagedLedgerOffloader class had multiple responsibilities in addition to providing an implementation for the LedgerOffloader interface. My goal was to simplify this class such that its only responsibility was to implement the LedgerOffloader interface.

The other major change was the addition of the JCloudBlobStoreProvider enum, which implements 3 interfaces that allow for it to handle the provider specific logic for things such as acquiring the credentials, validating the configuration, and creating a provider-specific instance of BlobStore.

Result

After this change, we will be able to easily add support for additional JClouds-supported providers by simply adding new elements to the JCloudBlobStoreProvider Enums since the other logic has been isolated and is not vendor specific.

See apache#2865 for more details

* Refactored JCloud Tiered Storage

* Refactored JCloud Tiered Storage

* Added missing import statements

* Refactored JCloud Tiered Storage

* Refactored JCloud Tiered Storage

* Added missing import statements

* Refactored JCloud Tiered Storage

* Refactored JCloud Tiered Storage

* Added missing import statements

* fix test

* add test logs

* fix logs

* fix test

* fix

* fix

* fix broker log

* fix configuration

* fix

* fix

* fix

* fix get BlobStore

* repair test presto query tiered storage data

* fix test

* fix test

* fix test TestPrestoQueryTieredStorage

* fix

* fix

Co-authored-by: Sijie Guo <[email protected]>
Co-authored-by: gaoran10 <[email protected]>
Co-authored-by: xiaolong.ran <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants