blob: 246911fdfc70929b8856a3f9a0fd08ef058c201d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.zookeeper;
import com.google.inject.Inject;
import com.yahoo.cloud.config.ZookeeperServerConfig;
import com.yahoo.component.AbstractComponent;
import java.nio.file.Path;
import java.time.Duration;
import java.util.concurrent.atomic.AtomicReference;
/**
* Starts or reconfigures zookeeper cluster.
* The QuorumPeer conditionally created here is owned by the Reconfigurer;
* when it already has a peer, that peer is used here in case start or shutdown is required.
*
* @author hmusum
*/
public class ReconfigurableVespaZooKeeperServer extends AbstractComponent implements VespaZooKeeperServer {
private QuorumPeer peer;
@Inject
public ReconfigurableVespaZooKeeperServer(Reconfigurer reconfigurer, ZookeeperServerConfig zookeeperServerConfig) {
peer = reconfigurer.startOrReconfigure(zookeeperServerConfig, this, () -> peer = new VespaQuorumPeer());
}
@Override
public void shutdown() {
peer.shutdown(Duration.ofMinutes(1));
}
@Override
public void start(Path configFilePath) {
peer.start(configFilePath);
}
@Override
public boolean reconfigurable() {
return true;
}
}
|