summaryrefslogtreecommitdiffstats
path: root/standalone-container
diff options
context:
space:
mode:
authorJon Bratseth <jonbratseth@yahoo.com>2016-09-29 23:28:23 +0200
committerGitHub <noreply@github.com>2016-09-29 23:28:23 +0200
commit8aeed8886002cc6ad9261da57763766cad5ca7bf (patch)
tree814bc1c016c679e67306101e7b409ce7c4d2272b /standalone-container
parent151d1cf4c09fc24c39d665a0818c64ff7bf80716 (diff)
parent0d27136b2912ce0dd6ca1c6cc5341ebeba71dc12 (diff)
Merge pull request #738 from yahoo/bratseth/support-document-api-in-applications
Bratseth/support document api in applications
Diffstat (limited to 'standalone-container')
-rw-r--r--standalone-container/src/main/scala/com/yahoo/application/container/impl/ClassLoaderOsgiFramework.scala3
-rw-r--r--standalone-container/src/main/scala/com/yahoo/container/standalone/StandaloneContainerApplication.scala11
-rw-r--r--standalone-container/src/main/scala/com/yahoo/container/standalone/StandaloneSubscriberFactory.scala3
-rw-r--r--standalone-container/src/test/java/com/yahoo/container/standalone/StandaloneContainerActivatorTest.java2
-rw-r--r--standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneContainer.scala2
-rw-r--r--standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneContainerTest.scala6
6 files changed, 19 insertions, 8 deletions
diff --git a/standalone-container/src/main/scala/com/yahoo/application/container/impl/ClassLoaderOsgiFramework.scala b/standalone-container/src/main/scala/com/yahoo/application/container/impl/ClassLoaderOsgiFramework.scala
index 6d45e6fa8a1..5a41462cb48 100644
--- a/standalone-container/src/main/scala/com/yahoo/application/container/impl/ClassLoaderOsgiFramework.scala
+++ b/standalone-container/src/main/scala/com/yahoo/application/container/impl/ClassLoaderOsgiFramework.scala
@@ -17,6 +17,8 @@ import org.osgi.framework.wiring._
import org.osgi.resource.{Wire, Capability, Requirement}
/**
+ * A (mock) OSGI implementation which loads classes from the system classpath
+ *
* @author tonytv
*/
final class ClassLoaderOsgiFramework extends OsgiFramework {
@@ -197,4 +199,5 @@ final class ClassLoaderOsgiFramework extends OsgiFramework {
override def createFilter(filter: String) = throw new UnsupportedOperationException
}
+
}
diff --git a/standalone-container/src/main/scala/com/yahoo/container/standalone/StandaloneContainerApplication.scala b/standalone-container/src/main/scala/com/yahoo/container/standalone/StandaloneContainerApplication.scala
index 3f31dcd67ca..fc57353c194 100644
--- a/standalone-container/src/main/scala/com/yahoo/container/standalone/StandaloneContainerApplication.scala
+++ b/standalone-container/src/main/scala/com/yahoo/container/standalone/StandaloneContainerApplication.scala
@@ -10,6 +10,7 @@ import java.io.{IOException, File}
import com.yahoo.config.model.test.MockRoot
import com.yahoo.config.model.application.provider._
import com.yahoo.vespa.defaults.Defaults
+import com.yahoo.vespa.model.VespaModel
import com.yahoo.vespa.model.container.xml.{ConfigServerContainerModelBuilder, ManhattanContainerModelBuilder, ContainerModelBuilder}
import org.w3c.dom.Element
import com.yahoo.config.model.builder.xml.XmlHelper
@@ -164,7 +165,7 @@ object StandaloneContainerApplication {
fileRegistry: FileRegistry,
preprocessedApplicationDir: File,
networkingOption: Networking,
- configModelRepo: ConfigModelRepo = new ConfigModelRepo): (MockRoot, Container) = {
+ configModelRepo: ConfigModelRepo = new ConfigModelRepo): (VespaModel, Container) = {
val logger = new BaseDeployLogger
val rawApplicationPackage = new FilesApplicationPackage.Builder(applicationPath.toFile).includeSourceFiles(true).preprocessedDir(preprocessedApplicationDir).build()
// TODO: Needed until we get rid of semantic rules
@@ -179,12 +180,13 @@ object StandaloneContainerApplication {
configDefinitionRepo(configDefinitionRepo).
build()
- val root = new MockRoot("", deployState)
+ val root = VespaModel.createIncomplete(deployState)
val vespaRoot = new ApplicationConfigProducerRoot(root,
"vespa",
deployState.getDocumentModel,
deployState.getProperties.vespaVersion(),
deployState.getProperties.applicationId())
+
val spec = containerRootElement(applicationPackage)
val containerModel = newContainerModelBuilder(networkingOption).build(deployState, configModelRepo, vespaRoot, spec)
@@ -192,11 +194,16 @@ object StandaloneContainerApplication {
containerModel.initialize(configModelRepo)
val container = first(containerModel.getCluster().getContainers)
+ // TODO: If we can do the mutations below on the builder, we can separate out model finalization from the
+ // VespaModel constructor, such that the above and below code to finalize the container can be
+ // replaced by root.finalize();
+
// Always disable rpc server for standalone container. This server will soon be removed anyway.
container.setRpcServerEnabled(false)
container.setHttpServerEnabled(networkingOption == Networking.enable)
initializeContainer(container, spec)
+
root.freezeModelTopology()
(root, container)
}
diff --git a/standalone-container/src/main/scala/com/yahoo/container/standalone/StandaloneSubscriberFactory.scala b/standalone-container/src/main/scala/com/yahoo/container/standalone/StandaloneSubscriberFactory.scala
index 432e5b82946..4ac88eaafae 100644
--- a/standalone-container/src/main/scala/com/yahoo/container/standalone/StandaloneSubscriberFactory.scala
+++ b/standalone-container/src/main/scala/com/yahoo/container/standalone/StandaloneSubscriberFactory.scala
@@ -4,6 +4,7 @@ package com.yahoo.container.standalone
import com.yahoo.config.model.test.MockRoot
import com.yahoo.config.{ConfigBuilder, ConfigInstance}
import com.yahoo.container.di.ConfigKeyT
+import com.yahoo.vespa.model.VespaModel
import scala.collection.JavaConversions._
import scala.collection.JavaConverters._
import com.yahoo.vespa.config.ConfigKey
@@ -14,7 +15,7 @@ import StandaloneSubscriberFactory._
* @author tonytv
* @author gjoranv
*/
-class StandaloneSubscriberFactory(root: MockRoot) extends SubscriberFactory {
+class StandaloneSubscriberFactory(root: VespaModel) extends SubscriberFactory {
class StandaloneSubscriber(configKeys: Set[ConfigKeyT]) extends Subscriber {
override def configChanged =
generation == 0
diff --git a/standalone-container/src/test/java/com/yahoo/container/standalone/StandaloneContainerActivatorTest.java b/standalone-container/src/test/java/com/yahoo/container/standalone/StandaloneContainerActivatorTest.java
index 484d4c4d50e..f847f05108e 100644
--- a/standalone-container/src/test/java/com/yahoo/container/standalone/StandaloneContainerActivatorTest.java
+++ b/standalone-container/src/test/java/com/yahoo/container/standalone/StandaloneContainerActivatorTest.java
@@ -24,7 +24,7 @@ import static org.hamcrest.collection.IsEmptyCollection.empty;
import static org.junit.Assert.assertThat;
/**
- * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
+ * @author Einar M R Rosenvinge
* @since 5.22.0
*/
public class StandaloneContainerActivatorTest {
diff --git a/standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneContainer.scala b/standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneContainer.scala
index 7152c0c0af1..f0c2ce6fa0d 100644
--- a/standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneContainer.scala
+++ b/standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneContainer.scala
@@ -32,7 +32,7 @@ object StandaloneContainer {
}
}
- def withContainerModel[T](containerNode: Node)(f: MockRoot => T) {
+ def withContainerModel[T](containerNode: Node)(f: VespaModel => T) {
withTempDirectory { applicationPath =>
createServicesXml(applicationPath, containerNode)
diff --git a/standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneContainerTest.scala b/standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneContainerTest.scala
index 41026e1c263..2705322ab32 100644
--- a/standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneContainerTest.scala
+++ b/standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneContainerTest.scala
@@ -58,7 +58,7 @@ class StandaloneContainerTest {
</services>
StandaloneContainer.withContainerModel(servicesXml) {
root =>
- assertNotNull(root.getProducer("container-1/standalone"))
+ assertTrue(root.getConfigProducer("container-1/standalone").isPresent)
}
}
@@ -72,10 +72,10 @@ class StandaloneContainerTest {
</jdisc>
StandaloneContainer.withContainerModel(xml) { root =>
- val container = root.getProducer("jdisc/standalone").asInstanceOf[AbstractService]
+ val container = root.getConfigProducer("jdisc/standalone").get().asInstanceOf[AbstractService]
println("portCnt: " + container.getPortCount)
println("numPorts: " + container.getNumPortsAllocated)
- assertThat(container.getNumPortsAllocated, is(1))
+ assertEquals(1, container.getNumPortsAllocated)
}
}