summaryrefslogtreecommitdiffstats
path: root/vespaclient-core/src/main/java/com/yahoo/feedapi/FeedContext.java
diff options
context:
space:
mode:
Diffstat (limited to 'vespaclient-core/src/main/java/com/yahoo/feedapi/FeedContext.java')
-rwxr-xr-xvespaclient-core/src/main/java/com/yahoo/feedapi/FeedContext.java35
1 files changed, 29 insertions, 6 deletions
diff --git a/vespaclient-core/src/main/java/com/yahoo/feedapi/FeedContext.java b/vespaclient-core/src/main/java/com/yahoo/feedapi/FeedContext.java
index a26064cd98b..885e28b63a5 100755
--- a/vespaclient-core/src/main/java/com/yahoo/feedapi/FeedContext.java
+++ b/vespaclient-core/src/main/java/com/yahoo/feedapi/FeedContext.java
@@ -1,6 +1,9 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.feedapi;
+import com.yahoo.cloud.config.ClusterListConfig;
+import com.yahoo.cloud.config.SlobroksConfig;
+import com.yahoo.document.config.DocumentmanagerConfig;
import com.yahoo.jdisc.Metric;
import com.yahoo.vespa.config.content.LoadTypeConfig;
import com.yahoo.document.DocumentTypeManager;
@@ -8,6 +11,7 @@ import com.yahoo.clientmetrics.ClientMetrics;
import com.yahoo.vespaclient.ClusterList;
import com.yahoo.vespaclient.config.FeederConfig;
+import javax.naming.OperationNotSupportedException;
import java.util.Map;
import java.util.TreeMap;
@@ -87,16 +91,35 @@ public class FeedContext {
return docTypeManager;
}
- public static FeedContext getInstance(FeederConfig feederConfig, LoadTypeConfig loadTypeConfig, Metric metric) {
+ public static FeedContext getInstance(FeederConfig feederConfig,
+ LoadTypeConfig loadTypeConfig,
+ DocumentmanagerConfig documentmanagerConfig,
+ SlobroksConfig slobroksConfig,
+ ClusterListConfig clusterListConfig,
+ Metric metric) {
synchronized (sync) {
try {
if (instance == null) {
MessagePropertyProcessor proc = new MessagePropertyProcessor(feederConfig, loadTypeConfig);
- MessageBusSessionFactory mbusFactory = new MessageBusSessionFactory(proc);
- instance = new FeedContext(proc,
- mbusFactory,
- mbusFactory.getAccess().getDocumentTypeManager(),
- new ClusterList("client"), metric);
+
+ if (System.getProperty("vespa.local", "false").equals("true")) {
+ // Use injected configs when running from Application. This means we cannot reconfigure
+ MessageBusSessionFactory mbusFactory = new MessageBusSessionFactory(proc, documentmanagerConfig, slobroksConfig);
+ instance = new FeedContext(proc,
+ mbusFactory,
+ mbusFactory.getAccess().getDocumentTypeManager(),
+ new ClusterList(clusterListConfig), metric);
+ }
+ else {
+ // Don't send configs to messagebus to make it self-subscribe instead as this instance
+ // survives reconfig :-/
+ // This code will die soon ...
+ MessageBusSessionFactory mbusFactory = new MessageBusSessionFactory(proc, null, null);
+ instance = new FeedContext(proc,
+ mbusFactory,
+ mbusFactory.getAccess().getDocumentTypeManager(),
+ new ClusterList("client"), metric);
+ }
} else {
instance.getPropertyProcessor().configure(feederConfig, loadTypeConfig);
}