use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.KeeperException in project lucene-solr by apache.
the class ManagedIndexSchemaFactory method warnIfNonManagedSchemaExists.
/**
* Return whether a non-managed schema exists, either in local storage or on ZooKeeper.
*/
private void warnIfNonManagedSchemaExists() {
if (!resourceName.equals(managedSchemaResourceName)) {
boolean exists = false;
SolrResourceLoader loader = config.getResourceLoader();
if (loader instanceof ZkSolrResourceLoader) {
ZkSolrResourceLoader zkLoader = (ZkSolrResourceLoader) loader;
String nonManagedSchemaPath = zkLoader.getConfigSetZkPath() + "/" + resourceName;
try {
exists = zkLoader.getZkController().pathExists(nonManagedSchemaPath);
} catch (InterruptedException e) {
// Restore the interrupted status
Thread.currentThread().interrupt();
// Log as warning and suppress the exception
log.warn("", e);
} catch (KeeperException e) {
// log as warning and suppress the exception
log.warn("Error checking for the existence of the non-managed schema " + resourceName, e);
}
} else {
// Config is not in ZooKeeper
InputStream nonManagedSchemaInputStream = null;
try {
nonManagedSchemaInputStream = loader.openSchema(resourceName);
if (null != nonManagedSchemaInputStream) {
exists = true;
}
} catch (IOException e) {
// This is expected when the non-managed schema does not exist
} finally {
IOUtils.closeQuietly(nonManagedSchemaInputStream);
}
}
if (exists) {
log.warn("The schema has been upgraded to managed, but the non-managed schema " + resourceName + " is still loadable. PLEASE REMOVE THIS FILE.");
}
}
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.KeeperException in project lucene-solr by apache.
the class ZkClientClusterStateProvider method connect.
@Override
public void connect() {
if (zkStateReader == null) {
synchronized (this) {
if (zkStateReader == null) {
ZkStateReader zk = null;
try {
zk = new ZkStateReader(zkHost, zkClientTimeout, zkConnectTimeout);
zk.createClusterStateWatchersAndUpdate();
zkStateReader = zk;
log.info("Cluster at {} ready", zkHost);
} catch (InterruptedException e) {
zk.close();
Thread.currentThread().interrupt();
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e);
} catch (KeeperException e) {
zk.close();
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e);
} catch (Exception e) {
if (zk != null)
zk.close();
// do not wrap because clients may be relying on the underlying exception being thrown
throw e;
}
}
}
}
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.KeeperException in project lucene-solr by apache.
the class ZkSolrClientTest method testZkCmdExectutor.
public void testZkCmdExectutor() throws Exception {
String zkDir = createTempDir("zkData").toFile().getAbsolutePath();
ZkTestServer server = null;
try {
server = new ZkTestServer(zkDir);
server.run();
AbstractZkTestCase.tryCleanSolrZkNode(server.getZkHost());
AbstractZkTestCase.makeSolrZkNode(server.getZkHost());
final int timeout = random().nextInt(10000) + 5000;
ZkCmdExecutor zkCmdExecutor = new ZkCmdExecutor(timeout);
final long start = System.nanoTime();
try {
zkCmdExecutor.retryOperation(new ZkOperation() {
@Override
public String execute() throws KeeperException, InterruptedException {
if (System.nanoTime() - start > TimeUnit.NANOSECONDS.convert(timeout, TimeUnit.MILLISECONDS)) {
throw new KeeperException.SessionExpiredException();
}
throw new KeeperException.ConnectionLossException();
}
});
} catch (KeeperException.SessionExpiredException e) {
} catch (Exception e) {
fail("Expected " + KeeperException.SessionExpiredException.class.getSimpleName() + " but got " + e.getClass().getSimpleName());
}
} finally {
if (server != null) {
server.shutdown();
}
}
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.KeeperException in project lucene-solr by apache.
the class SolrTestCaseJ4 method deleteCore.
/**
* Shuts down the test harness, and makes the best attempt possible
* to delete dataDir, unless the system property "solr.test.leavedatadir"
* is set.
*/
public static void deleteCore() {
if (h != null) {
log.info("###deleteCore");
// If the test case set up Zk, it should still have it as available,
// otherwise the core close will just be unnecessarily delayed.
CoreContainer cc = h.getCoreContainer();
if (!cc.getCores().isEmpty() && cc.isZooKeeperAware()) {
try {
cc.getZkController().getZkClient().exists("/", false);
} catch (KeeperException e) {
log.error("Testing connectivity to ZK by checking for root path failed", e);
fail("Trying to tear down a ZK aware core container with ZK not reachable");
} catch (InterruptedException ignored) {
}
}
h.close();
}
if (factoryProp == null) {
System.clearProperty("solr.directoryFactory");
}
solrConfig = null;
h = null;
lrf = null;
configString = schemaString = null;
}
use of org.apache.flink.shaded.zookeeper3.org.apache.zookeeper.KeeperException in project lucene-solr by apache.
the class ZkStateReader method createClusterStateWatchersAndUpdate.
public synchronized void createClusterStateWatchersAndUpdate() throws KeeperException, InterruptedException {
// We need to fetch the current cluster state and the set of live nodes
LOG.debug("Updating cluster state from ZooKeeper... ");
// Sanity check ZK structure.
if (!zkClient.exists(CLUSTER_STATE, true)) {
throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE, "Cannot connect to cluster at " + zkClient.getZkServerAddress() + ": cluster not found/not ready");
}
// on reconnect of SolrZkClient force refresh and re-add watches.
loadClusterProperties();
refreshLiveNodes(new LiveNodeWatcher());
refreshLegacyClusterState(new LegacyClusterStateWatcher());
refreshStateFormat2Collections();
refreshCollectionList(new CollectionsChildWatcher());
synchronized (ZkStateReader.this.getUpdateLock()) {
constructState(Collections.emptySet());
zkClient.exists(ALIASES, new Watcher() {
@Override
public void process(WatchedEvent event) {
// session events are not change events, and do not remove the watcher
if (EventType.None.equals(event.getType())) {
return;
}
try {
synchronized (ZkStateReader.this.getUpdateLock()) {
LOG.debug("Updating aliases... ");
// remake watch
final Watcher thisWatch = this;
final Stat stat = new Stat();
final byte[] data = zkClient.getData(ALIASES, thisWatch, stat, true);
ZkStateReader.this.aliases = ClusterState.load(data);
LOG.debug("New alias definition is: " + ZkStateReader.this.aliases.toString());
}
} catch (KeeperException.ConnectionLossException | KeeperException.SessionExpiredException e) {
LOG.warn("ZooKeeper watch triggered, but Solr cannot talk to ZK: [{}]", e.getMessage());
} catch (KeeperException e) {
LOG.error("A ZK error has occurred", e);
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "A ZK error has occurred", e);
} catch (InterruptedException e) {
// Restore the interrupted status
Thread.currentThread().interrupt();
LOG.warn("Interrupted", e);
}
}
}, true);
}
updateAliases();
if (securityNodeListener != null) {
addSecuritynodeWatcher(pair -> {
ConfigData cd = new ConfigData();
cd.data = pair.first() == null || pair.first().length == 0 ? EMPTY_MAP : Utils.getDeepCopy((Map) fromJSON(pair.first()), 4, false);
cd.version = pair.second() == null ? -1 : pair.second().getVersion();
securityData = cd;
securityNodeListener.run();
});
securityData = getSecurityProps(true);
}
}
Aggregations