Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 05D6A18E41 for ; Wed, 14 Oct 2015 17:59:38 +0000 (UTC) Received: (qmail 28826 invoked by uid 500); 14 Oct 2015 17:59:03 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 28786 invoked by uid 500); 14 Oct 2015 17:59:03 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 28777 invoked by uid 99); 14 Oct 2015 17:59:03 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Oct 2015 17:59:03 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 84E66E0523; Wed, 14 Oct 2015 17:59:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ecn@apache.org To: commits@accumulo.apache.org Date: Wed, 14 Oct 2015 17:59:03 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/3] accumulo git commit: ACCUMULO-4028 use known information to pick a random server Repository: accumulo Updated Branches: refs/heads/master c30e558ae -> 10cafac94 ACCUMULO-4028 use known information to pick a random server Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/0212f2ff Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/0212f2ff Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/0212f2ff Branch: refs/heads/master Commit: 0212f2ff2f304fb7d7261113882e28c1270968f3 Parents: 4deaf73 Author: Eric C. Newton Authored: Wed Oct 14 12:54:24 2015 -0400 Committer: Eric C. Newton Committed: Wed Oct 14 12:54:24 2015 -0400 ---------------------------------------------------------------------- .../accumulo/master/tableOps/BulkImport.java | 22 +++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/0212f2ff/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java ---------------------------------------------------------------------- diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java index e661968..5320aae 100644 --- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java +++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java @@ -31,6 +31,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map.Entry; +import java.util.Random; import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; @@ -42,10 +43,7 @@ import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.Instance; import org.apache.accumulo.core.client.IsolatedScanner; import org.apache.accumulo.core.client.Scanner; -import org.apache.accumulo.core.client.impl.ServerClient; import org.apache.accumulo.core.client.impl.Tables; -import org.apache.accumulo.core.client.impl.thrift.ClientService; -import org.apache.accumulo.core.client.impl.thrift.ClientService.Client; import org.apache.accumulo.core.client.impl.thrift.TableOperation; import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType; import org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException; @@ -59,8 +57,9 @@ import org.apache.accumulo.core.master.state.tables.TableState; import org.apache.accumulo.core.metadata.MetadataTable; import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection; import org.apache.accumulo.core.security.Authorizations; -import org.apache.accumulo.core.util.Pair; +import org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Client; import org.apache.accumulo.core.util.SimpleThreadPool; +import org.apache.accumulo.core.util.ThriftUtil; import org.apache.accumulo.core.util.UtilWaitThread; import org.apache.accumulo.fate.Repo; import org.apache.accumulo.master.Master; @@ -539,23 +538,24 @@ class LoadFiles extends MasterRepo { // Use the threadpool to assign files one-at-a-time to the server final List loaded = Collections.synchronizedList(new ArrayList()); + final Random random = new Random(); for (final String file : filesToLoad) { results.add(executor.submit(new Callable>() { @Override public List call() { List failures = new ArrayList(); - ClientService.Client client = null; + Client client = null; String server = null; try { // get a connection to a random tablet server, do not prefer cached connections because // this is running on the master and there are lots of connections to tablet servers // serving the metadata tablets long timeInMillis = master.getConfiguration().getConfiguration().getTimeInMillis(Property.MASTER_BULK_TIMEOUT); - Pair pair = ServerClient.getConnection(master.getInstance(), false, timeInMillis); - client = pair.getSecond(); - server = pair.getFirst(); + TServerInstance servers[] = master.onlineTabletServers().toArray(new TServerInstance[0]); + server = servers[random.nextInt(servers.length)].getLocation().toString(); + client = ThriftUtil.getTServerClient(server, master.getConfiguration().getConfiguration(), timeInMillis); List attempt = Collections.singletonList(file); - log.debug("Asking " + pair.getFirst() + " to bulk import " + file); + log.debug("Asking " + server + " to bulk import " + file); List fail = client.bulkImportFiles(Tracer.traceInfo(), SystemCredentials.get().toThrift(master.getInstance()), tid, tableId, attempt, errorDir, setTime); if (fail.isEmpty()) { @@ -566,7 +566,9 @@ class LoadFiles extends MasterRepo { } catch (Exception ex) { log.error("rpc failed server:" + server + ", tid:" + tid + " " + ex); } finally { - ServerClient.close(client); + if (client != null) { + ThriftUtil.returnClient(client); + } } return failures; }