diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-02-08 13:35:40 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2018-02-08 13:35:40 +0000 |
commit | 086f587961cb65f0d6641825608be7ef5acdfe5d (patch) | |
tree | 2611fb7eac73ffb1aee6e5c16185ad6d82330e4c /filedistributionmanager | |
parent | 6d6c5c8051042709371e3de580619cd9e5ade74f (diff) |
Remove FileDistributionManager.
Diffstat (limited to 'filedistributionmanager')
7 files changed, 0 insertions, 185 deletions
diff --git a/filedistributionmanager/.gitignore b/filedistributionmanager/.gitignore deleted file mode 100644 index 39c0275a1b2..00000000000 --- a/filedistributionmanager/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -target -/pom.xml.build diff --git a/filedistributionmanager/OWNERS b/filedistributionmanager/OWNERS deleted file mode 100644 index 31af040f698..00000000000 --- a/filedistributionmanager/OWNERS +++ /dev/null @@ -1 +0,0 @@ -bratseth diff --git a/filedistributionmanager/README b/filedistributionmanager/README deleted file mode 100644 index 935a0160136..00000000000 --- a/filedistributionmanager/README +++ /dev/null @@ -1 +0,0 @@ -Java wrapper of the file distribution component.
\ No newline at end of file diff --git a/filedistributionmanager/pom.xml b/filedistributionmanager/pom.xml deleted file mode 100644 index 9f037814a12..00000000000 --- a/filedistributionmanager/pom.xml +++ /dev/null @@ -1,20 +0,0 @@ -<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>com.yahoo.vespa</groupId> - <artifactId>parent</artifactId> - <version>6-SNAPSHOT</version> - <relativePath>../parent/pom.xml</relativePath> - </parent> - <artifactId>filedistributionmanager</artifactId> - <version>6-SNAPSHOT</version> - <dependencies> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>vespajlib</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> -</project> diff --git a/filedistributionmanager/src/main/java/com/yahoo/vespa/filedistribution/FileDistributionManager.java b/filedistributionmanager/src/main/java/com/yahoo/vespa/filedistribution/FileDistributionManager.java deleted file mode 100644 index f0c463abe70..00000000000 --- a/filedistributionmanager/src/main/java/com/yahoo/vespa/filedistribution/FileDistributionManager.java +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.filedistribution; - -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.concurrent.locks.Lock; - -/** - * @author tonytv - */ -public class FileDistributionManager { - - private final static boolean available; - - @SuppressWarnings({"UnusedDeclaration"}) // Needs to be here due to JNI - private long nativeFileDistributionManager; - - private final File applicationDirectory; - private final String appId; - private final Lock lock; - - - private native static void setup(); - - private native void init(byte[] fileDbDirectory, byte[] zkServers); - - private native String addFileImpl(byte[] absolutePath); - - private native void setDeployedFilesImpl(byte[] host, byte[] appId, byte[][] fileReferences); - - private native void removeDeploymentsThatHaveDifferentApplicationIdImpl(byte[][] asByteArrays, byte[] bytes); - - private byte[][] getAsByteArrays(Collection<String> strings) { - byte[][] byteArrays = new byte[strings.size()][]; - int i = 0; - for (String string : strings) { - byteArrays[i++] = string.getBytes(); - } - return byteArrays; - } - - @Override - protected void finalize() throws Throwable { - shutdown(); - super.finalize(); - } - - static { - available = loadLibrary("filedistributionmanager"); - if (available) - setup(); - } - - private static boolean loadLibrary(String name) { - try { - System.loadLibrary(name); - return true; - } - catch (UnsatisfiedLinkError e) { - return false; - } - } - - /** Returns whether this functionality is available in this runtime */ - public static boolean isAvailable() { return available; } - - private byte[] absolutePath(File file) { - return file.getAbsolutePath().getBytes(); - } - - private void ensureDirExists(File dir) { - if (!dir.exists()) { - throw new PathDoesNotExistException(dir.getPath()); - } - } - - public FileDistributionManager(File fileDbDirectory, File applicationDirectory, String zkServers, String appId, Lock lock) { - ensureDirExists(applicationDirectory); - ensureDirExists(fileDbDirectory); - - this.applicationDirectory = applicationDirectory; - this.appId = appId; - this.lock = lock; - - init(fileDbDirectory.getPath().getBytes(), zkServers.getBytes()); - } - - public String addFile(String relativePath) { - File path = new File(applicationDirectory, relativePath); - if (!path.exists()) - throw new PathDoesNotExistException(path.getPath()); - - try (LockGuard guard = new LockGuard(lock)) { - return addFileImpl(absolutePath(path)); - } - } - - public void setDeployedFiles(String hostName, Collection<String> fileReferences) { - try (LockGuard guard = new LockGuard(lock)) { - setDeployedFilesImpl(hostName.getBytes(), appId.getBytes(), getAsByteArrays(fileReferences)); - } - } - - public void reloadDeployFileDistributor() { - try (LockGuard guard = new LockGuard(lock)) { - /* - * Try sending signal to vespa-filedistributor and - * filedistributor processes. Note 15 char limit for process - * name on Linux, see pkill manual page for details. - */ - Runtime.getRuntime().exec("pkill -SIGUSR1 ^(vespa-filedistr|filedistributor)$"); - } catch (IOException e) { - throw new RuntimeException("Failed to reinitialize the filedistributor", e); - } - } - - - public native void shutdown(); - - public void removeDeploymentsThatHaveDifferentApplicationId(Collection<String> targetHostnames) { - try (LockGuard guard = new LockGuard(lock)) { - removeDeploymentsThatHaveDifferentApplicationIdImpl(getAsByteArrays(targetHostnames), appId.getBytes()); - } - } - - private static class LockGuard implements AutoCloseable { - private final Lock lock; - public LockGuard(Lock lock) { - this.lock = lock; - lock.lock(); - } - - @Override - public void close() { - lock.unlock(); - } - } -} diff --git a/filedistributionmanager/src/main/java/com/yahoo/vespa/filedistribution/PathDoesNotExistException.java b/filedistributionmanager/src/main/java/com/yahoo/vespa/filedistribution/PathDoesNotExistException.java deleted file mode 100755 index 5dfdc0f9d7d..00000000000 --- a/filedistributionmanager/src/main/java/com/yahoo/vespa/filedistribution/PathDoesNotExistException.java +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.filedistribution; - -/** - * @author gjoranv - */ -public class PathDoesNotExistException extends RuntimeException { - public final String path; - - PathDoesNotExistException(String path) { - super("Path '" + path + "' does not exist."); - this.path = path; - } -} diff --git a/filedistributionmanager/src/main/resources/filedistributionmanager_java.mak b/filedistributionmanager/src/main/resources/filedistributionmanager_java.mak deleted file mode 100644 index ea4da1df3d0..00000000000 --- a/filedistributionmanager/src/main/resources/filedistributionmanager_java.mak +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -ifndef MODULEDEF_FILEDISTRIBUTIONMANAGER_JAVA -MODULEDEF_FILEDISTRIBUTIONMANAGER_JAVA=FILEDISTRIBUTIONMANAGER_JAVA -MODULE_DEFINES_FILEDISTRIBUTIONMANAGER_JAVA= -MODULE_INCLUDES_FILEDISTRIBUTIONMANAGER_JAVA= -MODULE_MAKEMAKE_FILEDISTRIBUTIONMANAGER_JAVA= -MODULE_LIST += FILEDISTRIBUTIONMANAGER_JAVA -endif |