forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Make ManagedLedger storage configurable (apache#9397)
*Motivation* This is the first step to allow supporting different storage implementations for Pulsar
- Loading branch information
Showing
7 changed files
with
150 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
pulsar-broker/src/main/java/org/apache/pulsar/broker/storage/ManagedLedgerStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/** | ||
* 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.pulsar.broker.storage; | ||
|
||
import java.io.IOException; | ||
import org.apache.bookkeeper.client.BookKeeper; | ||
import org.apache.bookkeeper.mledger.ManagedLedgerFactory; | ||
import org.apache.bookkeeper.stats.StatsProvider; | ||
import org.apache.pulsar.broker.BookKeeperClientFactory; | ||
import org.apache.pulsar.broker.ServiceConfiguration; | ||
import org.apache.pulsar.common.classification.InterfaceAudience.Private; | ||
import org.apache.pulsar.common.classification.InterfaceStability.Unstable; | ||
import org.apache.zookeeper.ZooKeeper; | ||
|
||
/** | ||
* Storage to access {@link org.apache.bookkeeper.mledger.ManagedLedger}s. | ||
*/ | ||
@Private | ||
@Unstable | ||
public interface ManagedLedgerStorage extends AutoCloseable { | ||
|
||
/** | ||
* Initialize the managed ledger storage. | ||
* | ||
* @param conf service config | ||
* @param zkClient zk client | ||
* @param bookkeperProvider bookkeeper provider | ||
* @throws Exception | ||
*/ | ||
void initialize(ServiceConfiguration conf, | ||
ZooKeeper zkClient, | ||
BookKeeperClientFactory bookkeperProvider) throws Exception; | ||
|
||
/** | ||
* Return the factory to create {@link ManagedLedgerFactory}. | ||
* | ||
* @return the factory to create {@link ManagedLedgerFactory}. | ||
*/ | ||
ManagedLedgerFactory getManagedLedgerFactory(); | ||
|
||
/** | ||
* Return the stats provider to expose the stats of the storage implementation. | ||
* | ||
* @return the stats provider. | ||
*/ | ||
StatsProvider getStatsProvider(); | ||
|
||
/** | ||
* Return the default bookkeeper client. | ||
* | ||
* @return the default bookkeeper client. | ||
*/ | ||
BookKeeper getBookKeeperClient(); | ||
|
||
/** | ||
* Close the storage. | ||
* | ||
* @throws IOException | ||
*/ | ||
void close() throws IOException; | ||
|
||
/** | ||
* Initialize the {@link ManagedLedgerStorage} from the provided resources. | ||
* | ||
* @param conf service config | ||
* @param zkClient zookeeper client | ||
* @param bkProvider bookkeeper client provider | ||
* @return the initialized managed ledger storage. | ||
*/ | ||
static ManagedLedgerStorage create(ServiceConfiguration conf, | ||
ZooKeeper zkClient, | ||
BookKeeperClientFactory bkProvider) throws Exception { | ||
final Class<?> storageClass = Class.forName(conf.getManagedLedgerStorageClassName()); | ||
final ManagedLedgerStorage storage = (ManagedLedgerStorage) storageClass.newInstance(); | ||
storage.initialize(conf, zkClient, bkProvider); | ||
return storage; | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
pulsar-broker/src/main/java/org/apache/pulsar/broker/storage/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* 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. | ||
*/ | ||
/** | ||
* The storage layer for Apache Pulsar. | ||
*/ | ||
package org.apache.pulsar.broker.storage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters