diff options
author | Harald Musum <musum@yahoo-inc.com> | 2017-11-16 11:15:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-16 11:15:32 +0100 |
commit | 6fac1dceb62f0142cbd9a862c932558a14e38cea (patch) | |
tree | 1939894a5f81b26ce40df737f103e65b6b8b2a46 | |
parent | 8265f7cf4e007e66a825a43d96ebcbdbc5507ddf (diff) | |
parent | 7ce13177593a900534aa59f3a58391fee32a7ace (diff) |
Merge pull request #4140 from vespa-engine/hmusum/move-new-filedistribution-classes
Hmusum/move new filedistribution classes
-rw-r--r-- | config-proxy/pom.xml | 13 | ||||
-rw-r--r-- | config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ProxyServer.java | 4 | ||||
-rw-r--r-- | filedistribution/pom.xml | 38 | ||||
-rw-r--r-- | filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileDistributionRpcServer.java (renamed from config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDistributionRpcServer.java) | 4 | ||||
-rw-r--r-- | filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileDownloader.java (renamed from config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDownloader.java) | 4 | ||||
-rw-r--r-- | filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReceiver.java (renamed from config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileReceiver.java) | 2 | ||||
-rw-r--r-- | filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownload.java (renamed from config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileReferenceDownload.java) | 2 | ||||
-rw-r--r-- | filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownloader.java (renamed from config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileReferenceDownloader.java) | 2 | ||||
-rw-r--r-- | filedistribution/src/main/java/com/yahoo/vespa/filedistribution/RpcTester.java | 98 | ||||
-rw-r--r-- | filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileDownloaderTest.java (renamed from config-proxy/src/test/java/com/yahoo/vespa/config/proxy/filedistribution/FileDownloaderTest.java) | 4 |
10 files changed, 156 insertions, 15 deletions
diff --git a/config-proxy/pom.xml b/config-proxy/pom.xml index 8a7b6f253e2..13e2ddf40e8 100644 --- a/config-proxy/pom.xml +++ b/config-proxy/pom.xml @@ -57,10 +57,15 @@ <artifactId>hamcrest-core</artifactId> <scope>test</scope> </dependency> - <dependency> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> + <dependency> + <groupId>com.yahoo.vespa</groupId> + <artifactId>filedistribution</artifactId> + <version>${project.version}</version> + </dependency> </dependencies> <build> <plugins> diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ProxyServer.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ProxyServer.java index 173d2b8a43a..28bcca9db13 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ProxyServer.java +++ b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ProxyServer.java @@ -13,8 +13,8 @@ import com.yahoo.log.event.Event; import com.yahoo.system.CatchSigTerm; import com.yahoo.vespa.config.*; import com.yahoo.vespa.config.protocol.JRTServerConfigRequest; -import com.yahoo.vespa.config.proxy.filedistribution.FileDistributionRpcServer; -import com.yahoo.vespa.config.proxy.filedistribution.FileDownloader; +import com.yahoo.vespa.filedistribution.FileDistributionRpcServer; +import com.yahoo.vespa.filedistribution.FileDownloader; import java.util.List; import java.util.concurrent.Executors; diff --git a/filedistribution/pom.xml b/filedistribution/pom.xml index e63b85a22b8..288b641134f 100644 --- a/filedistribution/pom.xml +++ b/filedistribution/pom.xml @@ -4,7 +4,43 @@ 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> + <dependencies> + <dependency> + <groupId>com.yahoo.vespa</groupId> + <artifactId>config-lib</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.yahoo.vespa</groupId> + <artifactId>vespajlib</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.yahoo.vespa</groupId> + <artifactId>jrt</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.yahoo.vespa</groupId> + <artifactId>vespalog</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.yahoo.vespa</groupId> + <artifactId>config</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <parent> <groupId>com.yahoo.vespa</groupId> <artifactId>parent</artifactId> <version>6-SNAPSHOT</version> diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDistributionRpcServer.java b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileDistributionRpcServer.java index b0fbc7acd33..d09cf17b9e3 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDistributionRpcServer.java +++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileDistributionRpcServer.java @@ -1,5 +1,5 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.config.proxy.filedistribution; +// 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 com.yahoo.config.FileReference; import com.yahoo.jrt.DoubleArray; diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDownloader.java b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileDownloader.java index ac7555c7905..cd4b3afb9b5 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileDownloader.java +++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileDownloader.java @@ -1,5 +1,5 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.config.proxy.filedistribution; +// 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 com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileReceiver.java b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReceiver.java index e9631c445df..3999389d2c7 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileReceiver.java +++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReceiver.java @@ -1,6 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.config.proxy.filedistribution; +package com.yahoo.vespa.filedistribution; import com.yahoo.config.FileReference; import com.yahoo.jrt.Int32Value; diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileReferenceDownload.java b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownload.java index ce5a30dc7ad..fb511411128 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileReferenceDownload.java +++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownload.java @@ -1,6 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.config.proxy.filedistribution; +package com.yahoo.vespa.filedistribution; import com.google.common.util.concurrent.SettableFuture; import com.yahoo.config.FileReference; diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileReferenceDownloader.java b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownloader.java index c972cfbbf56..fbadddd624a 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/filedistribution/FileReferenceDownloader.java +++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/FileReferenceDownloader.java @@ -1,5 +1,5 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.config.proxy.filedistribution; +package com.yahoo.vespa.filedistribution; import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.ListenableFuture; diff --git a/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/RpcTester.java b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/RpcTester.java new file mode 100644 index 00000000000..28935c203fe --- /dev/null +++ b/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/RpcTester.java @@ -0,0 +1,98 @@ +// 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 com.yahoo.config.FileReference; +import com.yahoo.io.IOUtils; +import com.yahoo.jrt.DataValue; +import com.yahoo.jrt.Int32Value; +import com.yahoo.jrt.Int64Value; +import com.yahoo.jrt.Request; +import com.yahoo.jrt.Spec; +import com.yahoo.jrt.StringValue; +import com.yahoo.jrt.Supervisor; +import com.yahoo.jrt.Target; +import com.yahoo.jrt.Transport; +import com.yahoo.log.LogLevel; +import net.jpountz.xxhash.XXHash64; +import net.jpountz.xxhash.XXHashFactory; + +import java.io.File; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.logging.Logger; + +public class RpcTester { + + private static final Logger log = Logger.getLogger(RpcTester.class.getName()); + + private final Target target; + + private RpcTester(Target target) { + this.target = target; + } + + private void call(String fileReference, String filename, byte[] blob) { + new FileReceiver(target).receive(new FileReference(fileReference), filename, blob); + } + + public static void main(String[] args) { + //String fileReference = args[0]; + String fileReference = "59f93f445438c9db7ccbf1629f583c2aa004a68b"; + String filename = "com.yahoo.vespatest.ExtraHitSearcher-1.0.0-deploy.jar"; + File file = new File(String.format("/tmp/%s/%s", fileReference, filename)); + byte[] blob = null; + + try { + blob = IOUtils.readFileBytes(file); + } catch (IOException e) { + e.printStackTrace(); + } + + log.log(LogLevel.INFO, "Read blob from " + file.getAbsolutePath()); + + + Supervisor supervisor = new Supervisor(new Transport()); + + Spec spec = new Spec("tcp/localhost:19090"); + log.log(LogLevel.INFO, "Connecting to " + spec); + Target target = supervisor.connect(spec); + if (! target.isValid()) { + log.log(LogLevel.INFO, "Could not connect"); + System.exit(1); + } else { + log.log(LogLevel.INFO, "Connected to " + spec); + } + + new RpcTester(target).call(fileReference, filename, blob); + } + + class FileReceiver { + + Target target; + + FileReceiver(Target target) { + this.target = target; + } + + void receive(FileReference reference, String filename, byte[] content) { + + log.log(LogLevel.INFO, "Preparing receive call for " + reference.value() + " and file " + filename); + + XXHash64 hasher = XXHashFactory.fastestInstance().hash64(); + Request fileBlob = new Request("filedistribution.receiveFile"); + + log.log(LogLevel.INFO, "Calling " + fileBlob.methodName() + " with target " + target); + + fileBlob.parameters().add(new StringValue(reference.value())); + fileBlob.parameters().add(new StringValue(filename)); + fileBlob.parameters().add(new DataValue(content)); + fileBlob.parameters().add(new Int64Value(hasher.hash(ByteBuffer.wrap(content), 0))); + fileBlob.parameters().add(new Int32Value(0)); + fileBlob.parameters().add(new StringValue("OK")); + log.log(LogLevel.INFO, "Doing invokeSync"); + target.invokeSync(fileBlob, 5); + log.log(LogLevel.INFO, "Done with invokeSync"); + } + } +} diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/filedistribution/FileDownloaderTest.java b/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileDownloaderTest.java index d1b691b9d5e..738b0888956 100644 --- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/filedistribution/FileDownloaderTest.java +++ b/filedistribution/src/test/java/com/yahoo/vespa/filedistribution/FileDownloaderTest.java @@ -1,4 +1,6 @@ -package com.yahoo.vespa.config.proxy.filedistribution; +// 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 com.yahoo.config.FileReference; import com.yahoo.io.IOUtils; |