Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIP-135: Added Etcd MetadataStore implementation #13225

Merged
merged 16 commits into from
Jan 21, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed checkstyle
merlimat committed Jan 11, 2022
commit 0ad737a7244b2e535380ac4feb06833526f37612
Original file line number Diff line number Diff line change
@@ -52,7 +52,6 @@
import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.metadata.api.GetResult;
@@ -69,10 +68,6 @@
import org.apache.pulsar.metadata.impl.batching.OpGet;
import org.apache.pulsar.metadata.impl.batching.OpGetChildren;
import org.apache.pulsar.metadata.impl.batching.OpPut;
import org.apache.zookeeper.AddWatchMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;

@Slf4j
public class EtcdMetadataStore extends AbstractBatchedMetadataStore {
@@ -330,11 +325,12 @@ protected void batchOperation(List<MetadataOp> ops) {
if (ops.size() > 1 && cause instanceof StatusRuntimeException) {
Status.Code code = ((StatusRuntimeException) cause).getStatus().getCode();
if (
// This could be caused by having repeated keys in the batch, retry individually
code == Status.Code.INVALID_ARGUMENT ||

// We might have exceeded the max-frame size for the respons
code == Status.Code.RESOURCE_EXHAUSTED
code == Status.Code.INVALID_ARGUMENT /* This could be caused by having repeated keys
in the batch, retry individually */
||
code
== Status.Code.RESOURCE_EXHAUSTED /* We might have exceeded the max-frame
size for the response */
) {
ops.forEach(o -> batchOperation(Collections.singletonList(o)));
}
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@
import org.apache.pulsar.metadata.api.extended.SessionEvent;

/**
* Monitor the ETCd session state every few seconds and send notifications
* Monitor the ETCd session state every few seconds and send notifications.
*/
@Slf4j
public class EtcdSessionWatcher implements AutoCloseable {
Original file line number Diff line number Diff line change
@@ -48,10 +48,9 @@ private static MetadataStore newInstance(String metadataURL, MetadataStoreConfig

if (metadataURL.startsWith("memory://")) {
return new LocalMemoryMetadataStore(metadataURL, metadataStoreConfig);
}
if (metadataURL.startsWith("rocksdb://")) {
} else if (metadataURL.startsWith("rocksdb://")) {
return RocksdbMetadataStore.get(metadataURL, metadataStoreConfig);
} if (metadataURL.startsWith(EtcdMetadataStore.ETCD_SCHEME_IDENTIFIER)) {
} else if (metadataURL.startsWith(EtcdMetadataStore.ETCD_SCHEME_IDENTIFIER)) {
return new EtcdMetadataStore(metadataURL, metadataStoreConfig, enableSessionWatcher);
} else {
return new ZKMetadataStore(metadataURL, metadataStoreConfig, enableSessionWatcher);
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@
import static org.testng.Assert.assertTrue;
import io.etcd.jetcd.launcher.EtcdCluster;
import io.etcd.jetcd.launcher.EtcdClusterFactory;
import io.etcd.jetcd.test.EtcdClusterExtension;
import java.io.File;
import java.util.UUID;
import java.util.concurrent.CompletionException;