From 607e3cb63d4e5b1abd36a5519b4e08b2af391622 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Sat, 20 Apr 2019 14:10:24 +0200 Subject: Avoid '*' imports. Some minor cleanup while reading code. --- .../com/yahoo/feedapi/DummySessionFactory.java | 80 +++------------------- .../yahoo/feedapi/MessageBusSessionFactory.java | 12 ---- .../yahoo/feedapi/MessagePropertyProcessor.java | 12 ---- .../java/com/yahoo/feedapi/SessionFactory.java | 11 --- .../main/java/com/yahoo/feedapi/SingleSender.java | 4 -- 5 files changed, 11 insertions(+), 108 deletions(-) (limited to 'vespaclient-core/src') diff --git a/vespaclient-core/src/main/java/com/yahoo/feedapi/DummySessionFactory.java b/vespaclient-core/src/main/java/com/yahoo/feedapi/DummySessionFactory.java index dd1e5858aee..c644b551a79 100755 --- a/vespaclient-core/src/main/java/com/yahoo/feedapi/DummySessionFactory.java +++ b/vespaclient-core/src/main/java/com/yahoo/feedapi/DummySessionFactory.java @@ -2,8 +2,6 @@ package com.yahoo.feedapi; import com.yahoo.document.Document; -import com.yahoo.documentapi.VisitorParameters; -import com.yahoo.documentapi.VisitorSession; import com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage; import com.yahoo.jdisc.Metric; import com.yahoo.messagebus.EmptyReply; @@ -24,97 +22,41 @@ public class DummySessionFactory implements SessionFactory { } public final List messages; - private boolean autoReply = false; - private ReplyFactory autoReplyFactory = null; - private Error autoError; - private int sessionsCreated = 0; - OutputStream output = null; + private boolean autoReply; + private OutputStream output = null; - protected DummySessionFactory() { - messages = new ArrayList<>(); - } - - public static DummySessionFactory createDefault() { - return new DummySessionFactory(); - } - - protected DummySessionFactory(boolean autoReply) { + private DummySessionFactory(boolean autoReply) { this.autoReply = autoReply; messages = new ArrayList<>(); } - protected DummySessionFactory(ReplyFactory autoReplyFactory) { - this.autoReply = true; - this.autoReplyFactory = autoReplyFactory; - messages = new ArrayList<>(); - } - - public static DummySessionFactory createWithAutoReplyFactory(ReplyFactory autoReplyFactory) { - return new DummySessionFactory(autoReplyFactory); - } - - protected DummySessionFactory(Error e) { - autoReply = true; - this.autoError = e; - messages = new ArrayList<>(); - } - - public static DummySessionFactory createWithErrorAutoReply(Error e) { - return new DummySessionFactory(e); - } - public static DummySessionFactory createWithAutoReply() { return new DummySessionFactory(true); } - public DummySessionFactory(Error e, OutputStream out) { + public DummySessionFactory(OutputStream out) { messages = null; autoReply = true; output = out; } - public int sessionsCreated() { - return sessionsCreated; - } - void add(Message m) { + private void add(Message m) { if (messages != null) { messages.add(m); } - } @Override public SendSession createSendSession(ReplyHandler r, Metric metric) { - ++sessionsCreated; - if (output != null) { return new DumpDocuments(output, r, this); } if (autoReply) { - return new AutoReplySession(r, autoReplyFactory, autoError, this); + return new AutoReplySession(r, null, null, this); } return new DummySession(r, this); } - @Override - public VisitorSession createVisitorSession(VisitorParameters p) { - return null; - } - - public void sendReply(Message m, Error error) { - MyContext ctxt = (MyContext) m.getContext(); - - Reply r = new EmptyReply(); - r.setMessage(m); - r.setContext(ctxt.oldContext); - - if (error != null) { - r.addError(error); - } - - ctxt.handler.handleReply(r); - } - private class MyContext { MyContext(ReplyHandler handler, Object ctxt) { this.handler = handler; @@ -132,7 +74,7 @@ public class DummySessionFactory implements SessionFactory { Error e; DummySessionFactory owner; - public AutoReplySession(ReplyHandler handler, ReplyFactory replyFactory, + AutoReplySession(ReplyHandler handler, ReplyFactory replyFactory, Error e, DummySessionFactory owner) { this.handler = handler; this.replyFactory = replyFactory; @@ -145,7 +87,7 @@ public class DummySessionFactory implements SessionFactory { } @Override - protected Result onSend(Message m, boolean blockIfQueueFull) throws InterruptedException { + protected Result onSend(Message m, boolean blockIfQueueFull) { owner.add(m); handleMessage(m); Reply r; @@ -174,7 +116,7 @@ public class DummySessionFactory implements SessionFactory { private class DumpDocuments extends AutoReplySession { final OutputStream out; - public DumpDocuments(OutputStream out, ReplyHandler r, DummySessionFactory factory) { + DumpDocuments(OutputStream out, ReplyHandler r, DummySessionFactory factory) { super(r, null, null, factory); this.out = out; } @@ -191,13 +133,13 @@ public class DummySessionFactory implements SessionFactory { ReplyHandler handler; DummySessionFactory owner; - public DummySession(ReplyHandler handler, DummySessionFactory owner) { + DummySession(ReplyHandler handler, DummySessionFactory owner) { this.handler = handler; this.owner = owner; } @Override - protected Result onSend(Message m, boolean blockIfQueueFull) throws InterruptedException { + protected Result onSend(Message m, boolean blockIfQueueFull) { m.setContext(new MyContext(handler, m.getContext())); owner.add(m); return Result.ACCEPTED; 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 54e638717e0..12a4ecde493 100755 --- a/vespaclient-core/src/main/java/com/yahoo/feedapi/MessageBusSessionFactory.java +++ b/vespaclient-core/src/main/java/com/yahoo/feedapi/MessageBusSessionFactory.java @@ -3,8 +3,6 @@ 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; import com.yahoo.documentapi.messagebus.MessageBusParams; import com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage; @@ -30,7 +28,6 @@ public class MessageBusSessionFactory implements SessionFactory { String NUM_UPDATES = "num_updates"; } - @SuppressWarnings("unused") // used from extensions public MessageBusSessionFactory(MessagePropertyProcessor processor) { this(processor, null, null); } @@ -66,15 +63,6 @@ public class MessageBusSessionFactory implements SessionFactory { access.shutdown(); } - @Override - public synchronized VisitorSession createVisitorSession(VisitorParameters params) { - try { - return access.createVisitorSession(params); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - private class SourceSessionWrapper extends SendSession { private final SourceSession session; diff --git a/vespaclient-core/src/main/java/com/yahoo/feedapi/MessagePropertyProcessor.java b/vespaclient-core/src/main/java/com/yahoo/feedapi/MessagePropertyProcessor.java index 3897f1d7d2a..11688ba62e4 100644 --- a/vespaclient-core/src/main/java/com/yahoo/feedapi/MessagePropertyProcessor.java +++ b/vespaclient-core/src/main/java/com/yahoo/feedapi/MessagePropertyProcessor.java @@ -40,10 +40,6 @@ public class MessagePropertyProcessor implements ConfigSubscriber.SingleSubscrib private LoadTypeSet loadTypes = null; private boolean configChanged = false; - public MessagePropertyProcessor(String configId, String loadTypeConfig) { - new ConfigSubscriber().subscribe(this, FeederConfig.class, configId); - loadTypes = new LoadTypeSet(loadTypeConfig); - } public MessagePropertyProcessor(FeederConfig config, LoadTypeConfig loadTypeCfg) { loadTypes = new LoadTypeSet(); @@ -282,14 +278,6 @@ public class MessagePropertyProcessor implements ConfigSubscriber.SingleSubscrib this.priority = priority; } - public LoadType getLoadType() { - return loadType; - } - - public void setLoadType(LoadType loadType) { - this.loadType = loadType; - } - public boolean getAbortOnDocumentError() { return abortOnDocumentError; } diff --git a/vespaclient-core/src/main/java/com/yahoo/feedapi/SessionFactory.java b/vespaclient-core/src/main/java/com/yahoo/feedapi/SessionFactory.java index 0bba3964bf7..6dce2b6f315 100755 --- a/vespaclient-core/src/main/java/com/yahoo/feedapi/SessionFactory.java +++ b/vespaclient-core/src/main/java/com/yahoo/feedapi/SessionFactory.java @@ -1,8 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.feedapi; -import com.yahoo.documentapi.VisitorParameters; -import com.yahoo.documentapi.VisitorSession; import com.yahoo.jdisc.Metric; import com.yahoo.messagebus.ReplyHandler; @@ -20,13 +18,4 @@ public interface SessionFactory { * @return The session to use for sending messages. */ SendSession createSendSession(ReplyHandler handler, Metric metric); - - /** - * Creates a messagebus session for visiting data. - * - * @param params Parameters to the visitor - * @return A visitor session. - */ - VisitorSession createVisitorSession(VisitorParameters params); - } diff --git a/vespaclient-core/src/main/java/com/yahoo/feedapi/SingleSender.java b/vespaclient-core/src/main/java/com/yahoo/feedapi/SingleSender.java index e0e12b26ae6..9d0c740789e 100755 --- a/vespaclient-core/src/main/java/com/yahoo/feedapi/SingleSender.java +++ b/vespaclient-core/src/main/java/com/yahoo/feedapi/SingleSender.java @@ -27,10 +27,6 @@ public class SingleSender implements SimpleFeedAccess { this.blockingQueue = blockingQueue; } - public SingleSender(SharedSender.ResultCallback owner, SharedSender sender) { - this(owner, sender, true); - } - @Override public void put(Document doc) { send(new PutDocumentMessage(new DocumentPut(doc))); -- cgit v1.2.3