summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorJon Marius Venstad <jvenstad@yahoo-inc.com>2017-12-14 09:26:22 +0100
committerJon Marius Venstad <jvenstad@yahoo-inc.com>2017-12-14 09:26:22 +0100
commita3fc6158428e18169ee379f405ee35181e71c443 (patch)
tree78220382451bd0dc048ca2c9148ebc435f9f8aba /configserver
parentc403f41f013ca98726b4c34a1be1c6ec5924ec7f (diff)
parente494bf9f475d72f0a6f429e73dff03560f2c659f (diff)
Conflict resolved
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java14
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/CombinedLegacyDistribution.java35
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDBHandler.java10
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileServer.java11
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/MockFileDBHandler.java6
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/deploy/MockDeployer.java5
7 files changed, 69 insertions, 15 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
index 13401d4a4a6..a4dd943aa47 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
@@ -112,6 +112,18 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
* Creates a new deployment from the active application, if available.
*
* @param application the active application to be redeployed
+ * @return a new deployment from the local active, or empty if a local active application
+ * was not present for this id (meaning it either is not active or active on another
+ * node in the config server cluster)
+ */
+ public Optional<com.yahoo.config.provision.Deployment> deployFromLocalActive(ApplicationId application) {
+ return deployFromLocalActive(application, Duration.ofSeconds(configserverConfig.zookeeper().barrierTimeout()).plus(Duration.ofSeconds(5)));
+ }
+
+ /**
+ * Creates a new deployment from the active application, if available.
+ *
+ * @param application the active application to be redeployed
* @param timeout the timeout to use for each individual deployment operation
* @return a new deployment from the local active, or empty if a local active application
* was not present for this id (meaning it either is not active or active on another
@@ -352,7 +364,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
private void redeployApplication(ApplicationId applicationId, Deployer deployer, ExecutorService deploymentExecutor) {
log.log(LogLevel.DEBUG, () -> "Redeploying " + applicationId);
- deployer.deployFromLocalActive(applicationId, Duration.ofMinutes(30))
+ deployer.deployFromLocalActive(applicationId)
.ifPresent(deployment -> deploymentExecutor.execute(() -> {
try {
deployment.activate();
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/CombinedLegacyDistribution.java b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/CombinedLegacyDistribution.java
index 588f2d1d63f..f0e64a936a5 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/CombinedLegacyDistribution.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/CombinedLegacyDistribution.java
@@ -3,22 +3,43 @@ package com.yahoo.vespa.config.server.filedistribution;
import com.yahoo.config.FileReference;
import com.yahoo.config.model.api.FileDistribution;
+import com.yahoo.jrt.Request;
+import com.yahoo.jrt.Spec;
+import com.yahoo.jrt.StringArray;
+import com.yahoo.jrt.Supervisor;
+import com.yahoo.jrt.Target;
+import com.yahoo.jrt.Transport;
+import com.yahoo.log.LogLevel;
import java.util.Collection;
import java.util.Set;
+import java.util.logging.Logger;
+/**
+ * @author baldersheim
+ */
public class CombinedLegacyDistribution implements FileDistribution {
+ private final static Logger log = Logger.getLogger(CombinedLegacyDistribution.class.getName());
+
+ private final Supervisor supervisor = new Supervisor(new Transport());
private final FileDistribution legacy;
CombinedLegacyDistribution(FileDBHandler legacy) {
this.legacy = legacy;
}
+
@Override
public void sendDeployedFiles(String hostName, Set<FileReference> fileReferences) {
legacy.sendDeployedFiles(hostName, fileReferences);
}
@Override
+ public void startDownload(String hostName, Set<FileReference> fileReferences) {
+ // TODO: Not active for now
+ // startDownloadingFileReferences(hostName, fileReferences);
+ }
+
+ @Override
public void reloadDeployFileDistributor() {
legacy.reloadDeployFileDistributor();
}
@@ -27,4 +48,18 @@ public class CombinedLegacyDistribution implements FileDistribution {
public void removeDeploymentsThatHaveDifferentApplicationId(Collection<String> targetHostnames) {
legacy.removeDeploymentsThatHaveDifferentApplicationId(targetHostnames);
}
+
+ // Notifies config proxy which file references it should start downloading. It's OK if the call does not succeed,
+ // as downloading will then start synchronously when a service requests a file reference instead
+ private void startDownloadingFileReferences(String hostName, Set<FileReference> fileReferences) {
+ Target target = supervisor.connect(new Spec(hostName, 19090));
+ double timeout = 0.1;
+ Request request = new Request("filedistribution.setFileReferencesToDownload");
+ request.parameters().add(new StringArray(fileReferences.stream().map(FileReference::value).toArray(String[]::new)));
+ log.log(LogLevel.INFO, "Executing " + request.methodName() + " against " + target.toString());
+ target.invokeSync(request, timeout);
+ if (request.isError()) {
+ log.log(LogLevel.INFO, request.methodName() + " failed: " + request.errorCode() + " (" + request.errorMessage() + ")");
+ }
+ }
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDBHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDBHandler.java
index f0ce6104496..9b3f4c39a45 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDBHandler.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDBHandler.java
@@ -10,9 +10,8 @@ import java.util.*;
/**
* Implements invoker of filedistribution using manager with JNI.
*
- * @author tonytv
- * @author lulf
- * @since 5.1.14
+ * @author Tony Vaagenes
+ * @author Ulf Lilleengen
*/
public class FileDBHandler implements FileDistribution {
private final FileDistributionManager manager;
@@ -31,6 +30,11 @@ public class FileDBHandler implements FileDistribution {
}
@Override
+ public void startDownload(String hostName, Set<FileReference> fileReferences) {
+ throw new UnsupportedOperationException("Not valid for this Filedistribution implementation");
+ }
+
+ @Override
public void removeDeploymentsThatHaveDifferentApplicationId(Collection<String> targetHostnames) {
manager.removeDeploymentsThatHaveDifferentApplicationId(targetHostnames);
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileServer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileServer.java
index 81f5e62016a..a9c56cf99d0 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileServer.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileServer.java
@@ -6,12 +6,12 @@ import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.config.FileReference;
import com.yahoo.config.model.api.FileDistribution;
import com.yahoo.config.subscription.ConfigSourceSet;
-import com.yahoo.io.IOUtils;
import com.yahoo.jrt.Int32Value;
import com.yahoo.jrt.Request;
import com.yahoo.jrt.StringValue;
import com.yahoo.jrt.Supervisor;
import com.yahoo.jrt.Transport;
+import com.yahoo.log.LogLevel;
import com.yahoo.net.HostName;
import com.yahoo.vespa.config.Connection;
import com.yahoo.vespa.config.ConnectionPool;
@@ -108,8 +108,7 @@ public class FileServer {
private void serveFile(FileReference reference, Receiver target) {
File file = root.getFile(reference);
- // TODO remove once verified in system tests.
- log.info("Start serving reference '" + reference.value() + "' with file '" + file.getAbsolutePath() + "'");
+ log.log(LogLevel.DEBUG, "Start serving reference '" + reference.value() + "' with file '" + file.getAbsolutePath() + "'");
boolean success = false;
String errorDescription = "OK";
FileReferenceData fileData = FileReferenceDataBlob.empty(reference, file.getName());
@@ -122,8 +121,7 @@ public class FileServer {
}
target.receive(fileData, new ReplayStatus(success ? 0 : 1, success ? "OK" : errorDescription));
- // TODO remove once verified in system tests.
- log.info("Done serving reference '" + reference.toString() + "' with file '" + file.getAbsolutePath() + "'");
+ log.log(LogLevel.DEBUG, "Done serving reference '" + reference.toString() + "' with file '" + file.getAbsolutePath() + "'");
}
private FileReferenceData readFileReferenceData(FileReference reference) throws IOException {
@@ -143,8 +141,7 @@ public class FileServer {
private void serveFile(String fileReference, Request request, Receiver receiver) {
FileApiErrorCodes result;
try {
- // TODO remove once verified in system tests.
- log.info("Received request for reference '" + fileReference + "'");
+ log.log(LogLevel.DEBUG, "Received request for reference '" + fileReference + "'");
result = hasFile(fileReference)
? FileApiErrorCodes.OK
: FileApiErrorCodes.NOT_FOUND;
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/MockFileDBHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/MockFileDBHandler.java
index eb23d38e23e..caf64cca4d0 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/MockFileDBHandler.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/MockFileDBHandler.java
@@ -8,8 +8,7 @@ import java.util.Collection;
import java.util.Set;
/**
- * @author lulf
- * @since 5.1
+ * @author Ulf Lilleengen
*/
public class MockFileDBHandler implements FileDistribution {
public int sendDeployedFilesCalled = 0;
@@ -22,6 +21,9 @@ public class MockFileDBHandler implements FileDistribution {
}
@Override
+ public void startDownload(String hostName, Set<FileReference> fileReferences) { /* not implemented */ }
+
+ @Override
public void reloadDeployFileDistributor() {
reloadDeployFileDistributorCalled++;
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java
index 384ae0853d8..5d573323bb6 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ConfigServerBootstrapTest.java
@@ -29,7 +29,6 @@ import java.io.File;
import java.io.FileReader;
import java.time.Clock;
import java.util.ArrayList;
-import java.util.Optional;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertFalse;
@@ -71,7 +70,7 @@ public class ConfigServerBootstrapTest extends TestWithTenant {
VersionState versionState = new VersionState(versionFile);
assertTrue(versionState.isUpgraded());
ConfigServerBootstrap bootstrap =
- new ConfigServerBootstrap(applicationRepository, rpc, (application, timeout) -> Optional.empty(), versionState,
+ new ConfigServerBootstrap(applicationRepository, rpc, new MockDeployer(), versionState,
new StateMonitor(new HealthMonitorConfig(new HealthMonitorConfig.Builder()), new SystemTimer()));
waitUntilStarted(rpc, 60000);
assertFalse(versionState.isUpgraded());
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/MockDeployer.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/MockDeployer.java
index 4fc54943a79..051e7c9a8f9 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/MockDeployer.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/MockDeployer.java
@@ -15,6 +15,11 @@ public class MockDeployer implements com.yahoo.config.provision.Deployer {
public ApplicationId lastDeployed;
@Override
+ public Optional<Deployment> deployFromLocalActive(ApplicationId application) {
+ return deployFromLocalActive(application, Duration.ofSeconds(60));
+ }
+
+ @Override
public Optional<Deployment> deployFromLocalActive(ApplicationId application, Duration timeout) {
lastDeployed = application;
return Optional.empty();