use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project pravega by pravega.
the class StoreClientFactory method createZKClient.
@VisibleForTesting
static CuratorFramework createZKClient(ZKClientConfig zkClientConfig, Supplier<Boolean> canRetry, Consumer<Void> expiryHandler, ZKClientFactory zkClientFactory) {
if (zkClientConfig.isSecureConnectionToZooKeeper()) {
ZKTLSUtils.setSecureZKClientProperties(zkClientConfig.getTrustStorePath(), JKSHelper.loadPasswordFrom(zkClientConfig.getTrustStorePasswordPath()));
}
RetryWrapper retryPolicy = new RetryWrapper(new ExponentialBackoffRetry(zkClientConfig.getInitialSleepInterval(), zkClientConfig.getMaxRetries(), CURATOR_MAX_SLEEP_MS), canRetry);
// Create and initialize the curator client framework.
CuratorFramework zkClient = CuratorFrameworkFactory.builder().connectString(zkClientConfig.getConnectionString()).namespace(zkClientConfig.getNamespace()).zookeeperFactory(zkClientFactory).retryPolicy(retryPolicy).sessionTimeoutMs(zkClientConfig.getSessionTimeoutMs()).build();
zkClient.getConnectionStateListenable().addListener((client1, newState) -> {
if (newState.equals(ConnectionState.LOST)) {
expiryHandler.accept(null);
}
});
zkClient.start();
return zkClient;
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project pravega by pravega.
the class ControllerServiceWithStreamTest method setup.
@Before
public void setup() {
try {
zkServer = new TestingServerStarter().start();
} catch (Exception e) {
log.error("Error starting ZK server", e);
}
zkClient = CuratorFrameworkFactory.newClient(zkServer.getConnectString(), new ExponentialBackoffRetry(200, 10, 5000));
zkClient.start();
streamStore = spy(getStore());
kvtStore = spy(getKVTStore());
BucketStore bucketStore = StreamStoreFactory.createZKBucketStore(zkClient, executor);
TaskMetadataStore taskMetadataStore = TaskStoreFactory.createZKStore(zkClient, executor);
connectionFactory = new SocketConnectionFactoryImpl(ClientConfig.builder().controllerURI(URI.create("tcp://localhost")).build());
GrpcAuthHelper disabledAuthHelper = GrpcAuthHelper.getDisabledAuthHelper();
SegmentHelper segmentHelperMock = SegmentHelperMock.getSegmentHelperMock();
StreamMetrics.initialize();
TransactionMetrics.initialize();
EventHelper helperMock = EventHelperMock.getEventHelperMock(executor, "host", ((AbstractStreamMetadataStore) streamStore).getHostTaskIndex());
streamMetadataTasks = new StreamMetadataTasks(streamStore, bucketStore, taskMetadataStore, segmentHelperMock, executor, "host", disabledAuthHelper, helperMock);
kvtMetadataTasks = spy(new TableMetadataTasks(kvtStore, segmentHelperMock, executor, executor, "host", GrpcAuthHelper.getDisabledAuthHelper(), helperMock));
streamTransactionMetadataTasks = new StreamTransactionMetadataTasks(streamStore, segmentHelperMock, executor, "host", disabledAuthHelper);
StreamRequestHandler streamRequestHandler = new StreamRequestHandler(new AutoScaleTask(streamMetadataTasks, streamStore, executor), new ScaleOperationTask(streamMetadataTasks, streamStore, executor), new UpdateStreamTask(streamMetadataTasks, streamStore, bucketStore, executor), new SealStreamTask(streamMetadataTasks, streamTransactionMetadataTasks, streamStore, executor), new DeleteStreamTask(streamMetadataTasks, streamStore, bucketStore, executor), new TruncateStreamTask(streamMetadataTasks, streamStore, executor), new CreateReaderGroupTask(streamMetadataTasks, streamStore, executor), new DeleteReaderGroupTask(streamMetadataTasks, streamStore, executor), new UpdateReaderGroupTask(streamMetadataTasks, streamStore, executor), streamStore, new DeleteScopeTask(streamMetadataTasks, streamStore, kvtStore, kvtMetadataTasks, executor), executor);
streamMetadataTasks.setRequestEventWriter(new ControllerEventStreamWriterMock(streamRequestHandler, executor));
consumer = new ControllerService(kvtStore, kvtMetadataTasks, streamStore, bucketStore, streamMetadataTasks, streamTransactionMetadataTasks, segmentHelperMock, executor, null, requestTracker);
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project pravega by pravega.
the class ZKSegmentContainerMonitorTest method startClient.
private CuratorFramework startClient() {
val client = CuratorFrameworkFactory.newClient(zkUrl, new ExponentialBackoffRetry(RETRY_SLEEP_MS, MAX_RETRY));
client.start();
return client;
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project pravega by pravega.
the class BookKeeperRunner method initialize.
public void initialize() throws Exception {
// BookKeeper
// Pick random ports to reduce chances of collisions during concurrent test executions.
int zkPort = TestUtils.getAvailableListenPort();
val bookiePorts = new ArrayList<Integer>();
for (int i = 0; i < this.bookieCount; i++) {
bookiePorts.add(TestUtils.getAvailableListenPort());
}
this.bkRunner = BookKeeperServiceRunner.builder().startZk(true).zkPort(zkPort).secureZK(false).secureBK(false).ledgersPath("/ledgers/" + zkPort).bookiePorts(bookiePorts).build();
this.bkRunner.startAll();
// Create a ZKClient with a base namespace.
String baseNamespace = "pravega/" + zkPort;
this.zkClient = CuratorFrameworkFactory.builder().connectString("localhost:" + zkPort).namespace(baseNamespace).retryPolicy(new ExponentialBackoffRetry(1000, 5)).connectionTimeoutMs(5000).sessionTimeoutMs(5000).build();
this.zkClient.start();
// Attach a sub-namespace for the Container Metadata.
String logMetaNamespace = "segmentstore/containers";
this.configBuilder.include(BookKeeperConfig.builder().with(BookKeeperConfig.ZK_ADDRESS, "localhost:" + zkPort).with(BookKeeperConfig.ZK_METADATA_PATH, logMetaNamespace).with(BookKeeperConfig.BK_LEDGER_PATH, "/ledgers/" + zkPort).with(BookKeeperConfig.BK_ACK_QUORUM_SIZE, this.bookieCount).with(BookKeeperConfig.BK_WRITE_QUORUM_SIZE, this.bookieCount).with(BookKeeperConfig.BK_ENSEMBLE_SIZE, this.bookieCount));
}
use of org.apache.flink.shaded.curator5.org.apache.curator.retry.ExponentialBackoffRetry in project pravega by pravega.
the class ZKSegmentContainerManagerTest method startClient.
private CuratorFramework startClient() {
val client = CuratorFrameworkFactory.newClient(zkUrl, new ExponentialBackoffRetry(RETRY_SLEEP_MS, MAX_RETRY));
client.start();
return client;
}
Aggregations