Skip to content

[PIP-50] Package management implementation (part-1)#5613

Closed
zymap wants to merge 5 commits intoapache:masterfrom
zymap:pkg_management
Closed

[PIP-50] Package management implementation (part-1)#5613
zymap wants to merge 5 commits intoapache:masterfrom
zymap:pkg_management

Conversation

@zymap
Copy link
Member

@zymap zymap commented Nov 11, 2019


Motivation

Implementation of package management.
https://github.com/apache/pulsar/wiki/PIP-50%3A-Package-Management

Modifications

  • Implement package management
  • Abstraction storage

---

*Motivation*

Implementation of package management.
https://github.com/apache/pulsar/wiki/PIP-50%3A-Package-Management

*Modifications*

- Implement package management
- Abstraction storage
@zymap
Copy link
Member Author

zymap commented Nov 11, 2019

@sijie @jiazhai @wolfstudy PTAL

@zymap
Copy link
Member Author

zymap commented Nov 11, 2019

run java8 tests

@sijie sijie added this to the 2.5.0 milestone Nov 11, 2019
@zymap zymap force-pushed the pkg_management branch 2 times, most recently from ac36499 to d8c6ce8 Compare November 12, 2019 08:18
@zymap
Copy link
Member Author

zymap commented Nov 21, 2019

@sijie PTAL. Thanks.

@sijie sijie modified the milestones: 2.5.0, 2.6.0 Nov 25, 2019
@sijie sijie added area/broker type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages labels Nov 25, 2019
Copy link
Member

@sijie sijie left a comment

Choose a reason for hiding this comment

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

Please create an issue to track adding documentation about this new package management system.

/**
* Thrown package metadata already existAsync exceptions.
*/
public class PackageMetaAlreadyExistsException extends PackageException {
Copy link
Member

Choose a reason for hiding this comment

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

why do we have two AlreadyExistsException? Does it really happen that the package exists but the metadata doesn't exist?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because the metadata and package are two files, delete a package that needs to delete metadata as well. Delete package and metadata are two operations and I can not promise after deleting package the metadata will delete successfully.
If one of the delete operations was failed and the user ignores the error and uploads the same package again, the metadata or the package may be already existent.
Do you have some advice?

/**
* Thrown package metadata not found exceptions.
*/
public class PackageMetaNotFoundException extends PackageException {
Copy link
Member

Choose a reason for hiding this comment

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

Same comments similar to AlreadyExistsException.

return packageStorage.existAsync(metadataPath)
.thenCompose(metaExists -> metaExists
? packageStorage.deleteAsync(metadataPath)
: FutureUtil.failedFuture(new PackageMetaNotFoundException("Package metadata does not exists")))
Copy link
Member

Choose a reason for hiding this comment

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

data can still exists when the metadata file doesn't exist. e.g. a delete operation failed in between deleting metadat and data.

.thenApply(names -> names.stream().map(PackageName::get).collect(Collectors.toList()));
}

private String getMetadataStoragePath(PackageName packageName) {
Copy link
Member

Choose a reason for hiding this comment

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

static

return get(pkgName);
}

public static PackageName get(String type, String name, String version) {
Copy link
Member

Choose a reason for hiding this comment

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

don't you need to ensure the name is a validate "topic" name?

try {
return cache.get(packageName);
} catch (ExecutionException e) {
throw (RuntimeException) e.getCause();
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure it is a safe cast to RuntimeException?

this.namespaceName = NamespaceName.get(parts.get(0), parts.get(1));

rest = parts.get(2);
parts = Splitter.on("@").splitToList(rest);
Copy link
Member

Choose a reason for hiding this comment

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

don't you need to check the length first? e.g. if people don't specify the version "@".

Also if people don't specify the version, should we make the default version to latest?

return e;
}
}
throw new IllegalArgumentException("Invalid topic domain: '" + value + "'");
Copy link
Member

Choose a reason for hiding this comment

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

why this is "topic domain"?

CompletableFuture<Boolean> future = new CompletableFuture<>();
CompletableFuture.runAsync(() -> {
try {
future.complete(namespace.logExists(path));
Copy link
Member

Choose a reason for hiding this comment

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

namespace.getNamespaceDriver().getLogMetadataStore().getLogLocation() would return a completable future.

Copy link
Member Author

Choose a reason for hiding this comment

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

getLogLocation() seems not the log path. It's a URI. I find the namespace.getNamespaceDriver().getLogStreamMetadataStore(NamespaceDriver.Role.WRITER).logExists(uriOptional.get(), path) can reture a completable future.

List<CompletableFuture<DLOutputStream>> writeFuture = new ArrayList<>();
byte[] bytes = new byte[1024];
try {
while (inputStream.read(bytes) != -1) {
Copy link
Member

Choose a reason for hiding this comment

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

inputStream.read is a synchronous operation. you have to call this in a separate thread to not blocking the thread calling writeAsync.

import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class PackagesImplTest {
Copy link
Member

Choose a reason for hiding this comment

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

The test needs to cover different test cases.

import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class BKStorageTest {
Copy link
Member

Choose a reason for hiding this comment

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

Rename this to BKStorageMockTest and add one test for interacting with a real BK cluster.

/**
* Unit test of {@link DLInputStream}.
*/
public class DLInputStreamTest {
Copy link
Member

Choose a reason for hiding this comment

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

Please all add test cases for error cases.

/**
* Unit test of {@link DLOutputStream}.
*/
public class DLOutputStreamTest {
Copy link
Member

Choose a reason for hiding this comment

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

Please all add test cases for error cases.

@zymap
Copy link
Member Author

zymap commented Dec 30, 2019

@sijie I can not retrigger the test. So please take a look when you have time.

@codelipenghui
Copy link
Contributor

@zymap Could you please rebase with the master branch? @sijie Shall we need to onboard this PR in 2.6.0 release?

@codelipenghui codelipenghui modified the milestones: 2.6.0, 2.7.0 May 25, 2020
@codelipenghui codelipenghui modified the milestones: 2.7.0, 2.8.0 Nov 4, 2020
@zymap zymap closed this Dec 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/broker type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants