private final ZkEStoreProvider zkEStoreProvider;
public ZkPStoreProvider(PStoreRegistry registry) throws DrillbitStartupException {
ClusterCoordinator coord = registry.getClusterCoordinator();
if (!(coord instanceof ZKClusterCoordinator)) {
throw new DrillbitStartupException("A ZkPStoreProvider was created without a ZKClusterCoordinator.");
}
this.curator = ((ZKClusterCoordinator)registry.getClusterCoordinator()).getCurator();
if (registry.getConfig().hasPath(DRILL_EXEC_SYS_STORE_PROVIDER_ZK_BLOBROOT)) {
blobRoot = new Path(registry.getConfig().getString(DRILL_EXEC_SYS_STORE_PROVIDER_ZK_BLOBROOT));
} else {
String drillLogDir = System.getenv("DRILL_LOG_DIR");
if (drillLogDir == null) {
drillLogDir = "/var/log/drill";
}
blobRoot = new Path(new File(drillLogDir).getAbsoluteFile().toURI());
}
Configuration fsConf = new Configuration();
fsConf.set(FileSystem.FS_DEFAULT_NAME_KEY, blobRoot.toUri().toString());
try {
fs = FileSystemCreator.getFileSystem(registry.getConfig(), fsConf);
fs.mkdirs(blobRoot);
} catch (IOException e) {
throw new DrillbitStartupException("Unable to initialize blob storage.", e);
}
zkEStoreProvider = new ZkEStoreProvider(curator);
}