Skip to content

Commit

Permalink
reduce the frequency that the list of scan servers is sorted (#4547)
Browse files Browse the repository at this point in the history
The provided plugin for working with scan servers sorts the list of scan
servers fairly frequently.  This list will not change too often, so it
could be sorted less to offer a better amortized cost as the total
number of scan servers grows.

Also outside of the plugin, the plugin was being reset every 100ms.
Removed this to give the plugin more control.  Also there is currently
no way to change client config for a created Accumulo client, so there
is no need to recreate the plugin.
  • Loading branch information
keith-turner committed May 13, 2024
1 parent 3cac724 commit d4e2ae7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.accumulo.core.clientImpl;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Suppliers.memoize;
import static com.google.common.base.Suppliers.memoizeWithExpiration;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Objects.requireNonNull;
Expand Down Expand Up @@ -232,8 +233,7 @@ public ClientContext(SingletonReservation reservation, ClientInfo info,
saslSupplier = memoizeWithExpiration(
() -> SaslConnectionParams.from(getConfiguration(), getCredentials().getToken()), 100,
MILLISECONDS);
scanServerSelectorSupplier =
memoizeWithExpiration(this::createScanServerSelector, 100, MILLISECONDS);
scanServerSelectorSupplier = memoize(this::createScanServerSelector);
this.singletonReservation = Objects.requireNonNull(reservation);
this.tableops = new TableOperationsImpl(this);
this.namespaceops = new NamespaceOperationsImpl(this, tableops);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public void init(ScanServerSelector.InitParameters params) {
.computeIfAbsent(sserver.getGroup(), k -> new ArrayList<>()).add(sserver.getAddress()));
groupedServers.values().forEach(ssAddrs -> Collections.sort(ssAddrs));
return groupedServers;
}, 100, TimeUnit.MILLISECONDS);
}, 3, TimeUnit.SECONDS);

var opts = params.getOptions();

Expand Down

0 comments on commit d4e2ae7

Please sign in to comment.