diff options
8 files changed, 39 insertions, 54 deletions
diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/FileDistribution.java b/config-model-api/src/main/java/com/yahoo/config/model/api/FileDistribution.java index cecee567a0b..ae39440335a 100644 --- a/config-model-api/src/main/java/com/yahoo/config/model/api/FileDistribution.java +++ b/config-model-api/src/main/java/com/yahoo/config/model/api/FileDistribution.java @@ -15,7 +15,8 @@ import java.util.Set; */ public interface FileDistribution { - void sendDeployedFiles(String hostName, Set<FileReference> fileReferences); + // TODO: Remove when 6.223 is oldest version used + default void sendDeployedFiles(String hostName, Set<FileReference> fileReferences) {} /** * Notifies client which file references to download. Used to start downloading early (while @@ -27,9 +28,11 @@ public interface FileDistribution { */ void startDownload(String hostName, int port, Set<FileReference> fileReferences); - void reloadDeployFileDistributor(); + // TODO: Remove when 6.223 is oldest version used + default void reloadDeployFileDistributor() {} - void removeDeploymentsThatHaveDifferentApplicationId(Collection<String> targetHostnames); + // TODO: Remove when 6.223 is oldest version used + default void removeDeploymentsThatHaveDifferentApplicationId(Collection<String> targetHostnames) {} static String getDefaultFileDBRoot() { return Defaults.getDefaults().underVespaHome("var/db/vespa/filedistribution"); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java index a6b28a9d6e8..91830019573 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java @@ -201,7 +201,6 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Seri } public FileDistributor getFileDistributor() { - // return root.getFileDistributionConfigProducer().getFileDistributor(); return fileDistributor; } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/filedistribution/FileDistributor.java b/config-model/src/main/java/com/yahoo/vespa/model/filedistribution/FileDistributor.java index abd4b604a6d..a4557c2ea9c 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/filedistribution/FileDistributor.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/filedistribution/FileDistributor.java @@ -9,7 +9,6 @@ import com.yahoo.vespa.model.ConfigProxy; import com.yahoo.vespa.model.Host; import java.util.*; -import java.util.stream.Collectors; /** * Responsible for directing distribution of files to hosts. @@ -101,10 +100,6 @@ public class FileDistributor { return hosts; } - public Set<String> getTargetHostnames() { - return getTargetHosts().stream().map(Host::getHostname).collect(Collectors.toSet()); - } - /** Returns the host which is the source of the files */ public String fileSourceHost() { return fileRegistry.fileSourceHost(); @@ -119,7 +114,6 @@ public class FileDistributor { String fileSourceHost = fileSourceHost(); for (Host host : getTargetHosts()) { if ( ! host.getHostname().equals(fileSourceHost)) { - dbHandler.sendDeployedFiles(host.getHostname(), filesToSendToHost(host)); dbHandler.startDownload(host.getHostname(), ConfigProxy.BASEPORT, filesToSendToHost(host)); } } @@ -128,9 +122,6 @@ public class FileDistributor { configServerSpecs.stream() .filter(configServerSpec -> !configServerSpec.getHostName().equals(fileSourceHost)) .forEach(spec -> dbHandler.startDownload(spec.getHostName(), spec.getConfigServerPort(), allFilesToSend())); - - dbHandler.sendDeployedFiles(fileSourceHost, allFilesToSend()); - dbHandler.removeDeploymentsThatHaveDifferentApplicationId(getTargetHostnames()); } } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/filedistribution/FileDistributorTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/filedistribution/FileDistributorTestCase.java index 26d08bc1677..eabd0e5a7e0 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/filedistribution/FileDistributorTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/filedistribution/FileDistributorTestCase.java @@ -2,12 +2,15 @@ package com.yahoo.vespa.model.filedistribution; import com.yahoo.config.FileReference; +import com.yahoo.config.model.api.FileDistribution; import com.yahoo.config.model.application.provider.MockFileRegistry; import com.yahoo.config.model.test.MockHosts; import org.junit.Test; import java.util.Arrays; import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -22,13 +25,28 @@ public class FileDistributorTestCase { FileDistributor fileDistributor = new FileDistributor(new MockFileRegistry(), null); - FileReference ref1 = fileDistributor.sendFileToHosts("components/path1", Arrays.asList(hosts.host1, hosts.host2)); - FileReference ref2 = fileDistributor.sendFileToHosts("path2", Arrays.asList(hosts.host3)); + String file1 = "component/path1"; + String file2 = "component/path2"; + FileReference ref1 = fileDistributor.sendFileToHosts(file1, Arrays.asList(hosts.host1, hosts.host2)); + FileReference ref2 = fileDistributor.sendFileToHosts(file2, Arrays.asList(hosts.host3)); assertEquals(new HashSet<>(Arrays.asList(hosts.host1, hosts.host2, hosts.host3)), fileDistributor.getTargetHosts()); assertTrue( ref1 != null ); assertTrue( ref2 != null ); + + MockFileDistribution dbHandler = new MockFileDistribution(); + fileDistributor.sendDeployedFiles(dbHandler); + assertEquals(3, dbHandler.filesToDownloadCalled); // One time for each host + } + + private static class MockFileDistribution implements FileDistribution { + int filesToDownloadCalled = 0; + + @Override + public void startDownload(String hostName, int port, Set<FileReference> fileReferences) { + filesToDownloadCalled++; + } } } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDistributionImpl.java b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDistributionImpl.java index c39f85ec87f..bfc195cb32e 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDistributionImpl.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDistributionImpl.java @@ -11,7 +11,6 @@ import com.yahoo.jrt.Supervisor; import com.yahoo.jrt.Target; import com.yahoo.log.LogLevel; -import java.util.Collection; import java.util.Set; import java.util.logging.Logger; @@ -28,25 +27,10 @@ public class FileDistributionImpl implements FileDistribution { } @Override - public void sendDeployedFiles(String hostName, Set<FileReference> fileReferences) { - // Nothing do do, legacy handler not in use anymore - } - - @Override public void startDownload(String hostName, int port, Set<FileReference> fileReferences) { startDownloadingFileReferences(hostName, port, fileReferences); } - @Override - public void reloadDeployFileDistributor() { - // Nothing do do, legacy handler not in use anymore - } - - @Override - public void removeDeploymentsThatHaveDifferentApplicationId(Collection<String> targetHostnames) { - // Nothing do do, legacy handler not in use anymore - } - // 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, int port, Set<FileReference> fileReferences) { 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 d518867407a..728f327c829 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 @@ -4,31 +4,14 @@ package com.yahoo.vespa.config.server.filedistribution; import com.yahoo.config.FileReference; import com.yahoo.config.model.api.FileDistribution; -import java.util.Collection; import java.util.Set; /** * @author Ulf Lilleengen */ public class MockFileDBHandler implements FileDistribution { - public int sendDeployedFilesCalled = 0; - public int removeDeploymentsThatHaveDifferentApplicationIdCalled = 0; @Override - public void sendDeployedFiles(String hostName, Set<FileReference> fileReferences) { - sendDeployedFilesCalled++; - } + public void startDownload(String hostName, int port, Set<FileReference> fileReferences) {} - @Override - public void startDownload(String hostName, int port, Set<FileReference> fileReferences) { - throw new UnsupportedOperationException("Not valid for this Filedistribution implementation"); - } - - @Override - public void reloadDeployFileDistributor() {} - - @Override - public void removeDeploymentsThatHaveDifferentApplicationId(Collection<String> targetHostnames) { - removeDeploymentsThatHaveDifferentApplicationIdCalled++; - } } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/MockFileDistributionProvider.java b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/MockFileDistributionProvider.java index c45c0695343..531ba388d00 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/MockFileDistributionProvider.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/MockFileDistributionProvider.java @@ -1,6 +1,7 @@ // 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.server.filedistribution; +import com.yahoo.config.model.api.FileDistribution; import com.yahoo.config.model.application.provider.MockFileRegistry; /** @@ -8,11 +9,17 @@ import com.yahoo.config.model.application.provider.MockFileRegistry; * @since 5.1 */ public class MockFileDistributionProvider extends FileDistributionProvider { + public int timesCalled = 0; public MockFileDistributionProvider() { super(new MockFileRegistry(), new MockFileDBHandler()); } + public FileDistribution getFileDistribution() { + timesCalled++; + return super.getFileDistribution(); + } + public MockFileDBHandler getMockFileDBHandler() { return (MockFileDBHandler) getFileDistribution(); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java index ac16f1f71a7..4fbd7fe7232 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java @@ -68,7 +68,7 @@ public class SessionPreparerTest extends TestWithCurator { public TemporaryFolder folder = new TemporaryFolder(); @Before - public void setUp() throws Exception { + public void setUp() { componentRegistry = new TestComponentRegistry.Builder().curator(curator).build(); fileDistributionFactory = (MockFileDistributionFactory)componentRegistry.getFileDistributionFactory(); preparer = createPreparer(); @@ -123,15 +123,15 @@ public class SessionPreparerTest extends TestWithCurator { @Test public void require_that_filedistribution_is_ignored_on_dryrun() throws IOException { preparer.prepare(getContext(getApplicationPackage(testApp)), getLogger(), - new PrepareParams.Builder().dryRun(true).timeoutBudget(TimeoutBudgetTest.day()).build(), - Optional.empty(), tenantPath, Instant.now()); - assertThat(fileDistributionFactory.mockFileDistributionProvider.getMockFileDBHandler().sendDeployedFilesCalled, is(0)); + new PrepareParams.Builder().dryRun(true).timeoutBudget(TimeoutBudgetTest.day()).build(), + Optional.empty(), tenantPath, Instant.now()); + assertThat(fileDistributionFactory.mockFileDistributionProvider.timesCalled, is(0)); } @Test public void require_that_application_is_prepared() throws Exception { preparer.prepare(getContext(getApplicationPackage(testApp)), getLogger(), new PrepareParams.Builder().build(), Optional.empty(), tenantPath, Instant.now()); - assertThat(fileDistributionFactory.mockFileDistributionProvider.getMockFileDBHandler().sendDeployedFilesCalled, is(2)); + assertThat(fileDistributionFactory.mockFileDistributionProvider.timesCalled, is(2)); assertTrue(configCurator.exists(sessionsPath.append(ConfigCurator.USERAPP_ZK_SUBPATH).append("services.xml").getAbsolute())); } |