From 58c42b2ee9d83f72a896076b3fb6a3a8b13544fd Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Fri, 20 Sep 2019 15:22:18 +0200 Subject: Cleanup - no functional changes --- .../java/com/yahoo/search/cache/package-info.java | 10 -- .../com/yahoo/search/cluster/ClusterSearcher.java | 34 +++--- .../main/java/com/yahoo/search/cluster/Hasher.java | 18 ++- .../com/yahoo/search/cluster/PingableSearcher.java | 3 +- .../java/com/yahoo/documentapi/DocumentAccess.java | 124 ++++++++------------- 5 files changed, 72 insertions(+), 117 deletions(-) delete mode 100644 container-search/src/main/java/com/yahoo/search/cache/package-info.java diff --git a/container-search/src/main/java/com/yahoo/search/cache/package-info.java b/container-search/src/main/java/com/yahoo/search/cache/package-info.java deleted file mode 100644 index fb3a9188a55..00000000000 --- a/container-search/src/main/java/com/yahoo/search/cache/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -/** - * Cache package, exported to keep the ignored legacy cache config around until Vespa 7. - * - * @author bratseth - */ -@ExportPackage -package com.yahoo.search.cache; - -import com.yahoo.osgi.annotation.ExportPackage; diff --git a/container-search/src/main/java/com/yahoo/search/cluster/ClusterSearcher.java b/container-search/src/main/java/com/yahoo/search/cluster/ClusterSearcher.java index e99199d85f7..dd8b953e3d0 100644 --- a/container-search/src/main/java/com/yahoo/search/cluster/ClusterSearcher.java +++ b/container-search/src/main/java/com/yahoo/search/cluster/ClusterSearcher.java @@ -63,9 +63,7 @@ public abstract class ClusterSearcher extends PingableSearcher implements Nod } } - /** - * Pinging a node, called from ClusterMonitor - */ + /** Pinging a node, called from ClusterMonitor */ @Override public final void ping(T p, Executor executor) { log(LogLevel.FINE, "Sending ping to: ", p); @@ -149,9 +147,10 @@ public abstract class ClusterSearcher extends PingableSearcher implements Nod do { // The loop is in case there are other searchers available able to produce results if (connection == null) - return search(query, execution, ErrorMessage - .createNoBackendsInService("No in node could handle " + query + " according to " + - hasher + " in " + this)); + return search(query, + execution, + ErrorMessage.createNoBackendsInService("No in node could handle " + query + + " according to " + hasher + " in " + this)); if (timedOut(query)) return new Result(query, ErrorMessage.createTimeout("No time left for searching")); @@ -189,7 +188,7 @@ public abstract class ClusterSearcher extends PingableSearcher implements Nod } /** - * This is called (instead of search(quer,execution,connextion) to handle + * This is called (instead of search(query, execution, connection) to handle * searches where no (suitable) backend was available. The default * implementation returns an error result. */ @@ -198,7 +197,7 @@ public abstract class ClusterSearcher extends PingableSearcher implements Nod } /** - * Call search(Query,Execution,T) and handle any exceptions returned which + * Call search(Query, Execution, T) and handle any exceptions returned which * we do not want to propagate upwards By default this catches all runtime * exceptions and puts them into the result */ @@ -214,13 +213,12 @@ public abstract class ClusterSearcher extends PingableSearcher implements Nod } if (result == null) - result = new Result(query, ErrorMessage - .createBackendCommunicationError("No result returned in " + this + - " from " + connection + " for " + query)); + result = new Result(query, ErrorMessage.createBackendCommunicationError("No result returned in " + this + + " from " + connection + " for " + query)); if (result.hits().getError() != null) { log(LogLevel.FINE, "FAILED: ", query); - } else if (!result.isCached()) { + } else if ( ! result.isCached()) { log(LogLevel.FINE, "WORKING: ", query); } else { log(LogLevel.FINE, "CACHE HIT: ", query); @@ -243,15 +241,13 @@ public abstract class ClusterSearcher extends PingableSearcher implements Nod T connection = nodes.select(code, 0); if (connection != null) { if (timedOut(query)) { - result.hits().addError( - ErrorMessage.createTimeout("No time left to get summaries for " + result)); + result.hits().addError(ErrorMessage.createTimeout("No time left to get summaries for " + result)); } else { // query.setTimeout(getNodeTimeout(query)); doFill(connection, result, summaryClass, execution); } } else { - result.hits().addError( - ErrorMessage.createNoBackendsInService("Could not fill '" + result + "' in '" + this + "'")); + result.hits().addError(ErrorMessage.createNoBackendsInService("Could not fill '" + result + "' in '" + this + "'")); } } @@ -259,10 +255,8 @@ public abstract class ClusterSearcher extends PingableSearcher implements Nod try { fill(result, summaryClass, execution, connection); } catch (RuntimeException e) { - result.hits().addError( - ErrorMessage - .createBackendCommunicationError("Error filling " + result + " from " + connection + ": " + - Exceptions.toMessageString(e))); + result.hits().addError(ErrorMessage.createBackendCommunicationError("Error filling " + result + " from " + connection + ": " + + Exceptions.toMessageString(e))); } if (result.hits().getError() != null) { log(LogLevel.FINE, "FAILED: ", result.getQuery()); diff --git a/container-search/src/main/java/com/yahoo/search/cluster/Hasher.java b/container-search/src/main/java/com/yahoo/search/cluster/Hasher.java index 5eda79a0885..46752b0bedb 100644 --- a/container-search/src/main/java/com/yahoo/search/cluster/Hasher.java +++ b/container-search/src/main/java/com/yahoo/search/cluster/Hasher.java @@ -98,14 +98,13 @@ public class Hasher { * and determines how often this node will be selected compared * to the other nodes */ - public synchronized void add(T node,int load) { - assert(nodes != null); - if(!nodes.hasNode(node)) { + public synchronized void add(T node, int load) { + if ( ! nodes.hasNode(node)) { NodeFactor[] oldNodes = nodes.nodes; @SuppressWarnings("unchecked") - NodeFactor[] newNodes = (NodeFactor[]) new NodeFactor[oldNodes.length+ 1]; - System.arraycopy(oldNodes,0,newNodes,0,oldNodes.length); - newNodes[newNodes.length-1] = new NodeFactor<>(node, load); + NodeFactor[] newNodes = (NodeFactor[]) new NodeFactor[oldNodes.length + 1]; + System.arraycopy(oldNodes, 0, newNodes, 0, oldNodes.length); + newNodes[newNodes.length - 1] = new NodeFactor<>(node, load); //Atomic switch due to volatile nodes = new NodeList<>(newNodes); @@ -114,7 +113,7 @@ public class Hasher { /** Removes a node */ public synchronized void remove(T node) { - if( nodes.hasNode(node)) { + if (nodes.hasNode(node)) { NodeFactor[] oldNodes = nodes.nodes; @SuppressWarnings("unchecked") NodeFactor[] newNodes = (NodeFactor[]) new NodeFactor[oldNodes.length - 1]; @@ -128,10 +127,9 @@ public class Hasher { } } - /** - * Returns a list of nodes that are up. - */ + /** Returns a list of nodes that are up.*/ public NodeList getNodes() { return nodes; } + } diff --git a/container-search/src/main/java/com/yahoo/search/cluster/PingableSearcher.java b/container-search/src/main/java/com/yahoo/search/cluster/PingableSearcher.java index 145970f5407..57bb5c9d47d 100644 --- a/container-search/src/main/java/com/yahoo/search/cluster/PingableSearcher.java +++ b/container-search/src/main/java/com/yahoo/search/cluster/PingableSearcher.java @@ -14,8 +14,7 @@ import com.yahoo.search.searchchain.Execution; */ public abstract class PingableSearcher extends Searcher { - public PingableSearcher() { - } + public PingableSearcher() { } public PingableSearcher(ComponentId id) { super(id); diff --git a/documentapi/src/main/java/com/yahoo/documentapi/DocumentAccess.java b/documentapi/src/main/java/com/yahoo/documentapi/DocumentAccess.java index 2d6010fce41..d6c3d3ce92f 100644 --- a/documentapi/src/main/java/com/yahoo/documentapi/DocumentAccess.java +++ b/documentapi/src/main/java/com/yahoo/documentapi/DocumentAccess.java @@ -11,20 +11,20 @@ import com.yahoo.config.subscription.ConfigSubscriber; * access to documents in a document repository. The document api contains four * separate access types:

* - *
  • Synchronous random access - provided by {@link SyncSession}, - * allows simple access where throughput is not a concern.
  • + *
      + *
    • Synchronous random access - provided by {@link SyncSession}, + * allows simple access where throughput is not a concern. *
    • Asynchronous random access - provided by {@link AsyncSession}, - * allows document repository writes and random access with high - * throughput.
    • + * allows document repository writes and random access with high throughput. *
    • Visiting - provided by {@link VisitorSession}, allows a set of * documents to be accessed in an order decided by the document repository. This - * allows much higher read throughput than random access.
    • + * allows much higher read throughput than random access. *
    • Subscription - provided by {@link SubscriptionSession}, allows * changes to a defined set of documents in the repository to be - * visited.
    + * visited. + *
* - *

This class is the factory for creating the four session types mentioned - * above.

+ *

This class is the factory for creating the four session types mentioned above.

* *

There may be multiple implementations of the document api classes. If * default configuration is sufficient, use the {@link #createDefault} method to @@ -35,8 +35,7 @@ import com.yahoo.config.subscription.ConfigSubscriber; * access types defined in this interface. For example, some document * repositories, like indexes, are write only. Others may support random * access, but not visiting and subscription. Any method which is not supported - * by the underlying implementation will throw - * UnsupportedOperationException.

+ * by the underlying implementation will throw UnsupportedOperationException.

* *

Access to this class is thread-safe.

* @@ -50,22 +49,22 @@ public abstract class DocumentAccess { private final ConfigSubscriber documentTypeConfigSubscriber; /** - *

This is a convenience method to return a document access object with + * This is a convenience method to return a document access object with * all default parameter values. The client that calls this method is also * responsible for shutting the object down when done. If an error occurred * while attempting to create such an object, this method will throw an - * exception.

+ * exception. * - * @return A running document access object with all default configuration. + * @return a running document access object with all default configuration */ public static DocumentAccess createDefault() { return new com.yahoo.documentapi.messagebus.MessageBusDocumentAccess(); } /** - *

Constructs a new document access object.

+ * Constructs a new document access object. * - * @param params The parameters to use for setup. + * @param params the parameters to use for setup */ protected DocumentAccess(DocumentAccessParams params) { super(); @@ -80,89 +79,70 @@ public abstract class DocumentAccess { } /** - *

Returns a session for synchronous document access. Use this for simple - * access.

+ * Returns a session for synchronous document access. Use this for simple access. * - * @param parameters The parameters of this sync session. - * @return A session to use for synchronous document access. - * @throws UnsupportedOperationException If this access implementation does - * not support synchronous access. - * @throws RuntimeException If an error prevented the session - * from being created. + * @param parameters the parameters of this sync session + * @return a session to use for synchronous document access + * @throws UnsupportedOperationException if this access implementation does not support synchronous access + * @throws RuntimeException if an error prevented the session from being created. */ public abstract SyncSession createSyncSession(SyncParameters parameters); /** - *

Returns a session for asynchronous document access. Use this if high - * operation throughput is required.

+ * Returns a session for asynchronous document access. Use this if high operation throughput is required. * - * @param parameters The parameters of this async session. - * @return A session to use for asynchronous document access. - * @throws UnsupportedOperationException If this access implementation does - * not support asynchronous access. - * @throws RuntimeException If an error prevented the session - * from being created. + * @param parameters the parameters of this async session. + * @return a session to use for asynchronous document access. + * @throws UnsupportedOperationException if this access implementation does not support asynchronous access. + * @throws RuntimeException if an error prevented the session from being created */ public abstract AsyncSession createAsyncSession(AsyncParameters parameters); /** - *

Run a visitor with the given visitor parameters, and get the result - * back here.

+ * Run a visitor with the given visitor parameters, and get the result back here. * * @param parameters The parameters of this visitor session. - * @return A session used to track progress of the visitor and get the - * actual data returned. - * @throws UnsupportedOperationException If this access implementation does - * not support visiting. - * @throws RuntimeException If an error prevented the session - * from being created. - * @throws ParseException If the document selection string - * could not be parsed. + * @return a session used to track progress of the visitor and get the actual data returned. + * @throws UnsupportedOperationException if this access implementation does not support visiting + * @throws RuntimeException if an error prevented the session from being created + * @throws ParseException if the document selection string could not be parsed */ public abstract VisitorSession createVisitorSession(VisitorParameters parameters) throws ParseException; /** - *

Creates a destination session for receiving data from visiting. The - * visitor must be started and progress tracked through a visitor - * session.

+ * Creates a destination session for receiving data from visiting. + * The visitor must be started and progress tracked through a visitor session. * - * @param parameters The parameters of this visitor destination session. - * @return A session used to get the actual data returned. - * @throws UnsupportedOperationException If this access implementation does - * not support visiting. + * @param parameters the parameters of this visitor destination session + * @return a session used to get the actual data returned + * @throws UnsupportedOperationException if this access implementation does not support visiting. */ public abstract VisitorDestinationSession createVisitorDestinationSession(VisitorDestinationParameters parameters); /** - *

Creates a subscription and returns a session for getting data from - * it. Use this to get document operations being done by other parties.

+ * Creates a subscription and returns a session for getting data from it. + * Use this to get document operations being done by other parties. * - * @param parameters The parameters of this subscription session. - * @return A session to use for document subscription. - * @throws UnsupportedOperationException If this access implementation does - * not support subscription. - * @throws RuntimeException If an error prevented the session - * from being created. + * @param parameters The parameters of this subscription session + * @return a session to use for document subscription + * @throws UnsupportedOperationException if this access implementation does not support subscription + * @throws RuntimeException if an error prevented the session from being created */ public abstract SubscriptionSession createSubscription(SubscriptionParameters parameters); /** - *

Returns a session for document subscription. Use this to get document - * operations being done by other parties.

+ * Returns a session for document subscription. Use this to get document operations being done by other parties. * - * @param parameters The parameters of this subscription session. - * @return A session to use for document subscription. - * @throws UnsupportedOperationException If this access implementation does - * not support subscription. - * @throws RuntimeException If an error prevented the session - * from being created. + * @param parameters the parameters of this subscription session + * @return a session to use for document subscription + * @throws UnsupportedOperationException if this access implementation does not support subscription + * @throws RuntimeException if an error prevented the session from being created */ public abstract SubscriptionSession openSubscription(SubscriptionParameters parameters); /** * Shuts down the underlying sessions used by this DocumentAccess; - * subsequent use of this DocumentAccess will throw unspecified exceptions, - * depending on implementation. + * subsequent use of this DocumentAccess will throw unspecified exceptions, depending on implementation. * Classes overriding this must call super.shutdown(). */ public void shutdown() { @@ -170,13 +150,7 @@ public abstract class DocumentAccess { documentTypeConfigSubscriber.close(); } - /** - *

Returns the {@link DocumentTypeManager} used by this - * DocumentAccess.

- * - * @return The document type manager. - */ - public DocumentTypeManager getDocumentTypeManager() { - return documentTypeManager; - } + /** Returns the {@link DocumentTypeManager} used by this DocumentAccess. */ + public DocumentTypeManager getDocumentTypeManager() { return documentTypeManager; } + } -- cgit v1.2.3