use of org.apache.zeppelin.interpreter.thrift.LibraryMetadata in project zeppelin by apache.
the class RemoteInterpreterEventServer method getAllLibraryMetadatas.
@Override
public List<LibraryMetadata> getAllLibraryMetadatas(String interpreter) throws TException {
if (StringUtils.isBlank(interpreter)) {
LOGGER.warn("Interpreter is blank");
return Collections.emptyList();
}
File interpreterLocalRepo = new File(zConf.getAbsoluteDir(ZeppelinConfiguration.ConfVars.ZEPPELIN_DEP_LOCALREPO) + File.separator + interpreter);
if (!interpreterLocalRepo.exists()) {
LOGGER.warn("Local interpreter repository {} for interpreter {} doesn't exists", interpreterLocalRepo, interpreter);
return Collections.emptyList();
}
if (!interpreterLocalRepo.isDirectory()) {
LOGGER.warn("Local interpreter repository {} is no folder", interpreterLocalRepo);
return Collections.emptyList();
}
Collection<File> files = FileUtils.listFiles(interpreterLocalRepo, new String[] { "jar" }, false);
List<LibraryMetadata> metaDatas = new ArrayList<>(files.size());
for (File file : files) {
try {
metaDatas.add(new LibraryMetadata(file.getName(), FileUtils.checksumCRC32(file)));
} catch (IOException e) {
LOGGER.warn(e.getMessage(), e);
}
}
return metaDatas;
}
use of org.apache.zeppelin.interpreter.thrift.LibraryMetadata in project zeppelin by apache.
the class RemoteInterpreterDownloader method syncAllLibraries.
private void syncAllLibraries() {
LOGGER.info("Loading all libraries for interpreter {} to {}", interpreter, localRepoDir);
List<LibraryMetadata> metadatas = client.getAllLibraryMetadatas(interpreter);
if (!localRepoDir.isDirectory()) {
LOGGER.error("{} is no directory", localRepoDir);
return;
}
Set<String> syncedLibraries = new HashSet<>();
// Add or update new libraries
for (LibraryMetadata metadata : metadatas) {
File library = new File(localRepoDir, metadata.getName());
addOrUpdateLibrary(library, metadata);
syncedLibraries.add(metadata.getName());
}
// Delete old Jar files
for (File file : FileUtils.listFiles(localRepoDir, new String[] { "jar" }, false)) {
if (!syncedLibraries.contains(file.getName())) {
try {
LOGGER.info("Delete {}, because it's not present on the server side", file.toPath());
Files.delete(file.toPath());
} catch (IOException e) {
LOGGER.error("Unable to delete old library {} during sync.", file, e);
}
}
}
}
Aggregations