summaryrefslogtreecommitdiffstats
path: root/vespaclient-core
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-09-28 15:00:27 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-09-28 15:00:27 +0200
commitf9dd06806afef90b069f4fa0c99f77beb040851d (patch)
treeecce12a3af04d80e5d39b0ebce919aa5c0fef81b /vespaclient-core
parent321194bbe4a36d100d92188644d90c6cf4d373c7 (diff)
Support document-api in application
Diffstat (limited to 'vespaclient-core')
-rwxr-xr-xvespaclient-core/src/main/java/com/yahoo/feedapi/FeedContext.java14
-rwxr-xr-xvespaclient-core/src/main/java/com/yahoo/feedapi/FeederOptions.java12
-rwxr-xr-xvespaclient-core/src/main/java/com/yahoo/feedapi/MessageBusSessionFactory.java12
-rwxr-xr-xvespaclient-core/src/main/java/com/yahoo/feedhandler/VespaFeedHandler.java12
-rwxr-xr-xvespaclient-core/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerBase.java10
-rw-r--r--vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java32
6 files changed, 55 insertions, 37 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..c08d70b02f4 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;
@@ -87,16 +90,21 @@ 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);
+ MessageBusSessionFactory mbusFactory = new MessageBusSessionFactory(proc, documentmanagerConfig, slobroksConfig);
instance = new FeedContext(proc,
mbusFactory,
mbusFactory.getAccess().getDocumentTypeManager(),
- new ClusterList("client"), metric);
+ new ClusterList(clusterListConfig), metric);
} else {
instance.getPropertyProcessor().configure(feederConfig, loadTypeConfig);
}
diff --git a/vespaclient-core/src/main/java/com/yahoo/feedapi/FeederOptions.java b/vespaclient-core/src/main/java/com/yahoo/feedapi/FeederOptions.java
index 2894993b983..1546d605f02 100755
--- a/vespaclient-core/src/main/java/com/yahoo/feedapi/FeederOptions.java
+++ b/vespaclient-core/src/main/java/com/yahoo/feedapi/FeederOptions.java
@@ -252,18 +252,6 @@ public class FeederOptions {
return params;
}
- public MessageBusParams toMessageBusParams() {
- MessageBusParams mbusParams = new MessageBusParams();
- if (retryEnabled) {
- RetryTransientErrorsPolicy retryPolicy = new RetryTransientErrorsPolicy();
- retryPolicy.setBaseDelay(retryDelay);
- mbusParams.setRetryPolicy(retryPolicy);
- } else {
- mbusParams.setRetryPolicy(null);
- }
- return mbusParams;
- }
-
public RPCNetworkParams getNetworkParams() {
try {
RPCNetworkParams networkParams = new RPCNetworkParams();
diff --git a/vespaclient-core/src/main/java/com/yahoo/feedapi/MessageBusSessionFactory.java b/vespaclient-core/src/main/java/com/yahoo/feedapi/MessageBusSessionFactory.java
index 8021ea86783..2d340810b3c 100755
--- a/vespaclient-core/src/main/java/com/yahoo/feedapi/MessageBusSessionFactory.java
+++ b/vespaclient-core/src/main/java/com/yahoo/feedapi/MessageBusSessionFactory.java
@@ -1,6 +1,8 @@
// 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.SlobroksConfig;
+import com.yahoo.document.config.DocumentmanagerConfig;
import com.yahoo.documentapi.VisitorParameters;
import com.yahoo.documentapi.VisitorSession;
import com.yahoo.documentapi.messagebus.MessageBusDocumentAccess;
@@ -12,6 +14,7 @@ import com.yahoo.jdisc.Metric;
import com.yahoo.messagebus.Message;
import com.yahoo.messagebus.ReplyHandler;
import com.yahoo.messagebus.SourceSession;
+import com.yahoo.messagebus.network.rpc.RPCNetworkParams;
import java.util.Collections;
@@ -27,12 +30,17 @@ public class MessageBusSessionFactory implements SessionFactory {
String NUM_UPDATES = "num_updates";
}
- public MessageBusSessionFactory(MessagePropertyProcessor processor) {
+ public MessageBusSessionFactory(MessagePropertyProcessor processor,
+ DocumentmanagerConfig documentmanagerConfig,
+ SlobroksConfig slobroksConfig) {
this.processor = processor;
MessageBusParams params = new MessageBusParams(processor.getLoadTypes());
params.setTraceLevel(processor.getFeederOptions().getTraceLevel());
- params.setRPCNetworkParams(processor.getFeederOptions().getNetworkParams());
+ RPCNetworkParams rpcNetworkParams = processor.getFeederOptions().getNetworkParams();
+ rpcNetworkParams.setSlobroksConfig(slobroksConfig);
+ params.setRPCNetworkParams(rpcNetworkParams);
params.setDocumentManagerConfigId("client");
+ params.setDocumentmanagerConfig(documentmanagerConfig);
access = new MessageBusDocumentAccess(params);
}
diff --git a/vespaclient-core/src/main/java/com/yahoo/feedhandler/VespaFeedHandler.java b/vespaclient-core/src/main/java/com/yahoo/feedhandler/VespaFeedHandler.java
index 6e3facbdc98..08e1ca0482f 100755
--- a/vespaclient-core/src/main/java/com/yahoo/feedhandler/VespaFeedHandler.java
+++ b/vespaclient-core/src/main/java/com/yahoo/feedhandler/VespaFeedHandler.java
@@ -3,8 +3,11 @@ package com.yahoo.feedhandler;
import com.google.inject.Inject;
import com.yahoo.clientmetrics.RouteMetricSet;
+import com.yahoo.cloud.config.ClusterListConfig;
+import com.yahoo.cloud.config.SlobroksConfig;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.container.jdisc.HttpResponse;
+import com.yahoo.document.config.DocumentmanagerConfig;
import com.yahoo.feedapi.DocprocMessageProcessor;
import com.yahoo.feedapi.FeedContext;
import com.yahoo.feedapi.Feeder;
@@ -30,9 +33,14 @@ public final class VespaFeedHandler extends VespaFeedHandlerBase {
public static final String JSON_INPUT = "jsonInput";
@Inject
- public VespaFeedHandler(FeederConfig feederConfig, LoadTypeConfig loadTypeConfig, Executor executor,
+ public VespaFeedHandler(FeederConfig feederConfig,
+ LoadTypeConfig loadTypeConfig,
+ DocumentmanagerConfig documentmanagerConfig,
+ SlobroksConfig slobroksConfig,
+ ClusterListConfig clusterListConfig,
+ Executor executor,
Metric metric) throws Exception {
- super(feederConfig, loadTypeConfig, executor, metric);
+ super(feederConfig, loadTypeConfig, documentmanagerConfig, slobroksConfig, clusterListConfig, executor, metric);
}
VespaFeedHandler(FeedContext context, Executor executor) throws Exception {
diff --git a/vespaclient-core/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerBase.java b/vespaclient-core/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerBase.java
index fa1e6854593..6b4810f1ac4 100755
--- a/vespaclient-core/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerBase.java
+++ b/vespaclient-core/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerBase.java
@@ -3,11 +3,14 @@ package com.yahoo.feedhandler;
import com.google.inject.Inject;
import com.yahoo.clientmetrics.ClientMetrics;
+import com.yahoo.cloud.config.ClusterListConfig;
+import com.yahoo.cloud.config.SlobroksConfig;
import com.yahoo.component.provider.ComponentRegistry;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.container.jdisc.ThreadedHttpRequestHandler;
import com.yahoo.docproc.DocprocService;
import com.yahoo.document.DocumentTypeManager;
+import com.yahoo.document.config.DocumentmanagerConfig;
import com.yahoo.feedapi.FeedContext;
import com.yahoo.feedapi.MessagePropertyProcessor;
import com.yahoo.feedapi.SharedSender;
@@ -29,9 +32,14 @@ public abstract class VespaFeedHandlerBase extends ThreadedHttpRequestHandler {
@Inject
public VespaFeedHandlerBase(FeederConfig feederConfig,
LoadTypeConfig loadTypeConfig,
+ DocumentmanagerConfig documentmanagerConfig,
+ SlobroksConfig slobroksConfig,
+ ClusterListConfig clusterListConfig,
Executor executor,
Metric metric) throws Exception {
- this(FeedContext.getInstance(feederConfig, loadTypeConfig, metric), executor, (long)feederConfig.timeout() * 1000);
+ this(FeedContext.getInstance(feederConfig, loadTypeConfig, documentmanagerConfig,
+ slobroksConfig, clusterListConfig, metric),
+ executor, (long)feederConfig.timeout() * 1000);
}
public VespaFeedHandlerBase(FeedContext context, Executor executor) throws Exception {
diff --git a/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java b/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java
index 3ea3bb5cb9d..8d214651359 100644
--- a/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java
+++ b/vespaclient-core/src/main/java/com/yahoo/vespaclient/ClusterList.java
@@ -7,34 +7,32 @@ import com.yahoo.config.subscription.ConfigGetter;
import java.util.ArrayList;
import java.util.List;
+/** A list of content clusters, either obtained from a list, a given config or by self-subscribing */
public class ClusterList {
- List<ClusterDef> storageClusters = new ArrayList<ClusterDef>();
+
+ List<ClusterDef> storageClusters = new ArrayList<>();
public ClusterList() {
- this(null);
+ this((String)null);
}
public ClusterList(String configId) {
- if (configId != null) {
+ if (configId != null)
configure(new ConfigGetter<>(ClusterListConfig.class).getConfig(configId));
- }
}
-
- public List<ClusterDef> getStorageClusters() {
- return storageClusters;
+
+ public ClusterList(ClusterListConfig config) {
+ configure(config);
}
- public void configure(ClusterListConfig cfg) {
- storageClusters.clear();
- for (int i = 0; i < cfg.storage().size(); i++) {
- storageClusters.add(new ClusterDef(cfg.storage(i).name(),
- cfg.storage(i).configid()));
- }
+ private void configure(ClusterListConfig config) {
+ storageClusters.clear(); // TODO: Create a new
+ for (int i = 0; i < config.storage().size(); i++)
+ storageClusters.add(new ClusterDef(config.storage(i).name(), config.storage(i).configid()));
}
- public static ClusterList createMockedList(List<ClusterDef> clusters) {
- ClusterList list = new ClusterList(null);
- list.storageClusters = clusters;
- return list;
+ public List<ClusterDef> getStorageClusters() {
+ return storageClusters; // TODO: Use immutable list
}
+
}